[FFmpeg-devel] [PATCH 2/9] hevc: reduce allocation for skip_flag

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


Save only 2 CTB lines worth of data (i.e. at worst 16 lines).
---
 libavcodec/hevc.c | 4 ++--
 libavcodec/hevc.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index f8a495f..bed2f5f 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -99,7 +99,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
     if (!s->sao || !s->deblock || !s->split_cu_flag)
         goto fail;
 
-    s->skip_flag    = av_malloc(pic_size_in_ctb);
+    s->skip_flag    = av_malloc(16*s->sps->min_cb_width);
     s->tab_ct_depth = av_malloc_array(sps->min_cb_height, sps->min_cb_width);
     if (!s->skip_flag || !s->tab_ct_depth)
         goto fail;
@@ -1782,7 +1782,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
     if (s->sh.slice_type != I_SLICE) {
         uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb);
 
-        x = y_cb * min_cb_width + x_cb;
+        x = (y_cb&15) * min_cb_width + x_cb;
         for (y = 0; y < length; y++) {
             memset(&s->skip_flag[x], skip_flag, length);
             x += min_cb_width;
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 44d6a6c..8fd8655 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -81,7 +81,7 @@
  * Value of the luma sample at position (x, y) in the 2D array tab.
  */
 #define SAMPLE(tab, x, y) ((tab)[(((y)>>log2_min_cb_size)&15) * min_cb_width + ((x)>>log2_min_cb_size)])
-#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
+#define SAMPLE_CTB(tab, x, y) ((tab)[((y)&15) * min_cb_width + (x)])
 #define SAMPLE_CBF(tab, x, y) ((tab)[((y) & ((1<<log2_trafo_size)-1)) * MAX_CU_SIZE + ((x) & ((1<<log2_trafo_size)-1))])
 
 #define IS_IDR(s) ((s)->nal_unit_type == NAL_IDR_W_RADL || (s)->nal_unit_type == NAL_IDR_N_LP)
-- 
1.9.2.msysgit.0



More information about the ffmpeg-devel mailing list