1
0
Fork 0

avcodec/h264dec: Constify H.264 decoder

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-09-22 01:09:31 +02:00
parent 8e1bb594fb
commit 4e6cf5e52b
7 changed files with 27 additions and 27 deletions

View File

@ -282,7 +282,7 @@ static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2];
* Get the predicted number of non-zero coefficients.
* @param n block index
*/
static inline int pred_non_zero_count(const H264Context *h, H264SliceContext *sl, int n)
static inline int pred_non_zero_count(const H264Context *h, const H264SliceContext *sl, int n)
{
const int index8= scan8[n];
const int left = sl->non_zero_count_cache[index8 - 1];

View File

@ -34,7 +34,7 @@
#include <assert.h>
static int get_scale_factor(H264SliceContext *sl,
static int get_scale_factor(const H264SliceContext *sl,
int poc, int poc1, int i)
{
int poc0 = sl->ref_list[0][i].poc;
@ -83,7 +83,7 @@ static void fill_colmap(const H264Context *h, H264SliceContext *sl,
int map[2][16 + 32], int list,
int field, int colfield, int mbafi)
{
H264Picture *const ref1 = sl->ref_list[1][0].parent;
const H264Picture *const ref1 = sl->ref_list[1][0].parent;
int j, old_ref, rfield;
int start = mbafi ? 16 : 0;
int end = mbafi ? 16 + 2 * sl->ref_count[0] : sl->ref_count[0];
@ -150,7 +150,7 @@ void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *
if (h->picture_structure == PICT_FRAME) {
int cur_poc = h->cur_pic_ptr->poc;
int *col_poc = sl->ref_list[1][0].parent->field_poc;
const int *col_poc = sl->ref_list[1][0].parent->field_poc;
if (col_poc[0] == INT_MAX && col_poc[1] == INT_MAX) {
av_log(h->avctx, AV_LOG_ERROR, "co located POCs unavailable\n");
sl->col_parity = 1;

View File

@ -94,7 +94,7 @@ static void h264_copy_picture_params(H264Picture *dst, const H264Picture *src)
dst->needs_fg = src->needs_fg;
}
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, const H264Picture *src)
{
int ret, i;
@ -194,7 +194,7 @@ fail:
return ret;
}
void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src)
{
#if CONFIG_ERROR_RESILIENCE
int i;
@ -240,7 +240,7 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
av_log(avctx, AV_LOG_ERROR,
"hardware accelerator failed to decode picture\n");
} else if (!in_setup && cur->needs_fg && (!FIELD_PICTURE(h) || !h->first_field)) {
AVFrameSideData *sd = av_frame_get_side_data(cur->f, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
const AVFrameSideData *sd = av_frame_get_side_data(cur->f, AV_FRAME_DATA_FILM_GRAIN_PARAMS);
err = AVERROR_INVALIDDATA;
if (sd) // a decoding error may have happened before the side data could be allocated

View File

@ -48,7 +48,7 @@ static void pic_as_field(H264Ref *pic, const int parity)
pic->poc = pic->parent->field_poc[parity == PICT_BOTTOM_FIELD];
}
static void ref_from_h264pic(H264Ref *dst, H264Picture *src)
static void ref_from_h264pic(H264Ref *dst, const H264Picture *src)
{
memcpy(dst->data, src->f->data, sizeof(dst->data));
memcpy(dst->linesize, src->f->linesize, sizeof(dst->linesize));
@ -58,7 +58,8 @@ static void ref_from_h264pic(H264Ref *dst, H264Picture *src)
dst->parent = src;
}
static int split_field_copy(H264Ref *dest, H264Picture *src, int parity, int id_add)
static int split_field_copy(H264Ref *dest, const H264Picture *src,
int parity, int id_add)
{
int match = !!(src->reference & parity);
@ -275,7 +276,7 @@ static void h264_fill_mbaff_ref_list(H264SliceContext *sl)
int list, i, j;
for (list = 0; list < sl->list_count; list++) {
for (i = 0; i < sl->ref_count[list]; i++) {
H264Ref *frame = &sl->ref_list[list][i];
const H264Ref *frame = &sl->ref_list[list][i];
H264Ref *field = &sl->ref_list[list][16 + 2 * i];
field[0] = *frame;

View File

@ -266,7 +266,7 @@ fail:
return (ret < 0) ? ret : AVERROR(ENOMEM);
}
static int find_unused_picture(H264Context *h)
static int find_unused_picture(const H264Context *h)
{
int i;
@ -285,9 +285,8 @@ static int find_unused_picture(H264Context *h)
(pic) < (old_ctx)->DPB + H264_MAX_PICTURE_COUNT) ? \
&(new_ctx)->DPB[(pic) - (old_ctx)->DPB] : NULL)
static void copy_picture_range(H264Picture **to, H264Picture **from, int count,
H264Context *new_base,
H264Context *old_base)
static void copy_picture_range(H264Picture **to, H264Picture *const *from, int count,
H264Context *new_base, const H264Context *old_base)
{
int i;
@ -583,8 +582,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
static av_always_inline void backup_mb_border(const H264Context *h, H264SliceContext *sl,
uint8_t *src_y,
uint8_t *src_cb, uint8_t *src_cr,
const uint8_t *src_y,
const uint8_t *src_cb, const uint8_t *src_cr,
int linesize, int uvlinesize,
int simple)
{
@ -1185,7 +1184,7 @@ static int h264_export_frame_props(H264Context *h)
}
if (sps->pic_struct_present_flag && h->sei.picture_timing.present) {
H264SEIPictureTiming *pt = &h->sei.picture_timing;
const H264SEIPictureTiming *pt = &h->sei.picture_timing;
switch (pt->pic_struct) {
case H264_SEI_PIC_STRUCT_FRAME:
break;
@ -1983,7 +1982,7 @@ static int h264_slice_init(H264Context *h, H264SliceContext *sl,
if (j < sl->list_count && i < sl->ref_count[j] &&
sl->ref_list[j][i].parent->f->buf[0]) {
int k;
AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer;
const AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer;
for (k = 0; k < h->short_ref_count; k++)
if (h->short_ref[k]->f->buf[0]->buffer == buf) {
id_list[i] = k;
@ -2178,9 +2177,9 @@ int ff_h264_get_slice_type(const H264SliceContext *sl)
static av_always_inline void fill_filter_caches_inter(const H264Context *h,
H264SliceContext *sl,
int mb_type, int top_xy,
int left_xy[LEFT_MBS],
const int left_xy[LEFT_MBS],
int top_type,
int left_type[LEFT_MBS],
const int left_type[LEFT_MBS],
int mb_xy, int list)
{
int b_stride = h->b_stride;
@ -2237,7 +2236,7 @@ static av_always_inline void fill_filter_caches_inter(const H264Context *h,
}
{
int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
const int8_t *ref = &h->cur_pic.ref_index[list][4 * mb_xy];
const int *ref2frm = &h->ref2frm[sl->slice_num & (MAX_SLICES - 1)][list][(MB_MBAFF(sl) ? 20 : 2)];
uint32_t ref01 = (pack16to32(ref2frm[ref[0]], ref2frm[ref[1]]) & 0x00FF00FF) * 0x0101;
uint32_t ref23 = (pack16to32(ref2frm[ref[2]], ref2frm[ref[3]]) & 0x00FF00FF) * 0x0101;
@ -2264,7 +2263,7 @@ static int fill_filter_caches(const H264Context *h, H264SliceContext *sl, int mb
const int mb_xy = sl->mb_xy;
int top_xy, left_xy[LEFT_MBS];
int top_type, left_type[LEFT_MBS];
uint8_t *nnz;
const uint8_t *nnz;
uint8_t *nnz_cache;
top_xy = mb_xy - (h->mb_stride << MB_FIELD(sl));

View File

@ -66,7 +66,7 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
int (*mv)[2][4][2],
int mb_x, int mb_y, int mb_intra, int mb_skipped)
{
H264Context *h = opaque;
const H264Context *h = opaque;
H264SliceContext *sl = &h->slice_ctx[0];
sl->mb_x = mb_x;
@ -832,7 +832,7 @@ static int get_consumed_bytes(int pos, int buf_size)
return pos;
}
static int h264_export_enc_params(AVFrame *f, H264Picture *p)
static int h264_export_enc_params(AVFrame *f, const H264Picture *p)
{
AVVideoEncParams *par;
unsigned int nb_mb = p->mb_height * p->mb_width;

View File

@ -165,7 +165,7 @@ typedef struct H264Ref {
int poc;
int pic_id;
H264Picture *parent;
const H264Picture *parent;
} H264Ref;
typedef struct H264SliceContext {
@ -653,7 +653,7 @@ static av_always_inline int get_chroma_qp(const PPS *pps, int t, int qscale)
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src);
int ff_h264_ref_picture(H264Context *h, H264Picture *dst, const H264Picture *src);
int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture *src);
void ff_h264_unref_picture(H264Context *h, H264Picture *pic);
@ -678,6 +678,6 @@ void ff_h264_flush_change(H264Context *h);
void ff_h264_free_tables(H264Context *h);
void ff_h264_set_erpic(ERPicture *dst, H264Picture *src);
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src);
#endif /* AVCODEC_H264DEC_H */