Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-04-02 Thread Maxym Dmytrychenko
thanks for the feedbacks , below some answers and v2 is upcoming.

On Thu, Mar 29, 2018 at 1:03 AM, Mark Thompson  wrote:

> On 27/03/18 23:07, Maxym Dmytrychenko wrote:
> > On Tue, Mar 27, 2018 at 12:47 AM, Mark Thompson  wrote:
> >
> >> On 26/03/18 21:18, Maxym Dmytrychenko wrote:
> >>> Starting from API 1.25 helps to improve performance of the simultaneous
> >> encode,
> >>> 1:N scenario, like:
> >>>
> >>> ./avconv  -y -hwaccel qsv -c:v h264_qsv -r 3/1001 -i
> >>> ~/bbb_sunflower_1080p_60fps_normal.mp4  -vframes 600 -an \
> >>> -filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
> >>> [s2]scale_qsv=960:540[o2]" \
> >>> -map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
> >>> rawvideo /tmp/3200a.264 \
> >>> -map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
> >>> rawvideo /tmp/1750a.264
> >>
> >> Having seen this interface being added form the VAAPI side, I got the
> >> impression that this only makes sense if the parallel streams are
> actually
> >> in lock-step (as in your example).  What will happen if this isn't the
> case?
> >>
> > thanks for the points, Mark.
> > it is actually testing phase but can you share more details over
> example(s)
> > you mean?
>
> Well, your example has two streams which encode exactly in parallel - in
> every step both streams encode one frame.
>
> I don't know what the implementation inside libmfx is, but suppose the
> streams don't run at the same rate, e.g. if one stream is twice as fast as
> the other as in (with libx264):
>
> ./avconv -y -i in.mp4 -an -filter_complex 'split=2[a][b]' -map '[a]' -r 10
> -c:v libx264 out_10.mp4 -map '[b]' -r 20 -c:v libx264 out_20.mp4
>
> Does everything still work as expected?
>
> As a worse case, suppose you have multiple input streams with unknown
> properties (including framerate) which want to be encoded with low-latency,
> does setting this option affect that latency because some streams wait for
> new frames to appear on others?
>
>
this option in WIP now but expectations - latency should not be affected



