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

Function dca_decode_frame

libavcodec/dca.c:1199–1272  ·  view source on GitHub ↗

* Main frame decoding function * FIXME add arguments */

Source from the content-addressed store, hash-verified

1197 * FIXME add arguments
1198 */
1199static int dca_decode_frame(AVCodecContext * avctx,
1200 void *data, int *data_size,
1201 AVPacket *avpkt)
1202{
1203 const uint8_t *buf = avpkt->data;
1204 int buf_size = avpkt->size;
1205
1206 int i;
1207 int16_t *samples = data;
1208 DCAContext *s = avctx->priv_data;
1209 int channels;
1210
1211
1212 s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
1213 if (s->dca_buffer_size == -1) {
1214 av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
1215 return -1;
1216 }
1217
1218 init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
1219 if (dca_parse_frame_header(s) < 0) {
1220 //seems like the frame is corrupt, try with the next one
1221 *data_size=0;
1222 return buf_size;
1223 }
1224 //set AVCodec values with parsed data
1225 avctx->sample_rate = s->sample_rate;
1226 avctx->bit_rate = s->bit_rate;
1227
1228 channels = s->prim_channels + !!s->lfe;
1229
1230 if (s->amode<16) {
1231 avctx->channel_layout = dca_core_channel_layout[s->amode];
1232
1233 if (s->lfe) {
1234 avctx->channel_layout |= CH_LOW_FREQUENCY;
1235 s->channel_order_tab = dca_channel_reorder_lfe[s->amode];
1236 } else
1237 s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];
1238
1239 if (s->prim_channels > 0 &&
1240 s->channel_order_tab[s->prim_channels - 1] < 0)
1241 return -1;
1242
1243 if(avctx->request_channels == 2 && s->prim_channels > 2) {
1244 channels = 2;
1245 s->output = DCA_STEREO;
1246 avctx->channel_layout = CH_LAYOUT_STEREO;
1247 }
1248 } else {
1249 av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode);
1250 return -1;
1251 }
1252
1253
1254 /* There is nothing that prevents a dts frame to change channel configuration
1255 but FFmpeg doesn't support that so only set the channels if it is previously
1256 unset. Ideally during the first probe for channels the crc should be checked

Callers

nothing calls this directly

Calls 5

dca_convert_bitstreamFunction · 0.85
av_logFunction · 0.85
init_get_bitsFunction · 0.85
dca_parse_frame_headerFunction · 0.85
dca_decode_blockFunction · 0.85

Tested by

no test coverage detected