From 7366bb38f10e5955be4280e11b7dbe15d2c0edb8 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 11 Feb 2015 00:34:02 +0100 Subject: [PATCH] avcodec/mpegvideo_enc: Add intra_chroma_ac_vlc_length, it will be needed for mjpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo.h | 2 ++ libavcodec/mpegvideo_enc.c | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 81f412ba46..6215d237f2 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -443,6 +443,8 @@ typedef struct MpegEncContext { int ac_esc_length; ///< num of bits needed to encode the longest esc uint8_t *intra_ac_vlc_length; uint8_t *intra_ac_vlc_last_length; + uint8_t *intra_chroma_ac_vlc_length; + uint8_t *intra_chroma_ac_vlc_last_length; uint8_t *inter_ac_vlc_length; uint8_t *inter_ac_vlc_last_length; uint8_t *luma_dc_vlc_length; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index af75df6283..f17c6b33b2 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3813,8 +3813,13 @@ static int dct_quantize_trellis_c(MpegEncContext *s, qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; if(s->mpeg_quant || s->out_format == FMT_MPEG1) bias= 1<<(QMAT_SHIFT-1); - length = s->intra_ac_vlc_length; - last_length= s->intra_ac_vlc_last_length; + if (n > 3 && s->intra_chroma_ac_vlc_length) { + length = s->intra_chroma_ac_vlc_length; + last_length= s->intra_chroma_ac_vlc_last_length; + } else { + length = s->intra_ac_vlc_length; + last_length= s->intra_ac_vlc_last_length; + } } else { start_i = 0; last_non_zero = -1; @@ -4123,8 +4128,13 @@ static int messed_sign=0; start_i = 1; // if(s->mpeg_quant || s->out_format == FMT_MPEG1) // bias= 1<<(QMAT_SHIFT-1); - length = s->intra_ac_vlc_length; - last_length= s->intra_ac_vlc_last_length; + if (n > 3 && s->intra_chroma_ac_vlc_length) { + length = s->intra_chroma_ac_vlc_length; + last_length= s->intra_chroma_ac_vlc_last_length; + } else { + length = s->intra_ac_vlc_length; + last_length= s->intra_ac_vlc_last_length; + } } else { dc= 0; start_i = 0;