[email protected] (12020-06-19): > From: Limin Wang <[email protected]> > > Signed-off-by: Limin Wang <[email protected]> > --- > libavutil/timecode.c | 26 ++++++++++++++++++++++++++ > libavutil/timecode.h | 9 +++++++++ > 2 files changed, 35 insertions(+) > > diff --git a/libavutil/timecode.c b/libavutil/timecode.c > index 60077ba..7a7ed1d 100644 > --- a/libavutil/timecode.c > +++ b/libavutil/timecode.c > @@ -81,6 +81,32 @@ uint32_t av_timecode_get_smpte_from_framenum(const > AVTimecode *tc, int framenum) > (hh % 10); // units of hours > } > > +uint32_t av_timecode_get_smpte_by_tc_string(const char *buf) > +{ > + char c; > + int hh, mm, ss, ff, drop; > +
> + if (sscanf(buf, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
This accepts garbage at the end. Is it on purpose?
> + return AVERROR_INVALIDDATA;
You cannot return an error code with that function signature.
> + }
> + drop = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.',
> ...
> +
> + return 0 << 31 | // color frame flag (0: unsync mode, 1: sync
> mode)
> + drop << 30 | // drop frame flag (0: non drop, 1: drop)
> + (ff / 10) << 28 | // tens of frames
> + (ff % 10) << 24 | // units of frames
> + 0 << 23 | // PC (NTSC) or BGF0 (PAL)
> + (ss / 10) << 20 | // tens of seconds
> + (ss % 10) << 16 | // units of seconds
> + 0 << 15 | // BGF0 (NTSC) or BGF2 (PAL)
> + (mm / 10) << 12 | // tens of minutes
> + (mm % 10) << 8 | // units of minutes
> + 0 << 7 | // BGF2 (NTSC) or PC (PAL)
> + 0 << 6 | // BGF1
> + (hh / 10) << 4 | // tens of hours
> + (hh % 10); // units of hours
> +}
> +
> char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
> {
> int fps = tc->fps;
> diff --git a/libavutil/timecode.h b/libavutil/timecode.h
> index 37c1361..7bb4b78 100644
> --- a/libavutil/timecode.h
> +++ b/libavutil/timecode.h
> @@ -71,6 +71,15 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int
> fps);
> uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int
> framenum);
>
> /**
> + * Convert TC string to SMPTE 12M binary representation.
> + *
> + * @param buf TC string
> + * @return the SMPTE binary representation, or AVERROR otherwise
> + *
> + */
> +uint32_t av_timecode_get_smpte_by_tc_string(const char *buf);
> +
> +/**
> * Load timecode string in buf.
> *
> * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE
> long
Regards,
--
Nicolas George
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list [email protected] https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email [email protected] with subject "unsubscribe".
