From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion Date: Wed, 27 Jul 2022 00:08:12 +0200 Message-ID: <DB6PR0101MB221427147487A6CB753BFFC98F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw) In-Reply-To: <DB6PR0101MB22140CEE765FDFAB596653698F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> Also constify the corresponding code in mpegvideo.c that handles lowres. (Unfortunately, not everything that is const could be constified: ref_picture could be made const uint8_t* const* if C allowed the safe automatic conversion from uint8_t**; and pix_op, qpix_op could be made to point to const function pointers, but C's handling of const in pointers to arrays is broken.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpegvideo.c | 24 ++++++++++---------- libavcodec/mpegvideo.h | 2 +- libavcodec/mpegvideo_motion.c | 41 ++++++++++++++++++----------------- libavcodec/wmv2.c | 4 ++-- libavcodec/wmv2.h | 2 +- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 319934a114..1405176c06 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -916,12 +916,12 @@ void ff_mpv_common_end(MpegEncContext *s) static inline int hpel_motion_lowres(MpegEncContext *s, - uint8_t *dest, uint8_t *src, + uint8_t *dest, const uint8_t *src, int field_based, int field_select, int src_x, int src_y, int width, int height, ptrdiff_t stride, int h_edge_pos, int v_edge_pos, - int w, int h, h264_chroma_mc_func *pix_op, + int w, int h, const h264_chroma_mc_func *pix_op, int motion_x, int motion_y) { const int lowres = s->avctx->lowres; @@ -969,12 +969,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, int field_based, int bottom_field, int field_select, - uint8_t **ref_picture, - h264_chroma_mc_func *pix_op, + uint8_t *const *ref_picture, + const h264_chroma_mc_func *pix_op, int motion_x, int motion_y, int h, int mb_y) { - uint8_t *ptr_y, *ptr_cb, *ptr_cr; + const uint8_t *ptr_y, *ptr_cb, *ptr_cr; int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy; ptrdiff_t uvlinesize, linesize; const int lowres = s->avctx->lowres; @@ -1103,8 +1103,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s, static inline void chroma_4mv_motion_lowres(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture, - h264_chroma_mc_func * pix_op, + uint8_t *const *ref_picture, + const h264_chroma_mc_func * pix_op, int mx, int my) { const int lowres = s->avctx->lowres; @@ -1115,7 +1115,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, const int v_edge_pos = s->v_edge_pos >> lowres + 1; int emu = 0, src_x, src_y, sx, sy; ptrdiff_t offset; - uint8_t *ptr; + const uint8_t *ptr; if (s->quarter_sample) { mx /= 2; @@ -1172,8 +1172,8 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s, static inline void MPV_motion_lowres(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - int dir, uint8_t **ref_picture, - h264_chroma_mc_func *pix_op) + int dir, uint8_t *const *ref_picture, + const h264_chroma_mc_func *pix_op) { int mx, my; int mb_x, mb_y, i; @@ -1242,7 +1242,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s, break; case MV_TYPE_16X8: for (i = 0; i < 2; i++) { - uint8_t **ref2picture; + uint8_t *const *ref2picture; if (s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field) { @@ -1492,7 +1492,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], } if(lowres_flag){ - h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab; + const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab; if (s->mv_dir & MV_DIR_FORWARD) { MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 82889a0edd..287fd38bd3 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -586,7 +586,7 @@ void ff_init_block_index(MpegEncContext *s); void ff_mpv_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]); diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c index 9a450b7c8e..fe3bfc4454 100644 --- a/libavcodec/mpegvideo_motion.c +++ b/libavcodec/mpegvideo_motion.c @@ -36,9 +36,9 @@ static void gmc1_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture) + uint8_t *const *ref_picture) { - uint8_t *ptr; + const uint8_t *ptr; int src_x, src_y, motion_x, motion_y; ptrdiff_t offset, linesize, uvlinesize; int emu = 0; @@ -133,9 +133,9 @@ static void gmc1_motion(MpegEncContext *s, static void gmc_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture) + uint8_t *const *ref_picture) { - uint8_t *ptr; + const uint8_t *ptr; int linesize, uvlinesize; const int a = s->sprite_warping_accuracy; int ox, oy; @@ -232,7 +232,7 @@ void mpeg_motion_internal(MpegEncContext *s, int field_based, int bottom_field, int field_select, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, @@ -241,7 +241,7 @@ void mpeg_motion_internal(MpegEncContext *s, int is_16x8, int mb_y) { - uint8_t *ptr_y, *ptr_cb, *ptr_cr; + const uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, block_y_half; ptrdiff_t uvlinesize, linesize; @@ -369,7 +369,7 @@ void mpeg_motion_internal(MpegEncContext *s, /* apply one mpeg motion vector to the three components */ static void mpeg_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - int field_select, uint8_t **ref_picture, + int field_select, uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h, int is_16x8, int mb_y) { @@ -388,7 +388,7 @@ static void mpeg_motion(MpegEncContext *s, static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int bottom_field, int field_select, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h, int mb_y) { @@ -489,12 +489,12 @@ static inline void qpel_motion(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, int field_based, int bottom_field, - int field_select, uint8_t **ref_picture, + int field_select, uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int motion_x, int motion_y, int h) { - uint8_t *ptr_y, *ptr_cb, *ptr_cr; + const uint8_t *ptr_y, *ptr_cb, *ptr_cr; int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos; ptrdiff_t linesize, uvlinesize; @@ -593,11 +593,11 @@ static inline void qpel_motion(MpegEncContext *s, */ static void chroma_4mv_motion(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func *pix_op, int mx, int my) { - uint8_t *ptr; + const uint8_t *ptr; int src_x, src_y, dxy, emu = 0; ptrdiff_t offset; @@ -643,7 +643,7 @@ static void chroma_4mv_motion(MpegEncContext *s, pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); } -static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir) +static inline void prefetch_motion(MpegEncContext *s, uint8_t *const *pix, int dir) { /* fetch pixels for estimated mv 4 macroblocks ahead * optimized for 64byte cache lines */ @@ -661,11 +661,11 @@ static inline void apply_obmc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4]) { LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]); - Picture *cur_frame = &s->current_picture; + const Picture *cur_frame = &s->current_picture; int mb_x = s->mb_x; int mb_y = s->mb_y; const int xy = mb_x + mb_y * s->mb_stride; @@ -749,7 +749,7 @@ static inline void apply_8x8(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, int dir, - uint8_t **ref_picture, + uint8_t *const *ref_picture, qpel_mc_func (*qpix_op)[16], op_pixels_func (*pix_op)[4]) { @@ -757,7 +757,8 @@ static inline void apply_8x8(MpegEncContext *s, int i; int mb_x = s->mb_x; int mb_y = s->mb_y; - uint8_t *ptr, *dest; + uint8_t *dest; + const uint8_t *ptr; mx = 0; my = 0; @@ -833,7 +834,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, int dir, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int is_mpeg12) @@ -912,7 +913,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, case MV_TYPE_16X8: if (CONFIG_SMALL || is_mpeg12) { for (i = 0; i < 2; i++) { - uint8_t **ref2picture; + uint8_t *const *ref2picture; if ((s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field) && @@ -974,7 +975,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s, void ff_mpv_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, - uint8_t **ref_picture, + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]) { diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c index 8d1d117dea..5fea009e12 100644 --- a/libavcodec/wmv2.c +++ b/libavcodec/wmv2.c @@ -49,11 +49,11 @@ av_cold void ff_wmv2_common_init(MpegEncContext *s) void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture, op_pixels_func (*pix_op)[4], + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h) { WMV2Context *const w = s->private_ctx; - uint8_t *ptr; + const uint8_t *ptr; int dxy, mx, my, src_x, src_y, v_edge_pos; ptrdiff_t offset, linesize, uvlinesize; int emu = 0; diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h index cdd58cf011..e49b81cdfb 100644 --- a/libavcodec/wmv2.h +++ b/libavcodec/wmv2.h @@ -39,7 +39,7 @@ void ff_wmv2_common_init(MpegEncContext *s); void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - uint8_t **ref_picture, op_pixels_func (*pix_op)[4], + uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4], int motion_x, int motion_y, int h); -- 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-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 ` [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data Andreas Rheinhardt 2022-07-28 22:04 ` Michael Niedermayer 2022-07-26 22:08 ` Andreas Rheinhardt [this message] 2022-07-28 22:03 ` [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion 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=DB6PR0101MB221427147487A6CB753BFFC98F949@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