[FFmpeg-devel] Set AV_TIMECODE_FLAG_ALLOWNEGATIVE in avutil/timecode.c av_timecode_init_from_string

Clément Bœsch u at pkh.me
Thu Sep 11 09:22:34 CEST 2014


On Tue, Sep 09, 2014 at 12:24:21PM -0700, jon wrote:
> If the timecode value is negative it certainly seems safe to set the
> AV_TIMECODE_FLAG_ALLOWNEGATIVE on the AVTimecode object.

> From 35ae38f9557e1ff01040d0e681e843d1727f979b Mon Sep 17 00:00:00 2001
> From: Jon Morley <jon at tweaksoftware.com>
> Date: Tue, 9 Sep 2014 12:12:17 -0700
> Subject: [PATCH 2/2] libavutil/timecode.c: improve flag setting when init tc
>  from string
> 
> If the string begins with a negative HH (hour) value then make sure to
> set the AV_TIMECODE_FLAG_ALLOW_NEGATIVE flag for the resulting
> tc->flags.
> ---
>  libavutil/timecode.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/timecode.c b/libavutil/timecode.c
> index 1dfd040..b96a4d1 100644
> --- a/libavutil/timecode.c
> +++ b/libavutil/timecode.c
> @@ -201,9 +201,10 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
>      }
>  
>      memset(tc, 0, sizeof(*tc));
> -    tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
> -    tc->rate  = rate;
> -    tc->fps   = fps_from_frame_rate(rate);
> +    tc->flags  = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
> +    tc->flags |= (hh < 0) ? AV_TIMECODE_FLAG_ALLOWNEGATIVE : 0; // neg if starts with '-'
> +    tc->rate   = rate;
> +    tc->fps    = fps_from_frame_rate(rate);
>  
>      ret = check_timecode(log_ctx, tc);
>      if (ret < 0)

What does this fix exactly?

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140911/9c05f150/attachment.asc>


More information about the ffmpeg-devel mailing list