comparison aac.c @ 11819:9bdc0fe882fa libavcodec

aacdec: Work around illegal files with all elem_id tags set to the same value. Fixes issue 1882.
author alexc
date Thu, 03 Jun 2010 02:17:49 +0000
parents c3ca752c24ef
children 9103a9b3573a
comparison
equal deleted inserted replaced
11818:fd38b5438c26 11819:9bdc0fe882fa
111 111
112 static const char overread_err[] = "Input buffer exhausted before END element found\n"; 112 static const char overread_err[] = "Input buffer exhausted before END element found\n";
113 113
114 static ChannelElement *get_che(AACContext *ac, int type, int elem_id) 114 static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
115 { 115 {
116 /* Some buggy encoders appear to set all elem_ids to zero and rely on
117 channels always occurring in the same order. This is expressly forbidden
118 by the spec but we will try to work around it.
119 */
120 int err_printed = 0;
121 while (ac->tags_seen_this_frame[type][elem_id] && elem_id < MAX_ELEM_ID) {
122 if (ac->output_configured < OC_LOCKED && !err_printed) {
123 av_log(ac->avccontext, AV_LOG_WARNING, "Duplicate channel tag found, attempting to remap.\n");
124 err_printed = 1;
125 }
126 elem_id++;
127 }
128 if (elem_id == MAX_ELEM_ID)
129 return NULL;
130 ac->tags_seen_this_frame[type][elem_id] = 1;
131
116 if (ac->tag_che_map[type][elem_id]) { 132 if (ac->tag_che_map[type][elem_id]) {
117 return ac->tag_che_map[type][elem_id]; 133 return ac->tag_che_map[type][elem_id];
118 } 134 }
119 if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) { 135 if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) {
120 return NULL; 136 return NULL;
1967 av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); 1983 av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
1968 return -1; 1984 return -1;
1969 } 1985 }
1970 } 1986 }
1971 1987
1988 memset(ac->tags_seen_this_frame, 0, sizeof(ac->tags_seen_this_frame));
1972 // parse 1989 // parse
1973 while ((elem_type = get_bits(&gb, 3)) != TYPE_END) { 1990 while ((elem_type = get_bits(&gb, 3)) != TYPE_END) {
1974 elem_id = get_bits(&gb, 4); 1991 elem_id = get_bits(&gb, 4);
1975 1992
1976 if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) { 1993 if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) {