[FFmpeg-devel] [PATCH 24/57] avcodec/mpegvideo: Add const where appropriate
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Tue Apr 30 00:14:05 EEST 2024
Specifically, add const to the pointed-to-type of pointers
that point to something static or that belong to last_pic
or next_pic (because modifying these might lead to data races).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/h261dec.c | 2 +-
libavcodec/h261enc.c | 2 +-
libavcodec/ituh263dec.c | 6 +++---
libavcodec/ituh263enc.c | 2 +-
libavcodec/mpeg12dec.c | 6 +++---
libavcodec/mpeg12enc.c | 8 ++++----
libavcodec/mpeg4videodec.c | 9 ++++-----
libavcodec/mpeg4videoenc.c | 32 ++++++++++++++++---------------
libavcodec/mpeg_er.c | 2 +-
libavcodec/mpegvideo_enc.c | 6 +++---
libavcodec/mpegvideoenc.h | 2 +-
libavcodec/msmpeg4dec.c | 6 +++---
libavcodec/ratecontrol.c | 22 ++++++++++-----------
libavcodec/rv34.c | 3 ++-
libavcodec/vc1_loopfilter.c | 20 +++++++++----------
libavcodec/vc1_mc.c | 4 ++--
libavcodec/vc1_pred.c | 38 ++++++++++++++++++-------------------
libavcodec/vc1dec.c | 6 +++---
18 files changed, 88 insertions(+), 88 deletions(-)
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 77aa08687d..00edd7a7c2 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -281,7 +281,7 @@ static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded
{
MpegEncContext *const s = &h->s;
int level, i, j, run;
- RLTable *rl = &ff_h261_rl_tcoeff;
+ const RLTable *rl = &ff_h261_rl_tcoeff;
const uint8_t *scan_table;
/* For the variable length encoding there are two code tables, one being
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index 438ebb63d9..58ac23ebe7 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -167,7 +167,7 @@ static void h261_encode_block(H261EncContext *h, int16_t *block, int n)
{
MpegEncContext *const s = &h->s;
int level, run, i, j, last_index, last_non_zero, sign, slevel, code;
- RLTable *rl;
+ const RLTable *rl;
rl = &ff_h261_rl_tcoeff;
if (s->mb_intra) {
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 9358363ed8..492cb5e0d4 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -534,7 +534,7 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block,
int n, int coded)
{
int level, i, j, run;
- RLTable *rl = &ff_h263_rl_inter;
+ const RLTable *rl = &ff_h263_rl_inter;
const uint8_t *scan_table;
GetBitContext gb= s->gb;
@@ -719,7 +719,7 @@ static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
#define tab_size ((signed)FF_ARRAY_ELEMS(s->direct_scale_mv[0]))
#define tab_bias (tab_size / 2)
-static inline void set_one_direct_mv(MpegEncContext *s, Picture *p, int i)
+static inline void set_one_direct_mv(MpegEncContext *s, const Picture *p, int i)
{
int xy = s->block_index[i];
uint16_t time_pp = s->pp_time;
@@ -750,7 +750,7 @@ static inline void set_one_direct_mv(MpegEncContext *s, Picture *p, int i)
static int set_direct_mv(MpegEncContext *s)
{
const int mb_index = s->mb_x + s->mb_y * s->mb_stride;
- Picture *p = &s->next_pic;
+ const Picture *p = &s->next_pic;
int colocated_mb_type = p->mb_type[mb_index];
int i;
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 70a65423f3..b65a1c069a 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -305,7 +305,7 @@ static const int dquant_code[5]= {1,0,9,2,3};
static void h263_encode_block(MpegEncContext * s, int16_t * block, int n)
{
int level, run, last, i, j, last_index, last_non_zero, sign, slevel, code;
- RLTable *rl;
+ const RLTable *rl;
rl = &ff_h263_rl_inter;
if (s->mb_intra && !s->h263_aic) {
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index c04d351e0c..6877b9ef4a 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -160,7 +160,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- uint8_t *const scantable = s->intra_scantable.permutated;
+ const uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
@@ -244,7 +244,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- uint8_t *const scantable = s->intra_scantable.permutated;
+ const uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
@@ -331,7 +331,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
int level, dc, diff, i, j, run;
int component;
const RL_VLC_ELEM *rl_vlc;
- uint8_t *const scantable = s->intra_scantable.permutated;
+ const uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
int mismatch;
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index d04ee51852..326c0079df 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -470,7 +470,7 @@ void ff_mpeg1_encode_slice_header(MpegEncContext *s)
void ff_mpeg1_encode_picture_header(MpegEncContext *s)
{
MPEG12EncContext *const mpeg12 = (MPEG12EncContext*)s;
- AVFrameSideData *side_data;
+ const AVFrameSideData *side_data;
mpeg1_encode_sequence_header(s);
/* MPEG-1 picture header */
@@ -557,7 +557,7 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s)
side_data = av_frame_get_side_data(s->cur_pic_ptr->f,
AV_FRAME_DATA_STEREO3D);
if (side_data) {
- AVStereo3D *stereo = (AVStereo3D *)side_data->data;
+ const AVStereo3D *stereo = (AVStereo3D *)side_data->data;
uint8_t fpa_type;
switch (stereo->type) {
@@ -711,7 +711,7 @@ static inline void encode_dc(MpegEncContext *s, int diff, int component)
}
}
-static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n)
+static void mpeg1_encode_block(MpegEncContext *s, const int16_t *block, int n)
{
int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign;
int code, component;
@@ -793,7 +793,7 @@ next_coef:
}
static av_always_inline void mpeg1_encode_mb_internal(MpegEncContext *s,
- int16_t block[8][64],
+ const int16_t block[8][64],
int motion_x, int motion_y,
int mb_block_count,
int chroma_y_shift)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 9b36893d5e..1fda3053f0 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -1292,8 +1292,8 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block,
MpegEncContext *s = &ctx->m;
int level, i, last, run, qmul, qadd;
int av_uninit(dc_pred_dir);
- RLTable *rl;
- RL_VLC_ELEM *rl_vlc;
+ const RLTable *rl;
+ const RL_VLC_ELEM *rl_vlc;
const uint8_t *scan_table;
// Note intra & rvlc should be optimized away if this is inlined
@@ -1649,7 +1649,6 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
{
Mpeg4DecContext *ctx = s->avctx->priv_data;
int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
- int16_t *mot_val;
static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
const int xy = s->mb_x + s->mb_y * s->mb_stride;
int next;
@@ -1778,7 +1777,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64])
s->cur_pic.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
s->mv_type = MV_TYPE_8X8;
for (i = 0; i < 4; i++) {
- mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
+ int16_t *mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
mx = ff_h263_decode_motion(s, pred_x, s->f_code);
if (mx >= 0xffff)
return AVERROR_INVALIDDATA;
@@ -2071,7 +2070,7 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
int cc, dct_dc_size, dct_diff, code, j, idx = 1, group = 0, run = 0,
additional_code_len, sign, mismatch;
const VLCElem *cur_vlc = studio_intra_tab[0];
- uint8_t *const scantable = s->intra_scantable.permutated;
+ const uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
uint32_t flc;
const int min = -1 * (1 << (s->avctx->bits_per_raw_sample + 6));
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 593ee812c5..596155c8a1 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -71,7 +71,7 @@ static uint8_t uni_mpeg4_inter_rl_len[64 * 64 * 2 * 2];
* @param[in] block_last_index last index in scantable order that refers to a non zero element in block.
*/
static inline int get_block_rate(MpegEncContext *s, int16_t block[64],
- int block_last_index, uint8_t scantable[64])
+ int block_last_index, const uint8_t scantable[64])
{
int last = 0;
int j;
@@ -106,7 +106,7 @@ static inline int get_block_rate(MpegEncContext *s, int16_t block[64],
* @param[in] zigzag_last_index index referring to the last non zero coefficient in zigzag order
*/
static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64],
- const int dir[6], uint8_t *st[6],
+ const int dir[6], const uint8_t *st[6],
const int zigzag_last_index[6])
{
int i, n;
@@ -137,12 +137,12 @@ static inline void restore_ac_coeffs(MpegEncContext *s, int16_t block[6][64],
* @param[out] zigzag_last_index index referring to the last non zero coefficient in zigzag order
*/
static inline int decide_ac_pred(MpegEncContext *s, int16_t block[6][64],
- const int dir[6], uint8_t *st[6],
+ const int dir[6], const uint8_t *st[6],
int zigzag_last_index[6])
{
int score = 0;
int i, n;
- int8_t *const qscale_table = s->cur_pic.qscale_table;
+ const int8_t *const qscale_table = s->cur_pic.qscale_table;
memcpy(zigzag_last_index, s->block_last_index, sizeof(int) * 6);
@@ -288,14 +288,14 @@ static inline int mpeg4_get_dc_length(int level, int n)
* Encode an 8x8 block.
* @param n block index (0-3 are luma, 4-5 are chroma)
*/
-static inline void mpeg4_encode_block(MpegEncContext *s,
- int16_t *block, int n, int intra_dc,
- uint8_t *scan_table, PutBitContext *dc_pb,
+static inline void mpeg4_encode_block(const MpegEncContext *s,
+ const int16_t *block, int n, int intra_dc,
+ const uint8_t *scan_table, PutBitContext *dc_pb,
PutBitContext *ac_pb)
{
int i, last_non_zero;
- uint32_t *bits_tab;
- uint8_t *len_tab;
+ const uint32_t *bits_tab;
+ const uint8_t *len_tab;
const int last_index = s->block_last_index[n];
if (s->mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
@@ -350,11 +350,11 @@ static inline void mpeg4_encode_block(MpegEncContext *s,
}
static int mpeg4_get_block_length(MpegEncContext *s,
- int16_t *block, int n,
- int intra_dc, uint8_t *scan_table)
+ const int16_t *block, int n,
+ int intra_dc, const uint8_t *scan_table)
{
int i, last_non_zero;
- uint8_t *len_tab;
+ const uint8_t *len_tab;
const int last_index = s->block_last_index[n];
int len = 0;
@@ -403,8 +403,10 @@ static int mpeg4_get_block_length(MpegEncContext *s,
return len;
}
-static inline void mpeg4_encode_blocks(MpegEncContext *s, int16_t block[6][64],
- int intra_dc[6], uint8_t **scan_table,
+static inline void mpeg4_encode_blocks(MpegEncContext *s,
+ const int16_t block[6][64],
+ const int intra_dc[6],
+ const uint8_t * const *scan_table,
PutBitContext *dc_pb,
PutBitContext *ac_pb)
{
@@ -799,7 +801,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
int dc_diff[6]; // dc values with the dc prediction subtracted
int dir[6]; // prediction direction
int zigzag_last_index[6];
- uint8_t *scan_table[6];
+ const uint8_t *scan_table[6];
int i;
for (i = 0; i < 6; i++)
diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index 8d8b2aea92..360f3ce3e0 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -22,7 +22,7 @@
#include "mpegvideodec.h"
#include "mpeg_er.h"
-static void set_erpic(ERPicture *dst, Picture *src)
+static void set_erpic(ERPicture *dst, const Picture *src)
{
int i;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6b4c3b6649..15c6a90e9e 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -4223,8 +4223,8 @@ static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
int prev_run=0;
int prev_level=0;
int qmul, qadd, start_i, last_non_zero, i, dc;
- uint8_t * length;
- uint8_t * last_length;
+ const uint8_t *length;
+ const uint8_t *last_length;
int lambda;
int rle_index, run, q = 1, sum; //q is only used when s->mb_intra is true
@@ -4537,7 +4537,7 @@ static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
* permutation up, the block is not (inverse) permutated
* to scantable order!
*/
-void ff_block_permute(int16_t *block, uint8_t *permutation,
+void ff_block_permute(int16_t *block, const uint8_t *permutation,
const uint8_t *scantable, int last)
{
int i;
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index c20ea500eb..f7e681eaa6 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -152,7 +152,7 @@ int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int
void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64],
const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
-void ff_block_permute(int16_t *block, uint8_t *permutation,
+void ff_block_permute(int16_t *block, const uint8_t *permutation,
const uint8_t *scantable, int last);
static inline int get_bits_diff(MpegEncContext *s)
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index c354f46c50..a7b3fc4603 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -627,8 +627,8 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
{
int level, i, last, run, run_diff;
int av_uninit(dc_pred_dir);
- RLTable *rl;
- RL_VLC_ELEM *rl_vlc;
+ const RLTable *rl;
+ const RL_VLC_ELEM *rl_vlc;
int qmul, qadd;
if (s->mb_intra) {
@@ -811,7 +811,7 @@ int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
void ff_msmpeg4_decode_motion(MpegEncContext *s, int *mx_ptr, int *my_ptr)
{
- MVTable *mv;
+ const MVTable *mv;
int code, mx, my;
mv = &ff_mv_tables[s->mv_table_index];
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index ef46f149c5..0a17811ce9 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -70,7 +70,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
}
-static inline double qp2bits(RateControlEntry *rce, double qp)
+static inline double qp2bits(const RateControlEntry *rce, double qp)
{
if (qp <= 0.0) {
av_log(NULL, AV_LOG_ERROR, "qp<=0.0\n");
@@ -83,7 +83,7 @@ static double qp2bits_cb(void *rce, double qp)
return qp2bits(rce, qp);
}
-static inline double bits2qp(RateControlEntry *rce, double bits)
+static inline double bits2qp(const RateControlEntry *rce, double bits)
{
if (bits < 0.9) {
av_log(NULL, AV_LOG_ERROR, "bits<0.9\n");
@@ -96,7 +96,7 @@ static double bits2qp_cb(void *rce, double qp)
return bits2qp(rce, qp);
}
-static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q)
+static double get_diff_limited_q(MpegEncContext *s, const RateControlEntry *rce, double q)
{
RateControlContext *rcc = &s->rc_context;
AVCodecContext *a = s->avctx;
@@ -163,7 +163,7 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pic
*qmax_ret = qmax;
}
-static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
+static double modify_qscale(MpegEncContext *s, const RateControlEntry *rce,
double q, int frame_num)
{
RateControlContext *rcc = &s->rc_context;
@@ -385,7 +385,7 @@ static int init_pass2(MpegEncContext *s)
/* find qscale */
for (i = 0; i < rcc->num_entries; i++) {
- RateControlEntry *rce = &rcc->entry[i];
+ const RateControlEntry *rce = &rcc->entry[i];
qscale[i] = get_qscale(s, &rcc->entry[i], rate_factor, i);
rcc->last_qscale_for[rce->pict_type] = qscale[i];
@@ -394,20 +394,20 @@ static int init_pass2(MpegEncContext *s)
/* fixed I/B QP relative to P mode */
for (i = FFMAX(0, rcc->num_entries - 300); i < rcc->num_entries; i++) {
- RateControlEntry *rce = &rcc->entry[i];
+ const RateControlEntry *rce = &rcc->entry[i];
qscale[i] = get_diff_limited_q(s, rce, qscale[i]);
}
for (i = rcc->num_entries - 1; i >= 0; i--) {
- RateControlEntry *rce = &rcc->entry[i];
+ const RateControlEntry *rce = &rcc->entry[i];
qscale[i] = get_diff_limited_q(s, rce, qscale[i]);
}
/* smooth curve */
for (i = 0; i < rcc->num_entries; i++) {
- RateControlEntry *rce = &rcc->entry[i];
+ const RateControlEntry *rce = &rcc->entry[i];
const int pict_type = rce->new_pict_type;
int j;
double q = 0.0, sum = 0.0;
@@ -874,8 +874,8 @@ static void adaptive_quantization(MpegEncContext *s, double q)
void ff_get_2pass_fcode(MpegEncContext *s)
{
- RateControlContext *rcc = &s->rc_context;
- RateControlEntry *rce = &rcc->entry[s->picture_number];
+ const RateControlContext *rcc = &s->rc_context;
+ const RateControlEntry *rce = &rcc->entry[s->picture_number];
s->f_code = rce->f_code;
s->b_code = rce->b_code;
@@ -926,7 +926,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
rce = &rcc->entry[picture_number];
wanted_bits = rce->expected_bits;
} else {
- Picture *dts_pic;
+ const Picture *dts_pic;
rce = &local_rce;
/* FIXME add a dts field to AVFrame and ensure it is set and use it
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 941d983501..df1d570e73 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -679,7 +679,8 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
h264_chroma_mc_func (*chroma_mc))
{
MpegEncContext *s = &r->s;
- uint8_t *Y, *U, *V, *srcY, *srcU, *srcV;
+ uint8_t *Y, *U, *V;
+ const uint8_t *srcY, *srcU, *srcV;
int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off;
int is16x16 = 1;
diff --git a/libavcodec/vc1_loopfilter.c b/libavcodec/vc1_loopfilter.c
index 8afb4db190..8d20e20731 100644
--- a/libavcodec/vc1_loopfilter.c
+++ b/libavcodec/vc1_loopfilter.c
@@ -413,9 +413,9 @@ static av_always_inline void vc1_p_h_loop_filter(VC1Context *v, uint8_t *dest, u
}
}
-static av_always_inline void vc1_p_v_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
- uint8_t *is_intra, int16_t (*mv)[2], uint8_t *mv_f,
- int *ttblk, uint32_t flags, int block_num)
+static av_always_inline void vc1_p_v_loop_filter(VC1Context *v, uint8_t *dest, const uint32_t *cbp,
+ const uint8_t *is_intra, int16_t (*mv)[2], const uint8_t *mv_f,
+ const int *ttblk, uint32_t flags, int block_num)
{
MpegEncContext *s = &v->s;
int pq = v->pq;
@@ -799,7 +799,7 @@ void ff_vc1_p_loop_filter(VC1Context *v)
}
}
-static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk,
+static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *dest, const int *ttblk,
uint32_t flags, uint8_t fieldtx, int block_num)
{
MpegEncContext *s = &v->s;
@@ -849,7 +849,7 @@ static av_always_inline void vc1_p_h_intfr_loop_filter(VC1Context *v, uint8_t *d
}
}
-static av_always_inline void vc1_p_v_intfr_loop_filter(VC1Context *v, uint8_t *dest, int *ttblk,
+static av_always_inline void vc1_p_v_intfr_loop_filter(VC1Context *v, uint8_t *dest, const int *ttblk,
uint32_t flags, uint8_t fieldtx, int block_num)
{
MpegEncContext *s = &v->s;
@@ -1109,8 +1109,8 @@ void ff_vc1_p_intfr_loop_filter(VC1Context *v)
}
}
-static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
- int *ttblk, uint32_t flags, int block_num)
+static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *dest, const uint32_t *cbp,
+ const int *ttblk, uint32_t flags, int block_num)
{
MpegEncContext *s = &v->s;
int pq = v->pq;
@@ -1141,8 +1141,8 @@ static av_always_inline void vc1_b_h_intfi_loop_filter(VC1Context *v, uint8_t *d
}
}
-static av_always_inline void vc1_b_v_intfi_loop_filter(VC1Context *v, uint8_t *dest, uint32_t *cbp,
- int *ttblk, uint32_t flags, int block_num)
+static av_always_inline void vc1_b_v_intfi_loop_filter(VC1Context *v, uint8_t *dest, const uint32_t *cbp,
+ const int *ttblk, uint32_t flags, int block_num)
{
MpegEncContext *s = &v->s;
int pq = v->pq;
@@ -1174,7 +1174,7 @@ void ff_vc1_b_intfi_loop_filter(VC1Context *v)
MpegEncContext *s = &v->s;
int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
uint8_t *dest;
- uint32_t *cbp;
+ const uint32_t *cbp;
int *ttblk;
uint32_t flags = 0;
int i;
diff --git a/libavcodec/vc1_mc.c b/libavcodec/vc1_mc.c
index b60a48b38f..ad41004e66 100644
--- a/libavcodec/vc1_mc.c
+++ b/libavcodec/vc1_mc.c
@@ -58,7 +58,7 @@ static av_always_inline void vc1_scale_chroma(uint8_t *srcU, uint8_t *srcV,
}
static av_always_inline void vc1_lut_scale_luma(uint8_t *srcY,
- uint8_t *lut1, uint8_t *lut2,
+ const uint8_t *lut1, const uint8_t *lut2,
int k, int linesize)
{
int i, j;
@@ -78,7 +78,7 @@ static av_always_inline void vc1_lut_scale_luma(uint8_t *srcY,
}
static av_always_inline void vc1_lut_scale_chroma(uint8_t *srcU, uint8_t *srcV,
- uint8_t *lut1, uint8_t *lut2,
+ const uint8_t *lut1, const uint8_t *lut2,
int k, int uvlinesize)
{
int i, j;
diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
index 51ad668f23..f5e80fe0ef 100644
--- a/libavcodec/vc1_pred.c
+++ b/libavcodec/vc1_pred.c
@@ -33,7 +33,7 @@
#include "vc1_pred.h"
#include "vc1data.h"
-static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int dir)
+static av_always_inline int scaleforsame_x(const VC1Context *v, int n /* MV */, int dir)
{
int scaledvalue, refdist;
int scalesame1, scalesame2;
@@ -66,7 +66,7 @@ static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int di
return av_clip(scaledvalue, -v->range_x, v->range_x - 1);
}
-static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int dir)
+static av_always_inline int scaleforsame_y(const VC1Context *v, int i, int n /* MV */, int dir)
{
int scaledvalue, refdist;
int scalesame1, scalesame2;
@@ -103,7 +103,7 @@ static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */,
return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
}
-static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */)
+static av_always_inline int scaleforopp_x(const VC1Context *v, int n /* MV */)
{
int scalezone1_x, zone1offset_x;
int scaleopp1, scaleopp2, brfd;
@@ -130,7 +130,7 @@ static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */)
return av_clip(scaledvalue, -v->range_x, v->range_x - 1);
}
-static av_always_inline int scaleforopp_y(VC1Context *v, int n /* MV */, int dir)
+static av_always_inline int scaleforopp_y(const VC1Context *v, int n /* MV */, int dir)
{
int scalezone1_y, zone1offset_y;
int scaleopp1, scaleopp2, brfd;
@@ -161,7 +161,7 @@ static av_always_inline int scaleforopp_y(VC1Context *v, int n /* MV */, int dir
}
}
-static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */,
+static av_always_inline int scaleforsame(const VC1Context *v, int i, int n /* MV */,
int dim, int dir)
{
int brfd, scalesame;
@@ -182,7 +182,7 @@ static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */,
return n;
}
-static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */,
+static av_always_inline int scaleforopp(const VC1Context *v, int n /* MV */,
int dim, int dir)
{
int refdist, scaleopp;
@@ -215,7 +215,6 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
{
MpegEncContext *s = &v->s;
int xy, wrap, off = 0;
- int16_t *A, *B, *C;
int px, py;
int sum;
int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
@@ -301,7 +300,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
}
if (a_valid) {
- A = s->cur_pic.motion_val[dir][xy - wrap + v->blocks_off];
+ const int16_t *A = s->cur_pic.motion_val[dir][xy - wrap + v->blocks_off];
a_f = v->mv_f[dir][xy - wrap + v->blocks_off];
num_oppfield += a_f;
num_samefield += 1 - a_f;
@@ -312,7 +311,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
a_f = 0;
}
if (b_valid) {
- B = s->cur_pic.motion_val[dir][xy - wrap + off + v->blocks_off];
+ const int16_t *B = s->cur_pic.motion_val[dir][xy - wrap + off + v->blocks_off];
b_f = v->mv_f[dir][xy - wrap + off + v->blocks_off];
num_oppfield += b_f;
num_samefield += 1 - b_f;
@@ -323,7 +322,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
b_f = 0;
}
if (c_valid) {
- C = s->cur_pic.motion_val[dir][xy - 1 + v->blocks_off];
+ const int16_t *C = s->cur_pic.motion_val[dir][xy - 1 + v->blocks_off];
c_f = v->mv_f[dir][xy - 1 + v->blocks_off];
num_oppfield += c_f;
num_samefield += 1 - c_f;
@@ -692,8 +691,7 @@ void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
int direct, int mvtype)
{
MpegEncContext *s = &v->s;
- int xy, wrap, off = 0;
- int16_t *A, *B, *C;
+ int xy, wrap;
int px, py;
int sum;
int r_x, r_y;
@@ -743,10 +741,10 @@ void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
}
if ((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
- C = s->cur_pic.motion_val[0][xy - 2];
- A = s->cur_pic.motion_val[0][xy - wrap * 2];
- off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
- B = s->cur_pic.motion_val[0][xy - wrap * 2 + off];
+ int16_t *C = s->cur_pic.motion_val[0][xy - 2];
+ const int16_t *A = s->cur_pic.motion_val[0][xy - wrap * 2];
+ int off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
+ const int16_t *B = s->cur_pic.motion_val[0][xy - wrap * 2 + off];
if (!s->mb_x) C[0] = C[1] = 0;
if (!s->first_slice_line) { // predictor A is not out of bounds
@@ -812,10 +810,10 @@ void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
}
if ((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
- C = s->cur_pic.motion_val[1][xy - 2];
- A = s->cur_pic.motion_val[1][xy - wrap * 2];
- off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
- B = s->cur_pic.motion_val[1][xy - wrap * 2 + off];
+ int16_t *C = s->cur_pic.motion_val[1][xy - 2];
+ const int16_t *A = s->cur_pic.motion_val[1][xy - wrap * 2];
+ int off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
+ const int16_t *B = s->cur_pic.motion_val[1][xy - wrap * 2 + off];
if (!s->mb_x)
C[0] = C[1] = 0;
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index d8d58bb7eb..b89f695b56 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -211,7 +211,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
{
int i, plane, row, sprite;
int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } };
- uint8_t* src_h[2][2];
+ const uint8_t *src_h[2][2];
int xoff[2], xadv[2], yoff[2], yadv[2], alpha;
int ysub[2];
MpegEncContext *s = &v->s;
@@ -235,7 +235,7 @@ static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
v->sprite_output_frame->linesize[plane] * row;
for (sprite = 0; sprite <= v->two_sprites; sprite++) {
- uint8_t *iplane = s->cur_pic.data[plane];
+ const uint8_t *iplane = s->cur_pic.data[plane];
int iline = s->cur_pic.linesize[plane];
int ycoord = yoff[sprite] + yadv[sprite] * row;
int yline = ycoord >> 16;
@@ -667,7 +667,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
}
} else { // VC1/WVC1/WVP2
const uint8_t *start = avctx->extradata;
- uint8_t *end = avctx->extradata + avctx->extradata_size;
+ const uint8_t *end = avctx->extradata + avctx->extradata_size;
const uint8_t *next;
int size, buf2_size;
uint8_t *buf2 = NULL;
--
2.40.1
More information about the ffmpeg-devel
mailing list