diff --git a/doc/indevs.texi b/doc/indevs.texi index 09e33216dc88c94b81cea3256b152223394642dd..dc6cdb6deecd33c11a226ee06a46ec48acf1f3fd 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -289,6 +289,11 @@ Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio}, If set to @samp{true}, color bars are drawn in the event of a signal loss. Defaults to @samp{true}. +@item queue_size +Sets maximum input buffer size in bytes. If the buffering reaches this value, +incoming frames will be dropped. +Defaults to @samp{1073741824}. + @end table @subsection Examples diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index c12cf18d70337aed815cee4903be0a0914796590..749eb0f8b8e59db041e1e8dcf2f6d4e5e3f9907b 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; + int64_t max_q_size; } AVPacketQueue; struct decklink_ctx { diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index 72c5f9a71be1739f3a64b0cb95571442ec5364a8..e263480474cb96c2fff12983b31e82fa6bc8123d 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; + int64_t queue_size; }; #endif /* AVDEVICE_DECKLINK_COMMON_C_H */ diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 72449a8eca5fe30872eb340dc09ab41a78157cda..64157b4c16fc452e4544c63897d764c7aa5fbf6a 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 5b26d1257c461914a97ea08d5210b0f8cc61ef13..e2118a619c7a391f9fdf71057bb97023b6048722 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 }, + { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC }, { NULL }, }; diff --git a/libavdevice/version.h b/libavdevice/version.h index 0c0660209857e9fad43069814577196fc2135d0a..e0d3680578f8326365f9fda5699900c5d9dc3869 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 57 #define LIBAVDEVICE_VERSION_MINOR 7 -#define LIBAVDEVICE_VERSION_MICRO 100 +#define LIBAVDEVICE_VERSION_MICRO 101 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \