Commit 0d666200 authored by Marton Balint's avatar Marton Balint

avutil/timecode: use timecode fps for number of frame digits

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 8dd5bb72
......@@ -104,7 +104,7 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
{
int fps = tc->fps;
int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME;
int hh, mm, ss, ff, neg = 0;
int hh, mm, ss, ff, ff_len, neg = 0;
framenum += tc->start;
if (drop)
......@@ -119,9 +119,10 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
hh = framenum / (fps*3600LL);
if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
hh = hh % 24;
snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
ff_len = fps > 10000 ? 5 : fps > 1000 ? 4 : fps > 100 ? 3 : fps > 10 ? 2 : 1;
snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%0*d",
neg ? "-" : "",
hh, mm, ss, drop ? ';' : ':', ff);
hh, mm, ss, drop ? ';' : ':', ff_len, ff);
return buf;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment