changeset 4468:5455cb5a759c libavcodec

fix decoding of takethat.mp3
author michael
date Sat, 03 Feb 2007 12:42:12 +0000
parents a9f64d2a2e69
children a2e82396193c
files mpegaudiodec.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mpegaudiodec.c	Sat Feb 03 06:43:06 2007 +0000
+++ b/mpegaudiodec.c	Sat Feb 03 12:42:12 2007 +0000
@@ -1747,9 +1747,9 @@
         s_index+=4;
     }
     /* skip extension bits */
-    bits_left = end_pos - get_bits_count(&s->gb);
+    bits_left = end_pos2 - get_bits_count(&s->gb);
 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer);
-    if (bits_left < 0 || bits_left > 500) {
+    if (bits_left < 0/* || bits_left > 500*/) {
         av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
         s_index=0;
     }else if(bits_left > 0 && s->error_resilience >= FF_ER_AGGRESSIVE){
@@ -1759,6 +1759,14 @@
     memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index));
     skip_bits_long(&s->gb, bits_left);
 
+    i= get_bits_count(&s->gb);
+    if(s->in_gb.buffer && i >= s->gb.size_in_bits){
+        s->gb= s->in_gb;
+        s->in_gb.buffer=NULL;
+        assert((get_bits_count(&s->gb) & 7) == 0);
+        skip_bits_long(&s->gb, i - end_pos);
+    }
+
     return 0;
 }