[FFmpeg-devel] [PATCH 3/9] hevc: reduce allocation for tab_ipm

Christophe Gisquet christophe.gisquet at gmail.com
Thu Jul 10 08:47:50 CEST 2014


Minimal size for PUs is 4x4, so 2 CTB lines represent at most 32 lines.
is_pcm is used for simplicity in the inloop filter, so it can't be
modified equivalently.
---
 libavcodec/hevc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index bed2f5f..2b37f53 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -105,7 +105,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
         goto fail;
 
     s->cbf_luma = av_malloc_array(sps->min_tb_width, sps->min_tb_height);
-    s->tab_ipm  = av_mallocz(min_pu_size);
+    s->tab_ipm  = av_mallocz(32*sps->min_pu_width);
     s->is_pcm   = av_malloc(min_pu_size);
     if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
         goto fail;
@@ -1605,9 +1605,9 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
     int y0b              = y0 & ((1 << s->sps->log2_ctb_size) - 1);
 
     int cand_up   = (lc->ctb_up_flag || y0b) ?
-                    s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC;
+                    s->tab_ipm[((y_pu - 1)&31) * min_pu_width + x_pu] : INTRA_DC;
     int cand_left = (lc->ctb_left_flag || x0b) ?
-                    s->tab_ipm[y_pu * min_pu_width + x_pu - 1]   : INTRA_DC;
+                    s->tab_ipm[(y_pu&31) * min_pu_width + x_pu - 1]   : INTRA_DC;
 
     int y_ctb = (y0 >> (s->sps->log2_ctb_size)) << (s->sps->log2_ctb_size);
 
@@ -1662,7 +1662,7 @@ static int luma_intra_pred_mode(HEVCContext *s, int x0, int y0, int pu_size,
     if (!size_in_pus)
         size_in_pus = 1;
     for (i = 0; i < size_in_pus; i++) {
-        memset(&s->tab_ipm[(y_pu + i) * min_pu_width + x_pu],
+        memset(&s->tab_ipm[((y_pu + i)&31) * min_pu_width + x_pu],
                intra_pred_mode, size_in_pus);
 
         for (j = 0; j < size_in_pus; j++) {
@@ -1742,7 +1742,7 @@ static void intra_prediction_unit_default_value(HEVCContext *s,
     if (size_in_pus == 0)
         size_in_pus = 1;
     for (j = 0; j < size_in_pus; j++)
-        memset(&s->tab_ipm[(y_pu + j) * min_pu_width + x_pu], INTRA_DC, size_in_pus);
+        memset(&s->tab_ipm[((y_pu + j)&31) * min_pu_width + x_pu], INTRA_DC, size_in_pus);
     if (lc->cu.pred_mode == MODE_INTRA)
         for (j = 0; j < size_in_pus; j++)
             for (k = 0; k < size_in_pus; k++)
-- 
1.9.2.msysgit.0



More information about the ffmpeg-devel mailing list