[FFmpeg-devel] [PATCH 1/2] avcodec: support setting the chroma intra matrix

Michael Niedermayer michaelni at gmx.at
Mon Feb 10 19:02:58 CET 2014


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavcodec/avcodec.h       |   11 +++++++++++
 libavcodec/mpegvideo_enc.c |    3 ++-
 libavcodec/utils.c         |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 655c280..180b509 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2988,6 +2988,14 @@ typedef struct AVCodecContext {
 #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames
 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
 #endif
+
+    /**
+     * custom intra quantization matrix
+     * Code outside libavcodec should access this field using av_codec_g/set_chroma_intra_matrix()
+     * - encoding: Set by user, can be NULL.
+     * - decoding: Set by libavcodec.
+     */
+    uint16_t *chroma_intra_matrix;
 } AVCodecContext;
 
 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
@@ -3002,6 +3010,9 @@ void av_codec_set_lowres(AVCodecContext *avctx, int val);
 int  av_codec_get_seek_preroll(const AVCodecContext *avctx);
 void av_codec_set_seek_preroll(AVCodecContext *avctx, int val);
 
+uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx);
+void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val);
+
 /**
  * AVProfile.
  */
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 54ef15f..03de54b 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3507,8 +3507,9 @@ static int encode_picture(MpegEncContext *s, int picture_number)
         const uint16_t *  luma_matrix = ff_mpeg1_default_intra_matrix;
         const uint16_t *chroma_matrix = ff_mpeg1_default_intra_matrix;
 
+        if (s->avctx->chroma_intra_matrix)
+            chroma_matrix = s->avctx->chroma_intra_matrix;
         if (s->avctx->intra_matrix) {
-            chroma_matrix =
             luma_matrix = s->avctx->intra_matrix;
         }
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c8fd8c6..5df567d 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1114,6 +1114,7 @@ MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
 MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
 MAKE_ACCESSORS(AVCodecContext, codec, int, lowres)
 MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
+MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
 
 int av_codec_get_max_lowres(const AVCodec *codec)
 {
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list