From patchwork Mon Aug 14 04:55:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patagar, Ravindra" X-Patchwork-Id: 4705 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp3864988vsu; Sun, 13 Aug 2017 21:55:54 -0700 (PDT) X-Received: by 10.28.151.199 with SMTP id z190mr3898359wmd.100.1502686554459; Sun, 13 Aug 2017 21:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502686554; cv=none; d=google.com; s=arc-20160816; b=gbeOSMkW4sm6iON3BFuHEA/pZzgDZyEAl3l9zHMbxk+iqL1JOQWrws9jIEs8yVmXDd x/zq1us3v61NG0wPIgriqJOCmGLojWPebIJl3eFsfskJvTvr02UuaMD0yLX7XmZaMJ4q 8lk8Ia9pD6pBWeXKd4k/GA4yXHJlgFzpLRX9Rl2qTs7ZRJbc3swTZiNn9zPvH9dxnmGU g6icRN8ea/tdwSIohSjf4zwPOLInRxpm38g3njN6KEaFs3iLSg3Bsg7SwaYVahltsC/s 2YMFqyAlQyEY3E9TAhNVaN6koJvPK3EwvRE96tqmGpo6HCyz1hgHOaPQWQRvlQ+2ixNM BEdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:content-id:content-language :accept-language:message-id:date:thread-index:thread-topic:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=ejxmKH5jO9Q0N8+uZyumQNGT/+4LRKSxEgvQldfQcqE=; b=jBdIHZuYvHKsVlUZX6vUvneLkEwkd9IqUbiiBmywth/lGAdbIHsgo9njRC47XvZ8wY Gjm3WsYiN+MD+ajezMttonibzmhg2aueOQac27gqEek1ed3othvYzkot/r8EcwHIk5eT tJtGHMEHPhvWR4wE6NH2GNlGt6PgMKj+JWZqG9fJZ2s0rFRXv8gv2lx81XrQndb1irBc fsIZsaAlTahPZjSPHNNlcBmdBWdl8ZldAGPs/bcH/SZiQ1Bt+eb11yGzax1Mt9qpO/G3 2NmKP+p3/dx8sfQLVEaQA25amxcZe2JmUOiUaSTt1AZTNAhY4jdn1F4ZwxIkyJn5W9+z TO/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@akamai.com header.s=jan2016.eng header.b=Mi308PwM; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 140si3244846wmx.165.2017.08.13.21.55.53; Sun, 13 Aug 2017 21:55:54 -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=@akamai.com header.s=jan2016.eng header.b=Mi308PwM; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38919689D6A; Mon, 14 Aug 2017 07:55:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx0a-00190b01.pphosted.com (mx0a-00190b01.pphosted.com [67.231.149.131]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FF1F6805C0 for ; Mon, 14 Aug 2017 07:55:39 +0300 (EEST) Received: from pps.filterd (m0122332.ppops.net [127.0.0.1]) by mx0a-00190b01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7E4qmaF024809 for ; Mon, 14 Aug 2017 05:55:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=from : to : subject : date : message-id : content-type : content-id : content-transfer-encoding : mime-version; s=jan2016.eng; bh=ccVbZRPfnyf4PwVSQsdoQOI9euE+b+ocJHJFrlGKSAU=; b=Mi308PwMMUZziYuoZcHIm/K+JN2IjoWdqKZCDJwPPRb88GX/1VxyG/RSkzJHDbBzZZVq kwzELodda7x7+/sy3cP3uJnxSSPI0g/Jj44kxF82gg7hxYNYfoSthU+7X3xLVwoW/+3w MwjxhqQPq9WRk6CkwnmYUqVcYKZPr7pfZvovroxrzfISu7RiXTbO1KiL7niW7koBhEb1 nSL0llYLLQAc9ecftVGmY16lwPzlZc/yXs+yvMCrfQeNUCg8nfQB9LMIlGU7MLmBzoca StSe0O0mu4I7xyBdXmnesyVVks6wp3yIF5BpfymF7iQov24Q89ElD1Ep3zOntE4dGeXV Vw== Received: from prod-mail-ppoint1 (prod-mail-ppoint1.akamai.com [184.51.33.18]) by mx0a-00190b01.pphosted.com with ESMTP id 2c9sqcxnrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 14 Aug 2017 05:55:41 +0100 Received: from pps.filterd (prod-mail-ppoint1.akamai.com [127.0.0.1]) by prod-mail-ppoint1.akamai.com (8.16.0.17/8.16.0.17) with SMTP id v7E4ov9p007822 for ; Mon, 14 Aug 2017 00:55:40 -0400 Received: from email.msg.corp.akamai.com ([172.27.155.30]) by prod-mail-ppoint1.akamai.com with ESMTP id 2c9w0unbpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 14 Aug 2017 00:55:40 -0400 Received: from asin1ex-dag2mb3.msg.corp.akamai.com (172.27.155.103) by asin1ex-dag2mb1.msg.corp.akamai.com (172.27.155.101) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Mon, 14 Aug 2017 10:25:36 +0530 Received: from asin1ex-dag2mb3.msg.corp.akamai.com ([172.27.155.103]) by asin1ex-dag2mb3.msg.corp.akamai.com ([172.27.155.103]) with mapi id 15.00.1263.000; Mon, 14 Aug 2017 10:25:36 +0530 From: "Patagar, Ravindra" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH 1/1] libavdevice/decklink: configurablity to set max queue size Thread-Index: AQHTFLmRB2jzQHJSY0uPO03iacPCmg== Date: Mon, 14 Aug 2017 04:55:36 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.19.219.105] Content-ID: <3B51FBC9270D0140804EF09ED383B76C@akamai.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-14_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708140076 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-14_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708140077 Subject: [FFmpeg-devel] [PATCH 1/1] libavdevice/decklink: configurablity to set max queue size 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Configurablity to set max queue size so that worst case latency can be controlled. Signed-off-by: Ravindra Patagar --- libavdevice/decklink_common.h | 2 ++ libavdevice/decklink_common_c.h | 2 ++ libavdevice/decklink_dec.cpp | 7 +++++-- libavdevice/decklink_dec_c.c | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index c12cf18..64cc722 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -1,6 +1,7 @@ /* * Blackmagic DeckLink common code * Copyright (c) 2013-2014 Ramiro Polla, Luca Barbato, Deti Fliegl + * Copyright (c) 2017 Akamai Technologies, Inc. * * This file is part of FFmpeg. * @@ -38,6 +39,7 @@ typedef struct AVPacketQueue { pthread_mutex_t mutex; pthread_cond_t cond; AVFormatContext *avctx; + int max_q_size; } AVPacketQueue; struct decklink_ctx { diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index 72c5f9a..0ddd32a 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -1,6 +1,7 @@ /* * Blackmagic DeckLink common code * Copyright (c) 2013-2014 Ramiro Polla + * Copyright (c) 2017 Akamai Technologies, Inc. * * This file is part of FFmpeg. * @@ -48,6 +49,7 @@ struct decklink_cctx { int video_input; int draw_bars; char *format_code; + int queue_size; }; #endif /* AVDEVICE_DECKLINK_COMMON_C_H */ diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 72449a8..8e85c65 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -1,6 +1,7 @@ /* * Blackmagic DeckLink input * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl + * Copyright (c) 2017 Akamai Technologies, Inc. * * This file is part of FFmpeg. * @@ -187,10 +188,12 @@ static uint8_t* teletext_data_unit_from_vanc_data(uint8_t *src, uint8_t *tgt, in static void avpacket_queue_init(AVFormatContext *avctx, AVPacketQueue *q) { + struct decklink_cctx * ctx = (struct decklink_cctx *)avctx->priv_data; memset(q, 0, sizeof(AVPacketQueue)); pthread_mutex_init(&q->mutex, NULL); pthread_cond_init(&q->cond, NULL); q->avctx = avctx; + q->max_q_size = ctx->queue_size; } static void avpacket_queue_flush(AVPacketQueue *q) @@ -230,8 +233,8 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) { AVPacketList *pkt1; - // Drop Packet if queue size is > 1GB - if (avpacket_queue_size(q) > 1024 * 1024 * 1024 ) { + // Drop Packet if queue size is > maximum queue size + if (avpacket_queue_size(q) > q->max_q_size ) { av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer overrun!\n"); return -1; } diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c index 5b26d12..ea828be 100644 --- a/libavdevice/decklink_dec_c.c +++ b/libavdevice/decklink_dec_c.c @@ -1,6 +1,7 @@ /* * Blackmagic DeckLink input * Copyright (c) 2014 Deti Fliegl + * Copyright (c) 2017 Akamai Technologies, Inc. * * This file is part of FFmpeg. * @@ -64,6 +65,7 @@ static const AVOption options[] = { { "reference", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"}, { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"}, { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC }, + { "qbufsize", "Input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT, { .i64 = (1024 * 1024 * 1024)}, 0, INT_MAX, DEC, "bytes"}, { NULL }, };