Mercurial > libavcodec.hg
comparison aac.c @ 10491:74e51b86b934 libavcodec
Don't lock the channel output configuration based on the first value seen for
non extradata formats. Instead lock it only after the successful decoding of a
frame. This fixes issue 999.
author | alexc |
---|---|
date | Tue, 03 Nov 2009 22:50:02 +0000 |
parents | 03b0316b9ead |
children | 06d6393bbaeb |
comparison
equal
deleted
inserted
replaced
10490:27750570f2d4 | 10491:74e51b86b934 |
---|---|
192 * @return Returns error status. 0 - OK, !0 - error | 192 * @return Returns error status. 0 - OK, !0 - error |
193 */ | 193 */ |
194 static int output_configure(AACContext *ac, | 194 static int output_configure(AACContext *ac, |
195 enum ChannelPosition che_pos[4][MAX_ELEM_ID], | 195 enum ChannelPosition che_pos[4][MAX_ELEM_ID], |
196 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], | 196 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], |
197 int channel_config) | 197 int channel_config, enum OCStatus oc_type) |
198 { | 198 { |
199 AVCodecContext *avctx = ac->avccontext; | 199 AVCodecContext *avctx = ac->avccontext; |
200 int i, type, channels = 0, ret; | 200 int i, type, channels = 0, ret; |
201 | 201 |
202 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | 202 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); |
237 avctx->channel_layout = 0; | 237 avctx->channel_layout = 0; |
238 } | 238 } |
239 | 239 |
240 avctx->channels = channels; | 240 avctx->channels = channels; |
241 | 241 |
242 ac->output_configured = 1; | 242 ac->output_configured = oc_type; |
243 | 243 |
244 return 0; | 244 return 0; |
245 } | 245 } |
246 | 246 |
247 /** | 247 /** |
388 return ret; | 388 return ret; |
389 } else { | 389 } else { |
390 if ((ret = set_default_channel_config(ac, new_che_pos, channel_config))) | 390 if ((ret = set_default_channel_config(ac, new_che_pos, channel_config))) |
391 return ret; | 391 return ret; |
392 } | 392 } |
393 if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config))) | 393 if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_LOCKED))) |
394 return ret; | 394 return ret; |
395 | 395 |
396 if (extension_flag) { | 396 if (extension_flag) { |
397 switch (ac->m4ac.object_type) { | 397 switch (ac->m4ac.object_type) { |
398 case AOT_ER_BSAC: | 398 case AOT_ER_BSAC: |
1674 int size; | 1674 int size; |
1675 AACADTSHeaderInfo hdr_info; | 1675 AACADTSHeaderInfo hdr_info; |
1676 | 1676 |
1677 size = ff_aac_parse_header(gb, &hdr_info); | 1677 size = ff_aac_parse_header(gb, &hdr_info); |
1678 if (size > 0) { | 1678 if (size > 0) { |
1679 if (!ac->output_configured && hdr_info.chan_config) { | 1679 if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) { |
1680 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; | 1680 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; |
1681 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | 1681 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); |
1682 ac->m4ac.chan_config = hdr_info.chan_config; | 1682 ac->m4ac.chan_config = hdr_info.chan_config; |
1683 if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config)) | 1683 if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config)) |
1684 return -7; | 1684 return -7; |
1685 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config)) | 1685 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) |
1686 return -7; | 1686 return -7; |
1687 } else if (ac->output_configured != OC_LOCKED) { | |
1688 ac->output_configured = OC_NONE; | |
1687 } | 1689 } |
1688 ac->m4ac.sample_rate = hdr_info.sample_rate; | 1690 ac->m4ac.sample_rate = hdr_info.sample_rate; |
1689 ac->m4ac.sampling_index = hdr_info.sampling_index; | 1691 ac->m4ac.sampling_index = hdr_info.sampling_index; |
1690 ac->m4ac.object_type = hdr_info.object_type; | 1692 ac->m4ac.object_type = hdr_info.object_type; |
1691 if (hdr_info.num_aac_frames == 1) { | 1693 if (hdr_info.num_aac_frames == 1) { |
1758 case TYPE_PCE: { | 1760 case TYPE_PCE: { |
1759 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; | 1761 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; |
1760 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | 1762 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); |
1761 if ((err = decode_pce(ac, new_che_pos, &gb))) | 1763 if ((err = decode_pce(ac, new_che_pos, &gb))) |
1762 break; | 1764 break; |
1763 if (ac->output_configured) | 1765 if (ac->output_configured <= OC_TRIAL_PCE) |
1764 av_log(avccontext, AV_LOG_ERROR, | 1766 av_log(avccontext, AV_LOG_ERROR, |
1765 "Not evaluating a further program_config_element as this construct is dubious at best.\n"); | 1767 "Not evaluating a further program_config_element as this construct is dubious at best.\n"); |
1766 else | 1768 else |
1767 err = output_configure(ac, ac->che_pos, new_che_pos, 0); | 1769 err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE); |
1768 break; | 1770 break; |
1769 } | 1771 } |
1770 | 1772 |
1771 case TYPE_FIL: | 1773 case TYPE_FIL: |
1772 if (elem_id == 15) | 1774 if (elem_id == 15) |
1801 return -1; | 1803 return -1; |
1802 } | 1804 } |
1803 *data_size = data_size_tmp; | 1805 *data_size = data_size_tmp; |
1804 | 1806 |
1805 ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, 1024, avccontext->channels); | 1807 ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, 1024, avccontext->channels); |
1808 | |
1809 if (ac->output_configured) | |
1810 ac->output_configured = OC_LOCKED; | |
1806 | 1811 |
1807 return buf_size; | 1812 return buf_size; |
1808 } | 1813 } |
1809 | 1814 |
1810 static av_cold int aac_decode_close(AVCodecContext *avccontext) | 1815 static av_cold int aac_decode_close(AVCodecContext *avccontext) |