MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / cook_decode_frame

Function cook_decode_frame

libavcodec/cook.c:996–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

994 */
995
996static int cook_decode_frame(AVCodecContext *avctx,
997 void *data, int *data_size,
998 AVPacket *avpkt) {
999 const uint8_t *buf = avpkt->data;
1000 int buf_size = avpkt->size;
1001 COOKContext *q = avctx->priv_data;
1002 int i;
1003 int offset = 0;
1004 int chidx = 0;
1005
1006 if (buf_size < avctx->block_align)
1007 return buf_size;
1008
1009 /* estimate subpacket sizes */
1010 q->subpacket[0].size = avctx->block_align;
1011
1012 for(i=1;i<q->num_subpackets;i++){
1013 q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i];
1014 q->subpacket[0].size -= q->subpacket[i].size + 1;
1015 if (q->subpacket[0].size < 0) {
1016 av_log(avctx,AV_LOG_DEBUG,"frame subpacket size total > avctx->block_align!\n");
1017 return -1;
1018 }
1019 }
1020
1021 /* decode supbackets */
1022 *data_size = 0;
1023 for(i=0;i<q->num_subpackets;i++){
1024 q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv;
1025 q->subpacket[i].ch_idx = chidx;
1026 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align);
1027 decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data);
1028 offset += q->subpacket[i].size;
1029 chidx += q->subpacket[i].num_channels;
1030 av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb));
1031 }
1032 *data_size = sizeof(int16_t) * q->nb_channels * q->samples_per_channel;
1033
1034 /* Discard the first two frames: no valid audio. */
1035 if (avctx->frame_number < 2) *data_size = 0;
1036
1037 return avctx->block_align;
1038}
1039
1040#ifdef COOKDEBUG
1041static void dump_cook_context(COOKContext *q)

Callers

nothing calls this directly

Calls 3

av_logFunction · 0.85
decode_subpacketFunction · 0.85
get_bits_countFunction · 0.85

Tested by

no test coverage detected