Mercurial > libavcodec.hg
changeset 54:764f2eaf711e libavcodec
fixed mpeg2 qscale decoding
author | glantau |
---|---|
date | Sat, 11 Aug 2001 19:04:08 +0000 |
parents | adf7cea364ca |
children | 6064342168f4 |
files | mpeg12.c |
diffstat | 1 files changed, 18 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mpeg12.c Sat Aug 11 19:03:30 2001 +0000 +++ b/mpeg12.c Sat Aug 11 19:04:08 2001 +0000 @@ -489,6 +489,22 @@ 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 @@ } 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 @@ 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);