30 #if FF_API_OLD_TIMECODE 36 int avpriv_framenum_to_drop_timecode(
int frame_num)
39 int d = frame_num / 17982;
40 int m = frame_num % 17982;
42 return frame_num + 18 * d + 2 * ((m - 2) / 1798);
45 uint32_t avpriv_framenum_to_smpte_timecode(
unsigned frame,
int fps,
int drop)
49 ( ((frame % fps) / 10) << 28) |
50 ( ((frame % fps) % 10) << 24) |
52 ((((frame / fps) % 60) / 10) << 20) |
53 ((((frame / fps) % 60) % 10) << 16) |
55 ((((frame / (fps * 60)) % 60) / 10) << 12) |
56 ((((frame / (fps * 60)) % 60) % 10) << 8) |
59 ((((frame / (fps * 3600) % 24)) / 10) << 4) |
60 ( (frame / (fps * 3600) % 24)) % 10;
63 int avpriv_check_timecode_rate(
void *avcl,
AVRational rate,
int drop)
67 if (!rate.
num || !rate.
den) {
72 if (drop && fps != 30) {
87 char *avpriv_timecode_to_string(
char *
buf,
const struct ff_timecode *
tc,
unsigned frame)
89 int frame_num = tc->start +
frame;
90 int fps = (tc->rate.num + tc->rate.den/2) / tc->rate.den;
91 int hh, mm, ss, ff, neg = 0;
94 frame_num = avpriv_framenum_to_drop_timecode(frame_num);
96 frame_num = -frame_num;
100 ss = frame_num / fps % 60;
101 mm = frame_num / (fps*60) % 60;
102 hh = frame_num / (fps*3600);
103 snprintf(buf, 16,
"%s%02d:%02d:%02d%c%02d",
105 hh, mm, ss, tc->drop ?
';' :
':', ff);
109 int avpriv_init_smpte_timecode(
void *avcl,
struct ff_timecode *tc)
111 int hh, mm, ss, ff, fps,
ret;
114 if (sscanf(tc->str,
"%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
116 "syntax: hh:mm:ss[:;.]ff\n");
122 ret = avpriv_check_timecode_rate(avcl, tc->rate, tc->drop);
126 fps = (tc->rate.num + tc->rate.den/2) / tc->rate.den;
127 tc->start = (hh*3600 + mm*60 + ss) * fps + ff;
130 int tmins = 60*hh + mm;
131 tc->start -= 2 * (tmins - tmins/10);
136 int ff_framenum_to_drop_timecode(
int frame_num)
138 return avpriv_framenum_to_drop_timecode(frame_num);
141 uint32_t ff_framenum_to_smtpe_timecode(
unsigned frame,
int fps,
int drop)
143 return avpriv_framenum_to_smpte_timecode(frame, fps, drop);
146 int ff_init_smtpe_timecode(
void *avcl,
struct ff_timecode *tc)
148 return avpriv_init_smpte_timecode(avcl, tc);
Libavcodec version macros.
void av_log(void *avcl, int level, const char *fmt,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
rational number numerator/denominator