From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideo: Move sprite-related fields to Mpeg4DecContext Date: Wed, 12 Oct 2022 20:06:20 +0200 Message-ID: <AS8P250MB0744FFA0095755D5280D48638F229@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB07442BB411A6556D803295C78F229@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> Only used there. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpeg4videodec.c | 106 ++++++++++++++++++------------------- libavcodec/mpeg4videodec.h | 4 ++ libavcodec/mpegvideo.h | 4 -- libavcodec/vaapi_mpeg4.c | 2 +- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 1638664e00..dcf970af5a 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -81,12 +81,12 @@ static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, ptrdiff_t offset, linesize, uvlinesize; int emu = 0; - motion_x = s->sprite_offset[0][0]; - motion_y = s->sprite_offset[0][1]; - src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy + 1)); - src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy + 1)); - motion_x *= 1 << (3 - s->sprite_warping_accuracy); - motion_y *= 1 << (3 - s->sprite_warping_accuracy); + motion_x = ctx->sprite_offset[0][0]; + motion_y = ctx->sprite_offset[0][1]; + src_x = s->mb_x * 16 + (motion_x >> (ctx->sprite_warping_accuracy + 1)); + src_y = s->mb_y * 16 + (motion_y >> (ctx->sprite_warping_accuracy + 1)); + motion_x *= 1 << (3 - ctx->sprite_warping_accuracy); + motion_y *= 1 << (3 - ctx->sprite_warping_accuracy); src_x = av_clip(src_x, -16, s->width); if (src_x == s->width) motion_x = 0; @@ -128,12 +128,12 @@ static void gmc1_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; - motion_x = s->sprite_offset[1][0]; - motion_y = s->sprite_offset[1][1]; - src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy + 1)); - src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy + 1)); - motion_x *= 1 << (3 - s->sprite_warping_accuracy); - motion_y *= 1 << (3 - s->sprite_warping_accuracy); + motion_x = ctx->sprite_offset[1][0]; + motion_y = ctx->sprite_offset[1][1]; + src_x = s->mb_x * 8 + (motion_x >> (ctx->sprite_warping_accuracy + 1)); + src_y = s->mb_y * 8 + (motion_y >> (ctx->sprite_warping_accuracy + 1)); + motion_x *= 1 << (3 - ctx->sprite_warping_accuracy); + motion_y *= 1 << (3 - ctx->sprite_warping_accuracy); src_x = av_clip(src_x, -8, s->width >> 1); if (src_x == s->width >> 1) motion_x = 0; @@ -175,7 +175,7 @@ static void gmc_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, { const uint8_t *ptr; int linesize, uvlinesize; - const int a = s->sprite_warping_accuracy; + const int a = ctx->sprite_warping_accuracy; int ox, oy; linesize = s->linesize; @@ -183,46 +183,46 @@ static void gmc_motion(MpegEncContext *s, const Mpeg4DecContext *ctx, ptr = ref_picture[0]; - ox = s->sprite_offset[0][0] + s->sprite_delta[0][0] * s->mb_x * 16 + - s->sprite_delta[0][1] * s->mb_y * 16; - oy = s->sprite_offset[0][1] + s->sprite_delta[1][0] * s->mb_x * 16 + - s->sprite_delta[1][1] * s->mb_y * 16; + ox = ctx->sprite_offset[0][0] + ctx->sprite_delta[0][0] * s->mb_x * 16 + + ctx->sprite_delta[0][1] * s->mb_y * 16; + oy = ctx->sprite_offset[0][1] + ctx->sprite_delta[1][0] * s->mb_x * 16 + + ctx->sprite_delta[1][1] * s->mb_y * 16; ctx->mdsp.gmc(dest_y, ptr, linesize, 16, ox, oy, - s->sprite_delta[0][0], s->sprite_delta[0][1], - s->sprite_delta[1][0], s->sprite_delta[1][1], + ctx->sprite_delta[0][0], ctx->sprite_delta[0][1], + ctx->sprite_delta[1][0], ctx->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, s->h_edge_pos, s->v_edge_pos); ctx->mdsp.gmc(dest_y + 8, ptr, linesize, 16, - ox + s->sprite_delta[0][0] * 8, - oy + s->sprite_delta[1][0] * 8, - s->sprite_delta[0][0], s->sprite_delta[0][1], - s->sprite_delta[1][0], s->sprite_delta[1][1], - a + 1, (1 << (2 * a + 1)) - s->no_rounding, - s->h_edge_pos, s->v_edge_pos); + ox + ctx->sprite_delta[0][0] * 8, + oy + ctx->sprite_delta[1][0] * 8, + ctx->sprite_delta[0][0], ctx->sprite_delta[0][1], + ctx->sprite_delta[1][0], ctx->sprite_delta[1][1], + a + 1, (1 << (2 * a + 1)) - s->no_rounding, + s->h_edge_pos, s->v_edge_pos); if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) return; - ox = s->sprite_offset[1][0] + s->sprite_delta[0][0] * s->mb_x * 8 + - s->sprite_delta[0][1] * s->mb_y * 8; - oy = s->sprite_offset[1][1] + s->sprite_delta[1][0] * s->mb_x * 8 + - s->sprite_delta[1][1] * s->mb_y * 8; + ox = ctx->sprite_offset[1][0] + ctx->sprite_delta[0][0] * s->mb_x * 8 + + ctx->sprite_delta[0][1] * s->mb_y * 8; + oy = ctx->sprite_offset[1][1] + ctx->sprite_delta[1][0] * s->mb_x * 8 + + ctx->sprite_delta[1][1] * s->mb_y * 8; ptr = ref_picture[1]; ctx->mdsp.gmc(dest_cb, ptr, uvlinesize, 8, ox, oy, - s->sprite_delta[0][0], s->sprite_delta[0][1], - s->sprite_delta[1][0], s->sprite_delta[1][1], + ctx->sprite_delta[0][0], ctx->sprite_delta[0][1], + ctx->sprite_delta[1][0], ctx->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, (s->h_edge_pos + 1) >> 1, (s->v_edge_pos + 1) >> 1); ptr = ref_picture[2]; ctx->mdsp.gmc(dest_cr, ptr, uvlinesize, 8, ox, oy, - s->sprite_delta[0][0], s->sprite_delta[0][1], - s->sprite_delta[1][0], s->sprite_delta[1][1], + ctx->sprite_delta[0][0], ctx->sprite_delta[0][1], + ctx->sprite_delta[1][0], ctx->sprite_delta[1][1], a + 1, (1 << (2 * a + 1)) - s->no_rounding, (s->h_edge_pos + 1) >> 1, (s->v_edge_pos + 1) >> 1); } @@ -233,7 +233,7 @@ void ff_mpeg4_mcsel_motion(MpegEncContext *s, { const Mpeg4DecContext *const ctx = (Mpeg4DecContext*)s; - if (s->real_sprite_warping_points == 1) { + if (ctx->real_sprite_warping_points == 1) { gmc1_motion(s, ctx, dest_y, dest_cb, dest_cr, ref_picture); } else { @@ -418,8 +418,8 @@ static inline int mpeg4_is_resync(Mpeg4DecContext *ctx) static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *gb) { MpegEncContext *s = &ctx->m; - int a = 2 << s->sprite_warping_accuracy; - int rho = 3 - s->sprite_warping_accuracy; + int a = 2 << ctx->sprite_warping_accuracy; + int rho = 3 - ctx->sprite_warping_accuracy; int r = 16 / a; int alpha = 1; int beta = 0; @@ -607,7 +607,7 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g sprite_delta[1][1] = a; ctx->sprite_shift[0] = 0; ctx->sprite_shift[1] = 0; - s->real_sprite_warping_points = 1; + ctx->real_sprite_warping_points = 1; } else { int shift_y = 16 - ctx->sprite_shift[0]; int shift_c = 16 - ctx->sprite_shift[1]; @@ -653,18 +653,18 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext *ctx, GetBitContext *g goto overflow; } } - s->real_sprite_warping_points = ctx->num_sprite_warping_points; + ctx->real_sprite_warping_points = ctx->num_sprite_warping_points; } for (i = 0; i < 4; i++) { - s->sprite_offset[i&1][i>>1] = sprite_offset[i&1][i>>1]; - s->sprite_delta [i&1][i>>1] = sprite_delta [i&1][i>>1]; + ctx->sprite_offset[i&1][i>>1] = sprite_offset[i&1][i>>1]; + ctx->sprite_delta [i&1][i>>1] = sprite_delta [i&1][i>>1]; } return 0; overflow: - memset(s->sprite_offset, 0, sizeof(s->sprite_offset)); - memset(s->sprite_delta, 0, sizeof(s->sprite_delta)); + memset(ctx->sprite_offset, 0, sizeof(ctx->sprite_offset)); + memset(ctx->sprite_delta, 0, sizeof(ctx->sprite_delta)); return AVERROR_PATCHWELCOME; } @@ -832,25 +832,25 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n) MpegEncContext *s = &ctx->m; int x, y, mb_v, sum, dx, dy, shift; int len = 1 << (s->f_code + 4); - const int a = s->sprite_warping_accuracy; + const int a = ctx->sprite_warping_accuracy; if (s->workaround_bugs & FF_BUG_AMV) len >>= s->quarter_sample; - if (s->real_sprite_warping_points == 1) { + if (ctx->real_sprite_warping_points == 1) { if (ctx->divx_version == 500 && ctx->divx_build == 413 && a >= s->quarter_sample) - sum = s->sprite_offset[0][n] / (1 << (a - s->quarter_sample)); + sum = ctx->sprite_offset[0][n] / (1 << (a - s->quarter_sample)); else - sum = RSHIFT(s->sprite_offset[0][n] * (1 << s->quarter_sample), a); + sum = RSHIFT(ctx->sprite_offset[0][n] * (1 << s->quarter_sample), a); } else { - dx = s->sprite_delta[n][0]; - dy = s->sprite_delta[n][1]; + dx = ctx->sprite_delta[n][0]; + dy = ctx->sprite_delta[n][1]; shift = ctx->sprite_shift[0]; if (n) dy -= 1 << (shift + a + 1); else dx -= 1 << (shift + a + 1); - mb_v = s->sprite_offset[0][n] + dx * s->mb_x * 16U + dy * s->mb_y * 16U; + mb_v = ctx->sprite_offset[0][n] + dx * s->mb_x * 16U + dy * s->mb_y * 16U; sum = 0; for (y = 0; y < 16; y++) { @@ -2698,7 +2698,7 @@ static int decode_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb) ctx->num_sprite_warping_points = 0; return AVERROR_INVALIDDATA; } - s->sprite_warping_accuracy = get_bits(gb, 2); + ctx->sprite_warping_accuracy = get_bits(gb, 2); ctx->sprite_brightness_change = get_bits1(gb); if (ctx->vol_sprite_usage == STATIC_SPRITE) skip_bits1(gb); // low_latency_sprite @@ -3286,8 +3286,8 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, if (ctx->vol_sprite_usage == STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n"); } else { - memset(s->sprite_offset, 0, sizeof(s->sprite_offset)); - memset(s->sprite_delta, 0, sizeof(s->sprite_delta)); + memset(ctx->sprite_offset, 0, sizeof(ctx->sprite_offset)); + memset(ctx->sprite_delta, 0, sizeof(ctx->sprite_delta)); } } @@ -3329,7 +3329,7 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first, s->quarter_sample ? 'q' : 'h', s->data_partitioning, ctx->resync_marker, - ctx->num_sprite_warping_points, s->sprite_warping_accuracy, + ctx->num_sprite_warping_points, ctx->sprite_warping_accuracy, 1 - s->no_rounding, ctx->vo_type, ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold, ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p, diff --git a/libavcodec/mpeg4videodec.h b/libavcodec/mpeg4videodec.h index 302c5c38da..c0e6ec6592 100644 --- a/libavcodec/mpeg4videodec.h +++ b/libavcodec/mpeg4videodec.h @@ -38,7 +38,11 @@ typedef struct Mpeg4DecContext { int shape; int vol_sprite_usage; int sprite_brightness_change; + int sprite_warping_accuracy; int num_sprite_warping_points; + int real_sprite_warping_points; + int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY] + int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY] /// sprite trajectory points uint16_t sprite_traj[4][2]; /// sprite shift [isChroma] diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 007d681a09..925e61138d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -376,13 +376,9 @@ typedef struct MpegEncContext { uint16_t pb_time; ///< time distance between the last b and p,s,i frame uint16_t pp_field_time; uint16_t pb_field_time; ///< like above, just for interlaced - int real_sprite_warping_points; - int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY] - int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY] int mcsel; int quant_precision; int quarter_sample; ///< 1->qpel, 0->half pel ME/MC - int sprite_warping_accuracy; int data_partitioning; ///< data partitioning flag from header int partitioned_frame; ///< is current frame partitioned int low_delay; ///< no reordering needed / has no B-frames diff --git a/libavcodec/vaapi_mpeg4.c b/libavcodec/vaapi_mpeg4.c index ca3f3b22f6..4e74e0382b 100644 --- a/libavcodec/vaapi_mpeg4.c +++ b/libavcodec/vaapi_mpeg4.c @@ -66,7 +66,7 @@ static int vaapi_mpeg4_start_frame(AVCodecContext *avctx, av_unused const uint8_ .interlaced = !s->progressive_sequence, .obmc_disable = 1, .sprite_enable = ctx->vol_sprite_usage, - .sprite_warping_accuracy = s->sprite_warping_accuracy, + .sprite_warping_accuracy = ctx->sprite_warping_accuracy, .quant_type = s->mpeg_quant, .quarter_sample = s->quarter_sample, .data_partitioned = s->data_partitioning, -- 2.34.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:[~2022-10-12 18:06 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-12 18:03 [FFmpeg-devel] [PATCH 1/6] avcodec/mpegvideo_motion: Move mspel/gmc motion to mpeg4videodec.c Andreas Rheinhardt 2022-10-12 18:06 ` [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideodsp: Make MpegVideoDSP MPEG-4 only Andreas Rheinhardt 2022-10-12 18:06 ` Andreas Rheinhardt [this message] 2022-10-12 18:06 ` [FFmpeg-devel] [PATCH 4/6] avcodec/mpeg4videodec: Sync sprite_warping_accuracy between threads Andreas Rheinhardt 2022-10-12 18:06 ` [FFmpeg-devel] [PATCH 5/6] avcodec/mpeg4videodec: Remove always-true checks Andreas Rheinhardt 2022-10-13 21:05 ` Michael Niedermayer 2022-10-13 21:23 ` Andreas Rheinhardt 2022-10-13 22:22 ` Michael Niedermayer 2022-10-18 23:13 ` [FFmpeg-devel] [PATCH v2 " Andreas Rheinhardt 2022-10-12 18:06 ` [FFmpeg-devel] [PATCH 6/6] avcodec/mpeg4videodec: Reindent after the previous commit Andreas Rheinhardt 2022-10-19 12:24 ` [FFmpeg-devel] [PATCH 1/6] avcodec/mpegvideo_motion: Move mspel/gmc motion to mpeg4videodec.c 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=AS8P250MB0744FFA0095755D5280D48638F229@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