diff mbox series

[FFmpeg-devel,v2,03/69] avcodec/mjpegenc, speedhqenc: Remove nonsense assert

Message ID AM7PR03MB6660928EB7F0A88D9D5628678F269@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit f7d44804a6fe5c3ce29464553411e184eea6461a
Headers show
Series [FFmpeg-devel,v2,01/69] avcodec/avcodec: Avoid MpegEncContext in AVHWAccel.decode_mb | expand


Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 1, 2022, 1:06 p.m. UTC
Our code for writing optimal huffman tables is incompatible
with using multiple slices and hence commit
884506dfe2e29a5b2bd2905ca4f17e277e32acb1 that implemented this
also added an assert that slice_context_count is always 1.

Yet this was always wrong: a) The MJPEG-encoder has (and had)
the AV_CODEC_CAP_SLICE_THREADS capability, so asserting that
it always uses one slice context is incorrect.
b) This commit did not add any proper checks that ensured that
optimal huffman tables are never used together with multiple slices.
This only happened with 03eb0515c12637dbd20c2e3ca8503d7b47cf583a.
c) This assert is at the wrong place: ff_mjpeg_encode_init() is
called before the actual slice_context_count is set. This is
the reason why this assert was never triggered.

Therefore this commit removes this assert.
Also remove an assert from the SpeedHQ encoder sharing b) and c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavcodec/mjpegenc.c   | 2 --
 libavcodec/speedhqenc.c | 2 --
 2 files changed, 4 deletions(-)
diff mbox series


diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index d15b9ece50..022f171c9e 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -293,8 +293,6 @@  av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
     s->mjpeg_ctx = m;
-    av_assert0(s->slice_context_count == 1);
     if (s->codec_id == AV_CODEC_ID_AMV || (s->avctx->active_thread_type & FF_THREAD_SLICE))
         m->huffman = HUFFMAN_TABLE_DEFAULT;
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 967774931c..6df0316611 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -87,8 +87,6 @@  av_cold int ff_speedhq_encode_init(MpegEncContext *s)
     static AVOnce init_static_once = AV_ONCE_INIT;
-    av_assert0(s->slice_context_count == 1);
     if (s->width > 65500 || s->height > 65500) {
         av_log(s, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");
         return AVERROR(EINVAL);