[FFmpeg-devel] [PATCH 10/39] lavc/hevc/pred: stop accessing parameter sets through HEVCParamSets

Anton Khirnov anton at khirnov.net
Fri Jun 7 16:01:06 EEST 2024


Instead, accept PPS/SPS as function arguments.

Makes the code shorter and significantly reduces diff in future commits.
---
 libavcodec/hevc/hevcdec.c       |  26 +--
 libavcodec/hevc/pred.h          |   4 +-
 libavcodec/hevc/pred_template.c |  74 ++++----
 libavcodec/mips/hevcpred_mips.h |   4 +-
 libavcodec/mips/hevcpred_msa.c  | 291 ++++++++++++++++----------------
 5 files changed, 202 insertions(+), 197 deletions(-)

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index cf972ed560..5e4e5776e0 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -1160,7 +1160,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
         int trafo_size = 1 << log2_trafo_size;
         ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, s->ps.sps->log2_ctb_size);
 
-        s->hpc.intra_pred[log2_trafo_size - 2](lc, x0, y0, 0);
+        s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, x0, y0, 0);
     }
 
     if (cbf_luma || cbf_cb[0] || cbf_cr[0] ||
@@ -1247,7 +1247,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                 if (lc->cu.pred_mode == MODE_INTRA) {
                     ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c),
                                                     trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                    s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 1);
+                    s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 1);
                 }
                 if (cbf_cb[i])
                     ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
@@ -1277,7 +1277,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                 if (lc->cu.pred_mode == MODE_INTRA) {
                     ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c),
                                                     trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                    s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 2);
+                    s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 2);
                 }
                 if (cbf_cr[i])
                     ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
@@ -1306,7 +1306,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                 if (lc->cu.pred_mode == MODE_INTRA) {
                     ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
                                                     trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                    s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 1);
+                    s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 1);
                 }
                 if (cbf_cb[i])
                     ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
@@ -1316,7 +1316,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                 if (lc->cu.pred_mode == MODE_INTRA) {
                     ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size),
                                                 trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                    s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 2);
+                    s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 2);
                 }
                 if (cbf_cr[i])
                     ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
@@ -1329,26 +1329,26 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
             int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
             ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v,
                                             s->ps.sps->log2_ctb_size);
-            s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 1);
-            s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0, 2);
+            s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 1);
+            s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 2);
             if (s->ps.sps->chroma_format_idc == 2) {
                 ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c),
                                                 trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 1);
-                s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (1 << log2_trafo_size_c), 2);
+                s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 1);
+                s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 2);
             }
         } else if (blk_idx == 3) {
             int trafo_size_h = 1 << (log2_trafo_size + 1);
             int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]);
             ff_hevc_set_neighbour_available(lc, xBase, yBase,
                                             trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-            s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 1);
-            s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase, 2);
+            s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 1);
+            s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 2);
             if (s->ps.sps->chroma_format_idc == 2) {
                 ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << log2_trafo_size),
                                                 trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size);
-                s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 1);
-                s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (1 << log2_trafo_size), 2);
+                s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 1);
+                s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 2);
             }
         }
     }
diff --git a/libavcodec/hevc/pred.h b/libavcodec/hevc/pred.h
index b60d8176ae..1ac8f9666b 100644
--- a/libavcodec/hevc/pred.h
+++ b/libavcodec/hevc/pred.h
@@ -27,9 +27,11 @@
 #include <stdint.h>
 
 struct HEVCLocalContext;
+struct HEVCPPS;
 
 typedef struct HEVCPredContext {
-    void (*intra_pred[4])(struct HEVCLocalContext *lc, int x0, int y0, int c_idx);
+    void (*intra_pred[4])(struct HEVCLocalContext *lc,
+                          const struct HEVCPPS *pps, int x0, int y0, int c_idx);
 
     void (*pred_planar[4])(uint8_t *src, const uint8_t *top,
                            const uint8_t *left, ptrdiff_t stride);
diff --git a/libavcodec/hevc/pred_template.c b/libavcodec/hevc/pred_template.c
index fe9a22614a..ca21774f75 100644
--- a/libavcodec/hevc/pred_template.c
+++ b/libavcodec/hevc/pred_template.c
@@ -27,11 +27,13 @@
 
 #define POS(x, y) src[(x) + stride * (y)]
 
-static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc, int x0, int y0,
+static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc,
+                                              const HEVCPPS *pps,
+                                              int x0, int y0,
                                               int log2_size, int c_idx)
 {
 #define PU(x) \
-    ((x) >> s->ps.sps->log2_min_pu_size)
+    ((x) >> sps->log2_min_pu_size)
 #define MVF(x, y) \
     (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width])
 #define MVF_PU(x, y) \
@@ -39,7 +41,7 @@ static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc, int x0, int
 #define IS_INTRA(x, y) \
     (MVF_PU(x, y).pred_flag == PF_INTRA)
 #define MIN_TB_ADDR_ZS(x, y) \
