--- doc/APIchanges | 3 +++ libavutil/timecode.c | 24 +++++++++++++++--------- libavutil/timecode.h | 17 +++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges index ac506f4b56..71240d39fd 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2025-02-xx - xxxxxxxxxx - lavu 59.58.100 - timecode.h + Add av_timecode_set_smpte(). + 2025-02-xx - xxxxxxxxxx - lavu 59.57.100 - log.h Add flags AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME. diff --git a/libavutil/timecode.c b/libavutil/timecode.c index f454466f97..e6cd811a2b 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -136,23 +136,29 @@ static unsigned bcd2uint(uint8_t bcd) return low + 10*high; } -char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) +void av_timecode_set_smpte(int *drop, int *hh, int *mm, int *ss, int *ff, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) { - unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours - unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes - unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds - unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames - unsigned drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit + *hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours + *mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes + *ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds + *ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames + *drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { - ff <<= 1; + *ff <<= 1; if (!skip_field) { if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) - ff += !!(tcsmpte & 1 << 7); + *ff += !!(tcsmpte & 1 << 7); else - ff += !!(tcsmpte & 1 << 23); + *ff += !!(tcsmpte & 1 << 23); } } +} + +char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field) +{ + int hh, mm, ss, ff, drop; + av_timecode_set_smpte(&drop, &hh, &mm, &ss, &ff, rate, tcsmpte, prevent_df, skip_field); snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u", hh, mm, ss, drop ? ';' : ':', ff); diff --git a/libavutil/timecode.h b/libavutil/timecode.h index fe0fc83576..2685e48db2 100644 --- a/libavutil/timecode.h +++ b/libavutil/timecode.h @@ -95,6 +95,23 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum) */ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff); +/** + * Convert SMPTE 12M binary representation to sei info. + * + * @param drop drop flag output + * @param hh hour output + * @param mm minute output + * @param ss second output + * @param ff frame number output + * @param rate frame rate of the timecode + * @param tcsmpte the 32-bit SMPTE timecode + * @param prevent_df prevent the use of a drop flag when it is known the DF bit + * is arbitrary + * @param skip_field prevent the use of a field flag when it is known the field + * bit is arbitrary (e.g. because it is used as PC flag) + */ +void av_timecode_set_smpte(int *drop, int *hh, int *mm, int *ss, int *ff, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field); + /** * Load timecode string in buf. * diff --git a/libavutil/version.h b/libavutil/version.h index ee4a36cb17..4b584fd569 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 57 +#define LIBAVUTIL_VERSION_MINOR 58 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.45.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".