aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorLimin Wang <lance.lmwang@gmail.com>2020-07-12 22:19:31 +0800
committerLimin Wang <lance.lmwang@gmail.com>2020-08-16 22:51:11 +0800
commitd7af6d146983f8a63304fffb8535787f9e7bdee9 (patch)
tree6bc41eac70cf151ed1975fafd02f9a332bd77161 /libavcodec/utils.c
parent6328a5706832eac5568fb6d20fe2095790349598 (diff)
downloadffmpeg-d7af6d146983f8a63304fffb8535787f9e7bdee9.tar.gz
avcodec/utils: calculate frame number of HEVC if the framerate > 30FPS
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1814b417fc..14cb5cf1aa 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2213,7 +2213,7 @@ static unsigned bcd2uint(uint8_t bcd)
return low + 10*high;
}
-int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
+int ff_alloc_timecode_sei(const AVFrame *frame, AVRational rate, size_t prefix_len,
void **data, size_t *sei_size)
{
AVFrameSideData *sd = NULL;
@@ -2249,6 +2249,17 @@ int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
unsigned drop = tcsmpte & 1<<30 && !0; // 1-bit drop if not arbitrary bit
+ /* Calculate frame number of HEVC by SMPTE ST 12-1:2014 Sec 12.2 if rate > 30FPS */
+ if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
+ unsigned pc;
+ ff *= 2;
+ if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
+ pc = !!(tcsmpte & 1 << 7);
+ else
+ pc = !!(tcsmpte & 1 << 23);
+ ff = (ff + pc) & 0x7f;
+ }
+
put_bits(&pb, 1, 1); // clock_timestamp_flag
put_bits(&pb, 1, 1); // units_field_based_flag
put_bits(&pb, 5, 0); // counting_type