diff mbox

[FFmpeg-devel] lavc/vaapi_encode: Don't return error if the underlying driver doesn't support B frame

Message ID 20180206081717.24564-1-haihao.xiang@intel.com
State New
Headers show

Commit Message

Xiang, Haihao Feb. 6, 2018, 8:17 a.m. UTC
It is possible B frame is not supported for VAEntrypointEncSliceLP and
the underlying driver has advertised it, so it is better to disable B
frame instead of returning error for this case

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
 libavcodec/vaapi_encode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Jun Zhao Feb. 7, 2018, 2:31 a.m. UTC | #1
On 2018/2/6 16:17, Haihao Xiang wrote:
> It is possible B frame is not supported for VAEntrypointEncSliceLP and
> the underlying driver has advertised it, so it is better to disable B
> frame instead of returning error for this case
>
> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> ---
>  libavcodec/vaapi_encode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 550ea47991d..e371f5761ee 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1094,10 +1094,9 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx)
>                  goto fail;
>              }
>              if (avctx->max_b_frames > 0 && ref_l1 < 1) {
> -                av_log(avctx, AV_LOG_ERROR, "B frames are not "
> -                       "supported (%#x).\n", attr[i].value);
> -                err = AVERROR(EINVAL);
> -                goto fail;
> +                av_log(avctx, AV_LOG_WARNING, "B frames are not "
> +                       "supported (%#x) by the underlying driver.\n", attr[i].value);
> +                avctx->max_b_frames = 0;
I think check b frames when enable low_power in vaapi_encode_xxx_init()
more better.
>              }
>          }
>          break;
Xiang, Haihao Feb. 7, 2018, 3:14 a.m. UTC | #2
On Wed, 2018-02-07 at 10:31 +0800, Jun Zhao wrote:
> 

> On 2018/2/6 16:17, Haihao Xiang wrote:

> > It is possible B frame is not supported for VAEntrypointEncSliceLP and

> > the underlying driver has advertised it, so it is better to disable B

> > frame instead of returning error for this case

> > 

> > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > ---

> >  libavcodec/vaapi_encode.c | 7 +++----

> >  1 file changed, 3 insertions(+), 4 deletions(-)

> > 

> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c

> > index 550ea47991d..e371f5761ee 100644

> > --- a/libavcodec/vaapi_encode.c

> > +++ b/libavcodec/vaapi_encode.c

> > @@ -1094,10 +1094,9 @@ static av_cold int

> > vaapi_encode_config_attributes(AVCodecContext *avctx)

> >                  goto fail;

> >              }

> >              if (avctx->max_b_frames > 0 && ref_l1 < 1) {

> > -                av_log(avctx, AV_LOG_ERROR, "B frames are not "

> > -                       "supported (%#x).\n", attr[i].value);

> > -                err = AVERROR(EINVAL);

> > -                goto fail;

> > +                av_log(avctx, AV_LOG_WARNING, "B frames are not "

> > +                       "supported (%#x) by the underlying driver.\n",

> > attr[i].value);

> > +                avctx->max_b_frames = 0;

> 

> I think check b frames when enable low_power in vaapi_encode_xxx_init()

> more better.


VAConfigAttribEncMaxRefFrames is applicable for other CODECs and non-low power
mode. so I think it is better to handle this case in vaapi_encoder.c

Thanks
Haihao


> >              }

> >          }

> >          break;

> 

>
Xiang, Haihao March 7, 2018, 7:10 a.m. UTC | #3
Hi Mark,

Do you have any comment to this patch? FFmpeg-vaapi fails to use low power mode
for H.264 encoding.

Thanks
Haihao

> On Wed, 2018-02-07 at 10:31 +0800, Jun Zhao wrote:

> > 

> > On 2018/2/6 16:17, Haihao Xiang wrote:

> > > It is possible B frame is not supported for VAEntrypointEncSliceLP and

> > > the underlying driver has advertised it, so it is better to disable B

> > > frame instead of returning error for this case

> > > 

> > > Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>

> > > ---

> > >  libavcodec/vaapi_encode.c | 7 +++----

> > >  1 file changed, 3 insertions(+), 4 deletions(-)

> > > 

> > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c

