[FFmpeg-devel] [PATCH 1/1] libavdevice/decklink: configurablity to set max queue size

Patagar, Ravindra rpatagar at akamai.com
Thu Aug 17 13:38:35 EEST 2017


Hi Marton,

I have updated the patch as per your comments. Please find the updated patch attached.

Regards,
Ravindra.


On 8/15/17, 12:38 AM, "Marton Balint" <cus at passwd.hu> wrote:

    
    On Mon, 14 Aug 2017, Patagar, Ravindra wrote:
    
    >
    > Configurablity to set max queue size so that worst case latency can be controlled.
    > Signed-off-by: Ravindra Patagar <rpatagar at akamai.com>
    > ---
    > 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(-)
    >
    > 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"},
    
    I'd rather call the option "queue_size", shortened names should be fine 
    for variables, but for option names we tend to use normal text.
    
    Also please add documentation for it and increase libavdevice micro 
    version.
    
    Thanks,
    Marton
    _______________________________________________
    ffmpeg-devel mailing list
    ffmpeg-devel at ffmpeg.org
    http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
    


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libavdevice-decklink-configurablity-to-set-max-queue.patch
Type: application/octet-stream
Size: 5018 bytes
Desc: 0001-libavdevice-decklink-configurablity-to-set-max-queue.patch
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170817/7b2601e7/attachment.obj>


More information about the ffmpeg-devel mailing list