diff mbox series

[FFmpeg-devel,08/39] lavc/hevc/filter: stop accessing parameter sets through HEVCParamSets

Message ID 20240607130135.9088-8-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/39] lavc/hevcdec: do not free SliceHeader arrays in pic_arrays_free() | expand

Commit Message

Anton Khirnov June 7, 2024, 1:01 p.m. UTC
Instead, accept PPS as a function argument and retrieve SPS through it.

Makes the code shorter and significantly reduces diff in future commits.
---
 libavcodec/hevc/filter.c  | 311 ++++++++++++++++++++------------------
 libavcodec/hevc/hevcdec.c |  20 +--
 libavcodec/hevc/hevcdec.h |  14 +-
 3 files changed, 186 insertions(+), 159 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/hevc/filter.c b/libavcodec/hevc/filter.c
index db7525170d..081b3a3898 100644
--- a/libavcodec/hevc/filter.c
+++ b/libavcodec/hevc/filter.c
@@ -44,7 +44,8 @@  static const uint8_t betatable[52] = {
     38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64                      // QP 38...51
 };
 
-static int chroma_tc(const HEVCContext *s, int qp_y, int c_idx, int tc_offset)
+static int chroma_tc(const HEVCPPS *pps, const HEVCSPS *sps,
+                     int qp_y, int c_idx, int tc_offset)
 {
     static const int qp_c[] = {
         29, 30, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37
@@ -53,12 +54,12 @@  static int chroma_tc(const HEVCContext *s, int qp_y, int c_idx, int tc_offset)
 
     // slice qp offset is not used for deblocking
     if (c_idx == 1)
-        offset = s->ps.pps->cb_qp_offset;
+        offset = pps->cb_qp_offset;
     else
-        offset = s->ps.pps->cr_qp_offset;
+        offset = pps->cr_qp_offset;
 
     qp_i = av_clip(qp_y + offset, 0, 57);
-    if (s->ps.sps->chroma_format_idc == 1) {
+    if (sps->chroma_format_idc == 1) {
         if (qp_i < 30)
             qp = qp_i;
         else if (qp_i > 43)
@@ -74,16 +75,17 @@  static int chroma_tc(const HEVCContext *s, int qp_y, int c_idx, int tc_offset)
 }
 
 static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s,
+                        const HEVCPPS *pps, const HEVCSPS *sps,
                         int xBase, int yBase, int log2_cb_size)
 {
-    int ctb_size_mask        = (1 << s->ps.sps->log2_ctb_size) - 1;
-    int MinCuQpDeltaSizeMask = (1 << (s->ps.sps->log2_ctb_size -
-                                      s->ps.pps->diff_cu_qp_delta_depth)) - 1;
+    int ctb_size_mask        = (1 << sps->log2_ctb_size) - 1;
+    int MinCuQpDeltaSizeMask = (1 << (sps->log2_ctb_size -
+                                      pps->diff_cu_qp_delta_depth)) - 1;
     int xQgBase              = xBase - (xBase & MinCuQpDeltaSizeMask);
     int yQgBase              = yBase - (yBase & MinCuQpDeltaSizeMask);
-    int min_cb_width         = s->ps.sps->min_cb_width;
-    int x_cb                 = xQgBase >> s->ps.sps->log2_min_cb_size;
-    int y_cb                 = yQgBase >> s->ps.sps->log2_min_cb_size;
+    int min_cb_width         = sps->min_cb_width;
+    int x_cb                 = xQgBase >> sps->log2_min_cb_size;
+    int y_cb                 = yQgBase >> sps->log2_min_cb_size;
     int availableA           = (xBase   & ctb_size_mask) &&
                                (xQgBase & ctb_size_mask);
     int availableB           = (yBase   & ctb_size_mask) &&
@@ -110,31 +112,33 @@  static int get_qPy_pred(HEVCLocalContext *lc, const HEVCContext *s,
     else
         qPy_b = s->qp_y_tab[x_cb + (y_cb - 1) * min_cb_width];
 
-    av_assert2(qPy_a >= -s->ps.sps->qp_bd_offset && qPy_a < 52);
-    av_assert2(qPy_b >= -s->ps.sps->qp_bd_offset && qPy_b < 52);
+    av_assert2(qPy_a >= -sps->qp_bd_offset && qPy_a < 52);
+    av_assert2(qPy_b >= -sps->qp_bd_offset && qPy_b < 52);
 
     return (qPy_a + qPy_b + 1) >> 1;
 }
 
-void ff_hevc_set_qPy(HEVCLocalContext *lc, int xBase, int yBase, int log2_cb_size)
+void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCPPS *pps,
+                     int xBase, int yBase, int log2_cb_size)
 {
+    const HEVCSPS   *const sps = pps->sps;
     const HEVCContext *const s = lc->parent;
-    int qp_y = get_qPy_pred(lc, s, xBase, yBase, log2_cb_size);
+    int qp_y = get_qPy_pred(lc, s, pps, sps, xBase, yBase, log2_cb_size);
 
     if (lc->tu.cu_qp_delta != 0) {
-        int off = s->ps.sps->qp_bd_offset;
+        int off = sps->qp_bd_offset;
         lc->qp_y = FFUMOD(qp_y + lc->tu.cu_qp_delta + 52 + 2 * off,
                                  52 + off) - off;
     } else
         lc->qp_y = qp_y;
 }
 
-static int get_qPy(const HEVCContext *s, int xC, int yC)
+static int get_qPy(const HEVCSPS *sps, const int8_t *qp_y_tab, int xC, int yC)
 {
-    int log2_min_cb_size  = s->ps.sps->log2_min_cb_size;
+    int log2_min_cb_size  = sps->log2_min_cb_size;
     int x                 = xC >> log2_min_cb_size;
     int y                 = yC >> log2_min_cb_size;
-    return s->qp_y_tab[x + y * s->ps.sps->min_cb_width];
+    return qp_y_tab[x + y * sps->min_cb_width];
 }
 
 static void copy_CTB(uint8_t *dst, const uint8_t *src, int width, int height,
@@ -198,13 +202,14 @@  static void copy_vert(uint8_t *dst, const uint8_t *src,
     }
 }
 
-static void copy_CTB_to_hv(const HEVCContext *s, const uint8_t *src,
+static void copy_CTB_to_hv(const HEVCContext *s, const HEVCSPS *sps,
+                           const uint8_t *src,
                            ptrdiff_t stride_src, int x, int y, int width, int height,
                            int c_idx, int x_ctb, int y_ctb)
 {
-    int sh = s->ps.sps->pixel_shift;
-    int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
-    int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
+    int sh = sps->pixel_shift;
+    int w = sps->width >> sps->hshift[c_idx];
+    int h = sps->height >> sps->vshift[c_idx];
 
     /* copy horizontal edges */
     memcpy(s->sao_pixel_buffer_h[c_idx] + (((2 * y_ctb) * w + x) << sh),
@@ -219,27 +224,33 @@  static void copy_CTB_to_hv(const HEVCContext *s, const uint8_t *src,
 }
 
 static void restore_tqb_pixels(const HEVCContext *s,
+                               const HEVCPPS *pps, const HEVCSPS *sps,
                                uint8_t *src1, const uint8_t *dst1,
                                ptrdiff_t stride_src, ptrdiff_t stride_dst,
                                int x0, int y0, int width, int height, int c_idx)
 {
-    if ( s->ps.pps->transquant_bypass_enable_flag ||
-            (s->ps.sps->pcm_loop_filter_disabled && s->ps.sps->pcm_enabled)) {
+    if (pps->transquant_bypass_enable_flag ||
+        (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) {
         int x, y;
-        int min_pu_size  = 1 << s->ps.sps->log2_min_pu_size;
-        int hshift       = s->ps.sps->hshift[c_idx];
-        int vshift       = s->ps.sps->vshift[c_idx];
-        int x_min        = ((x0         ) >> s->ps.sps->log2_min_pu_size);
-        int y_min        = ((y0         ) >> s->ps.sps->log2_min_pu_size);
-        int x_max        = ((x0 + width ) >> s->ps.sps->log2_min_pu_size);
-        int y_max        = ((y0 + height) >> s->ps.sps->log2_min_pu_size);
-        int len          = (min_pu_size >> hshift) << s->ps.sps->pixel_shift;
+        int min_pu_size  = 1 << sps->log2_min_pu_size;
+        int hshift       = sps->hshift[c_idx];
+        int vshift       = sps->vshift[c_idx];
+        int x_min        = ((x0         ) >> sps->log2_min_pu_size);
+        int y_min        = ((y0         ) >> sps->log2_min_pu_size);
+        int x_max        = ((x0 + width ) >> sps->log2_min_pu_size);
+        int y_max        = ((y0 + height) >> sps->log2_min_pu_size);
+        int len          = (min_pu_size >> hshift) << sps->pixel_shift;
         for (y = y_min; y < y_max; y++) {
             for (x = x_min; x < x_max; x++) {
-                if (s->is_pcm[y * s->ps.sps->min_pu_width + x]) {
+                if (s->is_pcm[y * sps->min_pu_width + x]) {
                     int n;
-                    uint8_t *src = src1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_src + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
-                    const uint8_t *dst = dst1 + (((y << s->ps.sps->log2_min_pu_size) - y0) >> vshift) * stride_dst + ((((x << s->ps.sps->log2_min_pu_size) - x0) >> hshift) << s->ps.sps->pixel_shift);
+                    uint8_t *src = src1 +
+                         (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_src +
+                        ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift);
+                    const uint8_t *dst = dst1 +
+                         (((y << sps->log2_min_pu_size) - y0) >> vshift) * stride_dst +
+                        ((((x << sps->log2_min_pu_size) - x0) >> hshift) << sps->pixel_shift);
+
                     for (n = 0; n < (min_pu_size >> vshift); n++) {
                         memcpy(src, dst, len);
                         src += stride_src;
@@ -251,25 +262,27 @@  static void restore_tqb_pixels(const HEVCContext *s,
     }
 }
 
-#define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)])
+#define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)])
 
-static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, int y)
+static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s,
+                           const HEVCPPS *pps, const HEVCSPS *sps,
+                           int x, int y)
 {
     static const uint8_t sao_tab[8] = { 0, 1, 2, 2, 3, 3, 4, 4 };
     int c_idx;
     int edges[4];  // 0 left 1 top 2 right 3 bottom
-    int x_ctb                = x >> s->ps.sps->log2_ctb_size;
-    int y_ctb                = y >> s->ps.sps->log2_ctb_size;
-    int ctb_addr_rs          = y_ctb * s->ps.sps->ctb_width + x_ctb;
-    int ctb_addr_ts          = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs];
+    int x_ctb                = x >> sps->log2_ctb_size;
+    int y_ctb                = y >> sps->log2_ctb_size;
+    int ctb_addr_rs          = y_ctb * sps->ctb_width + x_ctb;
+    int ctb_addr_ts          = pps->ctb_addr_rs_to_ts[ctb_addr_rs];
     SAOParams *sao           = &CTB(s->sao, x_ctb, y_ctb);
     // flags indicating unfilterable edges
     uint8_t vert_edge[]      = { 0, 0 };
     uint8_t horiz_edge[]     = { 0, 0 };
     uint8_t diag_edge[]      = { 0, 0, 0, 0 };
     uint8_t lfase            = CTB(s->filter_slice_edges, x_ctb, y_ctb);
-    uint8_t no_tile_filter   = s->ps.pps->tiles_enabled_flag &&
-                               !s->ps.pps->loop_filter_across_tiles_enabled_flag;
+    uint8_t no_tile_filter   = pps->tiles_enabled_flag &&
+                               !pps->loop_filter_across_tiles_enabled_flag;
     uint8_t restore          = no_tile_filter || !lfase;
     uint8_t left_tile_edge   = 0;
     uint8_t right_tile_edge  = 0;
@@ -278,24 +291,24 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
 
     edges[0]   = x_ctb == 0;
     edges[1]   = y_ctb == 0;
-    edges[2]   = x_ctb == s->ps.sps->ctb_width  - 1;
-    edges[3]   = y_ctb == s->ps.sps->ctb_height - 1;
+    edges[2]   = x_ctb == sps->ctb_width  - 1;
+    edges[3]   = y_ctb == sps->ctb_height - 1;
 
     if (restore) {
         if (!edges[0]) {
-            left_tile_edge  = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]];
+            left_tile_edge  = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs-1]];
             vert_edge[0]    = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb - 1, y_ctb)) || left_tile_edge;
         }
         if (!edges[2]) {
-            right_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]];
+            right_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs+1]];
             vert_edge[1]    = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb + 1, y_ctb)) || right_tile_edge;
         }
         if (!edges[1]) {
-            up_tile_edge     = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]];
+            up_tile_edge     = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]];
             horiz_edge[0]    = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb - 1)) || up_tile_edge;
         }
         if (!edges[3]) {
-            bottom_tile_edge = no_tile_filter && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs + s->ps.sps->ctb_width]];
+            bottom_tile_edge = no_tile_filter && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs + sps->ctb_width]];
             horiz_edge[1]    = (!lfase && CTB(s->tab_slice_address, x_ctb, y_ctb) != CTB(s->tab_slice_address, x_ctb, y_ctb + 1)) || bottom_tile_edge;
         }
         if (!edges[0] && !edges[1]) {
@@ -312,32 +325,32 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
         }
     }
 
