[FFmpeg-devel] [PATCH 2/4] timecode: string representation can be negative.
Baptiste Coudurier
baptiste.coudurier at gmail.com
Sat Jan 7 04:14:40 CET 2012
On 01/05/2012 12:03 PM, Clément Bœsch wrote:
> From: Clément Bœsch <clement.boesch at smartjog.com>
>
> Timecode can be specified with a negative value in MOV...
> ---
> libavcodec/timecode.c | 7 +++++--
> libavcodec/timecode.h | 3 ++-
> libavcodec/version.h | 2 +-
> 3 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/timecode.c b/libavcodec/timecode.c
> index 420b276..a8b4242 100644
> --- a/libavcodec/timecode.c
> +++ b/libavcodec/timecode.c
> @@ -83,7 +83,7 @@ char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigne
> {
> int frame_num = tc->start + frame;
> int fps = (tc->rate.num + tc->rate.den/2) / tc->rate.den;
> - int hh, mm, ss, ff;
> + int hh, mm, ss, ff, neg = 0;
>
> if (tc->drop)
> frame_num = avpriv_framenum_to_drop_timecode(frame_num);
> @@ -91,7 +91,10 @@ char *avpriv_timecode_to_string(char *buf, const struct ff_timecode *tc, unsigne
> ss = frame_num / fps % 60;
> mm = frame_num / (fps*60) % 60;
> hh = frame_num / (fps*3600) % 24;
> - snprintf(buf, sizeof("hh:mm:ss.ff"), "%02d:%02d:%02d%c%02d",
> + if (ff < 0 || ss < 0 || mm < 0 || hh < 0)
> + neg = 1, ff = -ff, ss = -ss, mm = -mm, hh = -hh;
You only need to abs(frame_num) if frame_num < 0 and set neg, instead of
abs all values.
Except that patch is ok.
--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list