]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/hevc_filter.c
avcodec/iff: Factorize av_pix_fmt_desc_get() out
[ffmpeg] / libavcodec / hevc_filter.c
index 9f59170be7abe8caf7e661dcefc075f42d48fead..3aaf3e55f22e0a56292b861365cee9eb42f34434 100644 (file)
@@ -337,8 +337,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
 {
     uint8_t *src;
     int x, y;
-    int chroma;
-    int c_tc[2], tc[2], beta;
+    int chroma, beta;
+    int32_t c_tc[2], tc[2];
     uint8_t no_p[2] = { 0 };
     uint8_t no_q[2] = { 0 };
 
@@ -580,21 +580,27 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
     int min_tu_width     = s->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;
     int i, j, bs;
 
-    if (y0 > 0 && (y0 & 7) == 0) {
-        int bd_ctby = y0 & ((1 << s->sps->log2_ctb_size) - 1);
-        int bd_slice = s->sh.slice_loop_filter_across_slices_enabled_flag ||
-                       !(lc->boundary_flags & BOUNDARY_UPPER_SLICE);
-        int bd_tiles = s->pps->loop_filter_across_tiles_enabled_flag ||
-                       !(lc->boundary_flags & BOUNDARY_UPPER_TILE);
-        if (((bd_slice && bd_tiles)  || bd_ctby)) {
-            int yp_pu = (y0 - 1) >> log2_min_pu_size;
-            int yq_pu =  y0      >> log2_min_pu_size;
-            int yp_tu = (y0 - 1) >> log2_min_tu_size;
-            int yq_tu =  y0      >> log2_min_tu_size;
-            RefPicList *top_refPicList = ff_hevc_get_ref_list(s, s->ref,
-                                                              x0, y0 - 1);
+    boundary_upper = y0 > 0 && !(y0 & 7);
+    if (boundary_upper &&
+        ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
+          lc->boundary_flags & BOUNDARY_UPPER_SLICE &&
+          (y0 % (1 << s->sps->log2_ctb_size)) == 0) ||
+         (!s->pps->loop_filter_across_tiles_enabled_flag &&
+          lc->boundary_flags & BOUNDARY_UPPER_TILE &&
+          (y0 % (1 << s->sps->log2_ctb_size)) == 0)))
+        boundary_upper = 0;
+
+    if (boundary_upper) {
+        RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
+                              ff_hevc_get_ref_list(s, s->ref, x0, y0 - 1) :
+                              s->ref->refPicList;
+        int yp_pu = (y0 - 1) >> log2_min_pu_size;
+        int yq_pu =  y0      >> log2_min_pu_size;
+        int yp_tu = (y0 - 1) >> log2_min_tu_size;
+        int yq_tu =  y0      >> log2_min_tu_size;
 
             for (i = 0; i < (1 << log2_trafo_size); i += 4) {
                 int x_pu = (x0 + i) >> log2_min_pu_size;
@@ -609,26 +615,30 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
                 else if (curr_cbf_luma || top_cbf_luma)
                     bs = 1;
                 else
-                    bs = boundary_strength(s, curr, top, top_refPicList);
+                    bs = boundary_strength(s, curr, top, rpl_top);
                 s->horizontal_bs[((x0 + i) + y0 * s->bs_width) >> 2] = bs;
             }
-        }
     }
 
     // bs for vertical TU boundaries
-    if (x0 > 0 && (x0 & 7) == 0) {
-        int bd_ctbx = x0 & ((1 << s->sps->log2_ctb_size) - 1);
-        int bd_slice = s->sh.slice_loop_filter_across_slices_enabled_flag ||
-                       !(lc->boundary_flags & BOUNDARY_LEFT_SLICE);
-        int bd_tiles = s->pps->loop_filter_across_tiles_enabled_flag ||
-                       !(lc->boundary_flags & BOUNDARY_LEFT_TILE);
-        if (((bd_slice && bd_tiles)  || bd_ctbx)) {
-            int xp_pu = (x0 - 1) >> log2_min_pu_size;
-            int xq_pu =  x0      >> log2_min_pu_size;
-            int xp_tu = (x0 - 1) >> log2_min_tu_size;
-            int xq_tu =  x0      >> log2_min_tu_size;
-            RefPicList *left_refPicList = ff_hevc_get_ref_list(s, s->ref,
-                                                               x0 - 1, y0);
+    boundary_left = x0 > 0 && !(x0 & 7);
+    if (boundary_left &&
+        ((!s->sh.slice_loop_filter_across_slices_enabled_flag &&
+          lc->boundary_flags & BOUNDARY_LEFT_SLICE &&
+          (x0 % (1 << s->sps->log2_ctb_size)) == 0) ||
+         (!s->pps->loop_filter_across_tiles_enabled_flag &&
+          lc->boundary_flags & BOUNDARY_LEFT_TILE &&
+          (x0 % (1 << s->sps->log2_ctb_size)) == 0)))
+        boundary_left = 0;
+
+    if (boundary_left) {
+        RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
+                               ff_hevc_get_ref_list(s, s->ref, x0 - 1, y0) :
+                               s->ref->refPicList;
+        int xp_pu = (x0 - 1) >> log2_min_pu_size;
+        int xq_pu =  x0      >> log2_min_pu_size;
+        int xp_tu = (x0 - 1) >> log2_min_tu_size;
+        int xq_tu =  x0      >> log2_min_tu_size;
 
             for (i = 0; i < (1 << log2_trafo_size); i += 4) {
                 int y_pu      = (y0 + i) >> log2_min_pu_size;
@@ -643,16 +653,14 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
                 else if (curr_cbf_luma || left_cbf_luma)
                     bs = 1;
                 else
-                    bs = boundary_strength(s, curr, left, left_refPicList);
+                    bs = boundary_strength(s, curr, left, rpl_left);
                 s->vertical_bs[(x0 + (y0 + i) * s->bs_width) >> 2] = bs;
             }
-        }
     }
 
     if (log2_trafo_size > log2_min_pu_size && !is_intra) {
-        RefPicList *refPicList = ff_hevc_get_ref_list(s, s->ref,
-                                                           x0,
-                                                           y0);
+        RefPicList *rpl = s->ref->refPicList;
+
         // bs for TU internal horizontal PU boundaries
         for (j = 8; j < (1 << log2_trafo_size); j += 8) {
             int yp_pu = (y0 + j - 1) >> log2_min_pu_size;
@@ -663,7 +671,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
                 MvField *top  = &tab_mvf[yp_pu * min_pu_width + x_pu];
                 MvField *curr = &tab_mvf[yq_pu * min_pu_width + x_pu];
 
-                bs = boundary_strength(s, curr, top, refPicList);
+                bs = boundary_strength(s, curr, top, rpl);
                 s->horizontal_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
             }
         }
@@ -678,7 +686,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0,
                 MvField *left = &tab_mvf[y_pu * min_pu_width + xp_pu];
                 MvField *curr = &tab_mvf[y_pu * min_pu_width + xq_pu];
 
-                bs = boundary_strength(s, curr, left, refPicList);
+                bs = boundary_strength(s, curr, left, rpl);
                 s->vertical_bs[((x0 + i) + (y0 + j) * s->bs_width) >> 2] = bs;
             }
         }