-    s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
+    pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)]
 #define EXTEND(ptr, val, len)         \
 do {                                  \
     pixel4 pix = PIXEL_SPLAT_X4(val); \
@@ -70,27 +72,28 @@ do {                                  \
             else                                                               \
                 a = PIXEL_SPLAT_X4(ptr[i + 3])
 
+    const HEVCSPS   *const sps = pps->sps;
     const HEVCContext *const s = lc->parent;
     int i;
-    int hshift = s->ps.sps->hshift[c_idx];
-    int vshift = s->ps.sps->vshift[c_idx];
+    int hshift = sps->hshift[c_idx];
+    int vshift = sps->vshift[c_idx];
     int size = (1 << log2_size);
     int size_in_luma_h = size << hshift;
-    int size_in_tbs_h  = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_h  = size_in_luma_h >> sps->log2_min_tb_size;
     int size_in_luma_v = size << vshift;
-    int size_in_tbs_v  = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_v  = size_in_luma_v >> sps->log2_min_tb_size;
     int x = x0 >> hshift;
     int y = y0 >> vshift;
-    int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
-    int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
-    int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << s->ps.sps->log2_min_tb_size));
+    int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask;
+    int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask;
+    int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size));
 
     int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
 
     ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel);
     pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride;
 
-    int min_pu_width = s->ps.sps->min_pu_width;
+    int min_pu_width = sps->min_pu_width;
 
     enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
                               lc->tu.intra_pred_mode;
@@ -104,28 +107,28 @@ do {                                  \
     pixel  *top           = top_array  + 1;
     pixel  *filtered_left = filtered_left_array + 1;
     pixel  *filtered_top  = filtered_top_array  + 1;
-    int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v + spin) & s->ps.sps->tb_mask);
+    int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v + spin) & sps->tb_mask);
     int cand_left        = lc->na.cand_left;
     int cand_up_left     = lc->na.cand_up_left;
     int cand_up          = lc->na.cand_up;
-    int cand_up_right    = lc->na.cand_up_right && !spin && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1);
+    int cand_up_right    = lc->na.cand_up_right && !spin && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & sps->tb_mask, y_tb - 1);
 
-    int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) -
+    int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) -
                            (y0 + size_in_luma_v)) >> vshift;
-    int top_right_size   = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) -
+    int top_right_size   = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) -
                            (x0 + size_in_luma_h)) >> hshift;
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
+    if (pps->constrained_intra_pred_flag == 1) {
         int size_in_luma_pu_v = PU(size_in_luma_v);
         int size_in_luma_pu_h = PU(size_in_luma_h);
-        int on_pu_edge_x    = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size);
-        int on_pu_edge_y    = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size);
+        int on_pu_edge_x    = !av_mod_uintp2(x0, sps->log2_min_pu_size);
+        int on_pu_edge_y    = !av_mod_uintp2(y0, sps->log2_min_pu_size);
         if (!size_in_luma_pu_h)
             size_in_luma_pu_h++;
         if (cand_bottom_left == 1 && on_pu_edge_x) {
             int x_left_pu   = PU(x0 - 1);
             int y_bottom_pu = PU(y0 + size_in_luma_v);
-            int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu);
+            int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu);
             cand_bottom_left = 0;
             for (i = 0; i < max; i += 2)
                 cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
@@ -133,7 +136,7 @@ do {                                  \
         if (cand_left == 1 && on_pu_edge_x) {
             int x_left_pu   = PU(x0 - 1);
             int y_left_pu   = PU(y0);
-            int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu);
+            int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu);
             cand_left = 0;
             for (i = 0; i < max; i += 2)
                 cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
@@ -146,7 +149,7 @@ do {                                  \
         if (cand_up == 1 && on_pu_edge_y) {
             int x_top_pu    = PU(x0);
             int y_top_pu    = PU(y0 - 1);
-            int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu);
+            int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu);
             cand_up = 0;
             for (i = 0; i < max; i += 2)
                 cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
@@ -154,7 +157,7 @@ do {                                  \
         if (cand_up_right == 1 && on_pu_edge_y) {
             int y_top_pu    = PU(y0 - 1);
             int x_right_pu  = PU(x0 + size_in_luma_h);
-            int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu);
+            int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu);
             cand_up_right = 0;
             for (i = 0; i < max; i += 2)
                 cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
