From patchwork Tue Jul 14 23:29:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21021 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 8C4DB44BBA3 for ; Wed, 15 Jul 2020 02:30:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 51F6E68A964; Wed, 15 Jul 2020 02:30:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94B5568096E for ; Wed, 15 Jul 2020 02:30:17 +0300 (EEST) Received: by mail-pg1-f171.google.com with SMTP id l63so100619pge.12 for ; Tue, 14 Jul 2020 16:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4sX6II+E84rMNDEU7qEihAaa6pZkBT5UuoKa7179gOE=; b=uWGtsUaq6VRoIN8Y4f9j9m8+Cj2OajfEewzyhu/4zN0LnfFmaoEI6CwADOjtjryNBB ocmLEJPXoDwkJtylD9fbZCA8DXSulhLZGH+xr/CI9f2O/YTI57stypvOP9K0DE7S4nRn g072UaeU0kApZdBlD026R1N8GEU/JthemjcCa0aK18adxY8zzAf1/v2NyS0j4qFlZbw8 P+Fpq4jsyh9MaDNj+ahYgj31Xukjro/6h4OnTrLOV14vd6blkWeNBVsRJ6h6GdR5ltS6 Ygp/hMtQFSB1+lCWfZEC20BV/LQeQIsLAvsbfNyqVkPvHHjBytDBkfrkWE+pX9MXE6HK YrZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4sX6II+E84rMNDEU7qEihAaa6pZkBT5UuoKa7179gOE=; b=Kng7RJUVBbtQtY8jCSrqMumvHk5e7s6k7mAwEVZwhxmKyXIUCYja+AKEmSX3NDVwWC WWHIGQYAiXakK1ewdtDqj3bgMbvmsPehxrdvf+Usz/kdbDPQSOwBhShY+OzJGLsZAqhp EhVweUT2eAatzYOUpGhgq37XscpU5J+2HvM43QeUHqKurw9mYoGTMbX0a9tsrpquQspT 7pB99u4drGTAEflsRohXDAGuhKgKvy5UwwmVJSFIdazerxHPNPOTjwz1ui3HAawMdssg k1QK++M6GuxZaYrb1oHTLtd6yIxl6hI/1ahvhNRNIlpG4ogJqE0IDCL2fjfDa/j4BPEX DBpA== X-Gm-Message-State: AOAM530tYTLsUKgz1P4O0/dOE+g2GTvSSavHSqOIoQrDS8bDJ1wmsJ4G BRD7YJBvmWxTQUU9YBb/j5142Aws X-Google-Smtp-Source: ABdhPJwr7hZ1Uk0UactVKhNu16lFUVaTlmK2sKbLC3iSdN5kELxfNRXAnLNs5bfhq2T6GH47UFb3OQ== X-Received: by 2002:a63:7c42:: with SMTP id l2mr5460125pgn.35.1594769415214; Tue, 14 Jul 2020 16:30:15 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:14 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:29:57 +0800 Message-Id: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH 1/6] avcodec: add AV_CODEC_EXPORT_DATA_S12M_TC flag to export S12M timecode 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- doc/APIchanges | 3 +++ doc/codecs.texi | 3 +++ libavcodec/avcodec.h | 4 ++++ libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 67f2ac3..2811ee7 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-07-xx - xxxxxxxxxx - lavc 58.97.100 - avcodec.h + Add AV_CODEC_EXPORT_DATA_S12M_TC. + 2020-07-xx - xxxxxxxxxx - lavc 58.96.100 - packet.h Add AV_PKT_DATA_S12M_TIMECODE. diff --git a/doc/codecs.texi b/doc/codecs.texi index c092aad..263da9c 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -816,6 +816,9 @@ for codecs that support it. See also @file{doc/examples/export_mvs.c}. @item prft Export encoder Producer Reference Time into packet side-data (see @code{AV_PKT_DATA_PRFT}) for codecs that support it. +@item s12m_tc +Export SMPTE ST 12-1 timecode through packet side data (see @code{AV_PKT_DATA_S12M_TIMECODE}) +for codecs that support it. @end table @item error @var{integer} (@emph{encoding,video}) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index c91b2fd..f8420c0 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -410,6 +410,10 @@ typedef struct RcOverride{ * Export the AVVideoEncParams structure through frame side data. */ #define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2) +/** + * Export SMPTE ST 12-1 timecode through packet side data + */ +#define AV_CODEC_EXPORT_DATA_S12M_TC (1 << 3) /** * Pan Scan area. diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 8ba137f..dcedfbb 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -83,6 +83,7 @@ static const AVOption avcodec_options[] = { {"mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_MVS}, INT_MIN, INT_MAX, V|D, "export_side_data"}, {"prft", "export Producer Reference Time through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, A|V|S|E, "export_side_data"}, {"venc_params", "export video encoding parameters through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, INT_MAX, V|D, "export_side_data"}, +{"s12m_tc", "export SMPTE ST 12-1 timecode through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_S12M_TC}, INT_MIN, INT_MAX, V|D, "export_side_data"}, {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, diff --git a/libavcodec/version.h b/libavcodec/version.h index ad0bfd6..d5dca8c 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 96 +#define LIBAVCODEC_VERSION_MINOR 97 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ From patchwork Tue Jul 14 23:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21022 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 8E64644BBA3 for ; Wed, 15 Jul 2020 02:30:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7987A68AD50; Wed, 15 Jul 2020 02:30:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0081668096E for ; Wed, 15 Jul 2020 02:30:18 +0300 (EEST) Received: by mail-pj1-f43.google.com with SMTP id md7so174525pjb.1 for ; Tue, 14 Jul 2020 16:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hrlRFyqt+Vd9CANIUrKkJLCi8ePR4hn8509Bu0ufKyY=; b=i7YLwodj3uwk69FA361G8Ue/9h469vdONHXpZP/HpKz5rsKjfqSeKDXgLULMUIM1bW FSbW1YfoyUmBIVfibOlNXsfMPabAuzBxYbqmXjt8wW/oLhTIO0U36hxGslxoox8t/Jsb M892y7WBtfLhsvmccvfYzFAntCgY1nUSPZ4in8/XdZnLh8zPEtbhYLF42+0+AOenqaJE 3QWvwtgFQixzQLHH7cU9pHqvX1KBPXMWYmxsw6hKm14cECCxQbDPSrQyEsKB6wnyFB3g 7SHJi0B6GGWXmAZrT4HYBgjQyXu64xGlUjd/SfRYW647AzsjDFbqvXjmev1OgXMq0J3S 3ezQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hrlRFyqt+Vd9CANIUrKkJLCi8ePR4hn8509Bu0ufKyY=; b=UOHBtxmQir8/Fq0jfgKklwCjQKBnm2QJx9TJ9dEi3yRrMkZw0O+wScUJ6c6Dsn6F+z 70nSI2IGREx5kXPd5psTRVxZ4IwRwtFsE7myHBZJo4Zf/JT3WQ9lVfW5Gl7aBhhyRepU 7gDbUexjnbyp4tRolkQaGlvq84rUTZ05jDjNUuNpTvE+6ldXYp9Xd5Ff3fWbQqZ99j4P DrmiBH6fd4a5db1+NSNq0zZb5pYAHeQHeky3qt1zKHlt9UL/DX+ntoTgYVLijxuQB/BR 0xUjjPk4tDwBsEzgW0e31Bhhjg0OtcIdKWRvS6rV0IdQm2nnCS0zFU9FFGvwgAkiUerS 4K5g== X-Gm-Message-State: AOAM530SBzENJG5tDq6zxNdYgRbEBPJ6AivY8tW1/LVQmT4oqYrsKCVF n1Wi+omhzqrsLsK11YI8COHuTwlI X-Google-Smtp-Source: ABdhPJxNb364D1Er0tBU+viF3Otgj50EBRuDji5GeNImKnNKhvfLx8hqK21OeCROuLhu67lOdjSClw== X-Received: by 2002:a17:90a:de03:: with SMTP id m3mr6836864pjv.130.1594769416709; Tue, 14 Jul 2020 16:30:16 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:16 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:29:58 +0800 Message-Id: <1594769402-22526-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> References: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/utils: add ff_add_s12m_timecode_side_data() 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/internal.h | 5 +++++ libavcodec/utils.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 0a1c0a1..e0040fc 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -364,6 +364,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame); AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx); /** + * Add a S12M timecode side data to an codec context. + */ +uint32_t *ff_add_s12m_timecode_side_data(AVCodecContext *avctx); + +/** * Check AVFrame for A53 side data and allocate and fill SEI message with A53 info * * @param frame Raw frame to get A53 side data from diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 2ece34f..270c0c4 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2029,6 +2029,36 @@ AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx) return props; } +uint32_t *ff_add_s12m_timecode_side_data(AVCodecContext *avctx) +{ + AVPacketSideData *tmp; + uint32_t *data; + int size = sizeof(uint32_t) * 4; + int i; + + for (i = 0; i < avctx->nb_coded_side_data; i++) + if (avctx->coded_side_data[i].type == AV_PKT_DATA_S12M_TIMECODE) + return (uint32_t*)avctx->coded_side_data[i].data; + + data = av_mallocz(size); + if (!data) + return NULL; + + tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp)); + if (!tmp) { + av_freep(&data); + return NULL; + } + avctx->coded_side_data = tmp; + + avctx->coded_side_data[avctx->nb_coded_side_data].type = AV_PKT_DATA_S12M_TIMECODE; + avctx->coded_side_data[avctx->nb_coded_side_data].data = (uint8_t *)data; + avctx->coded_side_data[avctx->nb_coded_side_data].size = size; + avctx->nb_coded_side_data++; + + return data; +} + static void codec_parameters_reset(AVCodecParameters *par) { av_freep(&par->extradata); From patchwork Tue Jul 14 23:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21025 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 AAFD444585D for ; Wed, 15 Jul 2020 02:36:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B62568AE37; Wed, 15 Jul 2020 02:36:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFA9768AE37 for ; Wed, 15 Jul 2020 02:36:16 +0300 (EEST) Received: by mail-pg1-f195.google.com with SMTP id n5so153262pgf.7 for ; Tue, 14 Jul 2020 16:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PfPUDPSKlE0UFQ70ymGHanTWNYyRlQ2O90Vn/IHc0H8=; b=LNZ7G+JRS/i4aS84NpCHI37aNzLU1Atggb+KHJeT0trlTp2gqAi6LP3tI9kieoMry8 D626n5DKfI8ZBgGO5F2AHofvmaDbLKwagCziovO5R+MKzRqYvF0Le8iat+l0mwt8Skkx 6FUs3d14IjgJH2MhnIopbtKzBdaqaE0UYudMcdhK1gr0ScXptqc/+kziXrn31hCE3yKf vHVW+VMGxm2VLUx5fYTLQG7jJf+GwDGsGAvfbg3a5mvIASDqVRyIpvruDWokdMdo14S/ ErD66XCS1Szr1+2Igt/zaARTi2CG7LO477y8p4FXWFh/CCrW7HKFjEELCfllExBg4sUt PK2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PfPUDPSKlE0UFQ70ymGHanTWNYyRlQ2O90Vn/IHc0H8=; b=qKZkeRm54iEIMpPr9pQhmsCrIm/hA8aiYIla0jeRDNoBn/87G9DjvEEa2wK7ryMd+V vQ2GeOHvKc5YVswu49Zfs8KiVBtoRIj//o6afV9v8bMsM8S9NslivgDKrMSf3Q+DHzZb AdAauweDJc+RImnz+xgPtx8c70gdpqJovQW6oixmz7iv5Lq6TC9BopwYyn7YuxZ+34dB LDgT9FnCnLJRauhLzE6XBXXYdCJ71m+CKtuZQd6DEOgGe090T5rkcTgmy/3/SPAvPp1F XdSlK8CKujOR4E9xFW3fDIVz/RNUhS3Jz0ztkz5Oi4YkSb14tqOK5Hr7tLPPKlcjjNyE HVQA== X-Gm-Message-State: AOAM533d0ku3ZTTumu5lqlUVb3uybnX2ezCBdGt8C4hIJVTTKqtFUR/G FIDlvbNJbICmGgifRDPjv/gFp48r X-Google-Smtp-Source: ABdhPJxLPuxQZuIx84uDS9pYNz27Eyx74hlU8k1jLaV36sKydZFBo7k1sj5RwKsXOea4mWa522hI8g== X-Received: by 2002:a17:902:6a8b:: with SMTP id n11mr5754487plk.264.1594769418273; Tue, 14 Jul 2020 16:30:18 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:17 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:29:59 +0800 Message-Id: <1594769402-22526-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> References: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/h264_slice: export S12M timecode side data 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/h264_slice.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index c7b2764..db720de 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1307,6 +1307,7 @@ static int h264_export_frame_props(H264Context *h) if (h->sei.picture_timing.timecode_cnt > 0) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; + uint32_t *s12m_sd; AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, @@ -1316,6 +1317,12 @@ static int h264_export_frame_props(H264Context *h) tc_sd = (uint32_t*)tcside->data; tc_sd[0] = h->sei.picture_timing.timecode_cnt; + if (h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) { + s12m_sd = ff_add_s12m_timecode_side_data(h->avctx); + if (!s12m_sd) + return AVERROR(ENOMEM); + s12m_sd[0] = tc_sd[0]; + } for (int i = 0; i < tc_sd[0]; i++) { int drop = h->sei.picture_timing.timecode[i].dropframe; @@ -1325,6 +1332,9 @@ 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); + if (h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) { + s12m_sd[i + 1] = tc_sd[i + 1]; + } av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0); av_dict_set(&out->metadata, "timecode", tcbuf, 0); } From patchwork Tue Jul 14 23:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21023 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 5356A44BBA3 for ; Wed, 15 Jul 2020 02:30:29 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BE9D68A9BB; Wed, 15 Jul 2020 02:30:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E436468AF66 for ; Wed, 15 Jul 2020 02:30:21 +0300 (EEST) Received: by mail-pl1-f195.google.com with SMTP id o1so61825plk.1 for ; Tue, 14 Jul 2020 16:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NtRbK0VYoJMuLUU8F1ljekxTxLkM6lfZgGf26xreUbM=; b=IKD2cl44J3+9IiNJ9OfLT2S6sQDc1SFIm6hmvFX1iOsqF7+ayPPP8wlF9puJ3XDm8R igxuqlKuDFu1LQxaevWZuLVNBghaxjupPH3VR96giLO+L65HMZ3OQDxgP5vQl3VS+Xej KlF+LLu+b9evtt/Je2PtxO7v9sZ1JeCkCJeHAIhSO+sjdW7dXUH4eUzBI0oExwEoaA5I FlShOpDIYNypSP4Oj0qTVw50x7aqicp5n8+Tz3cqKZSzBn0nhofo+jUUKddaFS3i6H13 /UtaxUQd/6tmzyhbCcRldsaL3wf0O3AkXJWWBRPKFHTgyLiVFfxElNhrqLY3/TZArGL5 wK5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NtRbK0VYoJMuLUU8F1ljekxTxLkM6lfZgGf26xreUbM=; b=ngXV5W2YEcjZ5RFX7nst58vZ9qA1nGOpDewMFI9lDKq0QM6wqcr99pAFf05BViGCXO /uiKMkgTNW9Yp5Pl8UOcDDBX+KLWzguHSV42o9dB773TRj16UtC3ZrCYi0BDIa2LA4kS og9XzeC7K2NEt9PQhGt+ou2VGSCNSnvH0XZrC6aIff8pAQ/L3Zo6qioeH659nZ34hVAl WTGAtYU8Skgu/gtWlAs/N7QVD/zBjWgtTRW68LkYXNBshJ+rJOkV1bu8sqkZF/9Rse4P 7nvQ5YTg4Qu3uv+0igYzA8BCmmkZQ6Ceui1U0B/JqpsLW3Xj64pzRt+euTlE0GVFO/J3 fKgg== X-Gm-Message-State: AOAM533UC7SjSzt+aeZsZP/uXypDi3pVMkA1L0wIHR6fNGH2IripS9cF el9k26WEzW8QQeL5mPWqcuGNlS/e X-Google-Smtp-Source: ABdhPJxxO7A7gHODnRoCEak1OY18KotfCTkvHm9VIqo5Kw5rnGJP+zSM5Uj5CQnCMyrllHzHMtcsUw== X-Received: by 2002:a17:902:fe90:: with SMTP id x16mr6016930plm.307.1594769419803; Tue, 14 Jul 2020 16:30:19 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:19 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:30:00 +0800 Message-Id: <1594769402-22526-4-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> References: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/hevcdec: export S12M timecode side data 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/hevcdec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b77df8d..6e24c9b 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2827,6 +2827,7 @@ static int set_side_data(HEVCContext *s) if (s->sei.timecode.present) { uint32_t *tc_sd; char tcbuf[AV_TIMECODE_STR_SIZE]; + uint32_t *s12m_sd; AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, sizeof(uint32_t) * 4); if (!tcside) @@ -2834,6 +2835,12 @@ static int set_side_data(HEVCContext *s) tc_sd = (uint32_t*)tcside->data; tc_sd[0] = s->sei.timecode.num_clock_ts; + if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) { + s12m_sd = ff_add_s12m_timecode_side_data(s->avctx); + if (!s12m_sd) + return AVERROR(ENOMEM); + s12m_sd[0] = tc_sd[0]; + } for (int i = 0; i < tc_sd[0]; i++) { int drop = s->sei.timecode.cnt_dropped_flag[i]; @@ -2843,6 +2850,9 @@ 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); + if (s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_S12M_TC) { + s12m_sd[i + 1] = tc_sd[i + 1]; + } av_timecode_make_smpte_tc_string(tcbuf, tc_sd[i + 1], 0); av_dict_set(&out->metadata, "timecode", tcbuf, 0); } From patchwork Tue Jul 14 23:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21026 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 84F1044585D for ; Wed, 15 Jul 2020 02:36:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6CAC268B2B3; Wed, 15 Jul 2020 02:36:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1614E68B205 for ; Wed, 15 Jul 2020 02:36:30 +0300 (EEST) Received: by mail-pg1-f196.google.com with SMTP id m22so148968pgv.9 for ; Tue, 14 Jul 2020 16:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C3OBCwkU3YBUhM3til2CjVPeyZfvn+qafblxPf+mOXw=; b=NUt2ydZPBdA8J7GX36T2vdl/t4Ho4gk3mR3aBV49//ZX6rqmN3lkKxOH1bx6gR5Z8/ uXsoKSXCqrEJhWXJU1cggw58jsFGZ4ZPJ75SVGE/Z7nNfAImk4urF5CHKc4gtsa/Hm4k vZvJyowmufpyoGvKiJ+8pcMc+qG0RZjvMUdo1tADpgMPPSpgFV89esccjiLRTdchSWeA MEPaw+BsRQ3zKXJDC4J+tA5+XXvNyuuqvLdtQZF8ovnkt/LHahCxWyC5Q3ohLCdIkXRr hXvThTvx6eFcRfS7hRLFO+kWySdboPO5gBOM9pnxkxs/PWojuQdKolv8BgM7deFbMWhE DAoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C3OBCwkU3YBUhM3til2CjVPeyZfvn+qafblxPf+mOXw=; b=M0sXGTm2AJ7ux8/Oa/Pah4m8+vE2cMGJgEbMIpbYkIPgGQE/DQe9TGK+edPrJTA0eQ 7w15dSr9m7meBX0nl29oCC6tRnz9tSbS0zH3cOC5a4TFz5UrGJIAapXV8UEJo5S3NOTG 43Emm3j/zBS6tph3sJRmeHQyjiBG27zSx+omAx5F5Xo9f2WKw9UpxVplQnk2iWGyYJYj R2BLC3yr+ZD+EqBSio25rrY7A5YkSfk58PA9wnpsbib+533RUCwEJ8gYBRM57pfv/hqH htK+qEOwwHL9pkF54Ezu6CU5RfJ5RbCRGiJIrX7NHb9W0gDD8eyPRvC9J9jV50TCiExV jrIA== X-Gm-Message-State: AOAM532vyF+OXNeTf/qzRMlMHJffzESQUaMLNFJb4QE1G4NM/WIaw82M 6Qa2UQpf+X87wX0g4D6puYOkBqiX X-Google-Smtp-Source: ABdhPJyBmQKCRxMP1/KW3qUobtrztB3PcHnyqWDXmT9LF6/XGjdPJvmQpKVhki93cQiQugiiuGtnYQ== X-Received: by 2002:a63:2d44:: with SMTP id t65mr5417091pgt.257.1594769421296; Tue, 14 Jul 2020 16:30:21 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:20 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:30:01 +0800 Message-Id: <1594769402-22526-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> References: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/6] avformat/movenc: use the stream s12m side data for tmcd track if available 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Please test with below command: ./ffmpeg -export_side_data s12m_tc -i ../fate-suite/h264/crew_cif_timecode-2.h264 out.mp4 Signed-off-by: Limin Wang --- libavformat/movenc.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7db2e28..ca2c8a1 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6402,12 +6402,25 @@ static int mov_init(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AVDictionaryEntry *t = global_tcr; + AVTimecode tc; + uint32_t *tc_sd = (uint32_t *)av_stream_get_side_data(st, AV_PKT_DATA_S12M_TIMECODE, + NULL); + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && (t || (t=av_dict_get(st->metadata, "timecode", NULL, 0)))) { - AVTimecode tc; ret = mov_check_timecode_track(s, &tc, i, t->value); if (ret >= 0) mov->nb_meta_tmcd++; + } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && tc_sd) { + char tcbuf[AV_TIMECODE_STR_SIZE]; + int m = tc_sd[0] & 3; + if ( m > 0) { + /* use the first timecode if more than one TC */ + av_timecode_make_smpte_tc_string(tcbuf, tc_sd[1], 0); + ret = mov_check_timecode_track(s, &tc, i, tcbuf); + if (ret >= 0) + mov->nb_meta_tmcd++; + } } } @@ -6724,12 +6737,27 @@ static int mov_write_header(AVFormatContext *s) if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { AVTimecode tc; + uint32_t *tc_sd = (uint32_t *)av_stream_get_side_data(st, AV_PKT_DATA_S12M_TIMECODE, + NULL); if (!t) t = av_dict_get(st->metadata, "timecode", NULL, 0); - if (!t) - continue; - if (mov_check_timecode_track(s, &tc, i, t->value) < 0) + if (t) { + if (mov_check_timecode_track(s, &tc, i, t->value) < 0) + continue; + } else if (tc_sd) { + char tcbuf[AV_TIMECODE_STR_SIZE]; + int m = tc_sd[0] & 3; + if ( m < 1) + continue; + + /* use the first timecode if more than one */ + av_timecode_make_smpte_tc_string(tcbuf, tc_sd[1], 0); + ret = mov_check_timecode_track(s, &tc, i, tcbuf); + if (ret < 0) + continue; + } else continue; + if ((ret = mov_create_timecode_track(s, tmcd_track, i, tc)) < 0) return ret; tmcd_track++; From patchwork Tue Jul 14 23:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21024 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 601DF44BBA3 for ; Wed, 15 Jul 2020 02:30:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C34868AF66; Wed, 15 Jul 2020 02:30:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD8BC68AFE9 for ; Wed, 15 Jul 2020 02:30:24 +0300 (EEST) Received: by mail-pf1-f194.google.com with SMTP id m9so41582pfh.0 for ; Tue, 14 Jul 2020 16:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Or56HTgsKKpTu93z5rpqHmE34lcwce+sPjUF7v3tEFA=; b=kZ25+ctm02evzD5JXiPAoQwLnW8zo2nHDZrsOWBQzXxMN/wJkR61d1WjcpcMbgKnd0 F54CoyiD9aClovfjkqW83gc+yL3QNEV4d97014PThpxw7z44C3AIIwI/ilIWYYYyDcou NyrwZqp1l6uBSkRLglYCg9fDXgG31vi/8wErR723zw6GmQk9FrdaCpD+H2ub3jJw4cd/ PmZQvqHWQdd81Jj8ERd+Bix2QiiNfefEMIhkjPXbGkb0FGKdmUH5ZME7PuTHoM/kelPj ILh8GL1MRlMk0JRav/sbEj2ru1e0SepLFz5NPnRGwWMz8ox9cK/jCnWuumovuD0Uxu2J 6Yng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Or56HTgsKKpTu93z5rpqHmE34lcwce+sPjUF7v3tEFA=; b=U0NwdBHiQBiD+0HCrFSUoblFy6PVNp+V77pypUgRomQzH+krIO3CTbGYS5BaXWlT7d CeYu0QWEFENO4ImKCUXfJ7hZN2a5VkDlBI6Awzaq8vmTiA6a1sHn0YObN1BhfC1EipP9 Of5L7VepcYWCDt/qD374otfPDvxrHL2IdMj8/IxYUG2Ol7yBPq5C9bEsH0W9S3AeQ/OW 6i3OBhEeWHiKhOle1dlvg8mshw17j9mv66vZbuwxWf6s5C9qmNKqr1ac5Ralm4/aZSVg oDbNzakfeinqsPrp/FZpaLjQZIp1FgC2B8NqC56uLcO7jfns1cHAG7O0LJnDl9Jo3VBu haiA== X-Gm-Message-State: AOAM530IcaPu8MBaehHR8vt3B399jC1myIdDgG5R42mqcclj5z3XAzyt Cg30y8F/zW1PoC0/NCKWBCZ6AmeK X-Google-Smtp-Source: ABdhPJyMA8ELfsSPa/xIlZIoKzjC2Em+iR+gyEfZuvM1YCmb2dUeRVccpcQvDwNUglxG2bdsD8Az+Q== X-Received: by 2002:a62:794e:: with SMTP id u75mr6308609pfc.298.1594769422854; Tue, 14 Jul 2020 16:30:22 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id y198sm212954pfg.116.2020.07.14.16.30.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2020 16:30:22 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Jul 2020 07:30:02 +0800 Message-Id: <1594769402-22526-6-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> References: <1594769402-22526-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH 6/6] avformat/dv: use the stream s12m side data for timecode track if avaiable 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/dvenc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c index b04d604..b5fea8f 100644 --- a/libavformat/dvenc.c +++ b/libavformat/dvenc.c @@ -396,6 +396,18 @@ static int dv_write_header(AVFormatContext *s) } if (tcr && av_timecode_init_from_string(&dvc->tc, rate, tcr->value, s) >= 0) return 0; + + for (int i = 0; i < s->nb_streams; i++) { + uint32_t *sd = (uint32_t *)av_stream_get_side_data(s->streams[i], + AV_PKT_DATA_S12M_TIMECODE, NULL); + if (sd && sd[0] > 0) { + char tcbuf[AV_TIMECODE_STR_SIZE]; + /* use the first timecode */ + av_timecode_make_smpte_tc_string(tcbuf, sd[1], 0); + return av_timecode_init_from_string(&dvc->tc, rate, tcbuf, s); + } + } + return av_timecode_init(&dvc->tc, rate, 0, 0, s); }