avcodec/mpegvideo_motion: Constify ff_mpv_motion

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>
This commit is contained in:
Andreas Rheinhardt 2022-07-26 08:55:32 +02:00
parent 7e8c8cc04b
commit cee40a945a
5 changed files with 37 additions and 36 deletions

View File

@ -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);

View File

@ -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]);

View File

@ -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])
{

View File

@ -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;

View File

@ -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);