> (These questions are primarily trying to assess whether this should be
> enabled by default.)
>
> >> I'm also curious what the gain from this is, if you happen to have some
> >> numbers...
> >>
> > Actually depends on exact HW SKU and resolution/scenario, however, can be
> > well above 10%
> >
> >
> >>> ---
> >>>  libavcodec/qsv.c | 10 ++
> >>>  libavcodec/qsv_internal.h|  3 +++
> >>>  libavcodec/qsvdec.c  |  1 -
> >>>  libavcodec/qsvenc.c  | 16 +++-
> >>>  libavcodec/qsvenc.h  | 12 ++--
> >>>  libavcodec/qsvenc_h264.c |  4 
> >>>  libavfilter/qsvvpp.c |  9 ++---
> >>>  libavfilter/qsvvpp.h |  7 +++
> >>>  libavfilter/vf_deinterlace_qsv.c |  6 ++
> >>>  libavfilter/vf_scale_qsv.c   |  6 ++
> >>>  libavutil/hwcontext_qsv.c|  5 +
> >>>  libavutil/hwcontext_qsv.h|  3 +++
> >>>  12 files changed, 71 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> >>> index e78633d62..bab32836e 100644
> >>> --- a/libavcodec/qsv.c
> >>> +++ b/libavcodec/qsv.c
> >>> @@ -593,10 +593,12 @@ int ff_qsv_init_session_device(AVCodecContext
> >> *avctx, mfxSession *psession,
> >>>"Error setting a HW handle");
> >>>  }
> >>>
> >>> -err = MFXJoinSession(parent_session, session);
> >>> -if (err != MFX_ERR_NONE)
> >>> -return ff_qsv_print_error(avctx, err,
> >>> -  "Error joining session");
> >>> +if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
> >>> +err = MFXJoinSession(parent_session, session);
> >>> +if (err != MFX_ERR_NONE)
> >>> +return ff_qsv_print_error(avctx, err,
> >>> +  "Error joining session");
> >>> +}
> >>>
> >>>  ret = qsv_load_plugins(session, load_plugins, avctx);
> >>>  if (ret < 0) {
> >>> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> >>> index 975c8de44..516994a64 100644
> >>> --- a/libavcodec/qsv_internal.h
> >>> +++ b/libavcodec/qsv_internal.h
> >>> @@ -36,6 +36,9 @@
> >>>  (MFX_VERSION_MAJOR > (MAJOR) || \
> >>>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> >>>
> >>> +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
> >>> +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >= MINOR)
> >>> +
> >>>  typedef struct QSVMid {
> >>>  AVBufferRef *hw_frames_ref;
> >>>  mfxHDL handle;
> >>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> >>> index f31172de2..b45216291 100644
> >>> --- a/libavcodec/qsvdec.c
> >>> +++ b/libavcodec/qsvdec.c
> >>> @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx,
> >> QSVContext *q,
> >>>  av_freep();
> >>>  return 

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-28 Thread Mark Thompson
On 27/03/18 23:07, Maxym Dmytrychenko wrote:
> On Tue, Mar 27, 2018 at 12:47 AM, Mark Thompson  wrote:
> 
>> On 26/03/18 21:18, Maxym Dmytrychenko wrote:
>>> Starting from API 1.25 helps to improve performance of the simultaneous
>> encode,
>>> 1:N scenario, like:
>>>
>>> ./avconv  -y -hwaccel qsv -c:v h264_qsv -r 3/1001 -i
>>> ~/bbb_sunflower_1080p_60fps_normal.mp4  -vframes 600 -an \
>>> -filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
>>> [s2]scale_qsv=960:540[o2]" \
>>> -map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
>>> rawvideo /tmp/3200a.264 \
>>> -map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
>>> rawvideo /tmp/1750a.264
>>
>> Having seen this interface being added form the VAAPI side, I got the
>> impression that this only makes sense if the parallel streams are actually
>> in lock-step (as in your example).  What will happen if this isn't the case?
>>
> thanks for the points, Mark.
> it is actually testing phase but can you share more details over example(s)
> you mean?

Well, your example has two streams which encode exactly in parallel - in every 
step both streams encode one frame.

I don't know what the implementation inside libmfx is, but suppose the streams 
don't run at the same rate, e.g. if one stream is twice as fast as the other as 
in (with libx264):

./avconv -y -i in.mp4 -an -filter_complex 'split=2[a][b]' -map '[a]' -r 10 -c:v 
libx264 out_10.mp4 -map '[b]' -r 20 -c:v libx264 out_20.mp4

Does everything still work as expected?

As a worse case, suppose you have multiple input streams with unknown 
properties (including framerate) which want to be encoded with low-latency, 
does setting this option affect that latency because some streams wait for new 
frames to appear on others?

(These questions are primarily trying to assess whether this should be enabled 
by default.)

>> I'm also curious what the gain from this is, if you happen to have some
>> numbers...
>>
> Actually depends on exact HW SKU and resolution/scenario, however, can be
> well above 10%
> 
> 
>>> ---
>>>  libavcodec/qsv.c | 10 ++
>>>  libavcodec/qsv_internal.h|  3 +++
>>>  libavcodec/qsvdec.c  |  1 -
>>>  libavcodec/qsvenc.c  | 16 +++-
>>>  libavcodec/qsvenc.h  | 12 ++--
>>>  libavcodec/qsvenc_h264.c |  4 
>>>  libavfilter/qsvvpp.c |  9 ++---
>>>  libavfilter/qsvvpp.h |  7 +++
>>>  libavfilter/vf_deinterlace_qsv.c |  6 ++
>>>  libavfilter/vf_scale_qsv.c   |  6 ++
>>>  libavutil/hwcontext_qsv.c|  5 +
>>>  libavutil/hwcontext_qsv.h|  3 +++
>>>  12 files changed, 71 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
>>> index e78633d62..bab32836e 100644
>>> --- a/libavcodec/qsv.c
>>> +++ b/libavcodec/qsv.c
>>> @@ -593,10 +593,12 @@ int ff_qsv_init_session_device(AVCodecContext
>> *avctx, mfxSession *psession,
>>>"Error setting a HW handle");
>>>  }
>>>
>>> -err = MFXJoinSession(parent_session, session);
>>> -if (err != MFX_ERR_NONE)
>>> -return ff_qsv_print_error(avctx, err,
>>> -  "Error joining session");
>>> +if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
>>> +err = MFXJoinSession(parent_session, session);
>>> +if (err != MFX_ERR_NONE)
>>> +return ff_qsv_print_error(avctx, err,
>>> +  "Error joining session");
>>> +}
>>>
>>>  ret = qsv_load_plugins(session, load_plugins, avctx);
>>>  if (ret < 0) {
>>> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
>>> index 975c8de44..516994a64 100644
>>> --- a/libavcodec/qsv_internal.h
>>> +++ b/libavcodec/qsv_internal.h
>>> @@ -36,6 +36,9 @@
>>>  (MFX_VERSION_MAJOR > (MAJOR) || \
>>>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
>>>
>>> +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
>>> +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >= MINOR)
>>> +
>>>  typedef struct QSVMid {
>>>  AVBufferRef *hw_frames_ref;
>>>  mfxHDL handle;
>>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
>>> index f31172de2..b45216291 100644
>>> --- a/libavcodec/qsvdec.c
>>> +++ b/libavcodec/qsvdec.c
>>> @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx,
>> QSVContext *q,
>>>  av_freep();
>>>  return ret;
>>>  }
>>> -
>>
>> Stray change.
>>
> + per Luca's comment - will remove it.
> 
> 
>>
>>>  ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size
>> ?  : NULL,
>>>insurf, , sync);
>>>  if (ret == MFX_WRN_DEVICE_BUSY)
>>> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
>>> index f6b1a0d67..a8b446c5b 100644
>>> --- a/libavcodec/qsvenc.c

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-28 Thread Li, Zhong
> > > a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> > > f6b1a0d67..a8b446c5b
> > > 100644
> > > --- a/libavcodec/qsvenc.c
> > > +++ b/libavcodec/qsvenc.c
> > > @@ -135,7 +135,7 @@ static void dump_video_param(AVCodecContext
> > > *avctx, QSVEncContext *q,  #if QSV_HAVE_CO2
> > >  mfxExtCodingOption2 *co2 =
> > > (mfxExtCodingOption2*)coding_opts[1];
> > >  #endif
> > > -#if QSV_HAVE_CO3
> > > +#if QSV_HAVE_CO3 && QSV_HAVE_QVBR
> > >  mfxExtCodingOption3 *co3 =
> > > (mfxExtCodingOption3*)coding_opts[2];
> > >  #endif
> > >
> >
> > Not sure why we need this change and how it impacts MFE.
> >
> see co3 used only when  QSV_HAVE_QVBR - so it is logical and fixes
> compilation issue.
> 
Yes it is, at least correct for current implantation. 
As I know co3 has other options than QVBR cases. 
But it is also ok to remove QSV_HAVE_QVBR when other co3 options are added.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-27 Thread Maxym Dmytrychenko
On Tue, Mar 27, 2018 at 11:55 AM, Li, Zhong  wrote:

> > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index
> > 975c8de44..516994a64 100644
> > --- a/libavcodec/qsv_internal.h
> > +++ b/libavcodec/qsv_internal.h
> > @@ -36,6 +36,9 @@
> >  (MFX_VERSION_MAJOR > (MAJOR) || \
> >   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >=
> > (MINOR))
> >
> > +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR,
> > MINOR) \
> > +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >=
> > MINOR)
> > +
>
> Should also be ok for "MFX_VERSION.Major > MAJOR"? Just like
> QSV_VERSION_ATLEAST.
>
> good point to be fixed!
thanks