> > > index 550ea47991d..e371f5761ee 100644

> > > --- a/libavcodec/vaapi_encode.c

> > > +++ b/libavcodec/vaapi_encode.c

> > > @@ -1094,10 +1094,9 @@ static av_cold int

> > > vaapi_encode_config_attributes(AVCodecContext *avctx)

> > >                  goto fail;

> > >              }

> > >              if (avctx->max_b_frames > 0 && ref_l1 < 1) {

> > > -                av_log(avctx, AV_LOG_ERROR, "B frames are not "

> > > -                       "supported (%#x).\n", attr[i].value);

> > > -                err = AVERROR(EINVAL);

> > > -                goto fail;

> > > +                av_log(avctx, AV_LOG_WARNING, "B frames are not "

> > > +                       "supported (%#x) by the underlying driver.\n",

> > > attr[i].value);

> > > +                avctx->max_b_frames = 0;

> > 

> > I think check b frames when enable low_power in vaapi_encode_xxx_init()

> > more better.

> 

> VAConfigAttribEncMaxRefFrames is applicable for other CODECs and non-low power

> mode. so I think it is better to handle this case in vaapi_encoder.c

> 

> Thanks

> Haihao

> 

> 

> > >              }

> > >          }

> > >          break;

> > 

> > 

> 

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Mark Thompson March 8, 2018, 12:35 a.m. UTC | #4
On 07/03/18 07:10, Xiang, Haihao wrote:
> 
> Hi Mark,
> 
> Do you have any comment to this patch? FFmpeg-vaapi fails to use low power mode
> for H.264 encoding.

I still want to clean up all of this configuration stuff, but I guess it works ok for now.  So, I fixed the overlong line and applied with a clearer commit message.

Thanks,

- Mark


>> On Wed, 2018-02-07 at 10:31 +0800, Jun Zhao wrote:
>>>
>>> On 2018/2/6 16:17, Haihao Xiang wrote:
>>>> It is possible B frame is not supported for VAEntrypointEncSliceLP and
>>>> the underlying driver has advertised it, so it is better to disable B
>>>> frame instead of returning error for this case
>>>>
>>>> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
>>>> ---
>>>>  libavcodec/vaapi_encode.c | 7 +++----
>>>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
>>>> index 550ea47991d..e371f5761ee 100644
>>>> --- a/libavcodec/vaapi_encode.c
>>>> +++ b/libavcodec/vaapi_encode.c
>>>> @@ -1094,10 +1094,9 @@ static av_cold int
>>>> vaapi_encode_config_attributes(AVCodecContext *avctx)
>>>>                  goto fail;
>>>>              }
>>>>              if (avctx->max_b_frames > 0 && ref_l1 < 1) {
>>>> -                av_log(avctx, AV_LOG_ERROR, "B frames are not "
>>>> -                       "supported (%#x).\n", attr[i].value);
>>>> -                err = AVERROR(EINVAL);
>>>> -                goto fail;
>>>> +                av_log(avctx, AV_LOG_WARNING, "B frames are not "
>>>> +                       "supported (%#x) by the underlying driver.\n",
>>>> attr[i].value);
>>>> +                avctx->max_b_frames = 0;
>>>
>>> I think check b frames when enable low_power in vaapi_encode_xxx_init()
>>> more better.
>>
>> VAConfigAttribEncMaxRefFrames is applicable for other CODECs and non-low power
>> mode. so I think it is better to handle this case in vaapi_encoder.c
>>
>> Thanks
>> Haihao
>>
>>
>>>>              }
>>>>          }
>>>>          break;
diff mbox

Patch

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 550ea47991d..e371f5761ee 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1094,10 +1094,9 @@  static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx)
                 goto fail;
             }
             if (avctx->max_b_frames > 0 && ref_l1 < 1) {
-                av_log(avctx, AV_LOG_ERROR, "B frames are not "
-                       "supported (%#x).\n", attr[i].value);
-                err = AVERROR(EINVAL);
-                goto fail;
+                av_log(avctx, AV_LOG_WARNING, "B frames are not "
+                       "supported (%#x) by the underlying driver.\n", attr[i].value);
+                avctx->max_b_frames = 0;
             }
         }
         break;