1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/mpegvideoenc: Add MPVMainEncContext

This is in preparation for moving all the elements from
MpegEncContext that are only used by the main encoder thread
to MPVMainEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-02-28 18:56:15 +01:00
parent ad4f6a3d6e
commit f507f26e47
13 changed files with 21 additions and 17 deletions

View File

@ -89,7 +89,7 @@ const FFCodec ff_flv_encoder = {
.p.id = AV_CODEC_ID_FLV1,
.p.priv_class = &ff_mpv_enc_class,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = ff_mpv_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,

View File

@ -55,7 +55,7 @@ static uint8_t uni_h261_rl_len_last[64 * 128];
static uint8_t h261_mv_codes[64][2];
typedef struct H261EncContext {
MpegEncContext s;
MPVMainEncContext s;
H261Context common;
@ -167,7 +167,7 @@ static inline int get_cbp(MpegEncContext *s, int16_t block[6][64])
*/
static void h261_encode_block(H261EncContext *h, int16_t *block, int n)
{
MpegEncContext *const s = &h->s;
MpegEncContext *const s = &h->s.s;
int level, run, i, j, last_index, last_non_zero;
if (s->mb_intra) {

View File

@ -908,7 +908,7 @@ const FFCodec ff_h263_encoder = {
.p.priv_class = &h263_class,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = ff_mpv_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,
@ -941,7 +941,7 @@ const FFCodec ff_h263p_encoder = {
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = ff_mpv_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,

View File

@ -64,7 +64,7 @@ typedef struct MJpegHuffmanCode {
* MpegEncContext is followed by a MjpegContext; the other threads
* can access this shared context via MpegEncContext.mjpeg. */
typedef struct MJPEGEncContext {
MpegEncContext mpeg;
MPVMainEncContext mpeg;
MJpegContext mjpeg;
} MJPEGEncContext;

View File

@ -72,7 +72,7 @@ static uint32_t mpeg1_lum_dc_uni[512];
static uint32_t mpeg1_chr_dc_uni[512];
typedef struct MPEG12EncContext {
MpegEncContext mpeg;
MPVMainEncContext mpeg;
AVRational frame_rate_ext;
unsigned frame_rate_index;
@ -201,7 +201,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
if (mpeg12->mpeg.q_scale_type == 1) {
if (mpeg12->mpeg.s.q_scale_type == 1) {
if (avctx->qmax > 28) {
av_log(avctx, AV_LOG_ERROR,
"non linear quant only supports qmax <= 28 currently\n");

View File

@ -1395,7 +1395,7 @@ const FFCodec ff_mpeg4_encoder = {
CODEC_LONG_NAME("MPEG-4 part 2"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_MPEG4,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,

View File

@ -33,6 +33,10 @@
#include "libavutil/opt.h"
#include "mpegvideo.h"
typedef struct MPVMainEncContext {
MpegEncContext s; ///< The main slicecontext
} MPVMainEncContext;
#define MAX_FCODE 7
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
#define INPLACE_OFFSET 16

View File

@ -151,7 +151,7 @@ av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
static void find_best_tables(MSMPEG4EncContext *ms)
{
MpegEncContext *const s = &ms->s;
MpegEncContext *const s = &ms->m.s;
int i;
int best = 0, best_size = INT_MAX;
int chroma_best = 0, best_chroma_size = INT_MAX;

View File

@ -22,12 +22,12 @@
#ifndef AVCODEC_MSMPEG4ENC_H
#define AVCODEC_MSMPEG4ENC_H
#include "mpegvideo.h"
#include "mpegvideoenc.h"
#include "put_bits.h"
#include "rl.h"
typedef struct MSMPEG4EncContext {
MpegEncContext s;
MPVMainEncContext m;
/** [mb_intra][isChroma][level][run][last] */
unsigned ac_stats[2][2][MAX_LEVEL + 1][MAX_RUN + 1][2];

View File

@ -72,7 +72,7 @@ const FFCodec ff_rv10_encoder = {
.p.id = AV_CODEC_ID_RV10,
.p.priv_class = &ff_mpv_enc_class,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = ff_mpv_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,

View File

@ -69,7 +69,7 @@ const FFCodec ff_rv20_encoder = {
.p.id = AV_CODEC_ID_RV20,
.p.priv_class = &ff_mpv_enc_class,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.priv_data_size = sizeof(MpegEncContext),
.priv_data_size = sizeof(MPVMainEncContext),
.init = ff_mpv_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,

View File

@ -59,7 +59,7 @@ static uint32_t speedhq_chr_dc_uni[512];
static uint8_t uni_speedhq_ac_vlc_len[64 * 64 * 2];
typedef struct SpeedHQEncContext {
MpegEncContext m;
MPVMainEncContext m;
int slice_start;
} SpeedHQEncContext;

View File

@ -49,7 +49,7 @@ typedef struct WMV2EncContext {
static int encode_ext_header(WMV2EncContext *w)
{
MpegEncContext *const s = &w->msmpeg4.s;
MpegEncContext *const s = &w->msmpeg4.m.s;
PutBitContext pb;
int code;
@ -76,7 +76,7 @@ static int encode_ext_header(WMV2EncContext *w)
static av_cold int wmv2_encode_init(AVCodecContext *avctx)
{
WMV2EncContext *const w = avctx->priv_data;
MpegEncContext *const s = &w->msmpeg4.s;
MpegEncContext *const s = &w->msmpeg4.m.s;
s->private_ctx = &w->common;
if (ff_mpv_encode_init(avctx) < 0)