-    for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) {
-        int x0       = x >> s->ps.sps->hshift[c_idx];
-        int y0       = y >> s->ps.sps->vshift[c_idx];
+    for (c_idx = 0; c_idx < (sps->chroma_format_idc ? 3 : 1); c_idx++) {
+        int x0       = x >> sps->hshift[c_idx];
+        int y0       = y >> sps->vshift[c_idx];
         ptrdiff_t stride_src = s->cur_frame->f->linesize[c_idx];
-        int ctb_size_h = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->hshift[c_idx];
-        int ctb_size_v = (1 << (s->ps.sps->log2_ctb_size)) >> s->ps.sps->vshift[c_idx];
-        int width    = FFMIN(ctb_size_h, (s->ps.sps->width  >> s->ps.sps->hshift[c_idx]) - x0);
-        int height   = FFMIN(ctb_size_v, (s->ps.sps->height >> s->ps.sps->vshift[c_idx]) - y0);
+        int ctb_size_h = (1 << (sps->log2_ctb_size)) >> sps->hshift[c_idx];
+        int ctb_size_v = (1 << (sps->log2_ctb_size)) >> sps->vshift[c_idx];
+        int width    = FFMIN(ctb_size_h, (sps->width  >> sps->hshift[c_idx]) - x0);
+        int height   = FFMIN(ctb_size_v, (sps->height >> sps->vshift[c_idx]) - y0);
         int tab      = sao_tab[(FFALIGN(width, 8) >> 3) - 1];
-        uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << s->ps.sps->pixel_shift)];
+        uint8_t *src = &s->cur_frame->f->data[c_idx][y0 * stride_src + (x0 << sps->pixel_shift)];
         ptrdiff_t stride_dst;
         uint8_t *dst;
 
         switch (sao->type_idx[c_idx]) {
         case SAO_BAND:
-            copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
+            copy_CTB_to_hv(s, sps, src, stride_src, x0, y0, width, height, c_idx,
                            x_ctb, y_ctb);
-            if (s->ps.pps->transquant_bypass_enable_flag ||
-                (s->ps.sps->pcm_loop_filter_disabled && s->ps.sps->pcm_enabled)) {
+            if (pps->transquant_bypass_enable_flag ||
+                (sps->pcm_loop_filter_disabled && sps->pcm_enabled)) {
                 dst = lc->edge_emu_buffer;
                 stride_dst = 2*MAX_PB_SIZE;
-                copy_CTB(dst, src, width << s->ps.sps->pixel_shift, height, stride_dst, stride_src);
+                copy_CTB(dst, src, width << sps->pixel_shift, height, stride_dst, stride_src);
                 s->hevcdsp.sao_band_filter[tab](src, dst, stride_src, stride_dst,
                                                 sao->offset_val[c_idx], sao->band_position[c_idx],
                                                 width, height);
-                restore_tqb_pixels(s, src, dst, stride_src, stride_dst,
+                restore_tqb_pixels(s, pps, sps, src, dst, stride_src, stride_dst,
                                    x, y, width, height, c_idx);
             } else {
                 s->hevcdsp.sao_band_filter[tab](src, src, stride_src, stride_src,
@@ -348,13 +361,13 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
             break;
         case SAO_EDGE:
         {
-            int w = s->ps.sps->width >> s->ps.sps->hshift[c_idx];
-            int h = s->ps.sps->height >> s->ps.sps->vshift[c_idx];
+            int w = sps->width >> sps->hshift[c_idx];
+            int h = sps->height >> sps->vshift[c_idx];
             int left_edge = edges[0];
             int top_edge = edges[1];
             int right_edge = edges[2];
             int bottom_edge = edges[3];
-            int sh = s->ps.sps->pixel_shift;
+            int sh = sps->pixel_shift;
             int left_pixels, right_pixels;
 
             stride_dst = 2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE;
@@ -440,7 +453,7 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
                      (width + left_pixels + right_pixels) << sh,
                      height, stride_dst, stride_src);
 
-            copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
+            copy_CTB_to_hv(s, sps, src, stride_src, x0, y0, width, height, c_idx,
                            x_ctb, y_ctb);
             s->hevcdsp.sao_edge_filter[tab](src, dst, stride_src, sao->offset_val[c_idx],
                                             sao->eo_class[c_idx], width, height);
@@ -452,7 +465,7 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
                                                 vert_edge,
                                                 horiz_edge,
                                                 diag_edge);
-            restore_tqb_pixels(s, src, dst, stride_src, stride_dst,
+            restore_tqb_pixels(s, pps, sps, src, dst, stride_src, stride_dst,
                                x, y, width, height, c_idx);
             sao->type_idx[c_idx] = SAO_APPLIED;
             break;
@@ -461,9 +474,9 @@  static void sao_filter_CTB(HEVCLocalContext *lc, const HEVCContext *s, int x, in
     }
 }
 
-static int get_pcm(const HEVCContext *s, int x, int y)
+static int get_pcm(const HEVCSPS *sps, const uint8_t *is_pcm, int x, int y)
 {
-    int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
+    int log2_min_pu_size = sps->log2_min_pu_size;
     int x_pu, y_pu;
 
     if (x < 0 || y < 0)
@@ -472,9 +485,9 @@  static int get_pcm(const HEVCContext *s, int x, int y)
     x_pu = x >> log2_min_pu_size;
     y_pu = y >> log2_min_pu_size;
 
-    if (x_pu >= s->ps.sps->min_pu_width || y_pu >= s->ps.sps->min_pu_height)
+    if (x_pu >= sps->min_pu_width || y_pu >= sps->min_pu_height)
         return 2;
-    return s->is_pcm[y_pu * s->ps.sps->min_pu_width + x_pu];
+    return is_pcm[y_pu * sps->min_pu_width + x_pu];
 }
 
 #define TC_CALC(qp, bs)                                                 \
@@ -482,7 +495,9 @@  static int get_pcm(const HEVCContext *s, int x, int y)
                     (tc_offset & -2),                                   \
                     0, MAX_QP + DEFAULT_INTRA_TC_OFFSET)]
 
-static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
+static void deblocking_filter_CTB(const HEVCContext *s,
+                                  const HEVCPPS *pps, const HEVCSPS *sps,
+                                  int x0, int y0)
 {
     uint8_t **data     = s->cur_frame->f->data;
     int      *linesize = s->cur_frame->f->linesize;
@@ -494,18 +509,18 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
     uint8_t no_p[2] = { 0 };
     uint8_t no_q[2] = { 0 };
 
-    int log2_ctb_size = s->ps.sps->log2_ctb_size;
+    int log2_ctb_size = sps->log2_ctb_size;
     int x_end, x_end2, y_end;
     int ctb_size        = 1 << log2_ctb_size;
     int ctb             = (x0 >> log2_ctb_size) +
-                          (y0 >> log2_ctb_size) * s->ps.sps->ctb_width;
+                          (y0 >> log2_ctb_size) * sps->ctb_width;
     int cur_tc_offset   = s->deblock[ctb].tc_offset;
     int cur_beta_offset = s->deblock[ctb].beta_offset;
     int left_tc_offset, left_beta_offset;
     int tc_offset, beta_offset;
-    int pcmf = (s->ps.sps->pcm_enabled &&
-                s->ps.sps->pcm_loop_filter_disabled) ||
-               s->ps.pps->transquant_bypass_enable_flag;
+    int pcmf = (sps->pcm_enabled &&
+                sps->pcm_loop_filter_disabled) ||
+               pps->transquant_bypass_enable_flag;
 
     if (x0) {
         left_tc_offset   = s->deblock[ctb - 1].tc_offset;
@@ -516,17 +531,17 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
     }
 
     x_end = x0 + ctb_size;
-    if (x_end > s->ps.sps->width)
-        x_end = s->ps.sps->width;
+    if (x_end > sps->width)
+        x_end = sps->width;
     y_end = y0 + ctb_size;
-    if (y_end > s->ps.sps->height)
-        y_end = s->ps.sps->height;
+    if (y_end > sps->height)
+        y_end = sps->height;
 
     tc_offset   = cur_tc_offset;
     beta_offset = cur_beta_offset;
 
     x_end2 = x_end;
-    if (x_end2 != s->ps.sps->width)
+    if (x_end2 != sps->width)
         x_end2 -= 8;
     for (y = y0; y < y_end; y += 8) {
         // vertical filtering luma
@@ -534,18 +549,19 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
             const int bs0 = s->vertical_bs[(x +  y      * s->bs_width) >> 2];
             const int bs1 = s->vertical_bs[(x + (y + 4) * s->bs_width) >> 2];
             if (bs0 || bs1) {
-                const int qp = (get_qPy(s, x - 1, y)     + get_qPy(s, x, y)     + 1) >> 1;
+                const int qp = (get_qPy(sps, s->qp_y_tab, x - 1, y) +
+                                get_qPy(sps, s->qp_y_tab, x,     y) + 1) >> 1;
 
                 beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
 
                 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-                src     = &data[LUMA][y * linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
+                src     = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)];
                 if (pcmf) {
-                    no_p[0] = get_pcm(s, x - 1, y);
-                    no_p[1] = get_pcm(s, x - 1, y + 4);
-                    no_q[0] = get_pcm(s, x, y);
-                    no_q[1] = get_pcm(s, x, y + 4);
+                    no_p[0] = get_pcm(sps, s->is_pcm, x - 1, y);
+                    no_p[1] = get_pcm(sps, s->is_pcm, x - 1, y + 4);
+                    no_q[0] = get_pcm(sps, s->is_pcm, x, y);
+                    no_q[1] = get_pcm(sps, s->is_pcm, x, y + 4);
                     s->hevcdsp.hevc_v_loop_filter_luma_c(src, linesize[LUMA],
                                                          beta, tc, no_p, no_q);
                 } else
@@ -562,7 +578,8 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
             const int bs0 = s->horizontal_bs[( x      + y * s->bs_width) >> 2];
             const int bs1 = s->horizontal_bs[((x + 4) + y * s->bs_width) >> 2];
             if (bs0 || bs1) {
-                const int qp = (get_qPy(s, x, y - 1)     + get_qPy(s, x, y)     + 1) >> 1;
+                const int qp = (get_qPy(sps, s->qp_y_tab, x, y - 1) +
+                                get_qPy(sps, s->qp_y_tab, x, y)     + 1) >> 1;
 
                 tc_offset   = x >= x0 ? cur_tc_offset : left_tc_offset;
                 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
@@ -570,12 +587,12 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
                 beta = betatable[av_clip(qp + beta_offset, 0, MAX_QP)];
                 tc[0]   = bs0 ? TC_CALC(qp, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp, bs1) : 0;
-                src     = &data[LUMA][y * linesize[LUMA] + (x << s->ps.sps->pixel_shift)];
+                src     = &data[LUMA][y * linesize[LUMA] + (x << sps->pixel_shift)];
                 if (pcmf) {
-                    no_p[0] = get_pcm(s, x, y - 1);
-                    no_p[1] = get_pcm(s, x + 4, y - 1);
-                    no_q[0] = get_pcm(s, x, y);
-                    no_q[1] = get_pcm(s, x + 4, y);
+                    no_p[0] = get_pcm(sps, s->is_pcm, x, y - 1);
+                    no_p[1] = get_pcm(sps, s->is_pcm, x + 4, y - 1);
+                    no_q[0] = get_pcm(sps, s->is_pcm, x, y);
+                    no_q[1] = get_pcm(sps, s->is_pcm, x + 4, y);
                     s->hevcdsp.hevc_h_loop_filter_luma_c(src, linesize[LUMA],
                                                          beta, tc, no_p, no_q);
                 } else
@@ -585,10 +602,10 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
         }
     }
 
-    if (s->ps.sps->chroma_format_idc) {
+    if (sps->chroma_format_idc) {
         for (chroma = 1; chroma <= 2; chroma++) {
-            int h = 1 << s->ps.sps->hshift[chroma];
-            int v = 1 << s->ps.sps->vshift[chroma];
+            int h = 1 << sps->hshift[chroma];
+            int v = 1 << sps->vshift[chroma];
 
             // vertical filtering chroma
             for (y = y0; y < y_end; y += (8 * v)) {
@@ -597,17 +614,19 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
                     const int bs1 = s->vertical_bs[(x + (y + (4 * v)) * s->bs_width) >> 2];
 
                     if ((bs0 == 2) || (bs1 == 2)) {
-                        const int qp0 = (get_qPy(s, x - 1, y)           + get_qPy(s, x, y)           + 1) >> 1;
-                        const int qp1 = (get_qPy(s, x - 1, y + (4 * v)) + get_qPy(s, x, y + (4 * v)) + 1) >> 1;
+                        const int qp0 = (get_qPy(sps, s->qp_y_tab, x - 1, y) +
+                                         get_qPy(sps, s->qp_y_tab, x,     y) + 1) >> 1;
+                        const int qp1 = (get_qPy(sps, s->qp_y_tab, x - 1, y + (4 * v)) +
+                                         get_qPy(sps, s->qp_y_tab, x,     y + (4 * v)) + 1) >> 1;
 
-                        c_tc[0] = (bs0 == 2) ? chroma_tc(s, qp0, chroma, tc_offset) : 0;
-                        c_tc[1] = (bs1 == 2) ? chroma_tc(s, qp1, chroma, tc_offset) : 0;
-                        src       = &data[chroma][(y >> s->ps.sps->vshift[chroma]) * linesize[chroma] + ((x >> s->ps.sps->hshift[chroma]) << s->ps.sps->pixel_shift)];
+                        c_tc[0] = (bs0 == 2) ? chroma_tc(pps, sps, qp0, chroma, tc_offset) : 0;
+                        c_tc[1] = (bs1 == 2) ? chroma_tc(pps, sps, qp1, chroma, tc_offset) : 0;
+                        src       = &data[chroma][(y >> sps->vshift[chroma]) * linesize[chroma] + ((x >> sps->hshift[chroma]) << sps->pixel_shift)];
                         if (pcmf) {
-                            no_p[0] = get_pcm(s, x - 1, y);
-                            no_p[1] = get_pcm(s, x - 1, y + (4 * v));
-                            no_q[0] = get_pcm(s, x, y);
-                            no_q[1] = get_pcm(s, x, y + (4 * v));
+                            no_p[0] = get_pcm(sps, s->is_pcm, x - 1, y);
+                            no_p[1] = get_pcm(sps, s->is_pcm, x - 1, y + (4 * v));
+                            no_q[0] = get_pcm(sps, s->is_pcm, x, y);
+                            no_q[1] = get_pcm(sps, s->is_pcm, x, y + (4 * v));
                             s->hevcdsp.hevc_v_loop_filter_chroma_c(src, linesize[chroma],
                                                                    c_tc, no_p, no_q);
                         } else
@@ -622,23 +641,25 @@  static void deblocking_filter_CTB(const HEVCContext *s, int x0, int y0)
                 // horizontal filtering chroma
                 tc_offset = x0 ? left_tc_offset : cur_tc_offset;
                 x_end2 = x_end;
-                if (x_end != s->ps.sps->width)
+                if (x_end != sps->width)
                     x_end2 = x_end - 8 * h;
                 for (x = x0 ? x0 - 8 * h : 0; x < x_end2; x += (8 * h)) {
                     const int bs0 = s->horizontal_bs[( x          + y * s->bs_width) >> 2];
                     const int bs1 = s->horizontal_bs[((x + 4 * h) + y * s->bs_width) >> 2];
                     if ((bs0 == 2) || (bs1 == 2)) {
-                        const int qp0 = bs0 == 2 ? (get_qPy(s, x,           y - 1) + get_qPy(s, x,           y) + 1) >> 1 : 0;
-                        const int qp1 = bs1 == 2 ? (get_qPy(s, x + (4 * h), y - 1) + get_qPy(s, x + (4 * h), y) + 1) >> 1 : 0;
+                        const int qp0 = bs0 == 2 ? (get_qPy(sps, s->qp_y_tab, x,           y - 1) +
+                                                    get_qPy(sps, s->qp_y_tab, x,           y)     + 1) >> 1 : 0;
+                        const int qp1 = bs1 == 2 ? (get_qPy(sps, s->qp_y_tab, x + (4 * h), y - 1) +
+                                                    get_qPy(sps, s->qp_y_tab, x + (4 * h), y)     + 1) >> 1 : 0;
 
-                        c_tc[0]   = bs0 == 2 ? chroma_tc(s, qp0, chroma, tc_offset)     : 0;
-                        c_tc[1]   = bs1 == 2 ? chroma_tc(s, qp1, chroma, cur_tc_offset) : 0;
-                        src       = &data[chroma][(y >> s->ps.sps->vshift[1]) * linesize[chroma] + ((x >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)];
+                        c_tc[0]   = bs0 == 2 ? chroma_tc(pps, sps, qp0, chroma, tc_offset)     : 0;
+                        c_tc[1]   = bs1 == 2 ? chroma_tc(pps, sps, qp1, chroma, cur_tc_offset) : 0;
+                        src       = &data[chroma][(y >> sps->vshift[1]) * linesize[chroma] + ((x >> sps->hshift[1]) << sps->pixel_shift)];
                         if (pcmf) {
-                            no_p[0] = get_pcm(s, x,           y - 1);
-                            no_p[1] = get_pcm(s, x + (4 * h), y - 1);
-                            no_q[0] = get_pcm(s, x,           y);
-                            no_q[1] = get_pcm(s, x + (4 * h), y);
+                            no_p[0] = get_pcm(sps, s->is_pcm, x,           y - 1);
+                            no_p[1] = get_pcm(sps, s->is_pcm, x + (4 * h), y - 1);
+                            no_q[0] = get_pcm(sps, s->is_pcm, x,           y);
+                            no_q[1] = get_pcm(sps, s->is_pcm, x + (4 * h), y);
                             s->hevcdsp.hevc_h_loop_filter_chroma_c(src, linesize[chroma],
                                                                    c_tc, no_p, no_q);
                         } else
@@ -715,15 +736,16 @@  static int boundary_strength(const HEVCContext *s, const MvField *curr, const Mv
     return 1;
 }
 
-void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
-                                           int log2_trafo_size)
+void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCPPS *pps,
+                                           int x0, int y0, int log2_trafo_size)
 {
+    const HEVCSPS *const sps = pps->sps;
     const HEVCContext *s = lc->parent;
     const MvField *tab_mvf = s->cur_frame->tab_mvf;
-    int log2_min_pu_size = s->ps.sps->log2_min_pu_size;
-    int log2_min_tu_size = s->ps.sps->log2_min_tb_size;
-    int min_pu_width     = s->ps.sps->min_pu_width;
-    int min_tu_width     = s->ps.sps->min_tb_width;
+    int log2_min_pu_size = sps->log2_min_pu_size;
+    int log2_min_tu_size = sps->log2_min_tb_size;
+    int min_pu_width     = sps->min_pu_width;
+    int min_tu_width     = sps->min_tb_width;
     int is_intra = tab_mvf[(y0 >> log2_min_pu_size) * min_pu_width +
                            (x0 >> log2_min_pu_size)].pred_flag == PF_INTRA;
     int boundary_upper, boundary_left;
@@ -733,10 +755,10 @@  void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
     if (boundary_upper &&
         ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
           lc->boundary_flags & BOUNDARY_UPPER_SLICE &&
-          (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
-         (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
+          (y0 % (1 << sps->log2_ctb_size)) == 0) ||
+         (!pps->loop_filter_across_tiles_enabled_flag &&
           lc->boundary_flags & BOUNDARY_UPPER_TILE &&
-          (y0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
+          (y0 % (1 << sps->log2_ctb_size)) == 0)))
         boundary_upper = 0;
 
     if (boundary_upper) {
@@ -771,10 +793,10 @@  void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
     if (boundary_left &&
         ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
           lc->boundary_flags & BOUNDARY_LEFT_SLICE &&
-          (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0) ||
-         (!s->ps.pps->loop_filter_across_tiles_enabled_flag &&
+          (x0 % (1 << sps->log2_ctb_size)) == 0) ||
+         (!pps->loop_filter_across_tiles_enabled_flag &&
           lc->boundary_flags & BOUNDARY_LEFT_TILE &&
-          (x0 % (1 << s->ps.sps->log2_ctb_size)) == 0)))
+          (x0 % (1 << sps->log2_ctb_size)) == 0)))
         boundary_left = 0;
 
     if (boundary_left) {
@@ -843,10 +865,12 @@  void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
 #undef CB
 #undef CR
 
-void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size)
+void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCPPS *pps,
+                        int x, int y, int ctb_size)
 {
+    const HEVCSPS   *const sps = pps->sps;
     const HEVCContext *const s = lc->parent;
-    int x_end = x >= s->ps.sps->width  - ctb_size;
+    int x_end = x >= sps->width  - ctb_size;
     int skip = 0;
     if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
         (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY && !IS_IDR(s)) ||
@@ -859,20 +883,20 @@  void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size)
         skip = 1;
 
     if (!skip)
-        deblocking_filter_CTB(s, x, y);
-    if (s->ps.sps->sao_enabled && !skip) {
-        int y_end = y >= s->ps.sps->height - ctb_size;
+        deblocking_filter_CTB(s, pps, sps, x, y);
+    if (sps->sao_enabled && !skip) {
+        int y_end = y >= sps->height - ctb_size;
         if (y && x)
-            sao_filter_CTB(lc, s, x - ctb_size, y - ctb_size);
+            sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y - ctb_size);
         if (x && y_end)
-            sao_filter_CTB(lc, s, x - ctb_size, y);
+            sao_filter_CTB(lc, s, pps, sps, x - ctb_size, y);
         if (y && x_end) {
-            sao_filter_CTB(lc, s, x, y - ctb_size);
+            sao_filter_CTB(lc, s, pps, sps, x, y - ctb_size);
             if (s->threads_type & FF_THREAD_FRAME )
                 ff_progress_frame_report(&s->cur_frame->tf, y);
         }
         if (x_end && y_end) {
-            sao_filter_CTB(lc, s, x , y);
+            sao_filter_CTB(lc, s, pps, sps, x , y);
             if (s->threads_type & FF_THREAD_FRAME )
                 ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size);
         }
@@ -880,14 +904,15 @@  void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size)
         ff_progress_frame_report(&s->cur_frame->tf, y + ctb_size - 4);
 }
 
-void ff_hevc_hls_filters(HEVCLocalContext *lc, int x_ctb, int y_ctb, int ctb_size)
+void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCPPS *pps,
+                         int x_ctb, int y_ctb, int ctb_size)
 {
-    int x_end = x_ctb >= lc->parent->ps.sps->width  - ctb_size;
-    int y_end = y_ctb >= lc->parent->ps.sps->height - ctb_size;
+    int x_end = x_ctb >= pps->sps->width  - ctb_size;
+    int y_end = y_ctb >= pps->sps->height - ctb_size;
     if (y_ctb && x_ctb)
-        ff_hevc_hls_filter(lc, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size);
+        ff_hevc_hls_filter(lc, pps, x_ctb - ctb_size, y_ctb - ctb_size, ctb_size);
     if (y_ctb && x_end)
-        ff_hevc_hls_filter(lc, x_ctb, y_ctb - ctb_size, ctb_size);
+        ff_hevc_hls_filter(lc, pps, x_ctb, y_ctb - ctb_size, ctb_size);
     if (x_ctb && y_end)
-        ff_hevc_hls_filter(lc, x_ctb - ctb_size, y_ctb, ctb_size);
+        ff_hevc_hls_filter(lc, pps, x_ctb - ctb_size, y_ctb, ctb_size);
 }
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 5de229f78d..eeeaae6e3a 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1189,7 +1189,7 @@  static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                 return AVERROR_INVALIDDATA;
             }
 
-            ff_hevc_set_qPy(lc, cb_xBase, cb_yBase, log2_cb_size);
+            ff_hevc_set_qPy(lc, s->ps.pps, cb_xBase, cb_yBase, log2_cb_size);
         }
 
         if (s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma &&
@@ -1485,7 +1485,7 @@  do {
                 }
         }
         if (!s->sh.disable_deblocking_filter_flag) {
-            ff_hevc_deblocking_boundary_strengths(lc, x0, y0, log2_trafo_size);
+            ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_trafo_size);
             if (s->ps.pps->transquant_bypass_enable_flag &&
                 lc->cu.cu_transquant_bypass_flag)
                 set_deblocking_bypass(s, x0, y0, log2_trafo_size);
@@ -1514,7 +1514,7 @@  static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size
     int ret;
 
     if (!s->sh.disable_deblocking_filter_flag)
-        ff_hevc_deblocking_boundary_strengths(lc, x0, y0, log2_cb_size);
+        ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
 
     ret = init_get_bits(&gb, pcm, length);
     if (ret < 0)
@@ -2284,7 +2284,7 @@  static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i
         intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size);
 
         if (!s->sh.disable_deblocking_filter_flag)
-            ff_hevc_deblocking_boundary_strengths(lc, x0, y0, log2_cb_size);
+            ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
     } else {
         int pcm_flag = 0;
 
@@ -2372,13 +2372,13 @@  static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i
                     return ret;
             } else {
                 if (!s->sh.disable_deblocking_filter_flag)
-                    ff_hevc_deblocking_boundary_strengths(lc, x0, y0, log2_cb_size);
+                    ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size);
             }
         }
     }
 
     if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0)
-        ff_hevc_set_qPy(lc, x0, y0, log2_cb_size);
+        ff_hevc_set_qPy(lc, s->ps.pps, x0, y0, log2_cb_size);
 
     x = y_cb * min_cb_width + x_cb;
     for (y = 0; y < length; y++) {
@@ -2583,12 +2583,12 @@  static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
 
         ctb_addr_ts++;
         ff_hevc_save_states(lc, ctb_addr_ts);
-        ff_hevc_hls_filters(lc, x_ctb, y_ctb, ctb_size);
+        ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
     }
 
     if (x_ctb + ctb_size >= s->ps.sps->width &&
         y_ctb + ctb_size >= s->ps.sps->height)
-        ff_hevc_hls_filter(lc, x_ctb, y_ctb, ctb_size);
+        ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
 
     return ctb_addr_ts;
 }
@@ -2644,7 +2644,7 @@  static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
 
         ff_hevc_save_states(lc, ctb_addr_ts);
         ff_thread_report_progress2(s->avctx, ctb_row, thread, 1);
-        ff_hevc_hls_filters(lc, x_ctb, y_ctb, ctb_size);
+        ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
 
         if (!more_data && (x_ctb+ctb_size) < s->ps.sps->width && ctb_row != s->sh.num_entry_point_offsets) {
             /* Casting const away here is safe, because it is an atomic operation. */
@@ -2654,7 +2654,7 @@  static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
         }
 
         if ((x_ctb+ctb_size) >= s->ps.sps->width && (y_ctb+ctb_size) >= s->ps.sps->height ) {
-            ff_hevc_hls_filter(lc, x_ctb, y_ctb, ctb_size);
+            ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
             ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP);
             return ctb_addr_ts;
         }
diff --git a/libavcodec/hevc/hevcdec.h b/libavcodec/hevc/hevcdec.h
index eef7d66204..8816ebe1f4 100644
--- a/libavcodec/hevc/hevcdec.h
+++ b/libavcodec/hevc/hevcdec.h
@@ -655,12 +655,14 @@  void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps,
                               int nPbW, int nPbH, int log2_cb_size,
                               int part_idx, int merge_idx,
                               MvField *mv, int mvp_lx_flag, int LX);
-void ff_hevc_hls_filter(HEVCLocalContext *lc, int x, int y, int ctb_size);
-void ff_hevc_hls_filters(HEVCLocalContext *lc, int x_ctb, int y_ctb, int ctb_size);
-void ff_hevc_set_qPy(HEVCLocalContext *lc, int xBase, int yBase,
-                     int log2_cb_size);
-void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, int x0, int y0,
-                                           int log2_trafo_size);
+void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCPPS *pps,
+                        int x, int y, int ctb_size);
+void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCPPS *pps,
+                         int x_ctb, int y_ctb, int ctb_size);
+void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCPPS *pps,
+                     int xBase, int yBase, int log2_cb_size);
+void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCPPS *pps,
+                                           int x0, int y0, int log2_trafo_size);
 int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc);
 int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc);
 int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc);