aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-08-27 11:42:40 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-08-27 11:42:40 +0000
commitc0c66dd81d232731c7bedfe56821de5fe233a081 (patch)
tree4fad3e709f299ec1fabd186ac7b811862edded69 /libavcodec
parentbfe328caf087d05cdd07d69b1858d0fe39b99b97 (diff)
downloadffmpeg-c0c66dd81d232731c7bedfe56821de5fe233a081.tar.gz
fix low bitrate mp3
Originally committed as revision 6107 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mpegaudiodec.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 2d669a87eb..27a622c7d4 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -2517,15 +2517,26 @@ static int mp_decode_frame(MPADecodeContext *s,
default:
nb_frames = mp_decode_layer3(s);
- if(s->in_gb.buffer)
+ s->last_buf_size=0;
+ if(s->in_gb.buffer){
+ align_get_bits(&s->gb);
+ i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
+ if(i > 0 && i <= BACKSTEP_SIZE){
+ memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i);
+ s->last_buf_size=i;
+ }
s->gb= s->in_gb;
+ }
+
align_get_bits(&s->gb);
assert((get_bits_count(&s->gb) & 7) == 0);
- s->last_buf_size= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
- if(s->last_buf_size <0 || s->last_buf_size > BACKSTEP_SIZE || nb_frames<0)
- s->last_buf_size= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
- assert(s->last_buf_size <= buf_size - HEADER_SIZE);
- memcpy(s->last_buf, s->gb.buffer + buf_size - HEADER_SIZE - s->last_buf_size, s->last_buf_size);
+ i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
+
+ if(i<0 || s->last_buf_size + i > BACKSTEP_SIZE || nb_frames<0)
+ i= FFMIN(BACKSTEP_SIZE-s->last_buf_size, buf_size - HEADER_SIZE);
+ assert(i <= buf_size - HEADER_SIZE && i>= 0);
+ memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
+ s->last_buf_size += i;
break;
}