diff mbox

[FFmpeg-devel] lavc/hevc_ps: fix crop info for monochrome

Message ID 20180820020157.4388-1-quinkblack@foxmail.com
State Superseded
Headers show

Commit Message

Zhao Zhili Aug. 20, 2018, 2:01 a.m. UTC
The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The
current code use the value of 2.
---
 libavcodec/hevc_ps.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Ronald S. Bultje Aug. 20, 2018, 3:17 a.m. UTC | #1
Hi,

On Sun, Aug 19, 2018 at 10:01 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:

> @@ -628,8 +636,8 @@ static void decode_vui(GetBitContext *gb,
> AVCodecContext *avctx,
>          vui->default_display_window_flag = get_bits1(gb);
>
>      if (vui->default_display_window_flag) {
> -        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
> -        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
> +        uint8_t vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
> +        uint8_t horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
>          vui->def_disp_win.left_offset   = get_ue_golomb_long(gb) *
> horiz_mult;
>          vui->def_disp_win.right_offset  = get_ue_golomb_long(gb) *
> horiz_mult;
>          vui->def_disp_win.top_offset    = get_ue_golomb_long(gb) *
> vert_mult;
> @@ -923,8 +931,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb,
> unsigned int *sps_id,
>          return ret;
>
>      if (get_bits1(gb)) { // pic_conformance_flag
> -        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
> -        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
> +        uint8_t vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
> +        uint8_t horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
>          sps->pic_conf_win.left_offset   = get_ue_golomb_long(gb) *
> horiz_mult;
>          sps->pic_conf_win.right_offset  = get_ue_golomb_long(gb) *
> horiz_mult;
>          sps->pic_conf_win.top_offset    = get_ue_golomb_long(gb) *
> vert_mult;
>

Arrays should be uint8_t, scalars should be regular ints.

Ronald
diff mbox

Patch

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index fbd9fbf..ae1d4ad 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -70,6 +70,14 @@  static const AVRational vui_sar[] = {
     {  2,   1 },
 };
 
+static const uint8_t hevc_sub_width_c[] = {
+    1, 2, 2, 1
+};
+
+static const uint8_t hevc_sub_height_c[] = {
+    1, 2, 1, 1
+};
+
 static void remove_pps(HEVCParamSets *s, int id)
 {
     if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data)
@@ -628,8 +636,8 @@  static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
         vui->default_display_window_flag = get_bits1(gb);
 
     if (vui->default_display_window_flag) {
-        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
-        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
+        uint8_t vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
+        uint8_t horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
         vui->def_disp_win.left_offset   = get_ue_golomb_long(gb) * horiz_mult;
         vui->def_disp_win.right_offset  = get_ue_golomb_long(gb) * horiz_mult;
         vui->def_disp_win.top_offset    = get_ue_golomb_long(gb) *  vert_mult;
@@ -923,8 +931,8 @@  int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
         return ret;
 
     if (get_bits1(gb)) { // pic_conformance_flag
-        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
-        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
+        uint8_t vert_mult  = hevc_sub_height_c[sps->chroma_format_idc];
+        uint8_t horiz_mult = hevc_sub_width_c[sps->chroma_format_idc];
         sps->pic_conf_win.left_offset   = get_ue_golomb_long(gb) * horiz_mult;
         sps->pic_conf_win.right_offset  = get_ue_golomb_long(gb) * horiz_mult;
         sps->pic_conf_win.top_offset    = get_ue_golomb_long(gb) *  vert_mult;