>  typedef struct QSVMid {
> >  AVBufferRef *hw_frames_ref;
> >  mfxHDL handle;
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> > f31172de2..b45216291 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx,
> > QSVContext *q,
> >  av_freep();
> >  return ret;
> >  }
> > -
> >  ret = MFXVideoDECODE_DecodeFrameAsync(q->session,
> > avpkt->size ?  : NULL,
> >insurf, ,
> > sync);
> >  if (ret == MFX_WRN_DEVICE_BUSY) diff --git
> > a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f6b1a0d67..a8b446c5b
> > 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -135,7 +135,7 @@ static void dump_video_param(AVCodecContext
> > *avctx, QSVEncContext *q,  #if QSV_HAVE_CO2
> >  mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
> >  #endif
> > -#if QSV_HAVE_CO3
> > +#if QSV_HAVE_CO3 && QSV_HAVE_QVBR
> >  mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
> >  #endif
> >
>
> Not sure why we need this change and how it impacts MFE.
>
see co3 used only when  QSV_HAVE_QVBR - so it is logical and fixes
compilation issue.

___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-27 Thread Maxym Dmytrychenko
On Tue, Mar 27, 2018 at 12:47 AM, Mark Thompson  wrote:

> On 26/03/18 21:18, Maxym Dmytrychenko wrote:
> > Starting from API 1.25 helps to improve performance of the simultaneous
> encode,
> > 1:N scenario, like:
> >
> > ./avconv  -y -hwaccel qsv -c:v h264_qsv -r 3/1001 -i
> > ~/bbb_sunflower_1080p_60fps_normal.mp4  -vframes 600 -an \
> > -filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
> > [s2]scale_qsv=960:540[o2]" \
> > -map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
> > rawvideo /tmp/3200a.264 \
> > -map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
> > rawvideo /tmp/1750a.264
>
> Having seen this interface being added form the VAAPI side, I got the
> impression that this only makes sense if the parallel streams are actually
> in lock-step (as in your example).  What will happen if this isn't the case?
>
> thanks for the points, Mark.
it is actually testing phase but can you share more details over example(s)
you mean?


> I'm also curious what the gain from this is, if you happen to have some
> numbers...
>
> Actually depends on exact HW SKU and resolution/scenario, however, can be
well above 10%


> > ---
> >  libavcodec/qsv.c | 10 ++
> >  libavcodec/qsv_internal.h|  3 +++
> >  libavcodec/qsvdec.c  |  1 -
> >  libavcodec/qsvenc.c  | 16 +++-
> >  libavcodec/qsvenc.h  | 12 ++--
> >  libavcodec/qsvenc_h264.c |  4 
> >  libavfilter/qsvvpp.c |  9 ++---
> >  libavfilter/qsvvpp.h |  7 +++
> >  libavfilter/vf_deinterlace_qsv.c |  6 ++
> >  libavfilter/vf_scale_qsv.c   |  6 ++
> >  libavutil/hwcontext_qsv.c|  5 +
> >  libavutil/hwcontext_qsv.h|  3 +++
> >  12 files changed, 71 insertions(+), 11 deletions(-)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> > index e78633d62..bab32836e 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -593,10 +593,12 @@ int ff_qsv_init_session_device(AVCodecContext
> *avctx, mfxSession *psession,
> >"Error setting a HW handle");
> >  }
> >
> > -err = MFXJoinSession(parent_session, session);
> > -if (err != MFX_ERR_NONE)
> > -return ff_qsv_print_error(avctx, err,
> > -  "Error joining session");
> > +if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
> > +err = MFXJoinSession(parent_session, session);
> > +if (err != MFX_ERR_NONE)
> > +return ff_qsv_print_error(avctx, err,
> > +  "Error joining session");
> > +}
> >
> >  ret = qsv_load_plugins(session, load_plugins, avctx);
> >  if (ret < 0) {
> > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> > index 975c8de44..516994a64 100644
> > --- a/libavcodec/qsv_internal.h
> > +++ b/libavcodec/qsv_internal.h
> > @@ -36,6 +36,9 @@
> >  (MFX_VERSION_MAJOR > (MAJOR) || \
> >   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
> >
> > +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
> > +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >= MINOR)
> > +
> >  typedef struct QSVMid {
> >  AVBufferRef *hw_frames_ref;
> >  mfxHDL handle;
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index f31172de2..b45216291 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext *q,
> >  av_freep();
> >  return ret;
> >  }
> > -
>
> Stray change.
>
+ per Luca's comment - will remove it.


>
> >  ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size
> ?  : NULL,
> >insurf, , sync);
> >  if (ret == MFX_WRN_DEVICE_BUSY)
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> > index f6b1a0d67..a8b446c5b 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -135,7 +135,7 @@ static void dump_video_param(AVCodecContext *avctx,
> QSVEncContext *q,
> >  #if QSV_HAVE_CO2
> >  mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
> >  #endif
> > -#if QSV_HAVE_CO3
> > +#if QSV_HAVE_CO3 && QSV_HAVE_QVBR
> >  mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
> >  #endif
> >
> > @@ -656,6 +656,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >
> >  q->extparam_internal[q->nb_extparam_internal++] =
> (mfxExtBuffer *)>extco2;
> >  }
> > +#endif
> > +#if QSV_HAVE_MF
> > +if (avctx->codec_id == AV_CODEC_ID_H264) {
> > +mfxVersionver;
> > +ret = MFXQueryVersion(q->session,);
> > +if (ret >= MFX_ERR_NONE && QSV_RUNTIME_VERSION_ATLEAST(ver,
> 1, 25)) {
> > +q->extmfp.Header.BufferId =
> MFX_EXTBUFF_MULTI_FRAME_PARAM;
> > +   

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-27 Thread Li, Zhong
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index
> 975c8de44..516994a64 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -36,6 +36,9 @@
>  (MFX_VERSION_MAJOR > (MAJOR) || \
>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >=
> (MINOR))
> 
> +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR,
> MINOR) \
> +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >=
> MINOR)
> +

