summaryrefslogtreecommitdiff
path: root/libavcodec/mjpegenc_common.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-02-09 23:24:15 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-02-10 00:12:01 +0100
commit3e1507a9547ac09b6ff4372123cde09f19218f3d (patch)
tree80afbf6c25ff3d0f82e7c2a5216c2fca287959a5 /libavcodec/mjpegenc_common.c
parentf57665b3181d5cbed680754983d9a6fdc1bfec5f (diff)
downloadffmpeg-3e1507a9547ac09b6ff4372123cde09f19218f3d.tar.gz
avcodec/mjpegenc: Bypass the 2 pass encoding when optimal tables are not requested
This limits the bugs, speedloss and extra memory allocation to the case when optimal tables are needed. Fixes regressions with slice multi-threading Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mjpegenc_common.c')
-rw-r--r--libavcodec/mjpegenc_common.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index e53a45ca4d..722ad5e4da 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -480,7 +480,8 @@ static void ff_mjpeg_build_optimal_huffman(MJpegContext *m)
}
/**
- * Writes the complete JPEG frame.
+ * Writes the complete JPEG frame when optimal huffman tables are enabled,
+ * otherwise writes the stuffing.
*
* Header + values + stuffing.
*
@@ -508,11 +509,11 @@ int ff_mjpeg_encode_stuffing(MpegEncContext *s)
s->intra_ac_vlc_last_length = m->uni_ac_vlc_len;
s->intra_chroma_ac_vlc_length =
s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len;
- }
- ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
- s->pred, s->intra_matrix, s->chroma_intra_matrix);
- ff_mjpeg_encode_picture_frame(s);
+ ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
+ s->pred, s->intra_matrix, s->chroma_intra_matrix);
+ ff_mjpeg_encode_picture_frame(s);
+ }
ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
put_bits_count(&s->pb) / 4 + 1000);