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

Signed-off-by: Marton Balint <cus@passwd.hu>
release/5.1
Marton Balint 3 years ago
parent 8dd5bb7280
commit 0d666200d3
  1. 7
      libavutil/timecode.c

@ -104,7 +104,7 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
{ {
int fps = tc->fps; int fps = tc->fps;
int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME; 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; framenum += tc->start;
if (drop) if (drop)
@ -119,9 +119,10 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
hh = framenum / (fps*3600LL); hh = framenum / (fps*3600LL);
if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX) if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
hh = hh % 24; 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 ? "-" : "", neg ? "-" : "",
hh, mm, ss, drop ? ';' : ':', ff); hh, mm, ss, drop ? ';' : ':', ff_len, ff);
return buf; return buf;
} }

Loading…
Cancel
Save