Should also be ok for "MFX_VERSION.Major > MAJOR"? Just like 
QSV_VERSION_ATLEAST.

>  typedef struct QSVMid {
>  AVBufferRef *hw_frames_ref;
>  mfxHDL handle;
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> f31172de2..b45216291 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext *q,
>  av_freep();
>  return ret;
>  }
> -
>  ret = MFXVideoDECODE_DecodeFrameAsync(q->session,
> avpkt->size ?  : NULL,
>insurf, ,
> sync);
>  if (ret == MFX_WRN_DEVICE_BUSY) diff --git
> a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index f6b1a0d67..a8b446c5b
> 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -135,7 +135,7 @@ static void dump_video_param(AVCodecContext
> *avctx, QSVEncContext *q,  #if QSV_HAVE_CO2
>  mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
>  #endif
> -#if QSV_HAVE_CO3
> +#if QSV_HAVE_CO3 && QSV_HAVE_QVBR
>  mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
>  #endif
> 

Not sure why we need this change and how it impacts MFE. 
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-26 Thread Mark Thompson
On 26/03/18 21:18, Maxym Dmytrychenko wrote:
> Starting from API 1.25 helps to improve performance of the simultaneous 
> encode,
> 1:N scenario, like:
> 
> ./avconv  -y -hwaccel qsv -c:v h264_qsv -r 3/1001 -i
> ~/bbb_sunflower_1080p_60fps_normal.mp4  -vframes 600 -an \
> -filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
> [s2]scale_qsv=960:540[o2]" \
> -map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
> rawvideo /tmp/3200a.264 \
> -map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
> rawvideo /tmp/1750a.264

Having seen this interface being added form the VAAPI side, I got the 
impression that this only makes sense if the parallel streams are actually in 
lock-step (as in your example).  What will happen if this isn't the case?

I'm also curious what the gain from this is, if you happen to have some 
numbers...

> ---
>  libavcodec/qsv.c | 10 ++
>  libavcodec/qsv_internal.h|  3 +++
>  libavcodec/qsvdec.c  |  1 -
>  libavcodec/qsvenc.c  | 16 +++-
>  libavcodec/qsvenc.h  | 12 ++--
>  libavcodec/qsvenc_h264.c |  4 
>  libavfilter/qsvvpp.c |  9 ++---
>  libavfilter/qsvvpp.h |  7 +++
>  libavfilter/vf_deinterlace_qsv.c |  6 ++
>  libavfilter/vf_scale_qsv.c   |  6 ++
>  libavutil/hwcontext_qsv.c|  5 +
>  libavutil/hwcontext_qsv.h|  3 +++
>  12 files changed, 71 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index e78633d62..bab32836e 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -593,10 +593,12 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, 
> mfxSession *psession,
>"Error setting a HW handle");
>  }
>  
> -err = MFXJoinSession(parent_session, session);
> -if (err != MFX_ERR_NONE)
> -return ff_qsv_print_error(avctx, err,
> -  "Error joining session");
> +if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) {
> +err = MFXJoinSession(parent_session, session);
> +if (err != MFX_ERR_NONE)
> +return ff_qsv_print_error(avctx, err,
> +  "Error joining session");
> +}
>  
>  ret = qsv_load_plugins(session, load_plugins, avctx);
>  if (ret < 0) {
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
> index 975c8de44..516994a64 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -36,6 +36,9 @@
>  (MFX_VERSION_MAJOR > (MAJOR) || \
>   MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
>  
> +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
> +(MFX_VERSION.Major == MAJOR  && MFX_VERSION.Minor >= MINOR)
> +
>  typedef struct QSVMid {
>  AVBufferRef *hw_frames_ref;
>  mfxHDL handle;
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index f31172de2..b45216291 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext 
> *q,
>  av_freep();
>  return ret;
>  }
> -

Stray change.

>  ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ?  
> : NULL,
>insurf, , sync);
>  if (ret == MFX_WRN_DEVICE_BUSY)
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index f6b1a0d67..a8b446c5b 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -135,7 +135,7 @@ static void dump_video_param(AVCodecContext *avctx, 
> QSVEncContext *q,
>  #if QSV_HAVE_CO2
>  mfxExtCodingOption2 *co2 = (mfxExtCodingOption2*)coding_opts[1];
>  #endif
> -#if QSV_HAVE_CO3
> +#if QSV_HAVE_CO3 && QSV_HAVE_QVBR
>  mfxExtCodingOption3 *co3 = (mfxExtCodingOption3*)coding_opts[2];
>  #endif
>  
> @@ -656,6 +656,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  
>  q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
> *)>extco2;
>  }
> +#endif
> +#if QSV_HAVE_MF
> +if (avctx->codec_id == AV_CODEC_ID_H264) {
> +mfxVersionver;
> +ret = MFXQueryVersion(q->session,);
> +if (ret >= MFX_ERR_NONE && QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 
> 25)) {
> +q->extmfp.Header.BufferId = 
> MFX_EXTBUFF_MULTI_FRAME_PARAM;
> +q->extmfp.Header.BufferSz = sizeof(q->extmfp);
> +
> +q->extmfp.MFMode = q->mfmode;
> +av_log(avctx,AV_LOG_VERBOSE,"MFMode:%d\n", q->extmfp.MFMode);
> +q->extparam_internal[q->nb_extparam_internal++] = 
> (mfxExtBuffer *)>extmfp;
> +}
> +}

Why is this conditioned on H.264?  The API won't be different for other codecs, 
will it?

>  #endif
>  }
>  
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
> index 

Re: [libav-devel] [PATCH] qsv: adding Multi Frame Encode support

2018-03-26 Thread Luca Barbato

On 26/03/2018 22:18, Maxym Dmytrychenko wrote:

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index f31172de2..b45216291 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -332,7 +332,6 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
  av_freep();
  return ret;
  }
-
  ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ?  : 
NULL,
insurf, , sync);
  if (ret == MFX_WRN_DEVICE_BUSY)


this hunk seems a stray.

the rest looks fine.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel