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 12/47] avcodec/motion_est: Fix indentation Date: Sun, 15 Jun 2025 16:54:03 +0000 Message-ID: <d9df0d2ad8273877d1adf0fade02cc7f53bb392b.1750006479.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.98.ffstaging.FFmpeg.1750006478.ffmpegagent@gmail.com> From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Forgotten after 919e749772d09900b41877e21ccb994fab0013ab. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/motion_est.c | 180 ++++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 93aa909fb5..333048d1c8 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -118,64 +118,64 @@ static av_always_inline int cmp_direct_inline(MPVEncContext *const s, const int const uint8_t * const * const src = c->src[src_index]; int d; //FIXME check chroma 4mv, (no crashes ...) - av_assert2(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)); - if(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)){ - const int time_pp = s->c.pp_time; - const int time_pb = s->c.pb_time; - const int mask= 2*qpel+1; - if (s->c.mv_type == MV_TYPE_8X8) { - int i; - for(i=0; i<4; i++){ - int fx = c->direct_basis_mv[i][0] + hx; - int fy = c->direct_basis_mv[i][1] + hy; - int bx = hx ? fx - c->co_located_mv[i][0] : c->co_located_mv[i][0]*(time_pb - time_pp)/time_pp + ((i &1)<<(qpel+4)); - int by = hy ? fy - c->co_located_mv[i][1] : c->co_located_mv[i][1]*(time_pb - time_pp)/time_pp + ((i>>1)<<(qpel+4)); - int fxy= (fx&mask) + ((fy&mask)<<(qpel+1)); - int bxy= (bx&mask) + ((by&mask)<<(qpel+1)); - - uint8_t *dst= c->temp + 8*(i&1) + 8*stride*(i>>1); - if(qpel){ - c->qpel_put[1][fxy](dst, ref[0] + (fx>>2) + (fy>>2)*stride, stride); - c->qpel_avg[1][bxy](dst, ref[8] + (bx>>2) + (by>>2)*stride, stride); - }else{ - c->hpel_put[1][fxy](dst, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 8); - c->hpel_avg[1][bxy](dst, ref[8] + (bx>>1) + (by>>1)*stride, stride, 8); - } - } - }else{ - int fx = c->direct_basis_mv[0][0] + hx; - int fy = c->direct_basis_mv[0][1] + hy; - int bx = hx ? fx - c->co_located_mv[0][0] : (c->co_located_mv[0][0]*(time_pb - time_pp)/time_pp); - int by = hy ? fy - c->co_located_mv[0][1] : (c->co_located_mv[0][1]*(time_pb - time_pp)/time_pp); - int fxy= (fx&mask) + ((fy&mask)<<(qpel+1)); - int bxy= (bx&mask) + ((by&mask)<<(qpel+1)); - - if(qpel){ - c->qpel_put[1][fxy](c->temp , ref[0] + (fx>>2) + (fy>>2)*stride , stride); - c->qpel_put[1][fxy](c->temp + 8 , ref[0] + (fx>>2) + (fy>>2)*stride + 8 , stride); - c->qpel_put[1][fxy](c->temp + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8*stride, stride); - c->qpel_put[1][fxy](c->temp + 8 + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8 + 8*stride, stride); - c->qpel_avg[1][bxy](c->temp , ref[8] + (bx>>2) + (by>>2)*stride , stride); - c->qpel_avg[1][bxy](c->temp + 8 , ref[8] + (bx>>2) + (by>>2)*stride + 8 , stride); - c->qpel_avg[1][bxy](c->temp + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8*stride, stride); - c->qpel_avg[1][bxy](c->temp + 8 + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8 + 8*stride, stride); - }else{ - av_assert2((fx>>1) + 16*s->c.mb_x >= -16); - av_assert2((fy>>1) + 16*s->c.mb_y >= -16); - av_assert2((fx>>1) + 16*s->c.mb_x <= s->c.width); - av_assert2((fy>>1) + 16*s->c.mb_y <= s->c.height); - av_assert2((bx>>1) + 16*s->c.mb_x >= -16); - av_assert2((by>>1) + 16*s->c.mb_y >= -16); - av_assert2((bx>>1) + 16*s->c.mb_x <= s->c.width); - av_assert2((by>>1) + 16*s->c.mb_y <= s->c.height); - - c->hpel_put[0][fxy](c->temp, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 16); - c->hpel_avg[0][bxy](c->temp, ref[8] + (bx>>1) + (by>>1)*stride, stride, 16); + av_assert2(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1)); + if (x >= c->xmin && hx <= c->xmax << (qpel + 1) && + y >= c->ymin && hy <= c->ymax << (qpel + 1)) { + const int time_pp = s->c.pp_time; + const int time_pb = s->c.pb_time; + const int mask = 2 * qpel + 1; + if (s->c.mv_type == MV_TYPE_8X8) { + for(int i = 0; i < 4; ++i) { + int fx = c->direct_basis_mv[i][0] + hx; + int fy = c->direct_basis_mv[i][1] + hy; + int bx = hx ? fx - c->co_located_mv[i][0] : c->co_located_mv[i][0] * (time_pb - time_pp)/time_pp + ((i &1)<<(qpel+4)); + int by = hy ? fy - c->co_located_mv[i][1] : c->co_located_mv[i][1] * (time_pb - time_pp)/time_pp + ((i>>1)<<(qpel+4)); + int fxy = (fx & mask) + ((fy & mask) << (qpel + 1)); + int bxy = (bx & mask) + ((by & mask) << (qpel + 1)); + + uint8_t *dst = c->temp + 8 * (i & 1) + 8 * stride * (i >> 1); + if (qpel) { + c->qpel_put[1][fxy](dst, ref[0] + (fx >> 2) + (fy >> 2) * stride, stride); + c->qpel_avg[1][bxy](dst, ref[8] + (bx >> 2) + (by >> 2) * stride, stride); + } else { + c->hpel_put[1][fxy](dst, ref[0] + (fx >> 1) + (fy >> 1) * stride, stride, 8); + c->hpel_avg[1][bxy](dst, ref[8] + (bx >> 1) + (by >> 1) * stride, stride, 8); } } - d = cmp_func(s, c->temp, src[0], stride, 16); - }else - d= 256*256*256*32; + } else { + int fx = c->direct_basis_mv[0][0] + hx; + int fy = c->direct_basis_mv[0][1] + hy; + int bx = hx ? fx - c->co_located_mv[0][0] : (c->co_located_mv[0][0] * (time_pb - time_pp)/time_pp); + int by = hy ? fy - c->co_located_mv[0][1] : (c->co_located_mv[0][1] * (time_pb - time_pp)/time_pp); + int fxy = (fx & mask) + ((fy & mask) << (qpel + 1)); + int bxy = (bx & mask) + ((by & mask) << (qpel + 1)); + + if (qpel) { + c->qpel_put[1][fxy](c->temp , ref[0] + (fx>>2) + (fy>>2)*stride , stride); + c->qpel_put[1][fxy](c->temp + 8 , ref[0] + (fx>>2) + (fy>>2)*stride + 8 , stride); + c->qpel_put[1][fxy](c->temp + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8*stride, stride); + c->qpel_put[1][fxy](c->temp + 8 + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8 + 8*stride, stride); + c->qpel_avg[1][bxy](c->temp , ref[8] + (bx>>2) + (by>>2)*stride , stride); + c->qpel_avg[1][bxy](c->temp + 8 , ref[8] + (bx>>2) + (by>>2)*stride + 8 , stride); + c->qpel_avg[1][bxy](c->temp + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8*stride, stride); + c->qpel_avg[1][bxy](c->temp + 8 + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8 + 8*stride, stride); + } else { + av_assert2((fx >> 1) + 16 * s->c.mb_x >= -16); + av_assert2((fy >> 1) + 16 * s->c.mb_y >= -16); + av_assert2((fx >> 1) + 16 * s->c.mb_x <= s->c.width); + av_assert2((fy >> 1) + 16 * s->c.mb_y <= s->c.height); + av_assert2((bx >> 1) + 16 * s->c.mb_x >= -16); + av_assert2((by >> 1) + 16 * s->c.mb_y >= -16); + av_assert2((bx >> 1) + 16 * s->c.mb_x <= s->c.width); + av_assert2((by >> 1) + 16 * s->c.mb_y <= s->c.height); + + c->hpel_put[0][fxy](c->temp, ref[0] + (fx >> 1) + (fy >> 1) * stride, stride, 16); + c->hpel_avg[0][bxy](c->temp, ref[8] + (bx >> 1) + (by >> 1) * stride, stride, 16); + } + } + d = cmp_func(s, c->temp, src[0], stride, 16); + } else + d = 256 * 256 * 256 * 32; return d; } @@ -192,42 +192,42 @@ static av_always_inline int cmp_inline(MPVEncContext *const s, const int x, cons const uint8_t * const * const src = c->src[src_index]; int d; //FIXME check chroma 4mv, (no crashes ...) - int uvdxy; /* no, it might not be used uninitialized */ - if(dxy){ - if(qpel){ - if (h << size == 16) { - c->qpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride); //FIXME prototype (add h) - } else if (size == 0 && h == 8) { - c->qpel_put[1][dxy](c->temp , ref[0] + x + y*stride , stride); - c->qpel_put[1][dxy](c->temp + 8, ref[0] + x + y*stride + 8, stride); - } else - av_assert2(0); - if(chroma){ - int cx= hx/2; - int cy= hy/2; - cx= (cx>>1)|(cx&1); - cy= (cy>>1)|(cy&1); - uvdxy= (cx&1) + 2*(cy&1); - // FIXME x/y wrong, but MPEG-4 qpel is sick anyway, we should drop as much of it as possible in favor for H.264 - } - }else{ - c->hpel_put[size][dxy](c->temp, ref[0] + x + y*stride, stride, h); - if(chroma) - uvdxy= dxy | (x&1) | (2*(y&1)); + int uvdxy; /* no, it might not be used uninitialized */ + if (dxy) { + if (qpel) { + if (h << size == 16) { + c->qpel_put[size][dxy](c->temp, ref[0] + x + y * stride, stride); //FIXME prototype (add h) + } else if (size == 0 && h == 8) { + c->qpel_put[1][dxy](c->temp , ref[0] + x + y * stride , stride); + c->qpel_put[1][dxy](c->temp + 8, ref[0] + x + y * stride + 8, stride); + } else + av_assert2(0); + if (chroma) { + int cx = hx / 2; + int cy = hy / 2; + cx = (cx >> 1) | (cx & 1); + cy = (cy >> 1) | (cy & 1); + uvdxy = (cx & 1) + 2 * (cy & 1); + // FIXME x/y wrong, but MPEG-4 qpel is sick anyway, we should drop as much of it as possible in favor for H.264 } - d = cmp_func(s, c->temp, src[0], stride, h); - }else{ - d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h); - if(chroma) - uvdxy= (x&1) + 2*(y&1); - } - if(chroma){ - uint8_t * const uvtemp= c->temp + 16*stride; - c->hpel_put[size+1][uvdxy](uvtemp , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1); - c->hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1); - d += chroma_cmp_func(s, uvtemp , src[1], uvstride, h>>1); - d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1); + } else { + c->hpel_put[size][dxy](c->temp, ref[0] + x + y * stride, stride, h); + if (chroma) + uvdxy = dxy | (x & 1) | (2 * (y & 1)); } + d = cmp_func(s, c->temp, src[0], stride, h); + } else { + d = cmp_func(s, src[0], ref[0] + x + y * stride, stride, h); + if (chroma) + uvdxy = (x & 1) + 2 * (y & 1); + } + if (chroma) { + uint8_t *const uvtemp = c->temp + 16 * stride; + c->hpel_put[size + 1][uvdxy](uvtemp , ref[1] + (x >> 1) + (y >> 1) * uvstride, uvstride, h >> 1); + c->hpel_put[size + 1][uvdxy](uvtemp + 8, ref[2] + (x >> 1) + (y >> 1) * uvstride, uvstride, h >> 1); + d += chroma_cmp_func(s, uvtemp , src[1], uvstride, h >> 1); + d += chroma_cmp_func(s, uvtemp + 8, src[2], uvstride, h >> 1); + } return d; } -- 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 16:57 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 ` Andreas Rheinhardt [this message] 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 ` [FFmpeg-devel] [PATCH 37/47] avcodec/mpegvideo: Only use a single ac_val pointer Andreas Rheinhardt 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=d9df0d2ad8273877d1adf0fade02cc7f53bb392b.1750006479.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