comparison mpegaudiodec.c @ 4205:8c28f03cfdd5 libavcodec

detect a few more errors (fixes libmp3-bug.avi again) make pickyness of the decoder user selectable through error_resilience param like for video decoders
author michael
date Wed, 15 Nov 2006 17:58:35 +0000
parents 672724df5c9a
children 07625477adfa
comparison
equal deleted inserted replaced
4204:672724df5c9a 4205:8c28f03cfdd5
87 int frame_count; 87 int frame_count;
88 #endif 88 #endif
89 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g); 89 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g);
90 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 90 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
91 int dither_state; 91 int dither_state;
92 int error_resilience;
92 } MPADecodeContext; 93 } MPADecodeContext;
93 94
94 /** 95 /**
95 * Context for MP3On4 decoder 96 * Context for MP3On4 decoder
96 */ 97 */
303 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) 304 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
304 avctx->sample_fmt= SAMPLE_FMT_S32; 305 avctx->sample_fmt= SAMPLE_FMT_S32;
305 #else 306 #else
306 avctx->sample_fmt= SAMPLE_FMT_S16; 307 avctx->sample_fmt= SAMPLE_FMT_S16;
307 #endif 308 #endif
309 s->error_resilience= avctx->error_resilience;
308 310
309 if(avctx->antialias_algo != FF_AA_FLOAT) 311 if(avctx->antialias_algo != FF_AA_FLOAT)
310 s->compute_antialias= compute_antialias_integer; 312 s->compute_antialias= compute_antialias_integer;
311 else 313 else
312 s->compute_antialias= compute_antialias_float; 314 s->compute_antialias= compute_antialias_float;
1703 /* some encoders generate an incorrect size for this 1705 /* some encoders generate an incorrect size for this
1704 part. We must go back into the data */ 1706 part. We must go back into the data */
1705 s_index -= 4; 1707 s_index -= 4;
1706 skip_bits_long(&s->gb, last_pos - pos); 1708 skip_bits_long(&s->gb, last_pos - pos);
1707 av_log(NULL, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); 1709 av_log(NULL, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
1710 if(s->error_resilience >= FF_ER_COMPLIANT)
1711 s_index=0;
1708 break; 1712 break;
1709 } 1713 }
1710 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); 1714 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
1711 if(s->in_gb.buffer && pos >= s->gb.size_in_bits){ 1715 if(s->in_gb.buffer && pos >= s->gb.size_in_bits){
1712 s->gb= s->in_gb; 1716 s->gb= s->in_gb;
1740 v = -v; 1744 v = -v;
1741 g->sb_hybrid[pos] = v; 1745 g->sb_hybrid[pos] = v;
1742 } 1746 }
1743 s_index+=4; 1747 s_index+=4;
1744 } 1748 }
1745 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index));
1746
1747 /* skip extension bits */ 1749 /* skip extension bits */
1748 bits_left = end_pos - get_bits_count(&s->gb); 1750 bits_left = end_pos - get_bits_count(&s->gb);
1749 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); 1751 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer);
1750 if (bits_left < 0) { 1752 if (bits_left < 0 || bits_left > 16) {
1751 av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left); 1753 av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
1752 } 1754 s_index=0;
1755 }else if(bits_left > 0 && s->error_resilience >= FF_ER_AGGRESSIVE){
1756 av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
1757 s_index=0;
1758 }
1759 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index));
1753 skip_bits_long(&s->gb, bits_left); 1760 skip_bits_long(&s->gb, bits_left);
1754 1761
1755 return 0; 1762 return 0;
1756 } 1763 }
1757 1764