summaryrefslogtreecommitdiff
path: root/libavcodec/mpegvideo_enc.c
diff options
context:
space:
mode:
authorJerry Jiang <jerryjiang1128@gmail.com>2017-02-01 23:23:04 -0800
committerRostislav Pehlivanov <atomnuker@gmail.com>2017-02-08 13:59:53 +0000
commit884506dfe2e29a5b2bd2905ca4f17e277e32acb1 (patch)
treeefac020fcd29af2670ddbf40faff5edb5ddf718e /libavcodec/mpegvideo_enc.c
parent2d453188c2303da641dafb048dc1806790526dfd (diff)
Implement optimal huffman encoding for (M)JPEG.
> seems to break > make fate-vsynth1-mjpeg-444 Fixed.
Diffstat (limited to 'libavcodec/mpegvideo_enc.c')
-rw-r--r--libavcodec/mpegvideo_enc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index cdda73b654..b1d8dae4b2 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -266,7 +266,8 @@ static void mpv_encode_defaults(MpegEncContext *s)
s->picture_in_gop_number = 0;
}
-av_cold int ff_dct_encode_init(MpegEncContext *s) {
+av_cold int ff_dct_encode_init(MpegEncContext *s)
+{
if (ARCH_X86)
ff_dct_encode_init_x86(s);
@@ -642,6 +643,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
return -1;
}
+ if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) &&
+ (s->codec_id == AV_CODEC_ID_AMV ||
+ s->codec_id == AV_CODEC_ID_MJPEG)) {
+ // Used to produce garbage with MJPEG.
+ av_log(avctx, AV_LOG_ERROR,
+ "QP RD is no longer compatible with MJPEG or AMV\n");
+ return -1;
+ }
+
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->scenechange_threshold)
@@ -3932,9 +3942,8 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s->last_bits= put_bits_count(&s->pb);
switch(s->out_format) {
case FMT_MJPEG:
- if (CONFIG_MJPEG_ENCODER)
- ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
- s->pred, s->intra_matrix, s->chroma_intra_matrix);
+ /* The MJPEG headers are printed after the initial encoding so that the
+ * optimal huffman encoding can be found. */
break;
case FMT_H261:
if (CONFIG_H261_ENCODER)