@@ -184,20 +187,20 @@ do {                                  \
                size - bottom_left_size);
     }
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
+    if (pps->constrained_intra_pred_flag == 1) {
         if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
-            int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ?
-                                    2 * size : (s->ps.sps->width - x0) >> hshift;
-            int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ?
-                                    2 * size : (s->ps.sps->height - y0) >> vshift;
+            int size_max_x = x0 + ((2 * size) << hshift) < sps->width ?
+                                    2 * size : (sps->width - x0) >> hshift;
+            int size_max_y = y0 + ((2 * size) << vshift) < sps->height ?
+                                    2 * size : (sps->height - y0) >> vshift;
             int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
             if (!cand_up_right) {
-                size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ?
-                                                    size : (s->ps.sps->width - x0) >> hshift;
+                size_max_x = x0 + ((size) << hshift) < sps->width ?
+                             size : (sps->width - x0) >> hshift;
             }
             if (!cand_bottom_left) {
-                size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ?
-                                                     size : (s->ps.sps->height - y0) >> vshift;
+                size_max_y = y0 + (( size) << vshift) < sps->height ?
+                                                     size : (sps->height - y0) >> vshift;
             }
             if (cand_bottom_left || cand_left || cand_up_left) {
                 while (j > -1 && !IS_INTRA(-1, j))
@@ -285,14 +288,14 @@ do {                                  \
     top[-1] = left[-1];
 
     // Filtering process
-    if (!s->ps.sps->intra_smoothing_disabled && (c_idx == 0  || s->ps.sps->chroma_format_idc == 3)) {
+    if (!sps->intra_smoothing_disabled && (c_idx == 0  || sps->chroma_format_idc == 3)) {
         if (mode != INTRA_DC && size != 4){
             int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
             int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
                                           FFABS((int)(mode - 10U)));
             if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
                 int threshold = 1 << (BIT_DEPTH - 5);
-                if (s->ps.sps->strong_intra_smoothing_enabled && c_idx == 0 &&
+                if (sps->strong_intra_smoothing_enabled && c_idx == 0 &&
                     log2_size == 5 &&
                     FFABS(top[-1]  + top[63]  - 2 * top[31])  < threshold &&
                     FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
@@ -343,9 +346,10 @@ do {                                  \
 }
 
 #define INTRA_PRED(size)                                                            \
-static void FUNC(intra_pred_ ## size)(HEVCLocalContext *lc, int x0, int y0, int c_idx) \
+static void FUNC(intra_pred_ ## size)(HEVCLocalContext *lc, const HEVCPPS *pps,     \
+                                      int x0, int y0, int c_idx)                    \
 {                                                                                   \
-    FUNC(intra_pred)(lc, x0, y0, size, c_idx);                                      \
+    FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx);                                 \
 }
 
 INTRA_PRED(2)
diff --git a/libavcodec/mips/hevcpred_mips.h b/libavcodec/mips/hevcpred_mips.h
index 220ab307af..692a162151 100644
--- a/libavcodec/mips/hevcpred_mips.h
+++ b/libavcodec/mips/hevcpred_mips.h
@@ -67,7 +67,7 @@ void ff_pred_intra_pred_angular_3_msa(uint8_t *dst,
                                       const uint8_t *src_left,
                                       ptrdiff_t stride, int c_idx, int mode);
 
-void ff_intra_pred_8_16x16_msa(struct HEVCLocalContext *s, int x0, int y0, int c_idx);
-void ff_intra_pred_8_32x32_msa(struct HEVCLocalContext *s, int x0, int y0, int c_idx);
+void ff_intra_pred_8_16x16_msa(struct HEVCLocalContext *s, const struct HEVCPPS *pps, int x0, int y0, int c_idx);
+void ff_intra_pred_8_32x32_msa(struct HEVCLocalContext *s, const struct HEVCPPS *pps, int x0, int y0, int c_idx);
 
 #endif  // #ifndef AVCODEC_MIPS_HEVCPRED_MIPS_H
diff --git a/libavcodec/mips/hevcpred_msa.c b/libavcodec/mips/hevcpred_msa.c
index ef70d6b2e5..a6824712a2 100644
--- a/libavcodec/mips/hevcpred_msa.c
+++ b/libavcodec/mips/hevcpred_msa.c
@@ -1903,29 +1903,31 @@ void ff_pred_intra_pred_angular_3_msa(uint8_t *dst,
     }
 }
 
-void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
+void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, const HEVCPPS *pps,
+                               int x0, int y0, int c_idx)
 {
     v16u8 vec0;
+    const HEVCSPS   *const sps = pps->sps;
     const HEVCContext *const s = lc->parent;
     int i;
-    int hshift = s->ps.sps->hshift[c_idx];
-    int vshift = s->ps.sps->vshift[c_idx];
+    int hshift = sps->hshift[c_idx];
+    int vshift = sps->vshift[c_idx];
     int size_in_luma_h = 16 << hshift;
-    int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size;
     int size_in_luma_v = 16 << vshift;
-    int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size;
     int x = x0 >> hshift;
     int y = y0 >> vshift;
-    int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
-    int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
+    int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask;
+    int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask;
 
     int cur_tb_addr =
-        s->ps.pps->min_tb_addr_zs[(y_tb) * (s->ps.sps->tb_mask + 2) + (x_tb)];
+        pps->min_tb_addr_zs[(y_tb) * (sps->tb_mask + 2) + (x_tb)];
 
     ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(uint8_t);
     uint8_t *src = (uint8_t *) s->frame->data[c_idx] + x + y * stride;
 
-    int min_pu_width = s->ps.sps->min_pu_width;
+    int min_pu_width = sps->min_pu_width;
 
     enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
         lc->tu.intra_pred_mode;
@@ -1941,41 +1943,41 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
     uint8_t *filtered_top = filtered_top_array + 1;
     int cand_bottom_left = lc->na.cand_bottom_left
         && cur_tb_addr >
-        s->ps.pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & s->ps.sps->tb_mask) *
-                               (s->ps.sps->tb_mask + 2) + (x_tb - 1)];
+        pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & sps->tb_mask) *
+                               (sps->tb_mask + 2) + (x_tb - 1)];
     int cand_left = lc->na.cand_left;
     int cand_up_left = lc->na.cand_up_left;
     int cand_up = lc->na.cand_up;
     int cand_up_right = lc->na.cand_up_right
         && cur_tb_addr >
-        s->ps.pps->min_tb_addr_zs[(y_tb - 1) * (s->ps.sps->tb_mask + 2) +
-                               ((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask)];
+        pps->min_tb_addr_zs[(y_tb - 1) * (sps->tb_mask + 2) +
+                               ((x_tb + size_in_tbs_h) & sps->tb_mask)];
 
     int bottom_left_size =
         (((y0 + 2 * size_in_luma_v) >
-          (s->ps.sps->height) ? (s->ps.sps->height) : (y0 +
+          (sps->height) ? (sps->height) : (y0 +
                                                  2 * size_in_luma_v)) -
          (y0 + size_in_luma_v)) >> vshift;
     int top_right_size =
         (((x0 + 2 * size_in_luma_h) >
-          (s->ps.sps->width) ? (s->ps.sps->width) : (x0 + 2 * size_in_luma_h)) -
+          (sps->width) ? (sps->width) : (x0 + 2 * size_in_luma_h)) -
          (x0 + size_in_luma_h)) >> hshift;
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
-        int size_in_luma_pu_v = ((size_in_luma_v) >> s->ps.sps->log2_min_pu_size);
-        int size_in_luma_pu_h = ((size_in_luma_h) >> s->ps.sps->log2_min_pu_size);
-        int on_pu_edge_x = !(x0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
-        int on_pu_edge_y = !(y0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
+    if (pps->constrained_intra_pred_flag == 1) {
+        int size_in_luma_pu_v = ((size_in_luma_v) >> sps->log2_min_pu_size);
+        int size_in_luma_pu_h = ((size_in_luma_h) >> sps->log2_min_pu_size);
+        int on_pu_edge_x = !(x0 & ((1 << sps->log2_min_pu_size) - 1));
+        int on_pu_edge_y = !(y0 & ((1 << sps->log2_min_pu_size) - 1));
         if (!size_in_luma_pu_h)
             size_in_luma_pu_h++;
         if (cand_bottom_left == 1 && on_pu_edge_x) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
             int y_bottom_pu =
-                ((y0 + size_in_luma_v) >> s->ps.sps->log2_min_pu_size);
+                ((y0 + size_in_luma_v) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_v) >
-                 (s->ps.sps->min_pu_height -
-                  y_bottom_pu) ? (s->ps.sps->min_pu_height -
+                 (sps->min_pu_height -
+                  y_bottom_pu) ? (sps->min_pu_height -
                                   y_bottom_pu) : (size_in_luma_pu_v));
             cand_bottom_left = 0;
             for (i = 0; i < max; i += 2)
@@ -1986,12 +1988,12 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      PF_INTRA);
         }
         if (cand_left == 1 && on_pu_edge_x) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
-            int y_left_pu = ((y0) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
+            int y_left_pu = ((y0) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_v) >
-                 (s->ps.sps->min_pu_height -
-                  y_left_pu) ? (s->ps.sps->min_pu_height -
+                 (sps->min_pu_height -
+                  y_left_pu) ? (sps->min_pu_height -
                                 y_left_pu) : (size_in_luma_pu_v));
             cand_left = 0;
             for (i = 0; i < max; i += 2)
@@ -2002,20 +2004,20 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      PF_INTRA);
         }
         if (cand_up_left == 1) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             cand_up_left =
                 (s->cur_frame->tab_mvf[(x_left_pu) +
                                  (y_top_pu) * min_pu_width]).pred_flag ==
                 PF_INTRA;
         }
         if (cand_up == 1 && on_pu_edge_y) {
-            int x_top_pu = ((x0) >> s->ps.sps->log2_min_pu_size);
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_top_pu = ((x0) >> sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_h) >
-                 (s->ps.sps->min_pu_width -
-                  x_top_pu) ? (s->ps.sps->min_pu_width -
+                 (sps->min_pu_width -
+                  x_top_pu) ? (sps->min_pu_width -
                                x_top_pu) : (size_in_luma_pu_h));
             cand_up = 0;
             for (i = 0; i < max; i += 2)
@@ -2025,13 +2027,13 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                       min_pu_width]).pred_flag == PF_INTRA);
         }
         if (cand_up_right == 1 && on_pu_edge_y) {
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             int x_right_pu =
-                ((x0 + size_in_luma_h) >> s->ps.sps->log2_min_pu_size);
+                ((x0 + size_in_luma_h) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_h) >
-                 (s->ps.sps->min_pu_width -
-                  x_right_pu) ? (s->ps.sps->min_pu_width -
+                 (sps->min_pu_width -
+                  x_right_pu) ? (sps->min_pu_width -
                                  x_right_pu) : (size_in_luma_pu_h));
             cand_up_right = 0;
             for (i = 0; i < max; i += 2)
@@ -2086,56 +2088,55 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
         } while (0);
     }
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
+    if (pps->constrained_intra_pred_flag == 1) {
         if (cand_bottom_left || cand_left || cand_up_left || cand_up
             || cand_up_right) {
             int size_max_x =
                 x0 + ((2 * 16) << hshift) <
-                s->ps.sps->width ? 2 * 16 : (s->ps.sps->width - x0) >> hshift;
+                sps->width ? 2 * 16 : (sps->width - x0) >> hshift;
             int size_max_y =
                 y0 + ((2 * 16) << vshift) <
-                s->ps.sps->height ? 2 * 16 : (s->ps.sps->height - y0) >> vshift;
+                sps->height ? 2 * 16 : (sps->height - y0) >> vshift;
             int j = 16 + (cand_bottom_left ? bottom_left_size : 0) - 1;
             if (!cand_up_right) {
-                size_max_x = x0 + ((16) << hshift) < s->ps.sps->width ?
-                    16 : (s->ps.sps->width - x0) >> hshift;
+                size_max_x = x0 + ((16) << hshift) < sps->width ?
+                    16 : (sps->width - x0) >> hshift;
             }
             if (!cand_bottom_left) {
-                size_max_y = y0 + ((16) << vshift) < s->ps.sps->height ?
-                    16 : (s->ps.sps->height - y0) >> vshift;
+                size_max_y = y0 + ((16) << vshift) < sps->height ?
+                    16 : (sps->height - y0) >> vshift;
             }
             if (cand_bottom_left || cand_left || cand_up_left) {
                 while (j > -1
                        &&
                        !((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((j) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
                     j--;
                 if (!
                     ((s->cur_frame->tab_mvf[(((x0 +
-                                         ((-1) << hshift)) >> s->ps.sps->
+                                         ((-1) << hshift)) >> sps->
                                         log2_min_pu_size)) + (((y0 + ((j)
                                                                       <<
                                                                       vshift))
-                                                               >> s->ps.sps->
+                                                               >> sps->
                                                                log2_min_pu_size))
                                       * min_pu_width]).pred_flag == PF_INTRA)) {
                     j = 0;
                     while (j < size_max_x
                            &&
                            !((s->cur_frame->tab_mvf[(((x0 +
-                                                 ((j) << hshift)) >> s->ps.sps->
+                                                 ((j) << hshift)) >> sps->
                                                 log2_min_pu_size)) + (((y0 +
                                                                         ((-1) <<
                                                                          vshift))
-                                                                       >> s->
-                                                                       ps.sps->
+                                                                       >> sps->
                                                                        log2_min_pu_size))
                                               * min_pu_width]).pred_flag ==
                              PF_INTRA))
@@ -2144,12 +2145,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                         if (!
                             ((s->cur_frame->tab_mvf[(((x0 +
                                                  ((i -
-                                                   1) << hshift)) >> s->ps.sps->
+                                                   1) << hshift)) >> sps->
                                                 log2_min_pu_size)) + (((y0 +
                                                                         ((-1) <<
                                                                          vshift))
-                                                                       >> s->
-                                                                       ps.sps->
+                                                                       >> sps->
                                                                        log2_min_pu_size))
                                               * min_pu_width]).pred_flag ==
                              PF_INTRA))
@@ -2161,11 +2161,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 while (j < size_max_x
                        &&
                        !((s->cur_frame->tab_mvf[(((x0 +
-                                             ((j) << hshift)) >> s->ps.sps->
+                                             ((j) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 + ((-1)
                                                                           <<
                                                                           vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2177,11 +2177,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                 ((s->cur_frame->tab_mvf[(((x0 +
                                                      ((i -
                                                        1) << hshift)) >>
-                                                    s->ps.sps->log2_min_pu_size))
+                                                    sps->log2_min_pu_size))
                                                   + (((y0 + ((-1)
                                                              << vshift))
                                                       >>
-                                                      s->ps.sps->log2_min_pu_size))
+                                                      sps->log2_min_pu_size))
                                                   *
                                                   min_pu_width]).pred_flag ==
                                  PF_INTRA))
@@ -2192,11 +2192,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                 ((s->cur_frame->tab_mvf[(((x0 +
                                                      ((i -
                                                        1) << hshift)) >>
-                                                    s->ps.sps->log2_min_pu_size))
+                                                    sps->log2_min_pu_size))
                                                   + (((y0 + ((-1)
                                                              << vshift))
                                                       >>
-                                                      s->ps.sps->log2_min_pu_size))
+                                                      sps->log2_min_pu_size))
                                                   *
                                                   min_pu_width]).pred_flag ==
                                  PF_INTRA))
@@ -2211,11 +2211,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 for (i = 0; i < (0) + (size_max_y); i += 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2240,12 +2240,12 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      i > (size_max_y - 1) - (size_max_y); i -= 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i -
                                                                       3) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2254,11 +2254,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                         a = ((left[i - 3]) * 0x01010101U);
                 if (!
                     ((s->cur_frame->tab_mvf[(((x0 +
-                                         ((-1) << hshift)) >> s->ps.sps->
+                                         ((-1) << hshift)) >> sps->
                                         log2_min_pu_size)) + (((y0 + ((-1)
                                                                       <<
                                                                       vshift))
-                                                               >> s->ps.sps->
+                                                               >> sps->
                                                                log2_min_pu_size))
                                       * min_pu_width]).pred_flag == PF_INTRA))
                     left[-1] = left[0];
