1
0
Fork 0

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@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-28 21:16:29 +02:00
parent 0e18f1e9a3
commit b2f5899ec2
3 changed files with 45 additions and 35 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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);