diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-10-22 11:23:39 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-10-22 11:23:39 +0000 |
commit | 642ccefbc8293b010fafaa9b112051b57aa1af3d (patch) | |
tree | ee5e413ea61cc3c985bb2d1d302c101296fb1f48 /libavcodec/mpegvideo.c | |
parent | 7e4995c388020a3123d8eb82368127afdcccf0a6 (diff) | |
download | ffmpeg-642ccefbc8293b010fafaa9b112051b57aa1af3d.tar.gz |
move mmx quantizer matrixes out of MpegEncContext (23k -> 7k) (no meassureable slowdown)
Originally committed as revision 2412 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 96ae20b14e..b0580cb757 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -93,7 +93,7 @@ static uint8_t default_fcode_tab[MAX_MV*2+1]; enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1}; -static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64], +static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax) { int qscale; @@ -132,10 +132,10 @@ static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16 */ qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); // qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); - qmat16[qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); + qmat16[qscale][0][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); - if(qmat16[qscale][i]==0 || qmat16[qscale][i]==128*256) qmat16[qscale][i]=128*256-1; - qmat16_bias[qscale][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][i]); + if(qmat16[qscale][0][i]==0 || qmat16[qscale][0][i]==128*256) qmat16[qscale][0][i]=128*256-1; + qmat16[qscale][1][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][0][i]); } } } @@ -445,6 +445,8 @@ int MPV_common_init(MpegEncContext *s) CHECKED_ALLOCZ(s->q_intra_matrix, 64*32 * sizeof(int)) CHECKED_ALLOCZ(s->q_inter_matrix, 64*32 * sizeof(int)) + CHECKED_ALLOCZ(s->q_intra_matrix16, 64*32*2 * sizeof(uint16_t)) + CHECKED_ALLOCZ(s->q_inter_matrix16, 64*32*2 * sizeof(uint16_t)) } CHECKED_ALLOCZ(s->picture, MAX_PICTURE_COUNT * sizeof(Picture)) @@ -565,6 +567,8 @@ void MPV_common_end(MpegEncContext *s) av_freep(&s->lambda_table); av_freep(&s->q_intra_matrix); av_freep(&s->q_inter_matrix); + av_freep(&s->q_intra_matrix16); + av_freep(&s->q_inter_matrix16); for(i=0; i<MAX_PICTURE_COUNT; i++){ free_picture(s, &s->picture[i]); @@ -882,9 +886,9 @@ int MPV_encode_init(AVCodecContext *avctx) /* precompute matrix */ /* for mjpeg, we do include qscale in the matrix */ if (s->out_format != FMT_MJPEG) { - convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->q_intra_matrix16_bias, + convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, 1, 31); - convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->q_inter_matrix16_bias, + convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->inter_matrix, s->inter_quant_bias, 1, 31); } @@ -3502,7 +3506,7 @@ static void encode_picture(MpegEncContext *s, int picture_number) s->intra_matrix[j] = CLAMP_TO_8BIT((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3); } convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, - s->q_intra_matrix16_bias, s->intra_matrix, s->intra_quant_bias, 8, 8); + s->intra_matrix, s->intra_quant_bias, 8, 8); } //FIXME var duplication |