From patchwork Wed Oct 18 19:23:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Rice X-Patchwork-Id: 5619 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp1726858jah; Wed, 18 Oct 2017 12:23:20 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qooujco47ugvICsmseVqRAWWYUTaxkDHycuYCb+tfeC/cGDwZfX5RrbmIZe3HLNcN1CaR2 X-Received: by 10.28.28.138 with SMTP id c132mr6943979wmc.48.1508354600707; Wed, 18 Oct 2017 12:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508354600; cv=none; d=google.com; s=arc-20160816; b=wNS99/lBol0x+umce9vl6OO+MxeEHop5CnhOL5cyCP7tZuXz4+8PMPd5bBVKYH1dY/ YnZoDngTpKILpZc96dxgfxtUV9PACP3c0CQwc4EZYb6dgreIkzqxiFLzZ3pA/F1vPkI1 lyf96Y3ZEvmhA7a3b/nUAazGQz4qfhafZbKGTaxA9Q+XbKIFBhZBbdgJ9XflKPv6ln/g /MPUdF1mVdbPHjqlF8q+6UFhsMQun9q036lHLTgtuogghOh6Rf22+hhFFQbjPQC0H0QI rueN2P3juJxd3x0JQE0CKys9O6f2xyOygvduLXslq5OvuXp4CWmVSbhxsFYUws2ihz4S MoNw== 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:message-id:in-reply-to:to:references:date :mime-version:from:delivered-to:arc-authentication-results; bh=8Y1zM6jQsCy+4b00Ychb+sPu7ixoTsnN5udCp1KmhMo=; b=QycTO+4Z/ce2bPRVj1MHSV3/Zr9KQD7InK27up2ySIozZ7useMhtyOpgD3Jc5h8txU Oc8DF674DZbC9r/FuB/deNEHlXGpCoHJr463cFrwQCqbfBF778I6DVHwRX6gL4yrX/cW WUJP26nprjctF/tcRwU5Uu1+Q0SAwAAt5/rn/Syjr+X1RfIzZsLtHsiodHmgz5+RPhe7 pOeuRkmSroD7XEYAsAhxBIrInytTPC4Y3Md29ED6ohWY2uw0IU78pFFvhnfTEp5J7gyx DwfFCYg1FxUbePz+ISSe2U6SPllSj5YwSyTrJu4yC1pIgFY+ekLpwLDO6y3t5p/TZ3S3 qoxg== 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 o9si3308144wmf.214.2017.10.18.12.23.20; Wed, 18 Oct 2017 12:23:20 -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; 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 BBA47689FD9; Wed, 18 Oct 2017 22:23:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from server172-2.web-hosting.com (server172-2.web-hosting.com [68.65.122.110]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B64DC689FC0 for ; Wed, 18 Oct 2017 22:23:06 +0300 (EEST) Received: from [146.96.19.240] (port=26528 helo=[10.10.201.39]) by server172.web-hosting.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e4tvk-0012Wc-39 for ffmpeg-devel@ffmpeg.org; Wed, 18 Oct 2017 15:23:09 -0400 From: Dave Rice Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Date: Wed, 18 Oct 2017 15:23:02 -0400 References: <5823C84E-19DF-4E05-ABC0-72396DDD0BDA@dericed.com> To: FFmpeg development discussions and patches In-Reply-To: Message-Id: <5C9C4D52-2064-46F9-8623-6C8CFA3F3DC1@dericed.com> X-Mailer: Apple Mail (2.3226) X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server172.web-hosting.com X-AntiAbuse: Original Domain - ffmpeg.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dericed.com X-Get-Message-Sender-Via: server172.web-hosting.com: authenticated_id: dave@dericed.com X-Authenticated-Sender: server172.web-hosting.com: dave@dericed.com X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] libavdevice/decklink: 32 bit audio support 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" > On Oct 18, 2017, at 3:07 PM, Marton Balint wrote: > > On Mon, 16 Oct 2017, Dave Rice wrote: > >> Hi, >> >> I tested this with my Ultrastudio Express and confirmed that I'm getting higher bit depth recordings with the abitscope filter. This patch adds an option to get 32 bit audio as an input with the decklink device (beforehand only 16 bit audio was supported). This resolves http://trac.ffmpeg.org/ticket/6708 and is partly based upon Georg Lippitisch's earlier draft at https://ffmpeg.org/pipermail/ffmpeg-devel/2015-January/167649.html. >> >> >> From fbf2bd40471c8fa35374bb1a51c51a3f4f36b992 Mon Sep 17 00:00:00 2001 >> From: Dave Rice >> Date: Thu, 12 Oct 2017 13:40:59 -0400 >> Subject: [PATCH] libavdevice/decklink: 32 bit audio support >> >> Partially based upon Georg Lippitsch's patch at https://ffmpeg.org/pipermail/ffmpeg-devel/2015-January/167649.html. >> --- >> libavdevice/decklink_common.h | 1 + >> libavdevice/decklink_common_c.h | 1 + >> libavdevice/decklink_dec.cpp | 17 ++++++++++++++--- >> libavdevice/decklink_dec_c.c | 1 + >> 4 files changed, 17 insertions(+), 3 deletions(-) > > Missing docs/indevs.texi update and libavdevice micro bump. Updated. From 1e5ff78fec9b13eccac9a96acc358bbfd6a7015d Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Wed, 18 Oct 2017 15:21:46 -0400 Subject: [PATCH] libavdevice/decklink: 32 bit audio support --- doc/indevs.texi | 4 ++++ libavdevice/decklink_common.h | 1 + libavdevice/decklink_common_c.h | 1 + libavdevice/decklink_dec.cpp | 17 ++++++++++++++--- libavdevice/decklink_dec_c.c | 1 + libavdevice/version.h | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index 55a4084bb2..d308bbf7de 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -311,6 +311,10 @@ Sets maximum input buffer size in bytes. If the buffering reaches this value, incoming frames will be dropped. Defaults to @samp{1073741824}. +@item audio_depth +Sets the audio sample bit depth. Must be @samp{16} or @samp{32}. +Defaults to @samp{16}. + @end table @subsection Examples diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index 6b2525fb53..b6acb01bb9 100644 --- a/libavdevice/decklink_common.h +++ b/libavdevice/decklink_common.h @@ -97,6 +97,7 @@ struct decklink_ctx { int frames_buffer_available_spots; int channels; + int audio_depth; }; typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t; diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h index 5616ab32f9..368ac259e4 100644 --- a/libavdevice/decklink_common_c.h +++ b/libavdevice/decklink_common_c.h @@ -42,6 +42,7 @@ struct decklink_cctx { double preroll; int v210; int audio_channels; + int audio_depth; int duplex_mode; DecklinkPtsSource audio_pts_source; DecklinkPtsSource video_pts_source; diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index d9ac01ac91..7e97d5f064 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -771,7 +771,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( av_init_packet(&pkt); //hack among hacks - pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (16 / 8); + pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8); audioFrame->GetBytes(&audioFrameBytes); audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den); pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts); @@ -854,6 +854,7 @@ 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->audio_depth = cctx->audio_depth; cctx->ctx = ctx; /* Check audio channel option for valid values: 2, 8 or 16 */ @@ -866,6 +867,16 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) av_log(avctx, AV_LOG_ERROR, "Value of channels option must be one of 2, 8 or 16\n"); return AVERROR(EINVAL); } + + /* Check audio bit depth option for valid values: 16 or 32 */ + switch (cctx->audio_depth) { + case 16: + case 32: + break; + default: + av_log(avctx, AV_LOG_ERROR, "Value for audio bit depth option must be either 16 or 32\n"); + return AVERROR(EINVAL); + } /* List available devices. */ if (ctx->list_devices) { @@ -930,7 +941,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) goto error; } st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; - st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; + st->codecpar->codec_id = cctx->audio_depth == 32 ? AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE; st->codecpar->sample_rate = bmdAudioSampleRate48kHz; st->codecpar->channels = cctx->audio_channels; avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ @@ -1021,7 +1032,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) } av_log(avctx, AV_LOG_VERBOSE, "Using %d input audio channels\n", ctx->audio_st->codecpar->channels); - result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels); + result = ctx->dli->EnableAudioInput(bmdAudioSampleRate48kHz, cctx->audio_depth == 32 ? bmdAudioSampleType32bitInteger : bmdAudioSampleType16bitInteger, ctx->audio_st->codecpar->channels); if (result != S_OK) { av_log(avctx, AV_LOG_ERROR, "Cannot enable audio input\n"); diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c index 1127d23ada..1c6d826945 100644 --- a/libavdevice/decklink_dec_c.c +++ b/libavdevice/decklink_dec_c.c @@ -72,6 +72,7 @@ static const AVOption options[] = { { "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 }, + { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC }, { NULL }, }; diff --git a/libavdevice/version.h b/libavdevice/version.h index d3622c5395..68defac417 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 57 #define LIBAVDEVICE_VERSION_MINOR 11 -#define LIBAVDEVICE_VERSION_MICRO 100 +#define LIBAVDEVICE_VERSION_MICRO 101 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \