[FFmpeg-devel] avcodec: v4l2_m2m: reduce the minimum amount of buffers

Submitted by Maxime Jourdan on April 5, 2018, 4:42 p.m.

Details

Message ID CAHStOZ6crquW40AZtUHJy2oiOy5KB8ULqWQWm-RSyez_BMTAgg@mail.gmail.com
State New
Headers show

Commit Message

Maxime Jourdan April 5, 2018, 4:42 p.m.
Reduce the minimum amount of CAPTURE and OUTPUT buffers to 1.

There are drivers that may work with such drastic settings,
and FFmpeg doesn't complain.
---
 libavcodec/v4l2_m2m.h     | 2 +-
 libavcodec/v4l2_m2m_dec.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

     { NULL},
 };

Comments

Jorge Ramirez-Ortiz April 5, 2018, 8:14 p.m.
On 04/05/2018 06:42 PM, Maxime Jourdan wrote:
> Reduce the minimum amount of CAPTURE and OUTPUT buffers to 1.

makes sense to me if that is indeed the case.
could you provide a real life use case?

>
> There are drivers that may work with such drastic settings,
> and FFmpeg doesn't complain.
> ---
>  libavcodec/v4l2_m2m.h     | 2 +-
>  libavcodec/v4l2_m2m_dec.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
> index 452bf0d9bc..68e4e5d6c6 100644
> --- a/libavcodec/v4l2_m2m.h
> +++ b/libavcodec/v4l2_m2m.h
> @@ -38,7 +38,7 @@
>  #define V4L_M2M_DEFAULT_OPTS \
>      { "num_output_buffers", "Number of buffers in the output context",\
> -        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 
> 6, INT_MAX, FLAGS }
> +        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 
> 1, INT_MAX, FLAGS }
>  typedef struct V4L2m2mContext {
>      char devname[PATH_MAX];
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index bca45be148..5196680bbb 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -198,7 +198,7 @@ static av_cold int v4l2_decode_init(AVCodecContext 
> *avctx)
>  static const AVOption options[] = {
>      V4L_M2M_DEFAULT_OPTS,
>      { "num_capture_buffers", "Number of buffers in the capture context",
> -        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 
> 20, INT_MAX, FLAGS },
> +        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 1, 
> INT_MAX, FLAGS },
>      { NULL},
>  };
> -- 
> 2.16.2
Maxime Jourdan April 5, 2018, 8:24 p.m.
The AMLogic meson V4L2 M2M I'm developping (https://github.com/Elyotna/linux)
can fare with only one OUTPUT buffer for data input.

Granted, only 1 CAPTURE buffer is probably not going to cut it, but still,
I don't see the reason behind restricting the FFmpeg user to try with 1 (in
the end the driver will adjust the min/max buffers anyway).

2018-04-05 22:14 GMT+02:00 Jorge Ramirez-Ortiz <jramirez@baylibre.com>:

> On 04/05/2018 06:42 PM, Maxime Jourdan wrote:
>
>> Reduce the minimum amount of CAPTURE and OUTPUT buffers to 1.
>>
>
> makes sense to me if that is indeed the case.
> could you provide a real life use case?
>
>
>
>> There are drivers that may work with such drastic settings,
>> and FFmpeg doesn't complain.
>> ---
>>  libavcodec/v4l2_m2m.h     | 2 +-
>>  libavcodec/v4l2_m2m_dec.c | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
>> index 452bf0d9bc..68e4e5d6c6 100644
>> --- a/libavcodec/v4l2_m2m.h
>> +++ b/libavcodec/v4l2_m2m.h
>> @@ -38,7 +38,7 @@
>>  #define V4L_M2M_DEFAULT_OPTS \
>>      { "num_output_buffers", "Number of buffers in the output context",\
>> -        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 6,
>> INT_MAX, FLAGS }
>> +        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 1,
>> INT_MAX, FLAGS }
>>  typedef struct V4L2m2mContext {
>>      char devname[PATH_MAX];
>> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
>> index bca45be148..5196680bbb 100644
>> --- a/libavcodec/v4l2_m2m_dec.c
>> +++ b/libavcodec/v4l2_m2m_dec.c
>> @@ -198,7 +198,7 @@ static av_cold int v4l2_decode_init(AVCodecContext
>> *avctx)
>>  static const AVOption options[] = {
>>      V4L_M2M_DEFAULT_OPTS,
>>      { "num_capture_buffers", "Number of buffers in the capture context",
>> -        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 20,
>> INT_MAX, FLAGS },
>> +        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 1,
>> INT_MAX, FLAGS },
>>      { NULL},
>>  };
>> --
>> 2.16.2
>>
>
>

Patch hide | download patch | download mbox

diff --git a/libavcodec/v4l2_m2m.h b/libavcodec/v4l2_m2m.h
index 452bf0d9bc..68e4e5d6c6 100644
--- a/libavcodec/v4l2_m2m.h
+++ b/libavcodec/v4l2_m2m.h
@@ -38,7 +38,7 @@ 

 #define V4L_M2M_DEFAULT_OPTS \
     { "num_output_buffers", "Number of buffers in the output context",\
-        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 6,
INT_MAX, FLAGS }
+        OFFSET(num_output_buffers), AV_OPT_TYPE_INT, { .i64 = 16 }, 1,
INT_MAX, FLAGS }

 typedef struct V4L2m2mContext {
     char devname[PATH_MAX];
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index bca45be148..5196680bbb 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -198,7 +198,7 @@  static av_cold int v4l2_decode_init(AVCodecContext
*avctx)
 static const AVOption options[] = {
     V4L_M2M_DEFAULT_OPTS,
     { "num_capture_buffers", "Number of buffers in the capture context",
-        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 20,
INT_MAX, FLAGS },
+        OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 1,
INT_MAX, FLAGS },