From patchwork Wed Jun 24 13:43:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 20571 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 5EAF944AEEF for ; Wed, 24 Jun 2020 16:44:15 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4CBDE68B56F; Wed, 24 Jun 2020 16:44:15 +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 9926468B566 for ; Wed, 24 Jun 2020 16:44:07 +0300 (EEST) Received: by mail-pg1-f195.google.com with SMTP id r18so1431403pgk.11 for ; Wed, 24 Jun 2020 06:44:07 -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=elOKEXZ8l1d+mFaz4lCUc+XmND73gLhF9DoWHIIIP4E=; b=ms8dV7/LvdZdqZIn+Vxr6HGuLhUqbpNUz/sAWDM5/JKJ5qTR0POHfeYIBtbnbMJD68 UPpU4HHlZk3nAvp3s9vmnozdZ5oDSvw0+/vkbBX9Yqoc3t8/a+RUXzM9FL+wsDYtc859 vJQ6zhh2Fbefz6XRvgyCe9UbplLccT4h7CPEGgrQVxUWk2fPaR61/2mEnnXN3EC8/ra/ o2d9AgSOzLc+Uvsl0YWB1ejNVSKpVDjKxzUcSoTScA2CqIT+OK8pDRmI8RiE5tjEPtBx Ia6w7MoO6IZg2Q9vH0vqaXlXfU5TTkCNwWYuoCcZ/sACH9WhObLZnluT9U6BT745LUEx x8JA== 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=elOKEXZ8l1d+mFaz4lCUc+XmND73gLhF9DoWHIIIP4E=; b=kZ36+8R4+XjPE11oKJW8Nw3LoYi5nqrt57/ptY66Wvc/rfRmN9TmGiB5Qdy7NGyvXl T+7+NYtxLZDLgqQGPrukxihqJx3CKjXonM3vBzt6ngDpSlS2228xDuHucNZ7A3WaO3jo UcTepjtw6SDGJ17BNIoXIxC1y8euiCb3W0s0nPML+hAf+jP3X5J2+vGEUbYDaQd82nJu Rw0FjQ4bdeq2d/lxOf0jHkGiMij3Ecto0T5Lc9ZP2We/rbmp46151Z7TSspSSHpymEJm BDkyjyxYuC1qkMl/XUzm6DTwLXAuvrZPsx9BTq9dOaPwcvz/pUC5BvJHVIX7QKzZFG2L 4+pw== X-Gm-Message-State: AOAM5309Ko4rS4PxxHzOUsQ7M9/0R9qJTvAVPwfOBxmA4+xiAY0OT4Ah iexZtb0t1d+5B+TQjPw5wSnoPuGO X-Google-Smtp-Source: ABdhPJxfTipkZd6SZZJHz7vX6z036+lQd86HqSNpocXdlxzdfLPSWccy3JtgJs2OKMebUCrjUJt36Q== X-Received: by 2002:a63:bf04:: with SMTP id v4mr16628495pgf.212.1593006245657; Wed, 24 Jun 2020 06:44:05 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id z144sm21622329pfc.195.2020.06.24.06.44.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2020 06:44:05 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jun 2020 21:43:16 +0800 Message-Id: <1593006200-23911-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1593006200-23911-1-git-send-email-lance.lmwang@gmail.com> References: <1592410030-6553-1-git-send-email-lance.lmwang@gmail.com> <1593006200-23911-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v4 3/7] avcodec/h264_slice: use 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: 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 | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 47f3917..2a41de2 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1304,7 +1304,6 @@ static int h264_export_frame_props(H264Context *h) h->sei.unregistered.nb_buf_ref = 0; if (h->sei.picture_timing.timecode_cnt > 0) { - uint32_t tc = 0; uint32_t *tc_sd; AVFrameSideData *tcside = av_frame_new_side_data(cur->f, @@ -1317,33 +1316,13 @@ static int h264_export_frame_props(H264Context *h) tc_sd[0] = h->sei.picture_timing.timecode_cnt; for (int i = 0; i < tc_sd[0]; i++) { - 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(h->avctx->framerate, (AVRational) {30, 1}) == 1) { - frames = h->sei.picture_timing.timecode[i].frame / 2; - if (h->sei.picture_timing.timecode[i].frame % 2 == 1) { - if (av_cmp_q(h->avctx->framerate, (AVRational) {50, 1}) == 0) - tc |= (1 << 7); - else - tc |= (1 << 23); - } - } else { - frames = h->sei.picture_timing.timecode[i].frame; - } + int drop = h->sei.picture_timing.timecode[i].dropframe; + int hh = h->sei.picture_timing.timecode[i].hours; + int mm = h->sei.picture_timing.timecode[i].minutes; + int ss = h->sei.picture_timing.timecode[i].seconds; + int ff = h->sei.picture_timing.timecode[i].frame; - tc |= h->sei.picture_timing.timecode[i].dropframe << 30; - tc |= (frames / 10) << 28; - tc |= (frames % 10) << 24; - tc |= (h->sei.picture_timing.timecode[i].seconds / 10) << 20; - tc |= (h->sei.picture_timing.timecode[i].seconds % 10) << 16; - tc |= (h->sei.picture_timing.timecode[i].minutes / 10) << 12; - tc |= (h->sei.picture_timing.timecode[i].minutes % 10) << 8; - tc |= (h->sei.picture_timing.timecode[i].hours / 10) << 4; - tc |= (h->sei.picture_timing.timecode[i].hours % 10); - - tc_sd[i + 1] = tc; + tc_sd[i + 1] = av_timecode_get_smpte(h->avctx->framerate, drop, hh, mm, ss, ff); } h->sei.picture_timing.timecode_cnt = 0; }