@@ -2274,12 +2274,12 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      i > (size_max_y - 1) - (size_max_y); i -= 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i -
                                                                       3) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2293,11 +2293,11 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 for (i = 0; i < (0) + (size_max_x); i += 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((i) << hshift)) >> s->ps.sps->
+                                             ((i) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 + ((-1)
                                                                           <<
                                                                           vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2369,8 +2369,8 @@ void ff_intra_pred_8_16x16_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
     top[-1] = left[-1];
 
 
-    if (!s->ps.sps->intra_smoothing_disabled
-        && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
+    if (!sps->intra_smoothing_disabled
+        && (c_idx == 0 || sps->chroma_format_idc == 3)) {
         if (mode != INTRA_DC && 16 != 4) {
             int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
             int min_dist_vert_hor =
@@ -2423,26 +2423,27 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
     v8i16 res0, res1, res2, res3;
     v8i16 mul_val0 = { 63, 62, 61, 60, 59, 58, 57, 56 };
     v8i16 mul_val1 = { 1, 2, 3, 4, 5, 6, 7, 8 };
+    const HEVCSPS   *const sps = pps->sps;
     const HEVCContext *const s = lc->parent;
     int i;
-    int hshift = s->ps.sps->hshift[c_idx];
-    int vshift = s->ps.sps->vshift[c_idx];
+    int hshift = sps->hshift[c_idx];
+    int vshift = sps->vshift[c_idx];
     int size_in_luma_h = 32 << hshift;
-    int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size;
     int size_in_luma_v = 32 << vshift;
-    int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
+    int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size;
     int x = x0 >> hshift;
     int y = y0 >> vshift;
-    int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
-    int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
+    int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask;
+    int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask;
 
     int cur_tb_addr =
-        s->ps.pps->min_tb_addr_zs[(y_tb) * (s->ps.sps->tb_mask + 2) + (x_tb)];
+        pps->min_tb_addr_zs[(y_tb) * (sps->tb_mask + 2) + (x_tb)];
 
     ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(uint8_t);
     uint8_t *src = (uint8_t *) s->frame->data[c_idx] + x + y * stride;
 
-    int min_pu_width = s->ps.sps->min_pu_width;
+    int min_pu_width = sps->min_pu_width;
 
     enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
         lc->tu.intra_pred_mode;
@@ -2458,41 +2459,41 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
     uint8_t *filtered_top = filtered_top_array + 1;
     int cand_bottom_left = lc->na.cand_bottom_left
         && cur_tb_addr >
-        s->ps.pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & s->ps.sps->tb_mask) *
-                               (s->ps.sps->tb_mask + 2) + (x_tb - 1)];
+        pps->min_tb_addr_zs[((y_tb + size_in_tbs_v) & sps->tb_mask) *
+                               (sps->tb_mask + 2) + (x_tb - 1)];
     int cand_left = lc->na.cand_left;
     int cand_up_left = lc->na.cand_up_left;
     int cand_up = lc->na.cand_up;
     int cand_up_right = lc->na.cand_up_right
         && cur_tb_addr >
-        s->ps.pps->min_tb_addr_zs[(y_tb - 1) * (s->ps.sps->tb_mask + 2) +
-                               ((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask)];
+        pps->min_tb_addr_zs[(y_tb - 1) * (sps->tb_mask + 2) +
+                               ((x_tb + size_in_tbs_h) & sps->tb_mask)];
 
     int bottom_left_size =
         (((y0 + 2 * size_in_luma_v) >
-          (s->ps.sps->height) ? (s->ps.sps->height) : (y0 +
+          (sps->height) ? (sps->height) : (y0 +
                                                  2 * size_in_luma_v)) -
          (y0 + size_in_luma_v)) >> vshift;
     int top_right_size =
         (((x0 + 2 * size_in_luma_h) >
-          (s->ps.sps->width) ? (s->ps.sps->width) : (x0 + 2 * size_in_luma_h)) -
+          (sps->width) ? (sps->width) : (x0 + 2 * size_in_luma_h)) -
          (x0 + size_in_luma_h)) >> hshift;
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
-        int size_in_luma_pu_v = ((size_in_luma_v) >> s->ps.sps->log2_min_pu_size);
-        int size_in_luma_pu_h = ((size_in_luma_h) >> s->ps.sps->log2_min_pu_size);
-        int on_pu_edge_x = !(x0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
-        int on_pu_edge_y = !(y0 & ((1 << s->ps.sps->log2_min_pu_size) - 1));
+    if (pps->constrained_intra_pred_flag == 1) {
+        int size_in_luma_pu_v = ((size_in_luma_v) >> sps->log2_min_pu_size);
+        int size_in_luma_pu_h = ((size_in_luma_h) >> sps->log2_min_pu_size);
+        int on_pu_edge_x = !(x0 & ((1 << sps->log2_min_pu_size) - 1));
+        int on_pu_edge_y = !(y0 & ((1 << sps->log2_min_pu_size) - 1));
         if (!size_in_luma_pu_h)
             size_in_luma_pu_h++;
         if (cand_bottom_left == 1 && on_pu_edge_x) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
             int y_bottom_pu =
-                ((y0 + size_in_luma_v) >> s->ps.sps->log2_min_pu_size);
+                ((y0 + size_in_luma_v) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_v) >
-                 (s->ps.sps->min_pu_height -
-                  y_bottom_pu) ? (s->ps.sps->min_pu_height -
+                 (sps->min_pu_height -
+                  y_bottom_pu) ? (sps->min_pu_height -
                                   y_bottom_pu) : (size_in_luma_pu_v));
             cand_bottom_left = 0;
             for (i = 0; i < max; i += 2)
@@ -2503,12 +2504,12 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      PF_INTRA);
         }
         if (cand_left == 1 && on_pu_edge_x) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
-            int y_left_pu = ((y0) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
+            int y_left_pu = ((y0) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_v) >
-                 (s->ps.sps->min_pu_height -
-                  y_left_pu) ? (s->ps.sps->min_pu_height -
+                 (sps->min_pu_height -
+                  y_left_pu) ? (sps->min_pu_height -
                                 y_left_pu) : (size_in_luma_pu_v));
             cand_left = 0;
             for (i = 0; i < max; i += 2)
@@ -2519,20 +2520,20 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      PF_INTRA);
         }
         if (cand_up_left == 1) {
-            int x_left_pu = ((x0 - 1) >> s->ps.sps->log2_min_pu_size);
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_left_pu = ((x0 - 1) >> sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             cand_up_left =
                 (s->cur_frame->tab_mvf[(x_left_pu) +
                                  (y_top_pu) * min_pu_width]).pred_flag ==
                 PF_INTRA;
         }
         if (cand_up == 1 && on_pu_edge_y) {
-            int x_top_pu = ((x0) >> s->ps.sps->log2_min_pu_size);
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int x_top_pu = ((x0) >> sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_h) >
-                 (s->ps.sps->min_pu_width -
-                  x_top_pu) ? (s->ps.sps->min_pu_width -
+                 (sps->min_pu_width -
+                  x_top_pu) ? (sps->min_pu_width -
                                x_top_pu) : (size_in_luma_pu_h));
             cand_up = 0;
             for (i = 0; i < max; i += 2)
@@ -2542,13 +2543,13 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                       min_pu_width]).pred_flag == PF_INTRA);
         }
         if (cand_up_right == 1 && on_pu_edge_y) {
-            int y_top_pu = ((y0 - 1) >> s->ps.sps->log2_min_pu_size);
+            int y_top_pu = ((y0 - 1) >> sps->log2_min_pu_size);
             int x_right_pu =
-                ((x0 + size_in_luma_h) >> s->ps.sps->log2_min_pu_size);
+                ((x0 + size_in_luma_h) >> sps->log2_min_pu_size);
             int max =
                 ((size_in_luma_pu_h) >
-                 (s->ps.sps->min_pu_width -
-                  x_right_pu) ? (s->ps.sps->min_pu_width -
+                 (sps->min_pu_width -
+                  x_right_pu) ? (sps->min_pu_width -
                                  x_right_pu) : (size_in_luma_pu_h));
             cand_up_right = 0;
             for (i = 0; i < max; i += 2)
@@ -2601,56 +2602,55 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
         } while (0);
     }
 
-    if (s->ps.pps->constrained_intra_pred_flag == 1) {
+    if (pps->constrained_intra_pred_flag == 1) {
         if (cand_bottom_left || cand_left || cand_up_left || cand_up
             || cand_up_right) {
             int size_max_x =
                 x0 + ((2 * 32) << hshift) <
-                s->ps.sps->width ? 2 * 32 : (s->ps.sps->width - x0) >> hshift;
+                sps->width ? 2 * 32 : (sps->width - x0) >> hshift;
             int size_max_y =
                 y0 + ((2 * 32) << vshift) <
-                s->ps.sps->height ? 2 * 32 : (s->ps.sps->height - y0) >> vshift;
+                sps->height ? 2 * 32 : (sps->height - y0) >> vshift;
             int j = 32 + (cand_bottom_left ? bottom_left_size : 0) - 1;
             if (!cand_up_right) {
-                size_max_x = x0 + ((32) << hshift) < s->ps.sps->width ?
-                    32 : (s->ps.sps->width - x0) >> hshift;
+                size_max_x = x0 + ((32) << hshift) < sps->width ?
+                    32 : (sps->width - x0) >> hshift;
             }
             if (!cand_bottom_left) {
-                size_max_y = y0 + ((32) << vshift) < s->ps.sps->height ?
-                    32 : (s->ps.sps->height - y0) >> vshift;
+                size_max_y = y0 + ((32) << vshift) < sps->height ?
+                    32 : (sps->height - y0) >> vshift;
             }
             if (cand_bottom_left || cand_left || cand_up_left) {
                 while (j > -1
                        &&
                        !((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((j) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
                     j--;
                 if (!
                     ((s->cur_frame->tab_mvf[(((x0 +
-                                         ((-1) << hshift)) >> s->ps.sps->
+                                         ((-1) << hshift)) >> sps->
                                         log2_min_pu_size)) + (((y0 + ((j)
                                                                       <<
                                                                       vshift))
-                                                               >> s->ps.sps->
+                                                               >> sps->
                                                                log2_min_pu_size))
                                       * min_pu_width]).pred_flag == PF_INTRA)) {
                     j = 0;
                     while (j < size_max_x
                            &&
                            !((s->cur_frame->tab_mvf[(((x0 +
-                                                 ((j) << hshift)) >> s->ps.sps->
+                                                 ((j) << hshift)) >> sps->
                                                 log2_min_pu_size)) + (((y0 +
                                                                         ((-1) <<
                                                                          vshift))
-                                                                       >> s->
-                                                                       ps.sps->
+                                                                       >> sps->
                                                                        log2_min_pu_size))
                                               * min_pu_width]).pred_flag ==
                              PF_INTRA))
@@ -2659,12 +2659,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                         if (!
                             ((s->cur_frame->tab_mvf[(((x0 +
                                                  ((i -
-                                                   1) << hshift)) >> s->ps.sps->
+                                                   1) << hshift)) >> sps->
                                                 log2_min_pu_size)) + (((y0 +
                                                                         ((-1) <<
                                                                          vshift))
-                                                                       >> s->
-                                                                       ps.sps->
+                                                                       >> sps->
                                                                        log2_min_pu_size))
                                               * min_pu_width]).pred_flag ==
                              PF_INTRA))
@@ -2676,11 +2675,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 while (j < size_max_x
                        &&
                        !((s->cur_frame->tab_mvf[(((x0 +
-                                             ((j) << hshift)) >> s->ps.sps->
+                                             ((j) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 + ((-1)
                                                                           <<
                                                                           vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2692,11 +2691,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                 ((s->cur_frame->tab_mvf[(((x0 +
                                                      ((i -
                                                        1) << hshift)) >>
-                                                    s->ps.sps->log2_min_pu_size))
+                                                    sps->log2_min_pu_size))
                                                   + (((y0 + ((-1)
                                                              << vshift))
                                                       >>
-                                                      s->ps.sps->log2_min_pu_size))
+                                                      sps->log2_min_pu_size))
                                                   *
                                                   min_pu_width]).pred_flag ==
                                  PF_INTRA))
@@ -2707,11 +2706,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                                 ((s->cur_frame->tab_mvf[(((x0 +
                                                      ((i -
                                                        1) << hshift)) >>
-                                                    s->ps.sps->log2_min_pu_size))
+                                                    sps->log2_min_pu_size))
                                                   + (((y0 + ((-1)
                                                              << vshift))
                                                       >>
-                                                      s->ps.sps->log2_min_pu_size))
+                                                      sps->log2_min_pu_size))
                                                   *
                                                   min_pu_width]).pred_flag ==
                                  PF_INTRA))
@@ -2726,11 +2725,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 for (i = 0; i < (0) + (size_max_y); i += 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2754,12 +2753,12 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      i > (size_max_y - 1) - (size_max_y); i -= 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i -
                                                                       3) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2768,11 +2767,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                         a = ((left[i - 3]) * 0x01010101U);
                 if (!
                     ((s->cur_frame->tab_mvf[(((x0 +
-                                         ((-1) << hshift)) >> s->ps.sps->
+                                         ((-1) << hshift)) >> sps->
                                         log2_min_pu_size)) + (((y0 + ((-1)
                                                                       <<
                                                                       vshift))
-                                                               >> s->ps.sps->
+                                                               >> sps->
                                                                log2_min_pu_size))
                                       * min_pu_width]).pred_flag == PF_INTRA))
                     left[-1] = left[0];
@@ -2788,12 +2787,12 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      i > (size_max_y - 1) - (size_max_y); i -= 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((-1) << hshift)) >> s->ps.sps->
+                                             ((-1) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 +
                                                                     ((i -
                                                                       3) <<
                                                                      vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2807,11 +2806,11 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                 for (i = 0; i < (0) + (size_max_x); i += 4)
                     if (!
                         ((s->cur_frame->tab_mvf[(((x0 +
-                                             ((i) << hshift)) >> s->ps.sps->
+                                             ((i) << hshift)) >> sps->
                                             log2_min_pu_size)) + (((y0 + ((-1)
                                                                           <<
                                                                           vshift))
-                                                                   >> s->ps.sps->
+                                                                   >> sps->
                                                                    log2_min_pu_size))
                                           * min_pu_width]).pred_flag ==
                          PF_INTRA))
@@ -2886,8 +2885,8 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
     top[-1] = left[-1];
 
 
-    if (!s->ps.sps->intra_smoothing_disabled
-        && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
+    if (!sps->intra_smoothing_disabled
+        && (c_idx == 0 || sps->chroma_format_idc == 3)) {
         if (mode != INTRA_DC && 32 != 4) {
             int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
             int min_dist_vert_hor =
@@ -2901,7 +2900,7 @@ void ff_intra_pred_8_32x32_msa(HEVCLocalContext *lc, int x0, int y0, int c_idx)
                      0 ? ((int) (mode - 26U)) : (-((int) (mode - 26U))))));
             if (min_dist_vert_hor > intra_hor_ver_dist_thresh[5 - 3]) {
                 int threshold = 1 << (8 - 5);
-                if (s->ps.sps->strong_intra_smoothing_enabled
+                if (sps->strong_intra_smoothing_enabled
                     && c_idx == 0
                     && ((top[-1] + top[63] - 2 * top[31]) >=
                         0 ? (top[-1] + top[63] -
-- 
2.43.0



More information about the ffmpeg-devel mailing list