[FFmpeg-devel] [PATCH v2 2/3] avcodec/rawenc: propagate the Producer Reference time

Clément Péron peron.clem at gmail.com
Sun Dec 15 14:22:33 EET 2024


Hi Michael,

On Fri, 29 Nov 2024 at 20:22, Michael Niedermayer
<michael at niedermayer.cc> wrote:
>
> Hi
>
> On Fri, Nov 01, 2024 at 06:21:23PM +0100, Clément Péron wrote:
> > The Producer Reference time contains the source time when the frame
> > has been produced. This is usefull in the muxer so propagate it.
> >
> > Signed-off-by: Clément Péron <peron.clem at gmail.com>
> > ---
> >  libavcodec/rawenc.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
> > index 8c577006d9..f238c8e165 100644
> > --- a/libavcodec/rawenc.c
> > +++ b/libavcodec/rawenc.c
> > @@ -49,6 +49,8 @@ static av_cold int raw_encode_init(AVCodecContext *avctx)
> >  static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
> >                        const AVFrame *frame, int *got_packet)
> >  {
> > +    AVFrameSideData *side_data;
> > +
> >      int ret = av_image_get_buffer_size(frame->format,
> >                                         frame->width, frame->height, 1);
> >
> > @@ -78,6 +80,16 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt,
> >          }
> >      }
> >      *got_packet = 1;
> > +
> > +    // Forward the PRFT to Mux
> > +    side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_PRFT);
> > +    if (side_data && side_data->size) {
> > +        uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_PRFT, side_data->size);
> > +        if (!buf)
> > +            return AVERROR(ENOMEM);
> > +        memcpy(buf, side_data->data, side_data->size);
> > +    }
>
> It feels like there should be a simpler mechanism to forward side data
> but if theres not, then this is probably ok assuming the addition of PRFT
> and the rest of teh patchset is ok

I look a bit more to make this series more acceptable and avoid this
ugly code block.

One candidate could have been the ff_sd_global_map, unfortunately
there is no function that calls this map at each packet at the
encoding stage.
I would expect something like "ff_eencode_frame_props_from_frame()".

I looked a bit in the Git history and saw some work in progress by
Anton, maybe you have a better suggestion?
I would be interested to have some kind of automatic side data
forwarding between frame and packet at the encoding stage.

Thanks for your help,
Regards
Clement

>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are too smart to engage in politics are punished by being
> governed by those who are dumber. -- Plato
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list