diff options
author | Timo Rothenpieler <timo@rothenpieler.org> | 2025-02-23 00:53:09 +0100 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2025-03-02 18:43:08 +0100 |
commit | 9d5d51bd129cfb7cdb085aa4b474711d4a777735 (patch) | |
tree | fc7243d07465a14a4620f4eff4f29b445083dfee /libavutil/timecode.c | |
parent | 600ad36949a70c0187aa671469ebd81212528d61 (diff) | |
download | ffmpeg-9d5d51bd129cfb7cdb085aa4b474711d4a777735.tar.gz |
avutil/timecode: add ff_timecode_set_smpte
Diffstat (limited to 'libavutil/timecode.c')
-rw-r--r-- | libavutil/timecode.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/libavutil/timecode.c b/libavutil/timecode.c index f454466f97..bca16b6ac2 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -29,6 +29,7 @@ #include <stdio.h> #include "common.h" #include "timecode.h" +#include "timecode_internal.h" #include "log.h" #include "error.h" @@ -127,32 +128,10 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum_arg) return buf; } -static unsigned bcd2uint(uint8_t bcd) -{ - unsigned low = bcd & 0xf; - unsigned high = bcd >> 4; - if (low > 9 || high > 9) - return 0; - return low + 10*high; -} - char *av_timecode_make_smpte_tc_string2(char *buf, 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 - - if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { - ff <<= 1; - if (!skip_field) { - if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) - ff += !!(tcsmpte & 1 << 7); - else - ff += !!(tcsmpte & 1 << 23); - } - } + unsigned hh, mm, ss, ff, drop; + ff_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); |