Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: source/patched-ffmpeg-mt/libavcodec/aacdec.c

Issue 2850032: ffmpeg update to june 23 version which fixes mp4 crash on still frames with 3... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * AAC decoder 2 * AAC decoder
3 * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) 3 * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
4 * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) 4 * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
5 * 5 *
6 * This file is part of FFmpeg. 6 * This file is part of FFmpeg.
7 * 7 *
8 * FFmpeg is free software; you can redistribute it and/or 8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 * N Structured Audio tools 60 * N Structured Audio tools
61 * N Structured Audio Sample Bank Format 61 * N Structured Audio Sample Bank Format
62 * N MIDI 62 * N MIDI
63 * N Harmonic and Individual Lines plus Noise 63 * N Harmonic and Individual Lines plus Noise
64 * N Text-To-Speech Interface 64 * N Text-To-Speech Interface
65 * Y Spectral Band Replication 65 * Y Spectral Band Replication
66 * Y (not in this code) Layer-1 66 * Y (not in this code) Layer-1
67 * Y (not in this code) Layer-2 67 * Y (not in this code) Layer-2
68 * Y (not in this code) Layer-3 68 * Y (not in this code) Layer-3
69 * N SinuSoidal Coding (Transient, Sinusoid, Noise) 69 * N SinuSoidal Coding (Transient, Sinusoid, Noise)
70 * N (planned) Parametric Stereo 70 * Y Parametric Stereo
71 * N Direct Stream Transfer 71 * N Direct Stream Transfer
72 * 72 *
73 * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. 73 * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication.
74 * - HE AAC v2 comprises LC AAC with Spectral Band Replication and 74 * - HE AAC v2 comprises LC AAC with Spectral Band Replication and
75 Parametric Stereo. 75 Parametric Stereo.
76 */ 76 */
77 77
78 78
79 #include "avcodec.h" 79 #include "avcodec.h"
80 #include "internal.h" 80 #include "internal.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 enum ChannelPosition che_pos[4][MAX_ELEM_ID], 193 enum ChannelPosition che_pos[4][MAX_ELEM_ID],
194 int type, int id, 194 int type, int id,
195 int *channels) 195 int *channels)
196 { 196 {
197 if (che_pos[type][id]) { 197 if (che_pos[type][id]) {
198 if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(Channe lElement)))) 198 if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(Channe lElement))))
199 return AVERROR(ENOMEM); 199 return AVERROR(ENOMEM);
200 ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); 200 ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr);
201 if (type != TYPE_CCE) { 201 if (type != TYPE_CCE) {
202 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; 202 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
203 if (type == TYPE_CPE) { 203 if (type == TYPE_CPE ||
204 (type == TYPE_SCE && ac->m4ac.ps == 1)) {
204 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; 205 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
205 } 206 }
206 } 207 }
207 } else { 208 } else {
208 if (ac->che[type][id]) 209 if (ac->che[type][id])
209 ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr); 210 ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
210 av_freep(&ac->che[type][id]); 211 av_freep(&ac->che[type][id]);
211 } 212 }
212 return 0; 213 return 0;
213 } 214 }
214 215
215 /** 216 /**
216 * Configure output channel order based on the current program configuration ele ment. 217 * Configure output channel order based on the current program configuration ele ment.
217 * 218 *
218 * @param che_pos current channel position configuration 219 * @param che_pos current channel position configuration
219 * @param new_che_pos New channel position configuration - we only do somethin g if it differs from the current one. 220 * @param new_che_pos New channel position configuration - we only do somethin g if it differs from the current one.
220 * 221 *
221 * @return Returns error status. 0 - OK, !0 - error 222 * @return Returns error status. 0 - OK, !0 - error
222 */ 223 */
223 static av_cold int output_configure(AACContext *ac, 224 static av_cold int output_configure(AACContext *ac,
224 enum ChannelPosition che_pos[4][MAX_ELEM_ID], 225 enum ChannelPosition che_pos[4][MAX_ELEM_ID],
225 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], 226 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
226 int channel_config, enum OCStatus oc_type) 227 int channel_config, enum OCStatus oc_type)
227 { 228 {
228 AVCodecContext *avctx = ac->avctx; 229 AVCodecContext *avctx = ac->avctx;
229 int i, type, channels = 0, ret; 230 int i, type, channels = 0, ret;
230 231
232 if (new_che_pos != che_pos)
231 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); 233 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
232 234
233 if (channel_config) { 235 if (channel_config) {
234 for (i = 0; i < tags_per_config[channel_config]; i++) { 236 for (i = 0; i < tags_per_config[channel_config]; i++) {
235 if ((ret = che_configure(ac, che_pos, 237 if ((ret = che_configure(ac, che_pos,
236 aac_channel_layout_map[channel_config - 1][ i][0], 238 aac_channel_layout_map[channel_config - 1][ i][0],
237 aac_channel_layout_map[channel_config - 1][ i][1], 239 aac_channel_layout_map[channel_config - 1][ i][1],
238 &channels))) 240 &channels)))
239 return ret; 241 return ret;
240 } 242 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 467
466 init_get_bits(&gb, data, data_size * 8); 468 init_get_bits(&gb, data, data_size * 8);
467 gb.buffer_enforcing = 1; 469 gb.buffer_enforcing = 1;
468 470
469 if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0) 471 if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0)
470 return -1; 472 return -1;
471 if (ac->m4ac.sampling_index > 12) { 473 if (ac->m4ac.sampling_index > 12) {
472 av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac-> m4ac.sampling_index); 474 av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac-> m4ac.sampling_index);
473 return -1; 475 return -1;
474 } 476 }
477 if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1)
478 ac->m4ac.ps = 1;
475 479
476 skip_bits_long(&gb, i); 480 skip_bits_long(&gb, i);
477 481
478 switch (ac->m4ac.object_type) { 482 switch (ac->m4ac.object_type) {
479 case AOT_AAC_MAIN: 483 case AOT_AAC_MAIN:
480 case AOT_AAC_LC: 484 case AOT_AAC_LC:
481 if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config)) 485 if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config))
482 return -1; 486 return -1;
483 break; 487 break;
484 default: 488 default:
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first chan nel element.\n"); 1665 av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first chan nel element.\n");
1662 return res; 1666 return res;
1663 } else if (!ac->m4ac.sbr) { 1667 } else if (!ac->m4ac.sbr) {
1664 av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"); 1668 av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
1665 skip_bits_long(gb, 8 * cnt - 4); 1669 skip_bits_long(gb, 8 * cnt - 4);
1666 return res; 1670 return res;
1667 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) { 1671 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) {
1668 av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); 1672 av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
1669 skip_bits_long(gb, 8 * cnt - 4); 1673 skip_bits_long(gb, 8 * cnt - 4);
1670 return res; 1674 return res;
1675 } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac- >avctx->channels == 1) {
1676 ac->m4ac.sbr = 1;
1677 ac->m4ac.ps = 1;
1678 output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured);
1671 } else { 1679 } else {
1672 ac->m4ac.sbr = 1; 1680 ac->m4ac.sbr = 1;
1673 } 1681 }
1674 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_typ e); 1682 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_typ e);
1675 break; 1683 break;
1676 case EXT_DYNAMIC_RANGE: 1684 case EXT_DYNAMIC_RANGE:
1677 res = decode_dynamic_range(&ac->che_drc, gb, cnt); 1685 res = decode_dynamic_range(&ac->che_drc, gb, cnt);
1678 break; 1686 break;
1679 case EXT_FILL: 1687 case EXT_FILL:
1680 case EXT_FILL_DATA: 1688 case EXT_FILL_DATA:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; 1948 enum ChannelPosition new_che_pos[4][MAX_ELEM_ID];
1941 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); 1949 memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
1942 ac->m4ac.chan_config = hdr_info.chan_config; 1950 ac->m4ac.chan_config = hdr_info.chan_config;
1943 if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config )) 1951 if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config ))
1944 return -7; 1952 return -7;
1945 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_con fig, OC_TRIAL_FRAME)) 1953 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_con fig, OC_TRIAL_FRAME))
1946 return -7; 1954 return -7;
1947 } else if (ac->output_configured != OC_LOCKED) { 1955 } else if (ac->output_configured != OC_LOCKED) {
1948 ac->output_configured = OC_NONE; 1956 ac->output_configured = OC_NONE;
1949 } 1957 }
1950 if (ac->output_configured != OC_LOCKED) 1958 if (ac->output_configured != OC_LOCKED) {
1951 ac->m4ac.sbr = -1; 1959 ac->m4ac.sbr = -1;
1960 ac->m4ac.ps = -1;
1961 }
1952 ac->m4ac.sample_rate = hdr_info.sample_rate; 1962 ac->m4ac.sample_rate = hdr_info.sample_rate;
1953 ac->m4ac.sampling_index = hdr_info.sampling_index; 1963 ac->m4ac.sampling_index = hdr_info.sampling_index;
1954 ac->m4ac.object_type = hdr_info.object_type; 1964 ac->m4ac.object_type = hdr_info.object_type;
1955 if (!ac->avctx->sample_rate) 1965 if (!ac->avctx->sample_rate)
1956 ac->avctx->sample_rate = hdr_info.sample_rate; 1966 ac->avctx->sample_rate = hdr_info.sample_rate;
1957 if (hdr_info.num_aac_frames == 1) { 1967 if (hdr_info.num_aac_frames == 1) {
1958 if (!hdr_info.crc_absent) 1968 if (!hdr_info.crc_absent)
1959 skip_bits(gb, 16); 1969 skip_bits(gb, 16);
1960 } else { 1970 } else {
1961 av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS fr ame is", 0); 1971 av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS fr ame is", 0);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 aac_decode_init, 2140 aac_decode_init,
2131 NULL, 2141 NULL,
2132 aac_decode_close, 2142 aac_decode_close,
2133 aac_decode_frame, 2143 aac_decode_frame,
2134 .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), 2144 .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
2135 .sample_fmts = (const enum SampleFormat[]) { 2145 .sample_fmts = (const enum SampleFormat[]) {
2136 SAMPLE_FMT_S16,SAMPLE_FMT_NONE 2146 SAMPLE_FMT_S16,SAMPLE_FMT_NONE
2137 }, 2147 },
2138 .channel_layouts = aac_channel_layout, 2148 .channel_layouts = aac_channel_layout,
2139 }; 2149 };
OLDNEW
« no previous file with comments | « source/patched-ffmpeg-mt/libavcodec/Makefile ('k') | source/patched-ffmpeg-mt/libavcodec/aacsbr.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698