History

avutil/timecode: add av_timecode_make_smpte_tc_string2

Marton Balint committed 6 years ago

Commit 837b6eb1 parent 53574014 files · +39 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/timecode.c +18 −1
  3. libavutil/timecode.h +17 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182020-09-xx - xxxxxxxxxx - lavu 56.59.100 - timecode.h
19 Add av_timecode_make_smpte_tc_string2.
20
182020-08-21 - xxxxxxxxxx - lavu 56.58.100 - avstring.h212020-08-21 - xxxxxxxxxx - lavu 56.58.100 - avstring.h
19 Deprecate av_d2str(). Use av_asprintf() instead.22 Deprecate av_d2str(). Use av_asprintf() instead.
20 23
libavutil/timecode.c+18−1
@@ -136,16 +136,33 @@ static unsigned bcd2uint(uint8_t bcd) · 135 unmodified lines
136 return low + 10*high;136 return low + 10*high;
137}137}
138 138
139char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df)139char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
140{140{
141 unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours141 unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours
142 unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes142 unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes
143 unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds143 unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds
144 unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames144 unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
145 unsigned drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit145 unsigned drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit
146
147 if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
148 ff <<= 1;
149 if (!skip_field) {
150 if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
151 ff += !!(tcsmpte & 1 << 7);
152 else
153 ff += !!(tcsmpte & 1 << 23);
154 }
155 }
156
146 snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u",157 snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u",
147 hh, mm, ss, drop ? ';' : ':', ff);158 hh, mm, ss, drop ? ';' : ':', ff);
148 return buf;159 return buf;
160
161}
162
163char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df)
164{
165 return av_timecode_make_smpte_tc_string2(buf, (AVRational){30, 1}, tcsmpte, prevent_df, 1);
149}166}
150 167
151char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)168char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
libavutil/timecode.h+17−0
@@ -109,6 +109,23 @@ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss · 108 unmodified lines
109 */109 */
110char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);110char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);
111 111
112/**
113 * Get the timecode string from the SMPTE timecode format.
114 *
115 * In contrast to av_timecode_make_smpte_tc_string this function supports 50/60
116 * fps timecodes by using the field bit.
117 *
118 * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
119 * @param rate frame rate of the timecode
120 * @param tcsmpte the 32-bit SMPTE timecode
121 * @param prevent_df prevent the use of a drop flag when it is known the DF bit
122 * is arbitrary
123 * @param skip_field prevent the use of a field flag when it is known the field
124 * bit is arbitrary (e.g. because it is used as PC flag)
125 * @return the buf parameter
126 */
127char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field);
128
112/**129/**
113 * Get the timecode string from the SMPTE timecode format.130 * Get the timecode string from the SMPTE timecode format.
114 *131 *
libavutil/version.h+1−1
@@ -79,7 +79,7 @@ · 78 unmodified lines
79 */79 */
80 80
81#define LIBAVUTIL_VERSION_MAJOR 5681#define LIBAVUTIL_VERSION_MAJOR 56
82#define LIBAVUTIL_VERSION_MINOR 5882#define LIBAVUTIL_VERSION_MINOR 59
83#define LIBAVUTIL_VERSION_MICRO 10083#define LIBAVUTIL_VERSION_MICRO 100
84 84
85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \85#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t