[FFmpeg-cvslog] avcodec/mjpegenc: pass chroma quantization matrix through as well, not just luma

Michael Niedermayer git at videolan.org
Sat Jan 11 21:53:19 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Jan 11 21:26:51 2014 +0100| [859d74040e4b56b605abe92b00c0060b48eee73a] | committer: Michael Niedermayer

avcodec/mjpegenc: pass chroma quantization matrix through as well, not just luma

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=859d74040e4b56b605abe92b00c0060b48eee73a
---

 libavcodec/ljpegenc.c      |    2 +-
 libavcodec/mjpegenc.c      |   14 ++++++++------
 libavcodec/mjpegenc.h      |    3 ++-
 libavcodec/mpegvideo_enc.c |    2 +-
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 35b82fd..b7e3d35 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -233,7 +233,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     init_put_bits(&pb, pkt->data, pkt->size);
 
     ff_mjpeg_encode_picture_header(avctx, &pb, &s->scantable,
-                                   s->matrix);
+                                   s->matrix, s->matrix);
 
     header_bits = put_bits_count(&pb);
 
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 518a7d5..bf3e257 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -108,7 +108,8 @@ static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
 
 static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
                               ScanTable *intra_scantable,
-                              uint16_t intra_matrix[64],
+                              uint16_t luma_intra_matrix[64],
+                              uint16_t chroma_intra_matrix[64],
                               int hsample[3])
 {
     int i, j, size;
@@ -126,14 +127,14 @@ static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p,
     put_bits(p, 4, 0); /* table 0 */
     for(i=0;i<64;i++) {
         j = intra_scantable->permutated[i];
-        put_bits(p, 8, intra_matrix[j]);
+        put_bits(p, 8, luma_intra_matrix[j]);
     }
 #ifdef TWOMATRIXES
     put_bits(p, 4, 0); /* 8 bit precision */
     put_bits(p, 4, 1); /* table 1 */
     for(i=0;i<64;i++) {
-        j = s->intra_scantable.permutated[i];
-        put_bits(p, 8, s->chroma_intra_matrix[j]);
+        j = intra_scantable->permutated[i];
+        put_bits(p, 8, chroma_intra_matrix[j]);
     }
 #endif
     }
@@ -232,7 +233,8 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3
 
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
                                     ScanTable *intra_scantable,
-                                    uint16_t intra_matrix[64])
+                                    uint16_t luma_intra_matrix[64],
+                                    uint16_t chroma_intra_matrix[64])
 {
     const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG && avctx->codec_id != AV_CODEC_ID_AMV;
     int hsample[3], vsample[3];
@@ -247,7 +249,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
 
     jpeg_put_comments(avctx, pb);
 
-    jpeg_table_header(avctx, pb, intra_scantable, intra_matrix, hsample);
+    jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
 
     switch (avctx->codec_id) {
     case AV_CODEC_ID_MJPEG:  put_marker(pb, SOF0 ); break;
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 4b19e21..c5b05b5 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -53,7 +53,8 @@ int  ff_mjpeg_encode_init(MpegEncContext *s);
 void ff_mjpeg_encode_close(MpegEncContext *s);
 void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
                                     ScanTable *intra_scantable,
-                                    uint16_t intra_matrix[64]);
+                                    uint16_t luma_intra_matrix[64],
+                                    uint16_t chroma_intra_matrix[64]);
 void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
 void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
 void ff_mjpeg_encode_stuffing(MpegEncContext *s);
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 09f96e4..105f2cd 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3548,7 +3548,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
     case FMT_MJPEG:
         if (CONFIG_MJPEG_ENCODER)
             ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
-                                           s->intra_matrix);
+                                           s->intra_matrix, s->chroma_intra_matrix);
         break;
     case FMT_H261:
         if (CONFIG_H261_ENCODER)



More information about the ffmpeg-cvslog mailing list