Use -Werror in external/libhevc
am: 3dcae23965

Change-Id: I1a13a55d36f4dcda3a98885c87f16c8afb1da0c1
diff --git a/common/ihevc_structs.h b/common/ihevc_structs.h
index 0205582..52dda76 100644
--- a/common/ihevc_structs.h
+++ b/common/ihevc_structs.h
@@ -644,33 +644,33 @@
      * if 1, , for the highest temporal sub-layers, the temporal distance between the HRD output times
      * of consecutive pictures in output order is constrained refer to Table E-6
      */
-    UWORD8 au1_fixed_pic_rate_general_flag[6];
+    UWORD8 au1_fixed_pic_rate_general_flag[VPS_MAX_SUB_LAYERS];
 
-    UWORD8 au1_fixed_pic_rate_within_cvs_flag[6];
+    UWORD8 au1_fixed_pic_rate_within_cvs_flag[VPS_MAX_SUB_LAYERS];
 
     /**
      * if 1, , for the highest temporal sub-layers, the temporal distance (in clock ticks) between the
      * element units that specify HRD output times of consecutive pictures in output order is constrained
      * refer to Table E-6
      */
-    UWORD8 au1_elemental_duration_in_tc_minus1[6];
+    UWORD8 au1_elemental_duration_in_tc_minus1[VPS_MAX_SUB_LAYERS];
 
     /**
      * specifies the HRD operational mode
      */
-    UWORD8 au1_low_delay_hrd_flag[6];
+    UWORD8 au1_low_delay_hrd_flag[VPS_MAX_SUB_LAYERS];
 
     /**
      * 1 specifies the number of alternative CPB specifications in the
      * bitstream of the cvs when HighestTid is equal to i
      */
-    UWORD8 au1_cpb_cnt_minus1[6];
+    UWORD8 au1_cpb_cnt_minus1[VPS_MAX_SUB_LAYERS];
 
 
     /**
      * VUI level Sub-layer HRD parameters
      */
-    sub_lyr_hrd_params_t as_sub_layer_hrd_params[6];
+    sub_lyr_hrd_params_t as_sub_layer_hrd_params[VPS_MAX_SUB_LAYERS];
 
 }hrd_params_t;
 
diff --git a/decoder/ihevcd_decode.c b/decoder/ihevcd_decode.c
index 28455e0..dfb5042 100644
--- a/decoder/ihevcd_decode.c
+++ b/decoder/ihevcd_decode.c
@@ -668,7 +668,6 @@
 
         if(IHEVCD_IGNORE_SLICE == ret)
         {
-            ps_codec->s_parse.i4_cur_slice_idx = MAX(0, (ps_codec->s_parse.i4_cur_slice_idx - 1));
             ps_codec->pu1_inp_bitsbuf += (nal_ofst + nal_len);
             ps_codec->i4_bytes_remaining -= (nal_ofst + nal_len);
 
diff --git a/decoder/ihevcd_parse_headers.c b/decoder/ihevcd_parse_headers.c
index 28ab962..afa6de3 100644
--- a/decoder/ihevcd_parse_headers.c
+++ b/decoder/ihevcd_parse_headers.c
@@ -1886,6 +1886,19 @@
     BITS_PARSE("tiles_enabled_flag", value, ps_bitstrm, 1);
     ps_pps->i1_tiles_enabled_flag = value;
 
+    /* When tiles are enabled and width or height is >= 4096,
+     * CTB Size should at least be 32. 16x16 CTBs can result
+     * in tile position greater than 255 for 4096,
+     * which decoder does not support.
+     */
+    if((ps_pps->i1_tiles_enabled_flag) &&
+                    (ps_sps->i1_log2_ctb_size == 4) &&
+                    ((ps_sps->i2_pic_width_in_luma_samples >= 4096) ||
+                    (ps_sps->i2_pic_height_in_luma_samples >= 4096)))
+    {
+        return IHEVCD_INVALID_HEADER;
+    }
+
     BITS_PARSE("entropy_coding_sync_enabled_flag", value, ps_bitstrm, 1);
     ps_pps->i1_entropy_coding_sync_enabled_flag = value;
 
diff --git a/decoder/ihevcd_parse_slice.c b/decoder/ihevcd_parse_slice.c
index 126b14c..9f92a0d 100644
--- a/decoder/ihevcd_parse_slice.c
+++ b/decoder/ihevcd_parse_slice.c
@@ -2708,6 +2708,17 @@
         {
             tu_t *ps_tu = ps_codec->s_parse.ps_tu;
             pu_t *ps_pu = ps_codec->s_parse.ps_pu;
+            WORD32 pu_skip_wd, pu_skip_ht;
+            WORD32 rows_remaining, cols_remaining;
+
+            /* Set pu wd and ht based on whether the ctb is complete or not */
+            rows_remaining = ps_sps->i2_pic_height_in_luma_samples
+                            - (ps_codec->s_parse.i4_ctb_y << ps_sps->i1_log2_ctb_size);
+            pu_skip_ht = MIN(ctb_size, rows_remaining);
+
+            cols_remaining = ps_sps->i2_pic_width_in_luma_samples
+                            - (ps_codec->s_parse.i4_ctb_x << ps_sps->i1_log2_ctb_size);
+            pu_skip_wd = MIN(ctb_size, cols_remaining);
 
             ps_tu->b1_cb_cbf = 0;
             ps_tu->b1_cr_cbf = 0;
@@ -2731,8 +2742,8 @@
             ps_pu->b2_part_idx = 0;
             ps_pu->b4_pos_x = 0;
             ps_pu->b4_pos_y = 0;
-            ps_pu->b4_wd = (ctb_size >> 2) - 1;
-            ps_pu->b4_ht = (ctb_size >> 2) - 1;
+            ps_pu->b4_wd = (pu_skip_wd >> 2) - 1;
+            ps_pu->b4_ht = (pu_skip_ht >> 2) - 1;
             ps_pu->b1_intra_flag = 0;
             ps_pu->b3_part_mode = ps_codec->s_parse.s_cu.i4_part_mode;
             ps_pu->b1_merge_flag = 1;