From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 55/57] avcodec/mpegvideo: Remove pblocks Date: Mon, 29 Apr 2024 23:14:36 +0200 Message-ID: <AS8P250MB0744154608E5CEF1D6C8C5ED8F1B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <GV1SPRMB0021759DDCCEFEB3B9609B808F1B2@GV1SPRMB0021.EURP250.PROD.OUTLOOK.COM> It has been added in a579db0c4fe026d49c71d1ff64a2d1d07c152d68 due to XvMC, but today it is only used to swap U and V for VCR2, a MPEG-2 variant with U and V swapped. This can be done in a simpler fashion, namely by simply swapping the U and V pointers of the corresponding MPVWorkPictures. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpeg12dec.c | 20 ++++++++++++++++---- libavcodec/mpegvideo.c | 22 ++-------------------- libavcodec/mpegvideo.h | 1 - 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 55e3a31e95..139e825216 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -535,14 +535,14 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) { for (i = 0; i < mb_block_count; i++) - if ((ret = mpeg2_decode_block_intra(s, *s->pblocks[i], i)) < 0) + if ((ret = mpeg2_decode_block_intra(s, s->block[i], i)) < 0) return ret; } else { for (i = 0; i < 6; i++) { ret = ff_mpeg1_decode_block_intra(&s->gb, s->intra_matrix, s->intra_scantable.permutated, - s->last_dc, *s->pblocks[i], + s->last_dc, s->block[i], i, s->qscale); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", @@ -760,7 +760,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) for (i = 0; i < mb_block_count; i++) { if (cbp & (1 << 11)) { - if ((ret = mpeg2_decode_block_non_intra(s, *s->pblocks[i], i)) < 0) + if ((ret = mpeg2_decode_block_non_intra(s, s->block[i], i)) < 0) return ret; } else { s->block_last_index[i] = -1; @@ -770,7 +770,7 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64]) } else { for (i = 0; i < 6; i++) { if (cbp & 32) { - if ((ret = mpeg1_decode_block_inter(s, *s->pblocks[i], i)) < 0) + if ((ret = mpeg1_decode_block_inter(s, s->block[i], i)) < 0) return ret; } else { s->block_last_index[i] = -1; @@ -1279,6 +1279,7 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx = s->avctx; + int second_field = 0; int ret; if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) { @@ -1362,6 +1363,7 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size) if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_finish_setup(avctx); } else { // second field + second_field = 1; if (!s->cur_pic.ptr) { av_log(s->avctx, AV_LOG_ERROR, "first field missing\n"); return AVERROR_INVALIDDATA; @@ -1389,6 +1391,16 @@ static int mpeg_field_start(Mpeg1Context *s1, const uint8_t *buf, int buf_size) if (avctx->hwaccel) { if ((ret = FF_HW_CALL(avctx, start_frame, buf, buf_size)) < 0) return ret; + } else if (s->codec_tag == MKTAG('V', 'C', 'R', '2')) { + // Exchange UV + FFSWAP(uint8_t*, s->cur_pic.data[1], s->cur_pic.data[2]); + FFSWAP(ptrdiff_t, s->cur_pic.linesize[1], s->cur_pic.linesize[2]); + if (!second_field) { + FFSWAP(uint8_t*, s->next_pic.data[1], s->next_pic.data[2]); + FFSWAP(ptrdiff_t, s->next_pic.linesize[1], s->next_pic.linesize[2]); + FFSWAP(uint8_t*, s->last_pic.data[1], s->last_pic.data[2]); + FFSWAP(ptrdiff_t, s->last_pic.linesize[1], s->last_pic.linesize[2]); + } } return 0; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 17516f6fab..3cb8d06914 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -365,8 +365,6 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s) static int init_duplicate_context(MpegEncContext *s) { - int i; - if (s->encoding) { s->me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->me.map)); if (!s->me.map) @@ -382,15 +380,6 @@ static int init_duplicate_context(MpegEncContext *s) return AVERROR(ENOMEM); s->block = s->blocks[0]; - for (i = 0; i < 12; i++) { - s->pblocks[i] = &s->block[i]; - } - - if (s->avctx->codec_tag == AV_RL32("VCR2")) { - // exchange uv - FFSWAP(void *, s->pblocks[4], s->pblocks[5]); - } - if (s->out_format == FMT_H263) { int mb_height = s->msmpeg4_version == 6 /* VC-1 like */ ? FFALIGN(s->mb_height, 2) : s->mb_height; @@ -484,18 +473,12 @@ static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src) int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src) { MpegEncContext bak; - int i, ret; + int ret; // FIXME copy only needed parts backup_duplicate_context(&bak, dst); memcpy(dst, src, sizeof(MpegEncContext)); backup_duplicate_context(dst, &bak); - for (i = 0; i < 12; i++) { - dst->pblocks[i] = &dst->block[i]; - } - if (dst->avctx->codec_tag == AV_RL32("VCR2")) { - // exchange uv - FFSWAP(void *, dst->pblocks[4], dst->pblocks[5]); - } + ret = ff_mpv_framesize_alloc(dst->avctx, &dst->sc, dst->linesize); if (ret < 0) { av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context " @@ -679,7 +662,6 @@ static void clear_context(MpegEncContext *s) s->dct_error_sum = NULL; s->block = NULL; s->blocks = NULL; - memset(s->pblocks, 0, sizeof(s->pblocks)); s->ac_val_base = NULL; s->ac_val[0] = s->ac_val[1] = diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 6c30e4119d..43d28a269a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -467,7 +467,6 @@ typedef struct MpegEncContext { int rtp_payload_size; uint8_t *ptr_lastgob; - int16_t (*pblocks[12])[64]; int16_t (*block)[64]; ///< points to one of the following blocks int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block -- 2.40.1 _______________________________________________ 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:[~2024-04-29 21:21 UTC|newest] Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-29 0:28 [FFmpeg-devel] [PATCH 01/14] avcodec/get_buffer: Remove redundant check Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 02/14] avcodec/mpegpicture: Store linesize in ScratchpadContext Andreas Rheinhardt 2024-04-29 15:09 ` [FFmpeg-devel] [PATCH v2 2/14] " Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 03/14] avcodec/mpegvideo_dec: Sync linesize and uvlinesize between threads Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 04/14] avcodec/mpegvideo_dec: Factor allocating dummy frames out Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 05/14] avcodec/mpegpicture: Mark dummy frames as such Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 06/14] avcodec/mpeg12dec: Allocate dummy frames for non-I fields Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 07/14] avcodec/mpegvideo_motion: Remove dead checks for existence of reference Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 08/14] avcodec/mpegvideo_motion: Optimize check away Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 09/14] " Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 10/14] avcodec/mpegvideo_motion: Avoid constant function argument Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 11/14] avcodec/msmpeg4enc: Only calculate coded_cbp when used Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 12/14] avcodec/mpegvideo: Only allocate coded_block when needed Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 13/14] avcodec/mpegvideo: Don't reset coded_block unnecessarily Andreas Rheinhardt 2024-04-29 0:35 ` [FFmpeg-devel] [PATCH 14/14] avcodec/mpegvideo: Only allocate cbp_table, pred_dir_table when needed Andreas Rheinhardt 2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 15/57] avcodec/mpegpicture: Always reset motion val buffer Andreas Rheinhardt 2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 16/57] avcodec/mpegvideo: Redo aligning mb_height for VC-1 Andreas Rheinhardt 2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 17/57] avcodec/mpegvideo, mpegpicture: Add buffer pool Andreas Rheinhardt 2024-04-30 20:40 ` Michael Niedermayer 2024-04-30 20:58 ` James Almer 2024-04-30 21:07 ` Andreas Rheinhardt 2024-04-30 21:06 ` Andreas Rheinhardt 2024-04-29 21:13 ` [FFmpeg-devel] [PATCH 18/57] avcodec/mpegpicture: Reindent after the previous commit Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 19/57] avcodec/mpegpicture: Use RefStruct-pool API Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 20/57] avcodec/mpegvideo: Shorten variable names Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 21/57] avcodec/mpegpicture: Reduce value of MAX_PLANES define Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 22/57] avcodec/mpegpicture: Cache AVFrame.data and linesize values Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 23/57] avcodec/rv30, rv34, rv40: Avoid indirection Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 24/57] avcodec/mpegvideo: Add const where appropriate Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 25/57] avcodec/vc1_pred: Remove unused function parameter Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 26/57] avcodec/mpegpicture: Improve error messages and code Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 27/57] avcodec/mpegpicture: Split ff_alloc_picture() into check and alloc part Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 28/57] avcodec/mpegvideo_enc: Pass AVFrame*, not Picture* to alloc_picture() Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 29/57] avcodec/mpegvideo_enc: Move copying properties " Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 30/57] avcodec/mpegpicture: Rename Picture->MPVPicture Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 31/57] avcodec/mpegpicture: Split MPVPicture into WorkPicture and ordinary Pic Andreas Rheinhardt 2024-04-30 18:57 ` Michael Niedermayer 2024-04-30 19:07 ` Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 32/57] avcodec/error_resilience: Deduplicate cleanup code Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 33/57] avcodec/mpegvideo_enc: Factor setting length of B frame chain out Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 34/57] avcodec/mpegvideo_enc: Return early when getting length of B frame chain Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 35/57] avcodec/mpegvideo_enc: Reindentation Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 36/57] avcodec/mpeg12dec: Don't initialize inter tables for IPU Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 37/57] avcodec/mpeg12dec: Only initialize IDCT " Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 38/57] avcodec/mpeg12dec: Remove write-only assignment Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 39/57] avcodec/mpeg12dec: Set out_format only once Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 40/57] avformat/riff: Declare VCR2 to be MPEG-2 Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 41/57] avcodec/mpegvideo_dec: Add close function for mpegvideo-decoders Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 42/57] avcodec/mpegpicture: Make MPVPicture refcounted Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 43/57] avcodec/mpeg4videoenc: Avoid branch for writing stuffing Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 44/57] avcodec/mpeg4videoenc: Simplify writing startcodes Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 45/57] avcodec/mpegpicture: Use ThreadProgress instead of ThreadFrame API Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 46/57] avcodec/mpegpicture: Avoid loop and branch when setting motion_val Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 47/57] avcodec/mpegpicture: Use union for b_scratchpad and rd_scratchpad Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 48/57] avcodec/mpegpicture: Avoid MotionEstContext in ff_mpeg_framesize_alloc() Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 49/57] avcodec/mpegvideo_enc: Unify initializing PutBitContexts Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 50/57] avcodec/mpeg12enc: Simplify writing startcodes Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 51/57] avcodec/mpegvideo_dec: Simplify check for "does pic exist?" Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 52/57] avcodec/mpegvideo_dec: Don't sync encoder-only coded_picture_number Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 53/57] avcodec/mpeg12dec: Pass Mpeg1Context* in mpeg_field_start() Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 54/57] avcodec/mpeg12dec: Don't initialize inter_scantable Andreas Rheinhardt 2024-04-29 21:14 ` Andreas Rheinhardt [this message] 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 56/57] avcodec/mpegvideo: Use enum for msmpeg4_version Andreas Rheinhardt 2024-04-29 21:14 ` [FFmpeg-devel] [PATCH 57/57] avcodec/ituh263enc: Remove redundant check 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=AS8P250MB0744154608E5CEF1D6C8C5ED8F1B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=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