From patchwork Fri Jul 17 13:26:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 21141 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 4BAD344B1C3 for ; Fri, 17 Jul 2020 16:26:52 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 218A968B660; Fri, 17 Jul 2020 16:26:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A41668002C for ; Fri, 17 Jul 2020 16:26:45 +0300 (EEST) Received: by mail-pf1-f173.google.com with SMTP id a14so5393444pfi.2 for ; Fri, 17 Jul 2020 06:26:45 -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=fv2HRDvqGtv0fGBKu2WhE2F3LpfBJDfRLA7jGsvqYVA=; b=KZqYwlAJ4VRyjuLvmdei0ox3zaTCCJxnafV347FQYoOC9x5owBKf3o3lMLEUjHlh9c GI6UOkaxlJr4U5bm5vFNpqk42DWM0v5Q6GEDOE2C0ZEmtGBbiohcotvZeQo8jn2BIuZA JhxqkJiAdwzvZpAXOvTE0nCuMi4lHaND1cc6eyPd0C3Xjwu4Msn+Z3lwLaj1LQk7KOzx LMC8F9pSBp4D6TMSXDN1JPCvItFCLbnexX6xpYazolX5vY418buFgWfWhEdtNRJZwTEw Nq3WssNv9n9aT6UI0GhPCDG5XxKWaB++u+LJxJHi2pDwho4Pe/SM1LzBROogbrYLdUGY BTOg== 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=fv2HRDvqGtv0fGBKu2WhE2F3LpfBJDfRLA7jGsvqYVA=; b=f703hrSdYnhLTmz2fYnX4kGv4CRYGTQG3BEtarDZ/bUpQ+AmRk66ychlxctl7ze39T qfjRHr1jD96BHr3Oo7L5LFKwQeynfiS1F2LoT9Me3tQBoTLaOnuNJnj2zmLxKzzs2yoW YUsjfRna96+3ErUoDTIZ/Y/ozcflhli2ylKOFyy8sC7b7lc2e36G23Skv8SnCP74TxiU Jy1GT6EaoXLaZ5Z94i4ON6BUSOjsWg0elfy4cdeze9QwE3GK5FvXA0uCQJSmK5oSq6ai rUOhLSXfQ/f8DtcjXzVKzvgBKGjSJRvq3buBD0K29Mle7lGLGdEEDyvQmMH1ZuebQF1d OZtA== X-Gm-Message-State: AOAM531WxvimuxMjvwrEWA81uZSqt6LwG48CjEF4pDjaVpaMzsU5LZQ7 B4d1HinsExBm4A+/XYPYDoolHTUY X-Google-Smtp-Source: ABdhPJwFrWceIaEROuVM5Nls2iAMO0igAmlqeZLOfzsvwZmByrcRsoiKz5elnyyXJuMz8GfyD8nMDw== X-Received: by 2002:a63:3151:: with SMTP id x78mr8901075pgx.210.1594992403117; Fri, 17 Jul 2020 06:26:43 -0700 (PDT) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id t184sm8368078pfd.49.2020.07.17.06.26.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2020 06:26:42 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 17 Jul 2020 21:26:37 +0800 Message-Id: <1594992398-29104-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 Subject: [FFmpeg-devel] [PATCH 1/2] avdevice/decklink_dec: mark the field flag if framerate > 30FPS 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 In SMPTE ST 12-1: 2014 Sec 12.2, we need to mark the frame flag if the frame rate > 30FPS to avoid interoperability issues. It will be used by the encoder to identify even or odd frames and correctly calculate the frame number of the SEI TC. --- libavdevice/decklink_common.h | 1 + libavdevice/decklink_dec.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index bd68c7b..8ddc411 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -151,6 +151,7 @@ struct decklink_ctx { int channels; int audio_depth; unsigned long tc_seen; // used with option wait_for_tc + uint32_t last_tc; }; typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t; diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index dde68ff..a60c01b 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -884,12 +884,26 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( int metadata_len; uint8_t* packed_metadata; AVTimecode tcr; + AVRational rate = ctx->video_st->r_frame_rate; if (av_timecode_init_from_string(&tcr, ctx->video_st->r_frame_rate, tc, ctx) >= 0) { uint32_t tc_data = av_timecode_get_smpte_from_framenum(&tcr, 0); int size = sizeof(uint32_t) * 4; uint32_t *sd = (uint32_t *)av_packet_new_side_data(&pkt, AV_PKT_DATA_S12M_TIMECODE, size); + /* set the field flag if frame rate > 30FPS */ + /* Refer to SMPTE ST 12-1:2014 Sec 12.2 */ + if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) { + /* Odd frame */ + if (ctx->last_tc == tc_data) { + if (av_cmp_q(rate, (AVRational) {50, 1}) == 0) + tc_data |= (1 << 7); + else + tc_data |= (1 << 23); + } + } + ctx->last_tc = tc_data; + if (sd) { *sd = 1; // one TC *(sd + 1) = tc_data; // TC