diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 381f0fb626..b476bcd232 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -137,7 +137,7 @@ static void jpeg_table_header(MpegEncContext *s) if(s->avctx->active_thread_type & FF_THREAD_SLICE){ put_marker(p, DRI); put_bits(p, 16, 4); - put_bits(p, 16, s->mb_width); + put_bits(p, 16, s->mb_width*2/s->mjpeg_hsample[0]); } /* huffman table */ @@ -458,23 +458,31 @@ static void encode_block(MpegEncContext *s, DCTELEM *block, int n) void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]) { int i; - for(i=0;i<5;i++) { - encode_block(s, block[i], i); - } - if (s->chroma_format == CHROMA_420) { - encode_block(s, block[5], 5); - } else if (s->chroma_format == CHROMA_422) { - encode_block(s, block[6], 6); + if (s->chroma_format == CHROMA_444) { + encode_block(s, block[0], 0); + encode_block(s, block[2], 2); + encode_block(s, block[4], 4); + encode_block(s, block[8], 8); encode_block(s, block[5], 5); - encode_block(s, block[7], 7); - } else { + encode_block(s, block[9], 9); + + encode_block(s, block[1], 1); + encode_block(s, block[3], 3); encode_block(s, block[6], 6); - encode_block(s, block[8], 8); encode_block(s, block[10], 10); - encode_block(s, block[5], 5); encode_block(s, block[7], 7); - encode_block(s, block[9], 9); encode_block(s, block[11], 11); + } else { + for(i=0;i<5;i++) { + encode_block(s, block[i], i); + } + if (s->chroma_format == CHROMA_420) { + encode_block(s, block[5], 5); + } else { + encode_block(s, block[6], 6); + encode_block(s, block[5], 5); + encode_block(s, block[7], 7); + } } s->i_tex_bits += get_bits_diff(s); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 08dcf9e793..aff12c6f8e 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -751,6 +751,9 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx) s->mjpeg_vsample[0] = s->mjpeg_hsample[0] = s->mjpeg_vsample[1] = s->mjpeg_hsample[1] = s->mjpeg_vsample[2] = s->mjpeg_hsample[2] = 1; + } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P) { + s->mjpeg_vsample[0] = s->mjpeg_vsample[1] = s->mjpeg_vsample[2] = 2; + s->mjpeg_hsample[0] = s->mjpeg_hsample[1] = s->mjpeg_hsample[2] = 1; } else { s->mjpeg_vsample[0] = 2; s->mjpeg_vsample[1] = 2 >> chroma_v_shift; diff --git a/tests/ref/vsynth/vsynth1-mjpeg-444 b/tests/ref/vsynth/vsynth1-mjpeg-444 index 3ad0c51195..ba2491491a 100644 --- a/tests/ref/vsynth/vsynth1-mjpeg-444 +++ b/tests/ref/vsynth/vsynth1-mjpeg-444 @@ -1,4 +1,4 @@ -bf3e8f03857c8b3c7b1cdc7bb1aa5bae *tests/data/fate/vsynth1-mjpeg-444.avi -1987582 tests/data/fate/vsynth1-mjpeg-444.avi +94ca37e075ee24047b5dcd8f27b51a9f *tests/data/fate/vsynth1-mjpeg-444.avi +1989780 tests/data/fate/vsynth1-mjpeg-444.avi 313a4a76af13d5879ea4910107b7ea74 *tests/data/fate/vsynth1-mjpeg-444.out.rawvideo stddev: 7.37 PSNR: 30.77 MAXDIFF: 63 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-mjpeg-444 b/tests/ref/vsynth/vsynth2-mjpeg-444 index e04c31c7d7..b09f889ca0 100644 --- a/tests/ref/vsynth/vsynth2-mjpeg-444 +++ b/tests/ref/vsynth/vsynth2-mjpeg-444 @@ -1,4 +1,4 @@ -0af500d33a7e4d04e9778fb9ed6180b3 *tests/data/fate/vsynth2-mjpeg-444.avi -856628 tests/data/fate/vsynth2-mjpeg-444.avi +10abd087833f9bdf3b77c1aa37dc11e5 *tests/data/fate/vsynth2-mjpeg-444.avi +851442 tests/data/fate/vsynth2-mjpeg-444.avi 34edcb9c87ff7aac456a4fb07f43504b *tests/data/fate/vsynth2-mjpeg-444.out.rawvideo stddev: 4.05 PSNR: 35.96 MAXDIFF: 49 bytes: 7603200/ 7603200