Mercurial > libavcodec.hg
changeset 3281:7fac25904a8b libavcodec
missmatch control for mpeg2 intra dequantization if bitexact=1
author | michael |
---|---|
date | Fri, 28 Apr 2006 17:03:52 +0000 |
parents | 894ef0dba687 |
children | ecc93139021c |
files | i386/mpegvideo_mmx.c mpegvideo.c |
diffstat | 2 files changed, 39 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/i386/mpegvideo_mmx.c Fri Apr 28 14:19:11 2006 +0000 +++ b/i386/mpegvideo_mmx.c Fri Apr 28 17:03:52 2006 +0000 @@ -699,7 +699,8 @@ s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx; - s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx; + if(!(s->flags & CODEC_FLAG_BITEXACT)) + s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx; draw_edges = draw_edges_mmx;
--- a/mpegvideo.c Fri Apr 28 14:19:11 2006 +0000 +++ b/mpegvideo.c Fri Apr 28 17:03:52 2006 +0000 @@ -47,6 +47,8 @@ DCTELEM *block, int n, int qscale); static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, DCTELEM *block, int n, int qscale); +static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, + DCTELEM *block, int n, int qscale); static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, DCTELEM *block, int n, int qscale); static void dct_unquantize_h263_intra_c(MpegEncContext *s, @@ -266,6 +268,8 @@ s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; + if(s->flags & CODEC_FLAG_BITEXACT) + s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; #ifdef CONFIG_ENCODERS @@ -6527,6 +6531,39 @@ } } +static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, + DCTELEM *block, int n, int qscale) +{ + int i, level, nCoeffs; + const uint16_t *quant_matrix; + int sum=-1; + + if(s->alternate_scan) nCoeffs= 63; + else nCoeffs= s->block_last_index[n]; + + if (n < 4) + block[0] = block[0] * s->y_dc_scale; + else + block[0] = block[0] * s->c_dc_scale; + quant_matrix = s->intra_matrix; + for(i=1;i<=nCoeffs;i++) { + int j= s->intra_scantable.permutated[i]; + level = block[j]; + if (level) { + if (level < 0) { + level = -level; + level = (int)(level * qscale * quant_matrix[j]) >> 3; + level = -level; + } else { + level = (int)(level * qscale * quant_matrix[j]) >> 3; + } + block[j] = level; + sum+=level; + } + } + block[63]^=sum&1; +} + static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, DCTELEM *block, int n, int qscale) {