From patchwork Thu Nov 19 20:51:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23729 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 3060544AC04 for ; Thu, 19 Nov 2020 22:51:36 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 090FF68B8AF; Thu, 19 Nov 2020 22:51:36 +0200 (EET) 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 D259268B670 for ; Thu, 19 Nov 2020 22:51:29 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 477C3E4A4A; Thu, 19 Nov 2020 21:51:30 +0100 (CET) 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 Ot9FnEKnwslt; Thu, 19 Nov 2020 21:51:29 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D7CA6E4A2E; Thu, 19 Nov 2020 21:51:28 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:18 +0100 Message-Id: <20201119205123.21968-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] avutil/timecode: allow drop frame timecodes for multiples of 30000/1001 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" Signed-off-by: Marton Balint --- libavutil/timecode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index f2db21c52c..8fcdf320ee 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -196,8 +196,8 @@ static int check_timecode(void *log_ctx, AVTimecode *tc) av_log(log_ctx, AV_LOG_ERROR, "Valid timecode frame rate must be specified. Minimum value is 1\n"); return AVERROR(EINVAL); } - if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) { - av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n"); + if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps % 30 != 0) { + av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with multiples of 30000/1001 FPS\n"); return AVERROR(EINVAL); } if (check_fps(tc->fps) < 0) { @@ -252,7 +252,7 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st tc->start = (hh*3600 + mm*60 + ss) * tc->fps + ff; if (tc->flags & AV_TIMECODE_FLAG_DROPFRAME) { /* adjust frame number */ int tmins = 60*hh + mm; - tc->start -= (tc->fps == 30 ? 2 : 4) * (tmins - tmins/10); + tc->start -= (tc->fps / 30 * 2) * (tmins - tmins/10); } return 0; } From patchwork Thu Nov 19 20:51:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23730 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 355C244AC04 for ; Thu, 19 Nov 2020 22:51:40 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1923968B8A9; Thu, 19 Nov 2020 22:51:40 +0200 (EET) 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 B8FBB68B881 for ; Thu, 19 Nov 2020 22:51:33 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3671FE4A56; Thu, 19 Nov 2020 21:51:34 +0100 (CET) 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 ODuv3ztuY8wY; Thu, 19 Nov 2020 21:51:32 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3838FE4A2E; Thu, 19 Nov 2020 21:51:32 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:19 +0100 Message-Id: <20201119205123.21968-2-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119205123.21968-1-cus@passwd.hu> References: <20201119205123.21968-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avutil/timecode: add av_timecode_init_from_components 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 | 28 ++++++++++++++++++---------- libavutil/timecode.h | 17 +++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index b70c78a483..1966305587 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-9-xx - xxxxxxxxxx - lavu 56.61.100 - timecode.h + Add av_timecode_init_from_components. + 2020-xx-xx - xxxxxxxxxx - lavf 58.64.100 - avformat.h Add AVSTREAM_EVENT_FLAG_NEW_PACKETS. diff --git a/libavutil/timecode.c b/libavutil/timecode.c index 8fcdf320ee..1d2c4ea8ec 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -229,19 +229,12 @@ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start return check_timecode(log_ctx, tc); } -int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx) +int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx) { - char c; - int hh, mm, ss, ff, ret; - - if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) { - av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, " - "syntax: hh:mm:ss[:;.]ff\n"); - return AVERROR_INVALIDDATA; - } + int ret; memset(tc, 0, sizeof(*tc)); - tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ... + tc->flags = flags; tc->rate = rate; tc->fps = fps_from_frame_rate(rate); @@ -256,3 +249,18 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st } return 0; } + +int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx) +{ + char c; + int hh, mm, ss, ff, flags; + + if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) { + av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, " + "syntax: hh:mm:ss[:;.]ff\n"); + return AVERROR_INVALIDDATA; + } + flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ... + + return av_timecode_init_from_components(tc, rate, flags, hh, mm, ss, ff, log_ctx); +} diff --git a/libavutil/timecode.h b/libavutil/timecode.h index f9471a6e38..a912df262d 100644 --- a/libavutil/timecode.h +++ b/libavutil/timecode.h @@ -160,6 +160,23 @@ char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit); */ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx); +/** + * Init a timecode struct from the passed timecode components. + * + * @param log_ctx a pointer to an arbitrary struct of which the first field + * is a pointer to an AVClass struct (used for av_log) + * @param tc pointer to an allocated AVTimecode + * @param rate frame rate in rational form + * @param flags miscellaneous flags such as drop frame, +24 hours, ... + * (see AVTimecodeFlag) + * @param hh hours + * @param mm minutes + * @param ss seconds + * @param ff frames + * @return 0 on success, AVERROR otherwise + */ +int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx); + /** * Parse timecode representation (hh:mm:ss[:;.]ff). * diff --git a/libavutil/version.h b/libavutil/version.h index 1aca823650..55a59d6c58 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 60 +#define LIBAVUTIL_VERSION_MINOR 61 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ From patchwork Thu Nov 19 20:51:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23731 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 4218244AC04 for ; Thu, 19 Nov 2020 22:51:43 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2699868B8BD; Thu, 19 Nov 2020 22:51:43 +0200 (EET) 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 96A1C68B881 for ; Thu, 19 Nov 2020 22:51:36 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 1782FE4A4A; Thu, 19 Nov 2020 21:51:37 +0100 (CET) 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 P1W-vnsjLHTm; Thu, 19 Nov 2020 21:51:35 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 50FDEE4A2E; Thu, 19 Nov 2020 21:51:35 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:20 +0100 Message-Id: <20201119205123.21968-3-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119205123.21968-1-cus@passwd.hu> References: <20201119205123.21968-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] avdevice/decklink_dec: add support for 50/60 fps 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/indevs.texi | 5 +++ libavdevice/decklink_dec.cpp | 64 +++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 62b6ebb3e3..3924d03908 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -353,6 +353,11 @@ Timecode type to include in the frame and video stream metadata. Must be @samp{rp188hfr}, @samp{rp188any}, @samp{vitc}, @samp{vitc2}, or @samp{serial}. Defaults to @samp{none} (not included). +In order to properly support 50/60 fps timecodes, the ordering of the queried +timecode types for @samp{rp188any} is HFR, VITC1, VITC2 and LTC for >30 fps +content. Note that this is slightly different to the ordering used by the +DeckLink API, which is HFR, VITC1, LTC, VITC2. + @item video_input Sets the video input source. Must be @samp{unset}, @samp{sdi}, @samp{hdmi}, @samp{optical_sdi}, @samp{component}, @samp{composite} or @samp{s_video}. diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 6517b9df13..2042ac9b7c 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -789,6 +789,52 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, return pts; } +int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame) +{ + IDeckLinkTimecode *timecode; + int ret = AVERROR(ENOENT); +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + int hfr = (tc_format == bmdTimecodeRP188HighFrameRate); +#else + int hfr = 0; +#endif + if (videoFrame->GetTimecode(tc_format, &timecode) == S_OK) { + uint8_t hh, mm, ss, ff; + if (timecode->GetComponents(&hh, &mm, &ss, &ff) == S_OK) { + int flags = (timecode->GetFlags() & bmdTimecodeIsDropFrame) ? AV_TIMECODE_FLAG_DROPFRAME : 0; + if (!hfr && av_cmp_q(frame_rate, av_make_q(30, 1)) == 1) + ff = ff << 1 | !!(timecode->GetFlags() & bmdTimecodeFieldMark); + ret = av_timecode_init_from_components(tc, frame_rate, flags, hh, mm, ss, ff, avctx); + } + timecode->Release(); + } + return ret; +} + +int get_frame_timecode(AVFormatContext *avctx, decklink_ctx *ctx, AVTimecode *tc, IDeckLinkVideoInputFrame *videoFrame) +{ + AVRational frame_rate = ctx->video_st->r_frame_rate; + int ret; + /* 50/60 fps content has alternating VITC1 and VITC2 timecode (see SMPTE ST + * 12-2, section 7), so the native ordering of RP188Any (HFR, VITC1, LTC, + * VITC2) would not work because LTC might not contain the field flag. + * Therefore we query the types manually. */ + if (ctx->tc_format == bmdTimecodeRP188Any && av_cmp_q(frame_rate, av_make_q(30, 1)) == 1) { +#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000 + ret = get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188HighFrameRate, videoFrame); + if (ret == AVERROR(ENOENT)) +#endif + ret = get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188VITC1, videoFrame); + if (ret == AVERROR(ENOENT)) + ret = get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188VITC2, videoFrame); + if (ret == AVERROR(ENOENT)) + ret = get_bmd_timecode(avctx, tc, frame_rate, bmdTimecodeRP188LTC, videoFrame); + } else { + ret = get_bmd_timecode(avctx, tc, frame_rate, ctx->tc_format, videoFrame); + } + return ret; +} + HRESULT decklink_input_callback::VideoInputFrameArrived( IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame) { @@ -870,22 +916,16 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( // Handle Timecode (if requested) if (ctx->tc_format) { - IDeckLinkTimecode *timecode; - if (videoFrame->GetTimecode(ctx->tc_format, &timecode) == S_OK) { - const char *tc = NULL; - DECKLINK_STR decklink_tc; - if (timecode->GetString(&decklink_tc) == S_OK) { - tc = DECKLINK_STRDUP(decklink_tc); - DECKLINK_FREE(decklink_tc); - } - timecode->Release(); + AVTimecode tcr; + if (get_frame_timecode(avctx, ctx, &tcr, videoFrame) >= 0) { + char tcstr[AV_TIMECODE_STR_SIZE]; + const char *tc = av_timecode_make_string(&tcr, tcstr, 0); if (tc) { AVDictionary* metadata_dict = NULL; int metadata_len; uint8_t* packed_metadata; - AVTimecode tcr; - if (av_timecode_init_from_string(&tcr, ctx->video_st->r_frame_rate, tc, ctx) >= 0) { + if (av_cmp_q(ctx->video_st->r_frame_rate, av_make_q(60, 1)) < 1) { 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); @@ -896,7 +936,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } } - if (av_dict_set(&metadata_dict, "timecode", tc, AV_DICT_DONT_STRDUP_VAL) >= 0) { + if (av_dict_set(&metadata_dict, "timecode", tc, 0) >= 0) { packed_metadata = av_packet_pack_dictionary(metadata_dict, &metadata_len); av_dict_free(&metadata_dict); if (packed_metadata) { From patchwork Thu Nov 19 20:51:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23732 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 44BAB44AC04 for ; Thu, 19 Nov 2020 22:51:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 23E6868B8D5; Thu, 19 Nov 2020 22:51:45 +0200 (EET) 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 0560868B8BC for ; Thu, 19 Nov 2020 22:51:39 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4EE1DE4A65; Thu, 19 Nov 2020 21:51:39 +0100 (CET) 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 fFnTSjxb9A2U; Thu, 19 Nov 2020 21:51:37 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 80459E4A2E; Thu, 19 Nov 2020 21:51:37 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:21 +0100 Message-Id: <20201119205123.21968-4-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119205123.21968-1-cus@passwd.hu> References: <20201119205123.21968-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] avdevice/decklink_enc: simplify usage of buffercount type 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" Also remove some leftover declaration of CreateDeckLinkIteratorInstance(). Signed-off-by: Marton Balint --- libavdevice/decklink_common.h | 7 ------- libavdevice/decklink_enc.cpp | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index f35bd9ae6f..02f179f920 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -155,13 +155,6 @@ struct decklink_ctx { typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t; -#ifdef _WIN32 -typedef unsigned int buffercount_type; -IDeckLinkIterator *CreateDeckLinkIteratorInstance(void); -#else -typedef uint32_t buffercount_type; -#endif - static const BMDAudioConnection decklink_audio_connection_map[] = { (BMDAudioConnection)0, bmdAudioConnectionEmbedded, diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp index 883fdeadfb..ee341111ce 100644 --- a/libavdevice/decklink_enc.cpp +++ b/libavdevice/decklink_enc.cpp @@ -436,7 +436,7 @@ static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt) AVFrame *avframe = NULL, *tmp = (AVFrame *)pkt->data; AVPacket *avpacket = NULL; decklink_frame *frame; - buffercount_type buffered; + uint32_t buffered; HRESULT hr; if (st->codecpar->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) { @@ -525,7 +525,7 @@ static int decklink_write_audio_packet(AVFormatContext *avctx, AVPacket *pkt) struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; int sample_count = pkt->size / (ctx->channels << 1); - buffercount_type buffered; + uint32_t buffered; ctx->dlo->GetBufferedAudioSampleFrameCount(&buffered); if (pkt->pts > 1 && !buffered) From patchwork Thu Nov 19 20:51:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23733 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 672E544AC04 for ; Thu, 19 Nov 2020 22:51:48 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C89F68B7FB; Thu, 19 Nov 2020 22:51:48 +0200 (EET) 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 22BB168B903 for ; Thu, 19 Nov 2020 22:51:41 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3A801E4A66; Thu, 19 Nov 2020 21:51:41 +0100 (CET) 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 M9j-hJmwNikl; Thu, 19 Nov 2020 21:51:39 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 46FDCE4A57; Thu, 19 Nov 2020 21:51:39 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:22 +0100 Message-Id: <20201119205123.21968-5-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119205123.21968-1-cus@passwd.hu> References: <20201119205123.21968-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] avdevice/decklink: warn about too old decklink API version 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 --- libavdevice/decklink_common.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 8b58ede1ef..24aa9b1d13 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -70,9 +70,30 @@ static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx) #else iter = CreateDeckLinkIteratorInstance(); #endif - if (!iter) + if (!iter) { av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. " "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); + } else { + IDeckLinkAPIInformation *api; + int64_t version; +#ifdef _WIN32 + if (CoCreateInstance(CLSID_CDeckLinkAPIInformation, NULL, CLSCTX_ALL, + IID_IDeckLinkAPIInformation, (void**) &api) != S_OK) { + api = NULL; + } +#else + api = CreateDeckLinkAPIInformationInstance(); +#endif + if (api && api->GetInt(BMDDeckLinkAPIVersion, &version) == S_OK) { + if (version < BLACKMAGIC_DECKLINK_API_VERSION) + av_log(avctx, AV_LOG_WARNING, "Installed DeckLink drivers are too old and may be incompatible with the SDK this module was built against. " + "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); + } else { + av_log(avctx, AV_LOG_ERROR, "Failed to check installed DeckLink API version.\n"); + } + if (api) + api->Release(); + } return iter; } From patchwork Thu Nov 19 20:51:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 23741 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:c00a:0:0:0:0:0 with SMTP id c10csp638712ybf; Thu, 19 Nov 2020 12:52:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZXNTSzIEOkRbgI/D9E5CsdllmSBzGssx/QO0KaRA4dhsk1JyEJVLDDi8pp4s+wX8MmXZv X-Received: by 2002:a05:600c:2a4b:: with SMTP id x11mr6653445wme.165.1605819153764; Thu, 19 Nov 2020 12:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605819153; cv=none; d=google.com; s=arc-20160816; b=EdZO6SMZ5JTE8pCJyWTtYosR3qBCg/NLHGa1KiBBK4HSYVS/F3glHXBzt+dUwx670i VpL91LMSv8Xo+QyF7HzHRuidwaFBLSsONFNr4XckQgUZBx+0inbRHUBTK/4apjFSM8SX W1kWw4vse+62g/45iWqArX37dp0j0HXNI/tPCjXFiuvkLBdk+1P4XjS4pdW2s+5GnDVt bvJSZVystj2X0Z2xkeIdm9YWlJFK+/ONzJPdkeO893KSEOvV+gY2dnejJpzp0KGZVgDX 04N6xwSA8bnR4twnGZC3ypOFOPAN3DBNNic/c+jBSy8s8XO6Pf/u5ZKKKSvj1kcP3ngu MAOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=T48LEgy2lI1iH0nLSMCRajCOyp5JQXrlIbzT5B/zPU4=; b=Re+AcQDIX/ggkZTrFvzvtIXB8ul9VGG6HKhVRp61kI3KRWCPjz/ilhKz1dvSASjY5t PDCxEYArgPL1Nhqa2cFowy660V1pw/aixghFRbVpGp7e+9pPmkQ7iSLgTlIPXTZ6yC+N HSqynmi3nJ3QCMLZSQ/UGdfJvIBm33pAPF5EhatNUjlaCT2dYbMY28QVkOn7ilXOgLgJ VGDqijBFnmlC8J48zNKIducJvZK7uXNDIln6QAPMdwgoDvO3uS1EOcBvd2iuqvP4KcyQ EaUlZ7hflwjnxD9j+A9OIAju3t+hl0DiaGVz4Z1RnDoYJjp6g7ErU1aoUWPsN3B7bKZI 6GQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o8si584692wru.318.2020.11.19.12.52.33; Thu, 19 Nov 2020 12:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 440FC68B8F4; Thu, 19 Nov 2020 22:51:52 +0200 (EET) 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 ACC5C68B903 for ; Thu, 19 Nov 2020 22:51:44 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 36644E4A65; Thu, 19 Nov 2020 21:51:45 +0100 (CET) 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 kaqiDe4098oc; Thu, 19 Nov 2020 21:51:43 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 59005E4A4A; Thu, 19 Nov 2020 21:51:42 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Nov 2020 21:51:23 +0100 Message-Id: <20201119205123.21968-6-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201119205123.21968-1-cus@passwd.hu> References: <20201119205123.21968-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] fftools/cmdutils: also print warnings when using -sinks and -sources 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" X-TUID: KOGvyEimleZg Content-Length: 1569 Signed-off-by: Marton Balint --- fftools/cmdutils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 88fdbeaf1e..4eb68d2201 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2308,7 +2308,7 @@ int show_sources(void *optctx, const char *opt, const char *arg) int ret = 0; int error_level = av_log_get_level(); - av_log_set_level(AV_LOG_ERROR); + av_log_set_level(AV_LOG_WARNING); if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) goto fail; @@ -2346,7 +2346,7 @@ int show_sinks(void *optctx, const char *opt, const char *arg) int ret = 0; int error_level = av_log_get_level(); - av_log_set_level(AV_LOG_ERROR); + av_log_set_level(AV_LOG_WARNING); if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) goto fail;