[FFmpeg-cvslog] avcodec/utvideo: Split UTvideoContext into decoder and encoder contexts

Andreas Rheinhardt git at videolan.org
Sun Oct 1 02:11:47 EEST 2023


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Sep 28 21:16:29 2023 +0200| [b2f5899ec2062f209b9a4d4277910678c6d55f79] | committer: Andreas Rheinhardt

avcodec/utvideo: Split UTvideoContext into decoder and encoder contexts

In particular the encoder used only a small part of the context:
The new encoder context is only 128B here. It used to be 32992.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b2f5899ec2062f209b9a4d4277910678c6d55f79
---

 libavcodec/utvideo.h    | 35 +----------------------------------
 libavcodec/utvideodec.c | 27 +++++++++++++++++++++++++++
 libavcodec/utvideoenc.c | 18 +++++++++++++++++-
 3 files changed, 45 insertions(+), 35 deletions(-)

diff --git a/libavcodec/utvideo.h b/libavcodec/utvideo.h
index e5160aa394..b081b50a2f 100644
--- a/libavcodec/utvideo.h
+++ b/libavcodec/utvideo.h
@@ -27,12 +27,7 @@
  * Common Ut Video header
  */
 
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "bswapdsp.h"
-#include "utvideodsp.h"
-#include "lossless_videodsp.h"
-#include "lossless_videoencdsp.h"
+#include "libavutil/macros.h"
 
 enum {
     PRED_NONE = 0,
@@ -61,32 +56,4 @@ enum {
     UTVIDEO_444  = MKTAG('Y', 'V', '2', '4'),
 };
 
-typedef struct UtvideoContext {
-    const AVClass *class;
-    AVCodecContext *avctx;
-    UTVideoDSPContext utdsp;
-    BswapDSPContext bdsp;
-    LLVidDSPContext llviddsp;
-    LLVidEncDSPContext llvidencdsp;
-
-    uint32_t frame_info_size, flags, frame_info, offset;
-    int      planes;
-    int      slices;
-    int      compression;
-    int      interlaced;
-    int      frame_pred;
-    int      pro;
-    int      pack;
-
-    ptrdiff_t slice_stride;
-    uint8_t *slice_bits, *slice_buffer[4];
-    int      slice_bits_size;
-    void    *buffer;
-
-    const uint8_t *packed_stream[4][256];
-    size_t packed_stream_size[4][256];
-    const uint8_t *control_stream[4][256];
-    size_t control_stream_size[4][256];
-} UtvideoContext;
-
 #endif /* AVCODEC_UTVIDEO_H */
diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index 7ee07209d4..16f51e4b47 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -37,8 +37,35 @@
 #include "bytestream.h"
 #include "codec_internal.h"
 #include "get_bits.h"
+#include "lossless_videodsp.h"
 #include "thread.h"
 #include "utvideo.h"
+#include "utvideodsp.h"
+
+typedef struct UtvideoContext {
+    AVCodecContext *avctx;
+    UTVideoDSPContext utdsp;
+    BswapDSPContext bdsp;
+    LLVidDSPContext llviddsp;
+
+    uint32_t frame_info_size, flags, frame_info, offset;
+    int      planes;
+    int      slices;
+    int      compression;
+    int      interlaced;
+    int      frame_pred;
+    int      pro;
+    int      pack;
+
+    uint8_t *slice_bits;
+    int      slice_bits_size;
+    void    *buffer;
+
+    const uint8_t *packed_stream[4][256];
+    size_t packed_stream_size[4][256];
+    const uint8_t *control_stream[4][256];
+    size_t control_stream_size[4][256];
+} UtvideoContext;
 
 typedef struct HuffEntry {
     uint8_t len;
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 6e87bbc2b6..1fcb6854f2 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -33,11 +33,28 @@
 #include "encode.h"
 #include "bswapdsp.h"
 #include "bytestream.h"
+#include "lossless_videoencdsp.h"
 #include "put_bits.h"
 #include "mathops.h"
 #include "utvideo.h"
 #include "huffman.h"
 
+typedef struct UtvideoContext {
+    const AVClass *class;
+    BswapDSPContext bdsp;
+    LLVidEncDSPContext llvidencdsp;
+
+    uint32_t frame_info_size, flags;
+    int      planes;
+    int      slices;
+    int      compression;
+    int      frame_pred;
+
+    ptrdiff_t slice_stride;
+    uint8_t  *slice_bits, *slice_buffer[4];
+    int       slice_bits_size;
+} UtvideoContext;
+
 typedef struct HuffEntry {
     uint16_t sym;
     uint8_t  len;
@@ -76,7 +93,6 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
     int i, subsampled_height;
     uint32_t original_format;
 
-    c->avctx           = avctx;
     c->frame_info_size = 4;
     c->slice_stride    = FFALIGN(avctx->width, 32);
 



More information about the ffmpeg-cvslog mailing list