[libav-devel] [PATCH] qsv: better to use alignment by 16 and HEVC 10b requires alignment by 32

Li, Zhong zhong.li at intel.com
Tue Jan 9 03:14:10 CET 2018


LGTM

> -----Original Message-----
> From: libav-devel [mailto:libav-devel-bounces at libav.org] On Behalf Of
> Maxym Dmytrychenko
> Sent: Tuesday, January 9, 2018 4:35 AM
> To: libav-devel at libav.org
> Subject: [libav-devel] [PATCH] qsv: better to use alignment by 16 and HEVC
> 10b requires alignment by 32
> 
> ---
>  libavcodec/qsvdec.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> c74ec6836..9741f3310 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -475,6 +475,7 @@ int ff_qsv_process_data(AVCodecContext *avctx,
> QSVContext *q,
>      uint8_t *dummy_data;
>      int dummy_size;
>      int ret;
> +    const AVPixFmtDescriptor *desc;
> 
>      if (!q->avctx_internal) {
>          q->avctx_internal = avcodec_alloc_context3(NULL); @@ -511,8
> +512,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext
> *q,
> 
>      /* TODO: flush delayed frames on reinit */
>      if (q->parser->format       != q->orig_pix_fmt    ||
> -        q->parser->coded_width  != avctx->coded_width ||
> -        q->parser->coded_height != avctx->coded_height) {
> +        FFALIGN(q->parser->coded_width, 16)  !=
> FFALIGN(avctx->coded_width, 16) ||
> +        FFALIGN(q->parser->coded_height, 16) !=
> + FFALIGN(avctx->coded_height, 16)) {
>          enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV,
>                                             AV_PIX_FMT_NONE,
>                                             AV_PIX_FMT_NONE };
> @@ -531,8 +532,8 @@ int ff_qsv_process_data(AVCodecContext *avctx,
> QSVContext *q,
>          avctx->pix_fmt      = pix_fmts[1] = qsv_format;
>          avctx->width        = q->parser->width;
>          avctx->height       = q->parser->height;
> -        avctx->coded_width  = q->parser->coded_width;
> -        avctx->coded_height = q->parser->coded_height;
> +        avctx->coded_width  = FFALIGN(q->parser->coded_width, 16);
> +        avctx->coded_height = FFALIGN(q->parser->coded_height, 16);
>          avctx->field_order  = q->parser->field_order;
>          avctx->level        = q->avctx_internal->level;
>          avctx->profile      = q->avctx_internal->profile;
> @@ -543,6 +544,15 @@ int ff_qsv_process_data(AVCodecContext *avctx,
> QSVContext *q,
> 
>          avctx->pix_fmt = ret;
> 
> +        desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> +        if (!desc)
> +            goto reinit_fail;
> +
> +         if (desc->comp[0].depth > 8) {
> +            avctx->coded_width =  FFALIGN(q->parser->coded_width,
> 32);
> +            avctx->coded_height = FFALIGN(q->parser->coded_height,
> 32);
> +        }
> +
>          ret = qsv_decode_init(avctx, q);
>          if (ret < 0)
>              goto reinit_fail;
> --
> 2.14.3 (Apple Git-98)
> 
> _______________________________________________
> libav-devel mailing list
> libav-devel at libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel


More information about the libav-devel mailing list