- ct = (time_t)(c->frames / ((float)c->sys->frame_rate /
- (float)c->sys->frame_rate_base));
- brktimegm(ct, &tc);
- /*
- * LTC drop-frame frame counter drops two frames (0 and 1) every
- * minute, unless it is exactly divisible by 10
- */
- ltc_frame = (c->frames + 2*ct/60 - 2*ct/600) % c->sys->ltc_divisor;
- buf[1] = (0 << 7) | /* Color fame: 0 - unsync; 1 - sync mode */
- (1 << 6) | /* Drop frame timecode: 0 - nondrop; 1 - drop */
- ((ltc_frame / 10) << 4) | /* Tens of frames */
- (ltc_frame % 10); /* Units of frames */
- buf[2] = (1 << 7) | /* Biphase mark polarity correction: 0 - even; 1 - odd */
- ((tc.tm_sec / 10) << 4) | /* Tens of seconds */
- (tc.tm_sec % 10); /* Units of seconds */
- buf[3] = (1 << 7) | /* Binary group flag BGF0 */
- ((tc.tm_min / 10) << 4) | /* Tens of minutes */
- (tc.tm_min % 10); /* Units of minutes */
- buf[4] = (1 << 7) | /* Binary group flag BGF2 */
- (1 << 6) | /* Binary group flag BGF1 */
- ((tc.tm_hour / 10) << 4) | /* Tens of hours */
- (tc.tm_hour % 10); /* Units of hours */
- break;
+ ct = (time_t)av_rescale_rnd(c->frames, c->sys->time_base.num,
+ c->sys->time_base.den, AV_ROUND_DOWN);
+ brktimegm(ct, &tc);
+ /*
+ * LTC drop-frame frame counter drops two frames (0 and 1) every
+ * minute, unless it is exactly divisible by 10
+ */
+ ltc_frame = (c->frames + 2 * ct / 60 - 2 * ct / 600) % c->sys->ltc_divisor;
+ buf[1] = (0 << 7) | /* color frame: 0 - unsync; 1 - sync mode */
+ (1 << 6) | /* drop frame timecode: 0 - nondrop; 1 - drop */
+ ((ltc_frame / 10) << 4) | /* tens of frames */
+ (ltc_frame % 10); /* units of frames */
+ buf[2] = (1 << 7) | /* biphase mark polarity correction: 0 - even; 1 - odd */
+ ((tc.tm_sec / 10) << 4) | /* tens of seconds */
+ (tc.tm_sec % 10); /* units of seconds */
+ buf[3] = (1 << 7) | /* binary group flag BGF0 */
+ ((tc.tm_min / 10) << 4) | /* tens of minutes */
+ (tc.tm_min % 10); /* units of minutes */
+ buf[4] = (1 << 7) | /* binary group flag BGF2 */
+ (1 << 6) | /* binary group flag BGF1 */
+ ((tc.tm_hour / 10) << 4) | /* tens of hours */
+ (tc.tm_hour % 10); /* units of hours */
+ break;