[FFmpeg-devel] [PATCH 3/3] mmaldec with plain yuv420p without copy

Lluís Batlle i Rossell viric at viric.name
Fri Feb 12 00:49:24 EET 2021


On Thu, Feb 11, 2021 at 10:34:11PM +0000, Mark Thompson wrote:
> On 11/02/2021 21:48, Lluís Batlle i Rossel wrote:
> > From: Lluís Batlle i Rossell <viric at viric.name>
> > 
> > +
> 
> Random whitespace change?

likely. I can fix that.

> 
> >       if (!ref)
> >           return AVERROR(ENOMEM);
> > @@ -140,8 +141,19 @@ static int ffmmal_set_ref(AVFrame *frame, FFPoolRef *pool,
> >       atomic_fetch_add_explicit(&ref->pool->refcount, 1, memory_order_relaxed);
> >       mmal_buffer_header_acquire(buffer);
> > -    frame->format = AV_PIX_FMT_MMAL;
> > -    frame->data[3] = (uint8_t *)ref->buffer;
> > +    frame->format = avctx->pix_fmt;
> > +
> > +    if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
> > +        int w = FFALIGN(avctx->width, 32);
> > +        int h = FFALIGN(avctx->height, 16);
> > +
> > +        av_image_fill_arrays(frame->data, frame->linesize,
> > +                buffer->data + buffer->type->video.offset[0],
> > +                avctx->pix_fmt, w, h, 1);
> > +    } else {
> > +        frame->data[3] = (uint8_t *)ref->buffer;
> > +    }
> > +
> >       return 0;
> >   }
> > @@ -633,30 +645,14 @@ static int ffmal_copy_frame(AVCodecContext *avctx,  AVFrame *frame,
> 
> The function name is very misleading after this change.

Definitely. I can fix that.

> > +    if ((ret = ffmmal_set_ref(avctx, frame, ctx->pool_out, buffer)) < 0)
> > +        goto done;
> >       frame->pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : buffer->pts;
> >   #if FF_API_PKT_PTS
> > 
> 
> What happens if the user holds on to multiple of the output frames, perhaps because they are being queued into some other operation?  The number of buffers appears fixed, so what happens if they run out?

I don't know. I don't know how to trigger that situation. That would
affect also the "mmal" pixfmt, already present.

-- 
(Escriu-me xifrat si saps PGP / Write ciphered if you know PGP)
PGP key 7CBD1DA5 - https://emailselfdefense.fsf.org/


More information about the ffmpeg-devel mailing list