[FFmpeg-devel] [PATCH 3/6] avcodec/h264_slice: export S12M timecode side data

lance.lmwang at gmail.com lance.lmwang at gmail.com
Wed Jul 15 16:44:34 EEST 2020


On Wed, Jul 15, 2020 at 09:16:16AM +0100, Kieran Kunhya wrote:
> On Wed, 15 Jul 2020 at 02:19, <lance.lmwang at gmail.com> wrote:
> 
> > On Wed, Jul 15, 2020 at 12:54:35AM +0100, Kieran Kunhya wrote:
> > > On Wed, 15 Jul 2020 at 00:36, <lance.lmwang at gmail.com> wrote:
> > >
> > > > From: Limin Wang <lance.lmwang at gmail.com>
> > > >
> > > > Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> > > > ---
> > > >  libavcodec/h264_slice.c | 10 ++++++++++
> > > >  1 file changed, 10 insertions(+)
> > > >
> > > > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> > > > index c7b2764..db720de 100644
> > > > --- a/libavcodec/h264_slice.c
> > > > +++ b/libavcodec/h264_slice.c
> > > > @@ -1307,6 +1307,7 @@ static int h264_export_frame_props(H264Context
> > *h)
> > > >      if (h->sei.picture_timing.timecode_cnt > 0) {
> > > >          uint32_t *tc_sd;
> > > >          char tcbuf[AV_TIMECODE_STR_SIZE];
> > > > +        uint32_t *s12m_sd;
> > > >
> > > >          AVFrameSideData *tcside = av_frame_new_side_data(out,
> > > >
> > > > AV_FRAME_DATA_S12M_TIMECODE,
> > > > @@ -1316,6 +1317,12 @@ static int h264_export_frame_props(H264Context
> > *h)
> > > >
> > > >          tc_sd = (uint32_t*)tcside->data;
> > > >          tc_sd[0] = h->sei.picture_timing.timecode_cnt;
> > > > +        if (h->avctx->export_side_data &
> > AV_CODEC_EXPORT_DATA_S12M_TC) {
> > > > +            s12m_sd = ff_add_s12m_timecode_side_data(h->avctx);
> > > > +            if (!s12m_sd)
> > > > +                return AVERROR(ENOMEM);
> > > > +            s12m_sd[0] = tc_sd[0];
> > > > +        }
> > > >
> > > >          for (int i = 0; i < tc_sd[0]; i++) {
> > > >              int drop = h->sei.picture_timing.timecode[i].dropframe;
> > > > @@ -1325,6 +1332,9 @@ static int h264_export_frame_props(H264Context
> > *h)
> > > >              int   ff = h->sei.picture_timing.timecode[i].frame;
> > > >
> > > >              tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate,
> > > > drop, hh, mm, ss, ff);
> > > > +            if (h->avctx->export_side_data &
> > > > AV_CODEC_EXPORT_DATA_S12M_TC) {
> > > > +                s12m_sd[i + 1] = tc_sd[i + 1];
> > > > +            }
> > > >              av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0);
> > > >              av_dict_set(&out->metadata, "timecode", tcbuf, 0);
> > > >          }
> > > > --
> > >
> > >
> > > Does this not duplicate the existing logic?
> >
> > It's export packet timecode sidedata, so that you can export the TC side
> > data to stream
> > level. patch#5 show the command how to use it, before the patch, you had
> > to input timecode
> > to export the TC to tmcd track for mp4. Please give advise if you have
> > better way to get it,
> > thanks.
> >
> 
> I don't understand, timecode side data is already exported from H.264.
> Why do you need to create two side datas?

yes, it's better to have a function to copy the side data from frame to
packet level, I'm not sure where is the proper place and how to make the
frame and packet is sync by the timecode. Maybe libavcodec/encode.c is a
good place, but it didn't make sense if the video is copy directly. 

> 
> Kieran
> _______________________________________________
> 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".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list