Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
@ 2022-03-30  6:43 Wenbin Chen
  2022-03-30  6:43 ` [FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc Wenbin Chen
  2022-04-02  9:01 ` [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Xiang, Haihao
  0 siblings, 2 replies; 4+ messages in thread
From: Wenbin Chen @ 2022-03-30  6:43 UTC (permalink / raw)
  To: ffmpeg-devel

Qsv decoder only supports directly output nv12 and p010 to system
memory. For other format, we need to download frame from qsv format
to system memory. Now add other supported format to qsvdec.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsv.c          | 36 ++++++++++++++++++++++++++++++++++++
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c       | 23 +++++++++++++++++------
 3 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 67d0e3934a..8010eef172 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc)
     }
 }
 
+int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface)
+{
+    switch (frame->format) {
+    case AV_PIX_FMT_NV12:
+    case AV_PIX_FMT_P010:
+        surface->Data.Y  = frame->data[0];
+        surface->Data.UV = frame->data[1];
+        /* The SDK checks Data.V when using system memory for VP9 encoding */
+        surface->Data.V  = surface->Data.UV + 1;
+        break;
+    case AV_PIX_FMT_X2RGB10LE:
+    case AV_PIX_FMT_BGRA:
+        surface->Data.B = frame->data[0];
+        surface->Data.G = frame->data[0] + 1;
+        surface->Data.R = frame->data[0] + 2;
+        surface->Data.A = frame->data[0] + 3;
+        break;
+    case AV_PIX_FMT_YUYV422:
+        surface->Data.Y = frame->data[0];
+        surface->Data.U = frame->data[0] + 1;
+        surface->Data.V = frame->data[0] + 3;
+        break;
+
+    case AV_PIX_FMT_Y210:
+        surface->Data.Y16 = (mfxU16 *)frame->data[0];
+        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
+        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
+        break;
+    default:
+        return MFX_ERR_UNSUPPORTED;
+    }
+    surface->Data.PitchLow  = frame->linesize[0];
+
+    return 0;
+}
+
 int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
 {
     int i;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 58186ea7ca..e2aecdcbd6 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame);
 void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame *frame,
                                 mfxExtBuffer *param);
 
+int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface);
+
+
 #endif /* AVCODEC_QSV_INTERNAL_H */
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 661f15bc75..f159e2690f 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -132,21 +132,28 @@ static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame,
         frame->linesize[0] = FFALIGN(avctx->width, 128);
         break;
     case AV_PIX_FMT_P010:
+    case AV_PIX_FMT_YUYV422:
         frame->linesize[0] = 2 * FFALIGN(avctx->width, 128);
         break;
+    case AV_PIX_FMT_Y210:
+        frame->linesize[0] = 4 * FFALIGN(avctx->width, 128);
+        break;
     default:
         av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
         return AVERROR(EINVAL);
     }
 
-    frame->linesize[1] = frame->linesize[0];
     frame->buf[0]      = av_buffer_pool_get(pool);
     if (!frame->buf[0])
         return AVERROR(ENOMEM);
 
     frame->data[0] = frame->buf[0]->data;
-    frame->data[1] = frame->data[0] +
-                            frame->linesize[0] * FFALIGN(avctx->height, 64);
+    if (avctx->pix_fmt == AV_PIX_FMT_NV12 ||
+        avctx->pix_fmt == AV_PIX_FMT_P010) {
+        frame->linesize[1] = frame->linesize[0];
+        frame->data[1] = frame->data[0] +
+            frame->linesize[0] * FFALIGN(avctx->height, 64);
+    }
 
     ret = ff_attach_decode_data(frame);
     if (ret < 0)
@@ -426,9 +433,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
     if (frame->frame->format == AV_PIX_FMT_QSV) {
         frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
     } else {
-        frame->surface.Data.PitchLow = frame->frame->linesize[0];
-        frame->surface.Data.Y        = frame->frame->data[0];
-        frame->surface.Data.UV       = frame->frame->data[1];
+        ret = ff_qsv_map_frame_to_surface(frame->frame, &frame->surface);
+        if (ret < 0) {
+            av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
+            return AVERROR(EINVAL);
+        }
     }
 
     frame->surface.Info = q->frame_info;
@@ -993,6 +1002,8 @@ const FFCodec ff_##x##_qsv_decoder = { \
     .p.priv_class   = &x##_qsv_class, \
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
                                                     AV_PIX_FMT_P010, \
+                                                    AV_PIX_FMT_YUYV422, \
+                                                    AV_PIX_FMT_Y210, \
                                                     AV_PIX_FMT_QSV, \
                                                     AV_PIX_FMT_NONE }, \
     .hw_configs     = qsv_hw_configs, \
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc
  2022-03-30  6:43 [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Wenbin Chen
@ 2022-03-30  6:43 ` Wenbin Chen
  2022-04-02  9:01 ` [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Xiang, Haihao
  1 sibling, 0 replies; 4+ messages in thread
From: Wenbin Chen @ 2022-03-30  6:43 UTC (permalink / raw)
  To: ffmpeg-devel

Qsv encoder only support input P010 and nv12 format directly from system
memory. For other format, we need to upload frame to device memory and
input qsv format to encoder. Now add other system memory format support
to qsv encoder.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvenc.c      | 30 ++++--------------------------
 libavcodec/qsvenc_hevc.c |  2 ++
 2 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 55ce3d2499..eb94ab0650 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1606,32 +1606,10 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame,
         else if (frame->repeat_pict == 4)
             qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING;
 
-        qf->surface.Data.PitchLow  = qf->frame->linesize[0];
-        qf->surface.Data.Y         = qf->frame->data[0];
-        qf->surface.Data.UV        = qf->frame->data[1];
-
-        /* The SDK checks Data.V when using system memory for VP9 encoding */
-        switch (frame->format) {
-        case AV_PIX_FMT_NV12:
-            qf->surface.Data.V     = qf->surface.Data.UV + 1;
-            break;
-
-        case AV_PIX_FMT_P010:
-            qf->surface.Data.V     = qf->surface.Data.UV + 2;
-            break;
-
-        case AV_PIX_FMT_X2RGB10:
-        case AV_PIX_FMT_BGRA:
-            qf->surface.Data.B         = qf->frame->data[0];
-            qf->surface.Data.G         = qf->frame->data[0] + 1;
-            qf->surface.Data.R         = qf->frame->data[0] + 2;
-            qf->surface.Data.A         = qf->frame->data[0] + 3;
-            break;
-
-        default:
-            /* should not reach here */
-            av_assert0(0);
-            break;
+        ret = ff_qsv_map_frame_to_surface(qf->frame, &qf->surface);
+        if (ret < 0) {
+            av_log(q->avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
+            return AVERROR(EINVAL);
         }
     }
     qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 90000});
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 5c1571f62f..1814774655 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -303,6 +303,8 @@ const FFCodec ff_hevc_qsv_encoder = {
     .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
                                                     AV_PIX_FMT_P010,
+                                                    AV_PIX_FMT_YUYV422,
+                                                    AV_PIX_FMT_Y210,
                                                     AV_PIX_FMT_QSV,
 #if QSV_VERSION_ATLEAST(1, 17)
                                                     AV_PIX_FMT_BGRA,
-- 
2.32.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
  2022-03-30  6:43 [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Wenbin Chen
  2022-03-30  6:43 ` [FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc Wenbin Chen
@ 2022-04-02  9:01 ` Xiang, Haihao
  2022-04-02  9:26   ` Chen, Wenbin
  1 sibling, 1 reply; 4+ messages in thread
From: Xiang, Haihao @ 2022-04-02  9:01 UTC (permalink / raw)
  To: ffmpeg-devel

On Wed, 2022-03-30 at 14:43 +0800, Wenbin Chen wrote:
> Qsv decoder only supports directly output nv12 and p010 to system
> memory. For other format, we need to download frame from qsv format
> to system memory. Now add other supported format to qsvdec.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavcodec/qsv.c          | 36 ++++++++++++++++++++++++++++++++++++
>  libavcodec/qsv_internal.h |  3 +++
>  libavcodec/qsvdec.c       | 23 +++++++++++++++++------
>  3 files changed, 56 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 67d0e3934a..8010eef172 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t
> *fourcc)
>      }
>  }
>  
> +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1
> *surface)
> +{
> +    switch (frame->format) {
> +    case AV_PIX_FMT_NV12:
> +    case AV_PIX_FMT_P010:
> +        surface->Data.Y  = frame->data[0];
> +        surface->Data.UV = frame->data[1];
> +        /* The SDK checks Data.V when using system memory for VP9 encoding */
> +        surface->Data.V  = surface->Data.UV + 1;
> +        break;
> +    case AV_PIX_FMT_X2RGB10LE:
> +    case AV_PIX_FMT_BGRA:
> +        surface->Data.B = frame->data[0];
> +        surface->Data.G = frame->data[0] + 1;
> +        surface->Data.R = frame->data[0] + 2;
> +        surface->Data.A = frame->data[0] + 3;
> +        break;
> +    case AV_PIX_FMT_YUYV422:
> +        surface->Data.Y = frame->data[0];
> +        surface->Data.U = frame->data[0] + 1;
> +        surface->Data.V = frame->data[0] + 3;
> +        break;
> +
> +    case AV_PIX_FMT_Y210:
> +        surface->Data.Y16 = (mfxU16 *)frame->data[0];
> +        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
> +        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> +        break;
> +    default:
> +        return MFX_ERR_UNSUPPORTED;

Please change the return type to mfxStatus if you want to return a mfx error
code, otherwise return a ffmpeg error here. 

Thanks
Haihao


> +    }
> +    surface->Data.PitchLow  = frame->linesize[0];
> +
> +    return 0;
> +}
> +
>  int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
>  {
>      int i;
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index 58186ea7ca..e2aecdcbd6 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx,
> QSVFrame *frame);
>  void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame *frame,
>                                  mfxExtBuffer *param);
>  
> +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1
> *surface);
> +
> +
>  #endif /* AVCODEC_QSV_INTERNAL_H */
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 661f15bc75..f159e2690f 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -132,21 +132,28 @@ static int qsv_get_continuous_buffer(AVCodecContext
> *avctx, AVFrame *frame,
>          frame->linesize[0] = FFALIGN(avctx->width, 128);
>          break;
>      case AV_PIX_FMT_P010:
> +    case AV_PIX_FMT_YUYV422:
>          frame->linesize[0] = 2 * FFALIGN(avctx->width, 128);
>          break;
> +    case AV_PIX_FMT_Y210:
> +        frame->linesize[0] = 4 * FFALIGN(avctx->width, 128);
> +        break;
>      default:
>          av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
>          return AVERROR(EINVAL);
>      }
>  
> -    frame->linesize[1] = frame->linesize[0];
>      frame->buf[0]      = av_buffer_pool_get(pool);
>      if (!frame->buf[0])
>          return AVERROR(ENOMEM);
>  
>      frame->data[0] = frame->buf[0]->data;
> -    frame->data[1] = frame->data[0] +
> -                            frame->linesize[0] * FFALIGN(avctx->height, 64);
> +    if (avctx->pix_fmt == AV_PIX_FMT_NV12 ||
> +        avctx->pix_fmt == AV_PIX_FMT_P010) {
> +        frame->linesize[1] = frame->linesize[0];
> +        frame->data[1] = frame->data[0] +
> +            frame->linesize[0] * FFALIGN(avctx->height, 64);
> +    }
>  
>      ret = ff_attach_decode_data(frame);
>      if (ret < 0)
> @@ -426,9 +433,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext
> *q, QSVFrame *frame)
>      if (frame->frame->format == AV_PIX_FMT_QSV) {
>          frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
>      } else {
> -        frame->surface.Data.PitchLow = frame->frame->linesize[0];
> -        frame->surface.Data.Y        = frame->frame->data[0];
> -        frame->surface.Data.UV       = frame->frame->data[1];
> +        ret = ff_qsv_map_frame_to_surface(frame->frame, &frame->surface);
> +        if (ret < 0) {
> +            av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
> +            return AVERROR(EINVAL);
> +        }
>      }
>  
>      frame->surface.Info = q->frame_info;
> @@ -993,6 +1002,8 @@ const FFCodec ff_##x##_qsv_decoder = { \
>      .p.priv_class   = &x##_qsv_class, \
>      .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
>                                                      AV_PIX_FMT_P010, \
> +                                                    AV_PIX_FMT_YUYV422, \
> +                                                    AV_PIX_FMT_Y210, \
>                                                      AV_PIX_FMT_QSV, \
>                                                      AV_PIX_FMT_NONE }, \
>      .hw_configs     = qsv_hw_configs, \
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
  2022-04-02  9:01 ` [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Xiang, Haihao
@ 2022-04-02  9:26   ` Chen, Wenbin
  0 siblings, 0 replies; 4+ messages in thread
From: Chen, Wenbin @ 2022-04-02  9:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

> On Wed, 2022-03-30 at 14:43 +0800, Wenbin Chen wrote:
> > Qsv decoder only supports directly output nv12 and p010 to system
> > memory. For other format, we need to download frame from qsv format
> > to system memory. Now add other supported format to qsvdec.
> >
> > Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> > ---
> >  libavcodec/qsv.c          | 36 ++++++++++++++++++++++++++++++++++++
> >  libavcodec/qsv_internal.h |  3 +++
> >  libavcodec/qsvdec.c       | 23 +++++++++++++++++------
> >  3 files changed, 56 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > index 67d0e3934a..8010eef172 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat
> format, uint32_t
> > *fourcc)
> >      }
> >  }
> >
> > +int ff_qsv_map_frame_to_surface(const AVFrame *frame,
> mfxFrameSurface1
> > *surface)
> > +{
> > +    switch (frame->format) {
> > +    case AV_PIX_FMT_NV12:
> > +    case AV_PIX_FMT_P010:
> > +        surface->Data.Y  = frame->data[0];
> > +        surface->Data.UV = frame->data[1];
> > +        /* The SDK checks Data.V when using system memory for VP9
> encoding */
> > +        surface->Data.V  = surface->Data.UV + 1;
> > +        break;
> > +    case AV_PIX_FMT_X2RGB10LE:
> > +    case AV_PIX_FMT_BGRA:
> > +        surface->Data.B = frame->data[0];
> > +        surface->Data.G = frame->data[0] + 1;
> > +        surface->Data.R = frame->data[0] + 2;
> > +        surface->Data.A = frame->data[0] + 3;
> > +        break;
> > +    case AV_PIX_FMT_YUYV422:
> > +        surface->Data.Y = frame->data[0];
> > +        surface->Data.U = frame->data[0] + 1;
> > +        surface->Data.V = frame->data[0] + 3;
> > +        break;
> > +
> > +    case AV_PIX_FMT_Y210:
> > +        surface->Data.Y16 = (mfxU16 *)frame->data[0];
> > +        surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
> > +        surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
> > +        break;
> > +    default:
> > +        return MFX_ERR_UNSUPPORTED;
> 
> Please change the return type to mfxStatus if you want to return a mfx error
> code, otherwise return a ffmpeg error here.
> 
> Thanks
> Haihao
> 

Thanks for review. I will update it.

> 
> > +    }
> > +    surface->Data.PitchLow  = frame->linesize[0];
> > +
> > +    return 0;
> > +}
> > +
> >  int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
> >  {
> >      int i;
> > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> > index 58186ea7ca..e2aecdcbd6 100644
> > --- a/libavcodec/qsv_internal.h
> > +++ b/libavcodec/qsv_internal.h
> > @@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext
> *ctx,
> > QSVFrame *frame);
> >  void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame
> *frame,
> >                                  mfxExtBuffer *param);
> >
> > +int ff_qsv_map_frame_to_surface(const AVFrame *frame,
> mfxFrameSurface1
> > *surface);
> > +
> > +
> >  #endif /* AVCODEC_QSV_INTERNAL_H */
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index 661f15bc75..f159e2690f 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -132,21 +132,28 @@ static int
> qsv_get_continuous_buffer(AVCodecContext
> > *avctx, AVFrame *frame,
> >          frame->linesize[0] = FFALIGN(avctx->width, 128);
> >          break;
> >      case AV_PIX_FMT_P010:
> > +    case AV_PIX_FMT_YUYV422:
> >          frame->linesize[0] = 2 * FFALIGN(avctx->width, 128);
> >          break;
> > +    case AV_PIX_FMT_Y210:
> > +        frame->linesize[0] = 4 * FFALIGN(avctx->width, 128);
> > +        break;
> >      default:
> >          av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
> >          return AVERROR(EINVAL);
> >      }
> >
> > -    frame->linesize[1] = frame->linesize[0];
> >      frame->buf[0]      = av_buffer_pool_get(pool);
> >      if (!frame->buf[0])
> >          return AVERROR(ENOMEM);
> >
> >      frame->data[0] = frame->buf[0]->data;
> > -    frame->data[1] = frame->data[0] +
> > -                            frame->linesize[0] * FFALIGN(avctx->height, 64);
> > +    if (avctx->pix_fmt == AV_PIX_FMT_NV12 ||
> > +        avctx->pix_fmt == AV_PIX_FMT_P010) {
> > +        frame->linesize[1] = frame->linesize[0];
> > +        frame->data[1] = frame->data[0] +
> > +            frame->linesize[0] * FFALIGN(avctx->height, 64);
> > +    }
> >
> >      ret = ff_attach_decode_data(frame);
> >      if (ret < 0)
> > @@ -426,9 +433,11 @@ static int alloc_frame(AVCodecContext *avctx,
> QSVContext
> > *q, QSVFrame *frame)
> >      if (frame->frame->format == AV_PIX_FMT_QSV) {
> >          frame->surface = *(mfxFrameSurface1*)frame->frame->data[3];
> >      } else {
> > -        frame->surface.Data.PitchLow = frame->frame->linesize[0];
> > -        frame->surface.Data.Y        = frame->frame->data[0];
> > -        frame->surface.Data.UV       = frame->frame->data[1];
> > +        ret = ff_qsv_map_frame_to_surface(frame->frame, &frame-
> >surface);
> > +        if (ret < 0) {
> > +            av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n");
> > +            return AVERROR(EINVAL);
> > +        }
> >      }
> >
> >      frame->surface.Info = q->frame_info;
> > @@ -993,6 +1002,8 @@ const FFCodec ff_##x##_qsv_decoder = { \
> >      .p.priv_class   = &x##_qsv_class, \
> >      .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> >                                                      AV_PIX_FMT_P010, \
> > +                                                    AV_PIX_FMT_YUYV422, \
> > +                                                    AV_PIX_FMT_Y210, \
> >                                                      AV_PIX_FMT_QSV, \
> >                                                      AV_PIX_FMT_NONE }, \
> >      .hw_configs     = qsv_hw_configs, \
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-02  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30  6:43 [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Wenbin Chen
2022-03-30  6:43 ` [FFmpeg-devel] [PATCH 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc Wenbin Chen
2022-04-02  9:01 ` [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec Xiang, Haihao
2022-04-02  9:26   ` Chen, Wenbin

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git