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

Michael Niedermayer michael at niedermayer.cc
Fri Aug 17 03:23:36 EEST 2018


On Thu, Aug 16, 2018 at 11:29:09AM +0800, Zhao Zhili wrote:
> ---
>  libavcodec/hevc_ps.c | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index fbd9fbf..4161ab6 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -628,8 +628,17 @@ 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);
> +        unsigned horiz_mult, vert_mult;
> +        if (sps->chroma_format_idc == 1) {
> +            horiz_mult = 2;
> +            vert_mult = 2;
> +        } else if (sps->chroma_format_idc == 2) {
> +            horiz_mult = 2;
> +            vert_mult = 1;
> +        } else {
> +            horiz_mult = 1;
> +            vert_mult = 1;
> +        }
>          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 +932,17 @@ 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);
> +        unsigned horiz_mult, vert_mult;
> +        if (sps->chroma_format_idc == 1) {
> +            horiz_mult = 2;
> +            vert_mult = 2;
> +        } else if (sps->chroma_format_idc == 2) {
> +            horiz_mult = 2;
> +            vert_mult = 1;
> +        } else {
> +            horiz_mult = 1;
> +            vert_mult = 1;
> +        }

this should either stay simple code or it should be factored out.
duplicating this is not ideal.


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180817/16b380b7/attachment.sig>


More information about the ffmpeg-devel mailing list