[FFmpeg-devel] avcodec/mmaldec: use zero-copy for AV_PIX_FMT_MMAL

Submitted by Yevhen Kyriukha on Sept. 3, 2017, 12:44 p.m.

Details

Message ID 20170903124436.16963-1-kirgene@gmail.com
State New
Headers show

Commit Message

Yevhen Kyriukha Sept. 3, 2017, 12:44 p.m.
Signed-off-by: Yevhen Kyriukha <kirgene@gmail.com>
---
 libavcodec/mmaldec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

wm4 Sept. 4, 2017, 10:04 a.m.
On Sun,  3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha <kirgene@gmail.com> wrote:

> Signed-off-by: Yevhen Kyriukha <kirgene@gmail.com>
> ---
>  libavcodec/mmaldec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
> index 0b1195dc3e..19ca6ce7e7 100644
> --- a/libavcodec/mmaldec.c
> +++ b/libavcodec/mmaldec.c
> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>          goto fail;
>  
>      if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
> +        if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_ZERO_COPY, 1)))
> +            goto fail;
>          format_out->encoding = MMAL_ENCODING_OPAQUE;
>      } else {
>          format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>          FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended);
>      decoder->output[0]->buffer_num =
>          FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
> -    ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
> +    ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
> +                                           decoder->output[0]->buffer_num,
>                                             decoder->output[0]->buffer_size);
>      if (!ctx->pool_out->pool) {
>          ret = AVERROR(ENOMEM);

Why the change, and what are the implications? (The commit message
should contain this.)
Wang Bin Nov. 2, 2017, 8:39 a.m.
?? Outlook for Android<https://aka.ms/ghei36>
Wang Bin Nov. 2, 2017, 8:53 a.m.
> On Sun, 3 Sep 2017 15:44:36 +0300
Yevhen Kyriukha <kirgene@gmail.com> wrote:
>
>> Signed-off-by: Yevhen Kyriukha <kirgene@gmail.com>
>> —
>> libavcodec/mmaldec.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
>> index 0b1195dc3e..19ca6ce7e7 100644
>> --- a/libavcodec/mmaldec.c
>> +++ b/libavcodec/mmaldec.c
>> @@ -295,6 +295,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> goto fail;
>>  
>> if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
>> + if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_ZERO_COPY, 1)))
>> + goto fail;
>> format_out->encoding = MMAL_ENCODING_OPAQUE;
>> } else {
>> format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
>> @@ -332,7 +334,8 @@ static int ffmal_update_format(AVCodecContext *avctx)
>> FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended);
>> decoder->output[0]->buffer_num =
>> FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
>> - ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
>> + ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
>> + decoder->output[0]->buffer_num,
>> decoder->output[0]->buffer_size);
>> if (!ctx->pool_out->pool) {
>> ret = AVERROR(ENOMEM);

> Why the change, and what are the implications? (The commit message
> should contain this.)

I have confirmed with this patch EGLImage can be created from decoded mmal buffer. It’s really useful for players.

Patch hide | download patch | download mbox

diff --git a/libavcodec/mmaldec.c b/libavcodec/mmaldec.c
index 0b1195dc3e..19ca6ce7e7 100644
--- a/libavcodec/mmaldec.c
+++ b/libavcodec/mmaldec.c
@@ -295,6 +295,8 @@  static int ffmal_update_format(AVCodecContext *avctx)
         goto fail;
 
     if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
+        if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_ZERO_COPY, 1)))
+            goto fail;
         format_out->encoding = MMAL_ENCODING_OPAQUE;
     } else {
         format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
@@ -332,7 +334,8 @@  static int ffmal_update_format(AVCodecContext *avctx)
         FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended);
     decoder->output[0]->buffer_num =
         FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
-    ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
+    ctx->pool_out->pool = mmal_port_pool_create(decoder->output[0],
+                                           decoder->output[0]->buffer_num,
                                            decoder->output[0]->buffer_size);
     if (!ctx->pool_out->pool) {
         ret = AVERROR(ENOMEM);