diff mbox series

[FFmpeg-devel,06/14] avcodec/mjpegenc_common: Move code for MJPEG/AMV to mjpegenc

Message ID AM7PR03MB66606781D84A59310CAA44788F7D9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 8edb2c638cb2970585ad4bc1a5dc632bdc85ae45
Headers show
Series [FFmpeg-devel,01/14] avcodec/mjpegenc: Use custom close function directly | expand

Checks

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 Dec. 22, 2021, 3:25 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mjpegenc.c        |  4 ++++
 libavcodec/mjpegenc_common.c | 14 ++------------
 2 files changed, 6 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index b682036f87..c1b759f7a8 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -78,6 +78,10 @@  static void mjpeg_encode_picture_header(MpegEncContext *s)
 {
     ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable,
                                    s->pred, s->intra_matrix, s->chroma_intra_matrix);
+
+    s->esc_pos = put_bytes_count(&s->pb, 0);
+    for (int i = 1; i < s->slice_context_count; i++)
+        s->thread_context[i]->esc_pos = 0;
 }
 
 void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s)
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 0c6a98c394..8046e4b8f7 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -224,7 +224,6 @@  void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
 {
     const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG && avctx->codec_id != AV_CODEC_ID_AMV;
     int hsample[4], vsample[4];
-    int i;
     int components = 3 + (avctx->pix_fmt == AV_PIX_FMT_BGRA);
     int chroma_matrix = !!memcmp(luma_intra_matrix,
                                  chroma_intra_matrix,
@@ -235,7 +234,8 @@  void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
     put_marker(pb, SOI);
 
     // hack for AMV mjpeg format
-    if(avctx->codec_id == AV_CODEC_ID_AMV) goto end;
+    if (avctx->codec_id == AV_CODEC_ID_AMV)
+        return;
 
     jpeg_put_comments(avctx, pb);
 
@@ -319,16 +319,6 @@  void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
     }
 
     put_bits(pb, 8, 0); /* Ah/Al (not used) */
-
-end:
-    if (!lossless) {
-        MpegEncContext *s = avctx->priv_data;
-        av_assert0(avctx->codec->priv_data_size > sizeof(MpegEncContext));
-
-        s->esc_pos = put_bytes_count(pb, 0);
-        for(i=1; i<s->slice_context_count; i++)
-            s->thread_context[i]->esc_pos = 0;
-    }
 }
 
 void ff_mjpeg_escape_FF(PutBitContext *pb, int start)