From patchwork Sat Sep 5 18:22:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22115 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B7C6144BABC for ; Sat, 5 Sep 2020 21:22:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9318368A9AA; Sat, 5 Sep 2020 21:22:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CC72680890 for ; Sat, 5 Sep 2020 21:22:23 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E8053E44A9; Sat, 5 Sep 2020 20:22:22 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4ZxiOFIUy41S; Sat, 5 Sep 2020 20:22:20 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 88A11E3898; Sat, 5 Sep 2020 20:22:20 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:10 +0200 Message-Id: <20200905182217.28037-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] avutil/timecode: fix av_timecode_get_smpte_from_framenum with 50/60 fps X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" SMPTE 12M timecode can only count frames up to 39, because the tens-of-frames value is stored in 2 bit. In order to resolve this 50/60 fps SMPTE timecode is using the field bit (which is the same bit as the phase correction bit) to signal the least significant bit of a 50/60 fps timecode. See SMPTE ST 12-1:2014 section 12.1. Therefore we slightly change the format of the return value of av_timecode_get_smpte_from_framenum and AV_FRAME_DATA_S12M_TIMECODE and start using the previously unused Phase Correction bit as Field bit. (As the SMPTE standard suggests) We add 50/60 fps support to av_timecode_get_smpte_from_framenum by calling the recently added av_timecode_get_smpte function in it which already handles this properly. This change affects the decklink indev and the DV and MXF muxers. MXF has no fate test for 50/60fps content, DV does, therefore the changes. MediaInfo (a recent version) confirms that half-frame timecode must be inserted to DV. MXFInspect confirms valid timecode insertion to the System Item of MXF files. For MXF, also see EBU R122. Note that for DV the field flag is not used because in the HDV specs (SMPTE 370M) it is still defined as biphase mark polarity correction flag. So it should not matter that the DV muxer overrides the field bit. Signed-off-by: Marton Balint --- libavutil/timecode.c | 15 +-------------- libavutil/timecode.h | 7 +++---- tests/ref/vsynth/vsynth1-dv-hd | 2 +- tests/ref/vsynth/vsynth2-dv-hd | 2 +- tests/ref/vsynth/vsynth3-dv-hd | 2 +- tests/ref/vsynth/vsynth_lena-dv-hd | 2 +- 6 files changed, 8 insertions(+), 22 deletions(-) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index cca53d73c4..cb916970ef 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -65,20 +65,7 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum) ss = framenum / fps % 60; mm = framenum / (fps*60) % 60; hh = framenum / (fps*3600) % 24; - return 0 << 31 | // color frame flag (0: unsync mode, 1: sync mode) - drop << 30 | // drop frame flag (0: non drop, 1: drop) - (ff / 10) << 28 | // tens of frames - (ff % 10) << 24 | // units of frames - 0 << 23 | // PC (NTSC) or BGF0 (PAL) - (ss / 10) << 20 | // tens of seconds - (ss % 10) << 16 | // units of seconds - 0 << 15 | // BGF0 (NTSC) or BGF2 (PAL) - (mm / 10) << 12 | // tens of minutes - (mm % 10) << 8 | // units of minutes - 0 << 7 | // BGF2 (NTSC) or PC (PAL) - 0 << 6 | // BGF1 - (hh / 10) << 4 | // tens of hours - (hh % 10); // units of hours + return av_timecode_get_smpte(tc->rate, drop, hh, mm, ss, ff); } uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff) diff --git a/libavutil/timecode.h b/libavutil/timecode.h index 5801330921..e54b116e93 100644 --- a/libavutil/timecode.h +++ b/libavutil/timecode.h @@ -66,11 +66,11 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps); * the format description as follows: * bits 0-5: hours, in BCD(6bits) * bits 6: BGF1 - * bits 7: BGF2 (NTSC) or PC (PAL) + * bits 7: BGF2 (NTSC) or FIELD (PAL) * bits 8-14: minutes, in BCD(7bits) * bits 15: BGF0 (NTSC) or BGF2 (PAL) * bits 16-22: seconds, in BCD(7bits) - * bits 23: PC (NTSC) or BGF0 (PAL) + * bits 23: FIELD (NTSC) or BGF0 (PAL) * bits 24-29: frames, in BCD(6bits) * bits 30: drop frame flag (0: non drop, 1: drop) * bits 31: color frame flag (0: unsync mode, 1: sync mode) @@ -78,8 +78,7 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps); * @note Frame number adjustment is automatically done in case of drop timecode, * you do NOT have to call av_timecode_adjust_ntsc_framenum2(). * @note The frame number is relative to tc->start. - * @note Color frame (CF), binary group flags (BGF) and biphase mark polarity - * correction (PC) bits are set to zero. + * @note Color frame (CF) and binary group flags (BGF) bits are set to zero. */ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum); diff --git a/tests/ref/vsynth/vsynth1-dv-hd b/tests/ref/vsynth/vsynth1-dv-hd index 6b6d6e8159..3f2f9cc843 100644 --- a/tests/ref/vsynth/vsynth1-dv-hd +++ b/tests/ref/vsynth/vsynth1-dv-hd @@ -1,4 +1,4 @@ -22d1d62a834fe8416fe79c51760012c1 *tests/data/fate/vsynth1-dv-hd.dv +b2bcafc74dec5f9ca516cb25dd07459b *tests/data/fate/vsynth1-dv-hd.dv 14400000 tests/data/fate/vsynth1-dv-hd.dv 34b78cf725346c7f819c9d6209b8299a *tests/data/fate/vsynth1-dv-hd.out.rawvideo stddev: 4.30 PSNR: 35.45 MAXDIFF: 74 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth2-dv-hd b/tests/ref/vsynth/vsynth2-dv-hd index c6dcb5a953..0a5046e4ec 100644 --- a/tests/ref/vsynth/vsynth2-dv-hd +++ b/tests/ref/vsynth/vsynth2-dv-hd @@ -1,4 +1,4 @@ -4270e5d552e0a05193f44bff75c2d271 *tests/data/fate/vsynth2-dv-hd.dv +a9a4c750f7720e83d538d36c318be787 *tests/data/fate/vsynth2-dv-hd.dv 14400000 tests/data/fate/vsynth2-dv-hd.dv 15dbe911532aca81c67bdd2846419027 *tests/data/fate/vsynth2-dv-hd.out.rawvideo stddev: 1.75 PSNR: 43.26 MAXDIFF: 34 bytes: 7603200/ 7603200 diff --git a/tests/ref/vsynth/vsynth3-dv-hd b/tests/ref/vsynth/vsynth3-dv-hd index d069e6980e..11a51b18b8 100644 --- a/tests/ref/vsynth/vsynth3-dv-hd +++ b/tests/ref/vsynth/vsynth3-dv-hd @@ -1,4 +1,4 @@ -2f81f3ccec178ba2fd9d3e3b46f33670 *tests/data/fate/vsynth3-dv-hd.dv +63512193a0da09e15815c1be1b9c4fa5 *tests/data/fate/vsynth3-dv-hd.dv 14400000 tests/data/fate/vsynth3-dv-hd.dv a038ad7c3c09f776304ef7accdea9c74 *tests/data/fate/vsynth3-dv-hd.out.rawvideo stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 86700/ 86700 diff --git a/tests/ref/vsynth/vsynth_lena-dv-hd b/tests/ref/vsynth/vsynth_lena-dv-hd index aba756c5f1..8711b6fa2f 100644 --- a/tests/ref/vsynth/vsynth_lena-dv-hd +++ b/tests/ref/vsynth/vsynth_lena-dv-hd @@ -1,4 +1,4 @@ -01a61c53943a421fa6a5e03dbc205972 *tests/data/fate/vsynth_lena-dv-hd.dv +f17abb38ed2f416d57f3b956fae5dc82 *tests/data/fate/vsynth_lena-dv-hd.dv 14400000 tests/data/fate/vsynth_lena-dv-hd.dv 4db4175c80ea1f16b7ec303611b8873a *tests/data/fate/vsynth_lena-dv-hd.out.rawvideo stddev: 1.49 PSNR: 44.66 MAXDIFF: 27 bytes: 7603200/ 7603200 From patchwork Sat Sep 5 18:22:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22116 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C9D8244BABC for ; Sat, 5 Sep 2020 21:22:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A520668AC37; Sat, 5 Sep 2020 21:22:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4009168ABA8 for ; Sat, 5 Sep 2020 21:22:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 13290E3898; Sat, 5 Sep 2020 20:22:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2MRENVgcAF-l; Sat, 5 Sep 2020 20:22:23 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0F2D1E44BB; Sat, 5 Sep 2020 20:22:23 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:11 +0200 Message-Id: <20200905182217.28037-2-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] avutil/timecode: cosmetics on av_timecode_get_smpte X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavutil/timecode.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index cb916970ef..c0956adadb 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -71,31 +71,28 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum) uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff) { uint32_t tc = 0; - uint32_t frames; /* For SMPTE 12-M timecodes, frame count is a special case if > 30 FPS. See SMPTE ST 12-1:2014 Sec 12.1 for more info. */ if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { - frames = ff / 2; if (ff % 2 == 1) { if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) tc |= (1 << 7); else tc |= (1 << 23); } - } else { - frames = ff; + ff /= 2; } tc |= drop << 30; - tc |= (frames / 10) << 28; - tc |= (frames % 10) << 24; + tc |= (ff / 10) << 28; + tc |= (ff % 10) << 24; tc |= (ss / 10) << 20; tc |= (ss % 10) << 16; tc |= (mm / 10) << 12; tc |= (mm % 10) << 8; tc |= (hh / 10) << 4; - tc |= (hh % 10); + tc |= (hh % 10); return tc; } From patchwork Sat Sep 5 18:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22117 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CDE3444BABC for ; Sat, 5 Sep 2020 21:22:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5B4568AA40; Sat, 5 Sep 2020 21:22:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9678868AEBC for ; Sat, 5 Sep 2020 21:22:27 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 71C00E44BB; Sat, 5 Sep 2020 20:22:27 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q7wCcqe3nMIQ; Sat, 5 Sep 2020 20:22:25 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 33B8CE44CA; Sat, 5 Sep 2020 20:22:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:12 +0200 Message-Id: <20200905182217.28037-3-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avutil/timecode: do not trash bits on invalid av_timecode_get_smpte arguments X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The function has no way to return error, so let's clip or calculate modulo. Signed-off-by: Marton Balint --- libavutil/timecode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index c0956adadb..806638ddfc 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -84,6 +84,11 @@ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss ff /= 2; } + hh = hh % 24; + mm = av_clip(mm, 0, 59); + ss = av_clip(ss, 0, 59); + ff = ff % 40; + tc |= drop << 30; tc |= (ff / 10) << 28; tc |= (ff % 10) << 24; From patchwork Sat Sep 5 18:22:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22118 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 25D9344BABC for ; Sat, 5 Sep 2020 21:22:35 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E84D68B2D1; Sat, 5 Sep 2020 21:22:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CADF968B2B1 for ; Sat, 5 Sep 2020 21:22:28 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B7ACFE44A9; Sat, 5 Sep 2020 20:22:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gLkuyqI7Yhla; Sat, 5 Sep 2020 20:22:27 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B8ACBE44B0; Sat, 5 Sep 2020 20:22:26 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:13 +0200 Message-Id: <20200905182217.28037-4-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] avutil/timecode: add av_timecode_make_smpte_tc_string2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavutil/timecode.c | 19 ++++++++++++++++++- libavutil/timecode.h | 17 +++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0054908e1e..e2d7369c83 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-09-xx - xxxxxxxxxx - lavu 56.59.100 - timecode.h + Add av_timecode_make_smpte_tc_string2. + 2020-08-21 - xxxxxxxxxx - lavu 56.58.100 - avstring.h Deprecate av_d2str(). Use av_asprintf() instead. diff --git a/libavutil/timecode.c b/libavutil/timecode.c index 806638ddfc..f2db21c52c 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -136,16 +136,33 @@ static unsigned bcd2uint(uint8_t bcd) return low + 10*high; } -char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df) +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); + } + } + snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u", hh, mm, ss, drop ? ';' : ':', ff); return buf; + +} + +char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df) +{ + return av_timecode_make_smpte_tc_string2(buf, (AVRational){30, 1}, tcsmpte, prevent_df, 1); } char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit) diff --git a/libavutil/timecode.h b/libavutil/timecode.h index e54b116e93..f9471a6e38 100644 --- a/libavutil/timecode.h +++ b/libavutil/timecode.h @@ -109,6 +109,23 @@ uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss */ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum); +/** + * Get the timecode string from the SMPTE timecode format. + * + * In contrast to av_timecode_make_smpte_tc_string this function supports 50/60 + * fps timecodes by using the field bit. + * + * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long + * @param rate frame rate of the timecode + * @param tcsmpte the 32-bit SMPTE timecode + * @param prevent_df prevent the use of a drop flag when it is known the DF bit + * is arbitrary + * @param skip_field prevent the use of a field flag when it is known the field + * bit is arbitrary (e.g. because it is used as PC flag) + * @return the buf parameter + */ +char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field); + /** * Get the timecode string from the SMPTE timecode format. * diff --git a/libavutil/version.h b/libavutil/version.h index 3f0a4a8402..7028bd2c88 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 58 +#define LIBAVUTIL_VERSION_MINOR 59 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Sat Sep 5 18:22:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22119 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 650DD44BABC for ; Sat, 5 Sep 2020 21:22:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4EE3D68B34B; Sat, 5 Sep 2020 21:22:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B8625680890 for ; Sat, 5 Sep 2020 21:22:32 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A4C9EE44BB; Sat, 5 Sep 2020 20:22:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nIs3f2y2dY-F; Sat, 5 Sep 2020 20:22:30 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9DF9DE44B0; Sat, 5 Sep 2020 20:22:29 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:14 +0200 Message-Id: <20200905182217.28037-5-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] fftools/ffprobe: use av_timecode_make_smpte_tc_string2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- fftools/ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index d4e494f11f..86bd23d36d 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2225,7 +2225,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream, writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_TIMECODE_LIST); for (int j = 1; j <= m ; j++) { char tcbuf[AV_TIMECODE_STR_SIZE]; - av_timecode_make_smpte_tc_string(tcbuf, tc[j], 0); + av_timecode_make_smpte_tc_string2(tcbuf, stream->avg_frame_rate, tc[j], 0, 0); writer_print_section_header(w, SECTION_ID_FRAME_SIDE_DATA_TIMECODE); print_str("value", tcbuf); writer_print_section_footer(w); From patchwork Sat Sep 5 18:22:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22121 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7E70E44BABC for ; Sat, 5 Sep 2020 21:22:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6891068B50F; Sat, 5 Sep 2020 21:22:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B726B68B494 for ; Sat, 5 Sep 2020 21:22:36 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0274BE44A9; Sat, 5 Sep 2020 20:22:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id agxVxPkj4Q60; Sat, 5 Sep 2020 20:22:33 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8D5B3E3898; Sat, 5 Sep 2020 20:22:33 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:15 +0200 Message-Id: <20200905182217.28037-6-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] avcodec: use av_timecode_make_smpte_tc_string2 in hevc and h264 decoder X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavcodec/h264_slice.c | 2 +- libavcodec/hevcdec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index c7b2764270..cfc29e186c 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1325,7 +1325,7 @@ static int h264_export_frame_props(H264Context *h) int ff = h->sei.picture_timing.timecode[i].frame; tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); - av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0); + av_timecode_make_smpte_tc_string2(tcbuf, h->avctx->framerate, tc_sd[i + 1], 0, 0); av_dict_set(&out->metadata, "timecode", tcbuf, 0); } h->sei.picture_timing.timecode_cnt = 0; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b77df8d89f..c1de75abe1 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2843,7 +2843,7 @@ static int set_side_data(HEVCContext *s) int ff = s->sei.timecode.n_frames[i]; tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); - av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0); + av_timecode_make_smpte_tc_string2(tcbuf, s->avctx->framerate, tc_sd[i + 1], 0, 0); av_dict_set(&out->metadata, "timecode", tcbuf, 0); } From patchwork Sat Sep 5 18:22:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22122 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5B1F544BABC for ; Sat, 5 Sep 2020 21:22:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4223168B4FD; Sat, 5 Sep 2020 21:22:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BF4368B32D for ; Sat, 5 Sep 2020 21:22:38 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1058AE3898; Sat, 5 Sep 2020 20:22:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1GhJoic04B_B; Sat, 5 Sep 2020 20:22:36 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 52B8CE44B0; Sat, 5 Sep 2020 20:22:35 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:16 +0200 Message-Id: <20200905182217.28037-7-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] avfilter/vf_showinfo: use av_timecode_make_smpte_tc_string2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavfilter/vf_showinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 1be939614d..c63e6f075f 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -114,7 +114,7 @@ static void dump_stereo3d(AVFilterContext *ctx, AVFrameSideData *sd) av_log(ctx, AV_LOG_INFO, " (inverted)"); } -static void dump_s12m_timecode(AVFilterContext *ctx, AVFrameSideData *sd) +static void dump_s12m_timecode(AVFilterContext *ctx, AVFilterLink *link, AVFrameSideData *sd) { const uint32_t *tc = (const uint32_t *)sd->data; @@ -125,7 +125,7 @@ static void dump_s12m_timecode(AVFilterContext *ctx, AVFrameSideData *sd) for (int j = 1; j <= tc[0]; j++) { char tcbuf[AV_TIMECODE_STR_SIZE]; - av_timecode_make_smpte_tc_string(tcbuf, tc[j], 0); + av_timecode_make_smpte_tc_string2(tcbuf, link->frame_rate, tc[j], 0, 0); av_log(ctx, AV_LOG_INFO, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : ""); } } @@ -380,7 +380,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) dump_stereo3d(ctx, sd); break; case AV_FRAME_DATA_S12M_TIMECODE: { - dump_s12m_timecode(ctx, sd); + dump_s12m_timecode(ctx, inlink, sd); break; } case AV_FRAME_DATA_DISPLAYMATRIX: From patchwork Sat Sep 5 18:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 22120 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7845744BABC for ; Sat, 5 Sep 2020 21:22:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C27668B45C; Sat, 5 Sep 2020 21:22:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B04E068B32D for ; Sat, 5 Sep 2020 21:22:41 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 872E4E44BB; Sat, 5 Sep 2020 20:22:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z7YVQSS7p96P; Sat, 5 Sep 2020 20:22:40 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 29CABE44B0; Sat, 5 Sep 2020 20:22:39 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Sep 2020 20:22:17 +0200 Message-Id: <20200905182217.28037-8-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200905182217.28037-1-cus@passwd.hu> References: <20200905182217.28037-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] avformat: use av_timecode_make_smpte_tc_string2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" WSD format has no frames stored for playback time. Signed-off-by: Marton Balint --- libavformat/dump.c | 6 +++--- libavformat/dv.c | 2 +- libavformat/wsddec.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavformat/dump.c b/libavformat/dump.c index 6d29d85d1f..fe628010d3 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -408,7 +408,7 @@ static void dump_dovi_conf(void *ctx, const AVPacketSideData *sd) dovi->dv_bl_signal_compatibility_id); } -static void dump_s12m_timecode(void *ctx, const AVPacketSideData *sd) +static void dump_s12m_timecode(void *ctx, const AVStream *st, const AVPacketSideData *sd) { const uint32_t *tc = (const uint32_t *)sd->data; @@ -419,7 +419,7 @@ static void dump_s12m_timecode(void *ctx, const AVPacketSideData *sd) for (int j = 1; j <= tc[0]; j++) { char tcbuf[AV_TIMECODE_STR_SIZE]; - av_timecode_make_smpte_tc_string(tcbuf, tc[j], 0); + av_timecode_make_smpte_tc_string2(tcbuf, st->avg_frame_rate, tc[j], 0, 0); av_log(ctx, AV_LOG_INFO, "timecode - %s%s", tcbuf, j != tc[0] ? ", " : ""); } } @@ -492,7 +492,7 @@ static void dump_sidedata(void *ctx, const AVStream *st, const char *indent) break; case AV_PKT_DATA_S12M_TIMECODE: av_log(ctx, AV_LOG_INFO, "SMPTE ST 12-1:2014: "); - dump_s12m_timecode(ctx, sd); + dump_s12m_timecode(ctx, st, sd); break; default: av_log(ctx, AV_LOG_INFO, diff --git a/libavformat/dv.c b/libavformat/dv.c index d25641daac..3e0d12c0e3 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -315,7 +315,7 @@ static int dv_extract_timecode(DVDemuxContext* c, const uint8_t* frame, char *tc tc_pack = dv_extract_pack(frame, dv_timecode); if (!tc_pack) return 0; - av_timecode_make_smpte_tc_string(tc, AV_RB32(tc_pack + 1), prevent_df); + av_timecode_make_smpte_tc_string2(tc, av_inv_q(c->sys->time_base), AV_RB32(tc_pack + 1), prevent_df, 1); return 1; } diff --git a/libavformat/wsddec.c b/libavformat/wsddec.c index 2313b0ec4b..74db6acdab 100644 --- a/libavformat/wsddec.c +++ b/libavformat/wsddec.c @@ -120,7 +120,7 @@ static int wsd_read_header(AVFormatContext *s) } avio_skip(pb, 4); - av_timecode_make_smpte_tc_string(playback_time, avio_rb32(pb), 0); + av_timecode_make_smpte_tc_string2(playback_time, (AVRational){1,1}, avio_rb32(pb) & 0x00ffffffU, 1, 1); av_dict_set(&s->metadata, "playback_time", playback_time, 0); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;