diff mbox series

[FFmpeg-devel,3/3] avcodec/h264dec: Constify H.264 decoder

Message ID DU0P250MB07471850757DE7949AFC4A138FCDA@DU0P250MB0747.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 4e6cf5e52b4ba6fb8834c91099935525a86e0082
Headers show
Series [FFmpeg-devel,1/3] avcodec/h264idct_template: Don't include h264dec.h | expand

Commit Message

Andreas Rheinhardt Oct. 10, 2023, 1:27 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_cavlc.c   |  2 +-
 libavcodec/h264_direct.c  |  6 +++---
 libavcodec/h264_picture.c |  6 +++---
 libavcodec/h264_refs.c    |  7 ++++---
 libavcodec/h264_slice.c   | 23 +++++++++++------------
 libavcodec/h264dec.c      |  4 ++--
 libavcodec/h264dec.h      |  6 +++---
 7 files changed, 27 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index a06b775422..de223611c6 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -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];
diff --git a/libavcodec/h264_direct.c b/libavcodec/h264_direct.c
index 014491e29b..587274aa6d 100644
--- a/libavcodec/h264_direct.c
+++ b/libavcodec/h264_direct.c
@@ -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;
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index 9353e4b445..c3726059f7 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -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
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 1b24c493df..55f7255f01 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -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;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 27428dea33..1311ea0437 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -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));
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 796f80be8d..105bd9f631 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -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;
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 0009b539e7..14e9038275 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -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 */