From: Andreas Rheinhardt <ffmpegagent-at-gmail.com@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 37/47] avcodec/mpegvideo: Only use a single ac_val pointer Date: Sun, 15 Jun 2025 16:54:28 +0000 Message-ID: <dbeda535967bdba7834286e3b15183364bfa7c1a.1750006480.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.98.ffstaging.FFmpeg.1750006478.ffmpegagent@gmail.com> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> The chroma pointers ac_val[1] and ac_val[2] are no longer used anywhere. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/ituh263dec.c | 2 +- libavcodec/mpeg4video.c | 8 +++++--- libavcodec/mpeg4videodec.c | 6 ++---- libavcodec/mpeg4videoenc.c | 4 ++-- libavcodec/mpegvideo.c | 10 +++------- libavcodec/mpegvideo.h | 2 +- libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/vc1_block.c | 6 +++--- 8 files changed, 19 insertions(+), 23 deletions(-) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 809bfcf564..49a87486cc 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -451,7 +451,7 @@ static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n) int wrap, a, c, pred_dc, scale; const int xy = s->block_index[n]; int16_t *const dc_val = s->dc_val[0] + xy; - int16_t *const ac_val = (s->ac_val[0] + xy)[0]; + int16_t *const ac_val = (s->ac_val + xy)[0]; /* find prediction */ if (n < 4) { diff --git a/libavcodec/mpeg4video.c b/libavcodec/mpeg4video.c index a690077c58..a53ce72dfd 100644 --- a/libavcodec/mpeg4video.c +++ b/libavcodec/mpeg4video.c @@ -50,11 +50,13 @@ void ff_mpeg4_clean_buffers(MpegEncContext *s) l_xy = (2 * s->mb_y - 1) * l_wrap + s->mb_x * 2 - 1; c_wrap = s->mb_stride; int u_xy = 2 * mb_height * l_wrap + s->mb_y * c_wrap + s->mb_x - 1; + int v_xy = u_xy + c_wrap * (mb_height + 1); + int16_t (*ac_val)[16] = s->ac_val; /* clean AC */ - memset(s->ac_val[0] + l_xy, 0, (l_wrap * 2 + 1) * 16 * sizeof(int16_t)); - memset(s->ac_val[0] + u_xy, 0, (c_wrap + 1) * 16 * sizeof(int16_t)); - memset(s->ac_val[0] + u_xy + c_wrap * (mb_height + 1), 0, (c_wrap + 1) * 16 * sizeof(int16_t)); + memset(ac_val + l_xy, 0, (l_wrap * 2 + 1) * sizeof(*ac_val)); + memset(ac_val + u_xy, 0, (c_wrap + 1) * sizeof(*ac_val)); + memset(ac_val + v_xy, 0, (c_wrap + 1) * sizeof(*ac_val)); /* clean MV */ // we can't clear the MVs as they might be needed by a B-frame diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 1294138d05..d5d09e875d 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -326,7 +326,7 @@ void ff_mpeg4_pred_ac(MpegEncContext *s, int16_t *block, int n, int dir) int8_t *const qscale_table = s->cur_pic.qscale_table; /* find prediction */ - ac_val = &s->ac_val[0][0][0] + s->block_index[n] * 16; + ac_val = &s->ac_val[0][0] + s->block_index[n] * 16; ac_val1 = ac_val; if (s->ac_pred) { if (dir == 0) { @@ -3785,9 +3785,7 @@ static av_cold void clear_context(MpegEncContext *s) s->block = NULL; s->blocks = NULL; s->ac_val_base = NULL; - s->ac_val[0] = - s->ac_val[1] = - s->ac_val[2] =NULL; + s->ac_val = NULL; memset(&s->sc, 0, sizeof(s->sc)); s->p_field_mv_table_base = NULL; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 0fa8159f18..543fc9e649 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -130,7 +130,7 @@ static inline void restore_ac_coeffs(MPVEncContext *const s, int16_t block[6][64 memcpy(s->c.block_last_index, zigzag_last_index, sizeof(int) * 6); for (n = 0; n < 6; n++) { - int16_t *ac_val = &s->c.ac_val[0][0][0] + s->c.block_index[n] * 16; + int16_t *ac_val = &s->c.ac_val[0][0] + s->c.block_index[n] * 16; st[n] = s->c.intra_scantable.permutated; if (dir[n]) { @@ -169,7 +169,7 @@ static inline int decide_ac_pred(MPVEncContext *const s, int16_t block[6][64], score -= get_block_rate(s, block[n], s->c.block_last_index[n], s->c.intra_scantable.permutated); - ac_val = &s->c.ac_val[0][0][0] + s->c.block_index[n] * 16; + ac_val = &s->c.ac_val[0][0] + s->c.block_index[n] * 16; ac_val1 = ac_val; if (dir[n]) { const int xy = s->c.mb_x + s->c.mb_y * s->c.mb_stride - s->c.mb_stride; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 64563a509b..e528935f68 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -129,9 +129,7 @@ static av_cold int init_duplicate_context(MpegEncContext *s) /* ac values */ if (!FF_ALLOCZ_TYPED_ARRAY(s->ac_val_base, yc_size)) return AVERROR(ENOMEM); - s->ac_val[0] = s->ac_val_base + s->b8_stride + 1; - s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1; - s->ac_val[2] = s->ac_val[1] + c_size; + s->ac_val = s->ac_val_base + s->b8_stride + 1; } return 0; @@ -195,9 +193,7 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) COPY(start_mb_y); COPY(end_mb_y); COPY(ac_val_base); - COPY(ac_val[0]); - COPY(ac_val[1]); - COPY(ac_val[2]); + COPY(ac_val); #undef COPY } @@ -502,7 +498,7 @@ void ff_clean_intra_table_entries(MpegEncContext *s) dc_val[uxy] = dc_val[vxy] = 1024; /* ac pred */ - int16_t (*ac_val)[16] = s->ac_val[0]; + int16_t (*ac_val)[16] = s->ac_val; av_assume(!((uintptr_t)ac_val & 0xF)); // Don't reset the upper-left luma block, as it will only ever be // referenced by blocks from the same macroblock. diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 68d70cc0e3..72614d45f1 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -148,7 +148,7 @@ typedef struct MpegEncContext { uint8_t *coded_block_base; uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1) int16_t (*ac_val_base)[16]; - int16_t (*ac_val[3])[16]; ///< used for MPEG-4 AC prediction, all 3 arrays must be continuous + int16_t (*ac_val)[16]; ///< used for H.263 AIC, MPEG-4 AC prediction int mb_skipped; ///< MUST BE SET only during DECODING uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example) and used for B-frame encoding & decoding (contains skip table of next P-frame) */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 04cebee9c6..870cf7f5a7 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3327,7 +3327,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(storecoefs){ for(i=0; i<6; i++){ dc[i] = s->c.dc_val[0][s->c.block_index[i]]; - memcpy(ac[i], s->c.ac_val[0][s->c.block_index[i]], sizeof(int16_t)*16); + memcpy(ac[i], s->c.ac_val[s->c.block_index[i]], sizeof(*s->c.ac_val)); } } @@ -3337,7 +3337,7 @@ static int encode_thread(AVCodecContext *c, void *arg){ if(storecoefs){ for(i=0; i<6; i++){ s->c.dc_val[0][s->c.block_index[i]] = dc[i]; - memcpy(s->c.ac_val[0][s->c.block_index[i]], ac[i], sizeof(int16_t)*16); + memcpy(s->c.ac_val[s->c.block_index[i]], ac[i], sizeof(*s->c.ac_val)); } } } diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 1661fdd742..9427e96d1e 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -611,7 +611,7 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, /* Store the quantized DC coeff, used for prediction */ block[0] = dcdiff * s->y_dc_scale; - ac_val = s->ac_val[0][s->block_index[n]]; + ac_val = s->ac_val[s->block_index[n]]; ac_val2 = ac_val; if (dc_pred_dir) // left ac_val -= 16; @@ -750,7 +750,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq); - ac_val = s->ac_val[0][s->block_index[n]]; + ac_val = s->ac_val[s->block_index[n]]; ac_val2 = ac_val; if (dc_pred_dir) // left ac_val -= 16; @@ -938,7 +938,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, if (!a_avail) dc_pred_dir = 1; if (!c_avail) dc_pred_dir = 0; if (!a_avail && !c_avail) use_pred = 0; - ac_val = s->ac_val[0][s->block_index[n]]; + ac_val = s->ac_val[s->block_index[n]]; ac_val2 = ac_val; scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq); -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-06-15 17:02 UTC|newest] Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-15 16:53 [FFmpeg-devel] [PATCH 00/47] avcodec/mpeg4videodec: Don't zero blocks twice ffmpegagent 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 01/47] " Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 02/47] avcodec/rv10: Perform RV20 initialization during init Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 03/47] avcodec/rv10: Perform RV20 check only for RV20 Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 04/47] avcodec/ituh263dec: Don't process unnecessarily many coefficients Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 05/47] avcodec/ituh263dec: Remove redundant store Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 06/47] avcodec/ituh263enc: Don't use array unnecessarily Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 07/47] avcodec/ituh263enc: Fix indentation Andreas Rheinhardt 2025-06-15 16:53 ` [FFmpeg-devel] [PATCH 08/47] avcodec/mpeg12dec: Don't store block_last_index unnecessarily Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 09/47] avcodec/rv10: Avoid indirection when reading VLC codes Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 10/47] avcodec/mpeg_er: Mark ff_mpeg_er_init() as av_cold Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 11/47] avcodec/mpegvideo_enc: Remove always-true branch Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 12/47] avcodec/motion_est: Fix indentation Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 13/47] avcodec/svq1enc: Don't free scratchbuf upon error Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 14/47] avcodec/svq1enc: Allocate motion_val{8, 16} during init Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 15/47] avcodec/svq1enc: Stop calling ff_mpv_common_init() Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 16/47] avcodec/svq1enc: Remove write-only c_block_{width, height} Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 17/47] avcodec/svq1enc: Set MpegEncContext.avctx only once Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 18/47] avcodec/svq1enc: Don't initialize unneeded block_index Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 19/47] configure: Factor mpegvideoencdsp out of mpegvideoenc Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 20/47] configure: Relax svq1enc->mpegvideoenc dependency Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 21/47] configure: Relax diracdec->mpegvideoenc dependency Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 22/47] configure: Relax snowenc->mpegvideoenc dependency Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 23/47] avcodec/mpegvideo: Don't reset thread_context ptrs unnecessarily Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 24/47] avcodec/mpegvideo: Don't zero unnecessarily Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 25/47] avcodec/mpegvideo: Defer init of enc slice ctxs in ff_mpv_common_init() Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 26/47] avcodec/mpegvideo_enc: Simplify allocating non-slice buffers Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 27/47] avcodec/ituh263dec: Simplify AIC handling Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 28/47] avcodec/ituh263enc: " Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 29/47] avcodec/flvenc: Combine writing bits Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 30/47] avcodec/flvenc: Move ff_flv2_encode_ac_esc() to ituh263enc.c Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 31/47] avcodec/mpegvideo: Redo resetting intra table entry Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 32/47] avcodec/mpegvideo: Avoid {a, d}c_val[{1, 2}] Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 33/47] avcodec/mpegvideo: Provide alignment hint to compiler Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 34/47] avcodec/mpegvideo: Don't reset AC values of upper-left luma block Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 35/47] avcodec/mpegvideo: Combine stores Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 36/47] avcodec/mpeg4video: Don't use ac_val[1], ac_val[2] when cleaning buffers Andreas Rheinhardt 2025-06-15 16:54 ` Andreas Rheinhardt [this message] 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 38/47] avcodec/mpegvideo: Allocate ac_val jointly Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 39/47] avcodec/mpegvideo: Zero-init mbintra_table Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 40/47] avcodec/mpegvideo: Only keep MpegEncContext.dc_val[0] Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 41/47] avcodec/vc1: Only keep mb_type[0] Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 42/47] avcodec/mpegvideo: Allocate dc_val for each encoder slice Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 43/47] avcodec/{ituh263, mpeg4video}enc: Simplify out-of-slice DC prediction Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 44/47] avcodec/mpeg4video: Move ff_mpeg4_pred_dc() to decoder Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 45/47] avcodec/ituh263enc: Simplify encoding umotion vectors Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 46/47] avcodec/mpegvideo: Reduce stack usage when copying MpegEncContext Andreas Rheinhardt 2025-06-15 16:54 ` [FFmpeg-devel] [PATCH 47/47] avcodec/mpeg4videoenc: Fix data race when using AC prediction Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=dbeda535967bdba7834286e3b15183364bfa7c1a.1750006480.git.ffmpegagent@gmail.com \ --to=ffmpegagent-at-gmail.com@ffmpeg.org \ --cc=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git