History

avutil/timecode: add av_timecode_make_smpte_tc_string2

Marton Balint committed 6 years ago

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

Showing the changes to libavutil/timecode.c (1 of 4 files). Show all

Unified · Split

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)

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