Showing the changes to libavutil/timecode.c (1 of 4 files). Show all
Unified · Split
| @@ -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 | ||
| 139 | char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df) | 139 | char *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 hours | 141 | unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours |
| 142 | unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes | 142 | unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes |
| 143 | unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds | 143 | unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds |
| 144 | unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames | 144 | unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames |
| 145 | unsigned drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit | 145 | 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 | |||
| 163 | char *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 | ||
| 151 | char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit) | 168 | char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit) |