diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2001-08-11 19:04:08 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2001-08-11 19:04:08 +0000 |
commit | 0ee50938f16af075a3d8dd04837d44c082d51cba (patch) | |
tree | e6240a613bb889ae6f882c9bf42ac19eb149d5ef /libavcodec/mpeg12.c | |
parent | 991ae7b6a496d124af5465b359c8059cd2e7c4c3 (diff) | |
download | ffmpeg-streaming-0ee50938f16af075a3d8dd04837d44c082d51cba.zip ffmpeg-streaming-0ee50938f16af075a3d8dd04837d44c082d51cba.tar.gz |
fixed mpeg2 qscale decoding
Originally committed as revision 71 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r-- | libavcodec/mpeg12.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 2e758b4..a0f8a65 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -489,6 +489,22 @@ static inline int get_dmv(MpegEncContext *s) return 0; } +static inline int get_qscale(MpegEncContext *s) +{ + int qscale; + if (s->mpeg2) { + if (s->q_scale_type) { + qscale = non_linear_qscale[get_bits(&s->gb, 5)]; + } else { + qscale = get_bits(&s->gb, 5) << 1; + } + } else { + /* for mpeg1, we use the generic unquant code */ + qscale = get_bits(&s->gb, 5); + } + return qscale; +} + /* motion type (for mpeg2) */ #define MT_FIELD 1 #define MT_FRAME 2 @@ -594,16 +610,7 @@ static int mpeg_decode_mb(MpegEncContext *s, } if (mb_type & MB_QUANT) { - if (s->mpeg2) { - if (s->q_scale_type) { - s->qscale = non_linear_qscale[get_bits(&s->gb, 5)]; - } else { - s->qscale = get_bits(&s->gb, 5) << 1; - } - } else { - /* for mpeg1, we use the generic unquant code */ - s->qscale = get_bits(&s->gb, 5); - } + s->qscale = get_qscale(s); } if (mb_type & MB_INTRA) { if (s->concealment_motion_vectors) { @@ -1287,7 +1294,7 @@ static int mpeg_decode_slice(AVCodecContext *avctx, init_get_bits(&s->gb, buf, buf_size); - s->qscale = get_bits(&s->gb, 5); + s->qscale = get_qscale(s); /* extra slice info */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); |