Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data
Date: Wed, 27 Jul 2022 00:08:11 +0200
Message-ID: <DB6PR0101MB2214764FEF05B8F3D86682318F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <DB6PR0101MB22140CEE765FDFAB596653698F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com>

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/motion_est.c | 31 +++++++++++++++++--------------
 libavcodec/motion_est.h |  4 ++--
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 0903536697..29ab41dc8c 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -79,7 +79,10 @@ static int minima_cmp(const void *a, const void *b){
 #define FLAG_CHROMA 2
 #define FLAG_DIRECT 4
 
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
+static inline void init_ref(MotionEstContext *c, uint8_t *const src[3],
+                            uint8_t *const ref[3], uint8_t *const ref2[3],
+                            int x, int y, int ref_index)
+{
     const int offset[3]= {
           y*c->  stride + x,
         ((y*c->uvstride + x)>>1),
@@ -110,8 +113,8 @@ static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, co
     const int stride= c->stride;
     const int hx = subx + x * (1 << (1 + qpel));
     const int hy = suby + y * (1 << (1 + qpel));
-    uint8_t * const * const ref= c->ref[ref_index];
-    uint8_t * const * const src= c->src[src_index];
+    const uint8_t * const * const ref = c->ref[ref_index];
+    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));
@@ -184,8 +187,8 @@ static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int
     const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel?
     const int hx= subx + x*(1<<(1+qpel));
     const int hy= suby + y*(1<<(1+qpel));
-    uint8_t * const * const ref= c->ref[ref_index];
-    uint8_t * const * const src= c->src[src_index];
+    const uint8_t * const * const ref = c->ref[ref_index];
+    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 */
@@ -396,7 +399,7 @@ static int sad_hpel_motion_search(MpegEncContext * s,
     MotionEstContext * const c= &s->me;
     const int penalty_factor= c->sub_penalty_factor;
     int mx, my, dminh;
-    uint8_t *pix, *ptr;
+    const uint8_t *pix, *ptr;
     int stride= c->stride;
     LOAD_COMMON
 
@@ -641,7 +644,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
             const int offset= ((block&1) + (block>>1)*stride)*8;
             uint8_t *dest_y = c->scratchpad + offset;
             if(s->quarter_sample){
-                uint8_t *ref= c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
+                const uint8_t *ref = c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
                 dxy = ((my4 & 3) << 2) | (mx4 & 3);
 
                 if(s->no_rounding)
@@ -649,7 +652,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
                 else
                     s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
             }else{
-                uint8_t *ref= c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
+                const uint8_t *ref = c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
                 dxy = ((my4 & 1) << 1) | (mx4 & 1);
 
                 if(s->no_rounding)
@@ -805,7 +808,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index,
                 int dxy;
 
                 //FIXME chroma ME
-                uint8_t *ref= c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
+                const uint8_t *ref = c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
                 dxy = ((my_i & 1) << 1) | (mx_i & 1);
 
                 if(s->no_rounding){
@@ -885,7 +888,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
                                 int mb_x, int mb_y)
 {
     MotionEstContext * const c= &s->me;
-    uint8_t *pix, *ppix;
+    const uint8_t *pix, *ppix;
     int sum, mx = 0, my = 0, dmin = 0;
     int varc;            ///< the variance of the block (sum of squared (p[y][x]-average))
     int vard;            ///< sum of squared differences with the estimated motion vector
@@ -1187,13 +1190,13 @@ static inline int check_bidir_mv(MpegEncContext * s,
     const uint8_t * const mv_penalty_b = c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame
     int stride= c->stride;
     uint8_t *dest_y = c->scratchpad;
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int dxy;
     int src_x, src_y;
     int fbmin;
-    uint8_t **src_data= c->src[0];
-    uint8_t **ref_data= c->ref[0];
-    uint8_t **ref2_data= c->ref[2];
+    const uint8_t *const *src_data  = c->src[0];
+    const uint8_t *const *ref_data  = c->ref[0];
+    const uint8_t *const *ref2_data = c->ref[2];
 
     if(s->quarter_sample){
         dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index d0950bf7e6..292bdc70e9 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -77,8 +77,8 @@ typedef struct MotionEstContext {
     int ymax;
     int pred_x;
     int pred_y;
-    uint8_t *src[4][4];
-    uint8_t *ref[4][4];
+    const uint8_t *src[4][4];
+    const uint8_t *ref[4][4];
     int stride;
     int uvstride;
     /* temp variables for picture complexity calculation */
-- 
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".

  parent reply	other threads:[~2022-07-27  9:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 02/39] avcodec/hevcdec: Constify src pointers of HEVC DSP functions Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 03/39] avcodec/threadframe: Constify the frame in ff_thread_await_progress Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 04/39] avcodec: Constify ThreadFrames if possible Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target Andreas Rheinhardt
2022-07-27 10:25   ` Ronald S. Bultje
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 06/39] avcodec/wavpack: Constify slice threads' ptr to main context Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: " Andreas Rheinhardt
2022-07-27 10:24   ` Ronald S. Bultje
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 08/39] avcodec/proresdec2: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 09/39] avcodec/magicyuv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 10/39] avcodec/jpeg2000dec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 11/39] avcodec/dxv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 12/39] avcodec/dvdec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 13/39] avcodec/diracdec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 14/39] avcodec/half2float: Constify arrays in half2float() Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 15/39] avcodec/exr: Constify slice threads' ptr to main context Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 16/39] avcodec/xwdenc: Don't modify input frame Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 17/39] swscale/rgb2rgb: Don't cast const away Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 18/39] avcodec/gif: Remove redundant cast Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 19/39] avcodec/fitsenc: Don't cast const away unnecessarily Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 20/39] avcodec/diracdsp: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 21/39] avcodec/dxv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 22/39] avcodec/cinepakenc: Avoid casting const away Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 24/39] avcodec/ilbcdec: Move transient GetBitContext from ctx to stack Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 26/39] avcodec/pnmdec: Fix indentation Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 27/39] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 28/39] avcodec/snow: Remove unused halfpel_plane Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 29/39] avcodec/pngenc: Don't cast const away unnecessarily Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 30/39] avcodec/lossless_videoencdsp: Constify src sub_left_predict Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 31/39] avcodec/me_cmp: Constify me_cmp_func buffer parameters Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 32/39] avcodec/h264chroma: Constify src in h264_chroma_mc_func Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 33/39] avcodec/cfhdencdsp: Constify input pointers Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible Andreas Rheinhardt
2022-07-28 22:05   ` Michael Niedermayer
2022-07-30  9:55     ` Andreas Rheinhardt
2022-07-30 17:12       ` Michael Niedermayer
2022-08-02  9:30         ` Anton Khirnov
2022-08-03 15:28           ` Michael Niedermayer
2022-08-03 15:48             ` Michael Niedermayer
2022-08-06 13:07             ` Anton Khirnov
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 35/39] avcodec/mpegvideodsp: Constify src pointers Andreas Rheinhardt
2022-07-26 22:08 ` Andreas Rheinhardt [this message]
2022-07-28 22:04   ` [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data Michael Niedermayer
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion Andreas Rheinhardt
2022-07-28 22:03   ` Michael Niedermayer
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 38/39] avcodec: Constify frame->data pointers for encoders where possible Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index() Andreas Rheinhardt
2022-07-28 22:02   ` Michael Niedermayer

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=DB6PR0101MB2214764FEF05B8F3D86682318F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.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