From patchwork Tue Jun 11 09:46:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Riedl X-Patchwork-Id: 49791 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:613:0:b0:460:55fa:d5ed with SMTP id 19csp273295vqg; Tue, 11 Jun 2024 02:47:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUl6l/GDfgAJicVMLOsJ/Mm1mDN0tIkwbludHqsY6Go2lppeMd+lVNlxP68Ty0kcWXqeHOKnQ86Jzex94JXDDkl6o6RKvEcQI8mcw== X-Google-Smtp-Source: AGHT+IGsC+5WexK1ZaJlKgMmNQcHqtaA1hxRh544++01J8UqmtgEywSS8qOXwi390TcCdn/zXw6V X-Received: by 2002:a17:906:4a4f:b0:a6f:1045:d5dc with SMTP id a640c23a62f3a-a6f1045d63dmr477680266b.6.1718099230545; Tue, 11 Jun 2024 02:47:10 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57c74110593si2858782a12.123.2024.06.11.02.47.10; Tue, 11 Jun 2024 02:47:10 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@nativewaves.onmicrosoft.com header.s=selector2-nativewaves-onmicrosoft-com header.b=PJ4xLHlp; arc=fail (body hash mismatch); 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 BEEB468D7F8; Tue, 11 Jun 2024 12:47:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2128.outbound.protection.outlook.com [40.107.14.128]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D6E068D798 for ; Tue, 11 Jun 2024 12:46:59 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=erLCuChOCpelJkEqfvP7/an68pPR9sCi8Lunz+ZNVGWcKYgGsVwAHjLtZ+E3iqNEaj1YzZMqEDM4XaBr4AbRslhCm5Yb9IBIj5vFs3jlpqCvY38LOTr2wjOuUcC6UbNkf7muvmJ/+cA/xp1HdiTXkLeMZH0rCrAI/Cu2busJngHROmbDN3Oh9B2OVNxwURA65+juKGgwfOirCQKQfIRLoZ4J+RR1KiMmYcEJZzNKTeWM2E/mTrNbpz5CAChCYXwfywL0LM1UIi0fUrAP3ttkVKekuwL2UxuwdiWANkh1L4TF47q7+jRFWTtM5OUXvk5IJCJMT05PELDVgNz+Mvi53w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9ejNNIHgJw6cF1KOPX1rUZ5TAcRhJVXtLrFMdn70/uY=; b=fsfwCFU09yKDBs2L5PnWAoI4ikSK93fUW1v2k9c+a/E8nQcnglc9pKR0EFA+gTTMXENv9Tw45mpFbguRVaSYrf8B90FOSivZxA3sguyiDFT6vUo73InS11wUHrXQ86ozeiHsuSrU1TyV+C1Nq/xzgDeP0YH1gi9b4NbAJnkck7EmuilNOAJqnlAaJlgZm/RsOZk+sfOQSRznfTSQAbkpHmQdYV+uX63loYJFatBaayVCFki0g6Rtvsd55Xu0XC67SMI2bwS1RcPsR0wjSyxsPwAVny1ZJLWcT3I3zBGzp+VVfkoBwcdY7paO9VOiKjejAq6oAdzDoFsvZv29P1XiMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nativewaves.com; dmarc=pass action=none header.from=nativewaves.com; dkim=pass header.d=nativewaves.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nativewaves.onmicrosoft.com; s=selector2-nativewaves-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9ejNNIHgJw6cF1KOPX1rUZ5TAcRhJVXtLrFMdn70/uY=; b=PJ4xLHlp8xfVzWTaWU0l5vNDgNBWOdrOvsmfcAjHKJfZbhhoECTGAiV7XsnK3QS/YPzBPheiyZDeZB8sGyhkct3c5oGHu8L83FTZGLjLGvvVtW3RP0oX2bTSWzLlV4B3uGKY1m5S22V5AlYcx9Aak+qJTEZOqRu4yGoELx5GzBI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nativewaves.com; Received: from DB9PR03MB7673.eurprd03.prod.outlook.com (2603:10a6:10:2c2::17) by DU2PR03MB9998.eurprd03.prod.outlook.com (2603:10a6:10:493::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.17; Tue, 11 Jun 2024 09:46:52 +0000 Received: from DB9PR03MB7673.eurprd03.prod.outlook.com ([fe80::d133:f032:3270:cb45]) by DB9PR03MB7673.eurprd03.prod.outlook.com ([fe80::d133:f032:3270:cb45%4]) with mapi id 15.20.7677.014; Tue, 11 Jun 2024 09:46:52 +0000 Message-ID: Date: Tue, 11 Jun 2024 11:46:54 +0200 User-Agent: Mozilla Thunderbird From: Michael Riedl To: ffmpeg-devel@ffmpeg.org References: <2aedc19d-4f8d-4a77-ab01-7457d89d23b1@nativewaves.com> Content-Language: en-US In-Reply-To: <2aedc19d-4f8d-4a77-ab01-7457d89d23b1@nativewaves.com> X-ClientProxiedBy: VI1PR04CA0067.eurprd04.prod.outlook.com (2603:10a6:802:2::38) To DB9PR03MB7673.eurprd03.prod.outlook.com (2603:10a6:10:2c2::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB7673:EE_|DU2PR03MB9998:EE_ X-MS-Office365-Filtering-Correlation-Id: b31c59e5-1a2f-4051-2643-08dc89fb6c27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|376005|366007; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Ap8oKQ/I493c8idtn03jSuDIX686Wrr?= =?utf-8?q?3TiR8d8gBGzaTmWg+2P4AWTIL40mzsFhMeRBWEWZMzhJ4v1fhiLCuf22IvTqZgwn+?= =?utf-8?q?rdNxQRDESrNgt1MPphuFkpqlatg2tMbCr58L0IHs5ifjEb8EbzI2lT2iQhhUfYx+t?= =?utf-8?q?KU5MqaxFxp/MCS+mFInargK3rYjiGlvkUnB6G4xfeXm3Q2KPiCEgzStxQyP5U4aIN?= =?utf-8?q?FSy7dbfEI8PRPBRto8ux795R+TI15vGOBDMR9I/4Z0flbp/AHjzfa+QQGj1iwvyoU?= =?utf-8?q?usyMIxV1iuYRPvA8QHmBCxQPXuxSocy7SkCOVirNYTr6XkKYcFJX4UOiYnHMUnQVU?= =?utf-8?q?w6XxHc3VMf+xCWh1l0ZDLtycPER4FkQs+rsJ3AAcNUMCOTDr8UEFe0vfJYiQ6D2ti?= =?utf-8?q?KJDl2y2v3NrWWGcQ8VLbHm2Nz8lVQuuoewX+fb2M3xsvFPSkOeVDwRYhXCUvT07Jt?= =?utf-8?q?BiOhdPp2HNwBweCT8gNjs3IDD5oO7RHaRM5oT3YWdNHGrz+4i1De9cIkeRa9noPuC?= =?utf-8?q?oExuxUGhAVpy3ENnpvcZ/sOFGDKgCsYDURWQqs9Ceauj4nahKUhNJ+sGPJRCdLYIQ?= =?utf-8?q?+T5cpHOYi+fVK5pbvzTfRcjk6nyB5SddOW7MRAqMpJolrPBfcM/VQlGVzO+YYuXlH?= =?utf-8?q?TjMGCBZnWdkN3PnHqHASuRKu9hg+2OZj36t63pIkiLwxN47GjaixgEPhVuJLwEz5E?= =?utf-8?q?Ry9/iiYIpJbzqq9IhUKVH+mteXTNjSPFNOjiWMSUUpHJIGu1dAsPr29sSUc/LoDxO?= =?utf-8?q?J5NH88YuJxTyJC43SSGndLhWaflMXbsReqEtxozQBc/nNHtFZm0P2wbv9dZ0yz2TK?= =?utf-8?q?qfeic3ws9cK61po3YoZZOLHNo/ka/INMfetAE4IGJmxSOPj2dcsQmYnOKZG21TFu0?= =?utf-8?q?6jFFMctAeIzYFWjOdPmrzJaxtxuUy1xsEZfUxcxcdS5R0ypV0ZBeqw6A+lUhSLIFC?= =?utf-8?q?Euspc/iNjHRD9qe+2pQd12yEf6s+fzWuUK2I7lbwhKF8kf/I+L5Dbj0c/NWjvgv7d?= =?utf-8?q?+i2Hmhv5g8/+dQqdR4weoQJHJUuf1iRQIpx1iapG0ADErO0TMzGb44WIefAKC1dUa?= =?utf-8?q?hL4DPQx9yDNwk9Xp7OjSUGuzDSQ8VIuOQv8Vs2TNPlsRYnillLn2Wim2z5PWGvTV7?= =?utf-8?q?bieI8YJRiEax09F+1coKwre/Tm7MeGLZgCuKicf+Am6R1yup1ZULfU/9Pe+wtrO9Y?= =?utf-8?q?utC0EXME2EbXqvz6JmpWCBCF8NaE2sXnwkVuCxgZ1QpTIo/v19TCnDI4iUH7AjTQN?= =?utf-8?q?Pr+KcZKwHrM18?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR03MB7673.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005)(366007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?STk7GSU+x6FU1N7M7w3ilfZmsAOH?= =?utf-8?q?xhW4LTjVmT9ep4UtsubVI3g1cjHs9inDCD9uA211eT9yFDo331wVv7FV0MbVPs2Uc?= =?utf-8?q?L8j07Hu/sV6OghXmX5jdW+GhToiBrWptdW8fKDrFWhk0s8SIWY1LGeFWsYXr4U63c?= =?utf-8?q?iLxypFjhdz+WwMiFpcpi4Hggmodxqyq/0Xb692z0xKyZSSHb/zZtiGYTme/+3b5RW?= =?utf-8?q?DXFq/j6K8iN3KLyYFPBuC12MhLJy+VaOOFIXB1xpBoAM1gpzZxFpP6yho8VWGdTPs?= =?utf-8?q?ZGf1UB+S2oTIV9+WBCm6gDstQIR1+upwR2d0/JZRSES1h1xYFLC2abSqCvHoMFpMV?= =?utf-8?q?+147xmuSKxIYPEBuQIy2FTBf/L+KuGizrh+E7FW1D9xRigXOU9qkZszm8o0igGWFX?= =?utf-8?q?AFjmp0dIBKk/DdU6w8yd0zIvGeyDAyPCbthqAuZWbdrRWrDHSpbhQnzVNeF5Mebll?= =?utf-8?q?rDFWI/TpiAqrzpapaV849nSO11ZE5PsAs4+kLbo03jhDmA1XRQB9Ova3HdU4UbsB8?= =?utf-8?q?3w/liwKD3R3OdLCFaFA8xLzXvplDvqY7l+1e6pxqvYjuES7g+IiVZQWD9uEe0qYek?= =?utf-8?q?Xy7O3XqS8GPACADGAbcznVlC3ZnLpGbnVx0ps1qmOmWi7ZoSYU4RI+Ob1MLCJHuCm?= =?utf-8?q?Hi3c3trz8Nib7qTLl4horXGD8iD39v4/hsDof9OjvU9Xxh0ebIU2xPCi//Q0Px/HH?= =?utf-8?q?3Vq2klOJkr1G1gQK39hWv6tjshTLi38XYCy8x2oYUVCKTAlQGvoaeqSuG2S/Z/C1g?= =?utf-8?q?XcMRgsk02uITRtgv6I4aD4L9E3FyPngCSCmqg1p2Jgsp+IMuf1DXYjuFrIQTA3oQh?= =?utf-8?q?jdwVuDLWPhA8GXv0DeR8k/31qb0/DTJMCaWxavHjv0aNZzQpWq6JcHKkgm7Nvg+2T?= =?utf-8?q?nzRX2j1W1TZEofu6OdDfElc+Eopzj6J7tA+iy5P8yRXTnILtIOpHlGb5kAFlZp6Vg?= =?utf-8?q?tR1Cb3eJJMAdMovbk3P/5pUmoxRpUl/2Kr14J63MUBf1Ov9qk2AbcrGWh/aULQ44P?= =?utf-8?q?qD5rYGOrCi5ec0kKiK5MGwt+bLK0/QMYML9OpydAKezjHTcX4Z53qRv72sXsaTibw?= =?utf-8?q?17Z8vjL3+V64mPidlAwZ5fNe6iCDR+jsREgT2yszB0kKQesDq5pqM9l/FlmG8wsNx?= =?utf-8?q?/s3z9WLOX/3JpXk3kHvmEuQ7RRYt4lPpsJTTl9Ls04gwYo+9Jiq2UlFB+HnS6R5cS?= =?utf-8?q?dCv8r1Aeta4ovxwr2blK8LG5G6QGwoNGTsB+OQKXxwlwuCFyPqXv0BVkSR2516qdE?= =?utf-8?q?h57kIjs/pWwvQka9jmHq0TrpS1N91LHUUWxy1lgD5KplLrrQbEUtDRTjW/uL0gy5q?= =?utf-8?q?wUGRtD2I8494334AWudJ2uIeFZMX3nHYAUXhWR5QRmqFAWg3fte9ZBEfUMfbO+v32?= =?utf-8?q?eAqfJTF2sUtGdJ2t2Xu00XtQumKwXo8rRmciaTmUUBD+ZKN1O4owkBrgPGoZo3imO?= =?utf-8?q?gv5D+A2A/5qvooSPavvzl+MaH9+f2eRVbkTna776YsRUXGizPbX6B4HoZx6oa7SeA?= =?utf-8?q?wDcfWvB9R7BH4xU9m21qZzdJbZcCL/rTK7j5hnf6ZxmIK5beRNlvfqA=3D?= X-OriginatorOrg: nativewaves.com X-MS-Exchange-CrossTenant-Network-Message-Id: b31c59e5-1a2f-4051-2643-08dc89fb6c27 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB7673.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 09:46:52.5048 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e4239718-b000-4513-8314-02ef46bd0276 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Nj4rfGBLIdwBv2dljbbvtS5J/RvfeAVpx/IbNtQa25PwUjdiivKXYoAm1jKlgI7BoFDuSltqqymrktm5flSy4dDADS6fufSP5QFYiE18V0A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR03MB9998 Subject: [FFmpeg-devel] [PATCH v4] libavdevice/decklink: extend available actions on signal loss X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RFw2mEcxQfU9 Deprecate the option 'draw_bars' in favor of the new option 'signal_loss_action', which controls the behavior when the input signal is not available (including the behavior previously available through draw_bars). The default behavior remains unchanged to be backwards compatible. The new option is more flexible for extending now and in the future. The new value 'repeat' repeats the last video frame. This is useful for very short dropouts and was not available before. Signed-off-by: Michael Riedl --- doc/indevs.texi | 16 ++++++++++++++++ libavdevice/decklink_common.h | 1 + libavdevice/decklink_common_c.h | 7 +++++++ libavdevice/decklink_dec.cpp | 34 ++++++++++++++++++++++++++++----- libavdevice/decklink_dec_c.c | 6 +++++- 5 files changed, 58 insertions(+), 6 deletions(-) -- 2.45.2 diff --git a/doc/indevs.texi b/doc/indevs.texi index 734fc65752..cdf44a6638 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -396,6 +396,22 @@ Defaults to @samp{audio}. @item draw_bars If set to @samp{true}, color bars are drawn in the event of a signal loss. Defaults to @samp{true}. +This option is deprecated, please use the @code{signal_loss_action} option. + +@item signal_loss_action +Sets the action to take in the event of a signal loss. Accepts one of the +following values: + +@table @option +@item 1, none +Do nothing on signal loss. This usually results in black frames. +@item 2, bars +Draw color bars on signal loss. Only supported for 8-bit input signals. +@item 3, repeat +Repeat the last video frame on signal loss. +@end table + +Defaults to @samp{bars}. @item queue_size Sets maximum input buffer size in bytes. If the buffering reaches this value, diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index c54a635876..6b32dc2d09 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -147,6 +147,7 @@ struct decklink_ctx { DecklinkPtsSource video_pts_source; int draw_bars; BMDPixelFormat raw_format; + DecklinkSignalLossAction signal_loss_action; int frames_preroll; int frames_buffer; diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index 9c55d89149..53d2c583e7 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -37,6 +37,12 @@ typedef enum DecklinkPtsSource { PTS_SRC_NB } DecklinkPtsSource; +typedef enum DecklinkSignalLossAction { + SIGNAL_LOSS_NONE = 1, + SIGNAL_LOSS_REPEAT = 2, + SIGNAL_LOSS_BARS = 3 +} DecklinkSignalLossAction; + struct decklink_cctx { const AVClass *cclass; @@ -68,6 +74,7 @@ struct decklink_cctx { int64_t timestamp_align; int timing_offset; int wait_for_tc; + DecklinkSignalLossAction signal_loss_action; }; #endif /* AVDEVICE_DECKLINK_COMMON_C_H */ diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 671573853b..d057366378 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -593,6 +593,7 @@ private: int no_video; int64_t initial_video_pts; int64_t initial_audio_pts; + IDeckLinkVideoInputFrame* last_video_frame; }; decklink_input_callback::decklink_input_callback(AVFormatContext *_avctx) : _refs(1) @@ -602,10 +603,13 @@ decklink_input_callback::decklink_input_callback(AVFormatContext *_avctx) : _ref ctx = (struct decklink_ctx *)cctx->ctx; no_video = 0; initial_audio_pts = initial_video_pts = AV_NOPTS_VALUE; + last_video_frame = nullptr; } decklink_input_callback::~decklink_input_callback() { + if (last_video_frame) + last_video_frame->Release(); } ULONG decklink_input_callback::AddRef(void) @@ -730,6 +734,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( BMDTimeValue frameDuration; int64_t wallclock = 0, abs_wallclock = 0; struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; + IDeckLinkVideoInputFrame *currentVideoFrame = videoFrame; // video frame that holds frameBytes if (ctx->autodetect) { if (videoFrame && !(videoFrame->GetFlags() & bmdFrameHasNoInputSource) && @@ -773,7 +778,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( ctx->video_st->time_base.den); if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) { - if (ctx->draw_bars && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) { + if (ctx->signal_loss_action == SIGNAL_LOSS_BARS && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) { unsigned bars[8] = { 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035, 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 }; @@ -785,6 +790,9 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( for (int x = 0; x < width; x += 2) *p++ = bars[(x * 8) / width]; } + } else if (ctx->signal_loss_action == SIGNAL_LOSS_REPEAT && last_video_frame) { + currentVideoFrame = last_video_frame; + currentVideoFrame->GetBytes(&frameBytes); } if (!no_video) { @@ -793,6 +801,12 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } no_video = 1; } else { + if (ctx->signal_loss_action == SIGNAL_LOSS_REPEAT) { + if (last_video_frame) + last_video_frame->Release(); + last_video_frame = videoFrame; + last_video_frame->AddRef(); + } if (no_video) { av_log(avctx, AV_LOG_WARNING, "Frame received (#%lu) - Input returned " "- Frames dropped %u\n", ctx->frameCount, ++ctx->dropped); @@ -854,8 +868,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( pkt.flags |= AV_PKT_FLAG_KEY; pkt.stream_index = ctx->video_st->index; pkt.data = (uint8_t *)frameBytes; - pkt.size = videoFrame->GetRowBytes() * - videoFrame->GetHeight(); + pkt.size = currentVideoFrame->GetRowBytes() * + currentVideoFrame->GetHeight(); //fprintf(stderr,"Video Frame size %d ts %d\n", pkt.size, pkt.pts); if (!no_video) { @@ -931,9 +945,9 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( } } - pkt.buf = av_buffer_create(pkt.data, pkt.size, decklink_object_free, videoFrame, 0); + pkt.buf = av_buffer_create(pkt.data, pkt.size, decklink_object_free, currentVideoFrame, 0); if (pkt.buf) - videoFrame->AddRef(); + currentVideoFrame->AddRef(); if (ff_decklink_packet_queue_put(&ctx->queue, &pkt) < 0) { ++ctx->dropped; @@ -1036,6 +1050,7 @@ av_cold int ff_decklink_read_close(AVFormatContext *avctx) ctx->dli->StopStreams(); ctx->dli->DisableVideoInput(); ctx->dli->DisableAudioInput(); + ctx->dli->SetCallback(nullptr); } ff_decklink_cleanup(avctx); @@ -1074,6 +1089,15 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) ctx->audio_pts_source = cctx->audio_pts_source; ctx->video_pts_source = cctx->video_pts_source; ctx->draw_bars = cctx->draw_bars; + ctx->signal_loss_action = cctx->signal_loss_action; + if (!ctx->draw_bars && ctx->signal_loss_action == SIGNAL_LOSS_BARS) { + ctx->signal_loss_action = SIGNAL_LOSS_NONE; + av_log(avctx, AV_LOG_WARNING, "Setting signal_loss_action to none because draw_bars is false\n"); + } + if (!ctx->draw_bars && ctx->signal_loss_action != SIGNAL_LOSS_NONE) { + av_log(avctx, AV_LOG_ERROR, "options draw_bars and signal_loss_action are mutually exclusive\n"); + return AVERROR(EINVAL); + } ctx->audio_depth = cctx->audio_depth; if (cctx->raw_format > 0 && (unsigned int)cctx->raw_format < FF_ARRAY_ELEMS(decklink_raw_format_map)) ctx->raw_format = decklink_raw_format_map[cctx->raw_format]; diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c index e211c9d3f4..b8cdb7bd8e 100644 --- a/libavdevice/decklink_dec_c.c +++ b/libavdevice/decklink_dec_c.c @@ -95,12 +95,16 @@ static const AVOption options[] = { { "reference", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, .unit = "pts_source"}, { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, .unit = "pts_source"}, { "abs_wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_ABS_WALLCLOCK}, 0, 0, DEC, .unit = "pts_source"}, - { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC }, + { "draw_bars", "use option signal_loss_action instead" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC | AV_OPT_FLAG_DEPRECATED }, { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC }, { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC }, { "decklink_copyts", "copy timestamps, do not remove the initial offset", OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, { "timestamp_align", "capture start time alignment (in seconds)", OFFSET(timestamp_align), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, DEC }, { "wait_for_tc", "drop frames till a frame with timecode is received. TC format must be set", OFFSET(wait_for_tc), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC }, + { "signal_loss_action", "action on signal loss", OFFSET(signal_loss_action), AV_OPT_TYPE_INT, { .i64 = SIGNAL_LOSS_BARS }, SIGNAL_LOSS_NONE, SIGNAL_LOSS_BARS, DEC, .unit = "signal_loss_action" }, + { "none", "do not do anything (usually leads to black frames)", 0, AV_OPT_TYPE_CONST, { .i64 = SIGNAL_LOSS_NONE }, 0, 0, DEC, .unit = "signal_loss_action"}, + { "bars", "draw color bars (only supported for 8-bit signals)", 0, AV_OPT_TYPE_CONST, { .i64 = SIGNAL_LOSS_BARS }, 0, 0, DEC, .unit = "signal_loss_action"}, + { "repeat", "repeat the last video frame", 0, AV_OPT_TYPE_CONST, { .i64 = SIGNAL_LOSS_REPEAT }, 0, 0, DEC, .unit = "signal_loss_action"}, { NULL }, };