From patchwork Fri Jun 11 20:30:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28223 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp766319iol; Fri, 11 Jun 2021 13:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM8F265OTqssykkiyeJXED9NGrw+3rNBbmed6NLbZhnjzMtFmOzpf0z9sXFHy2fDzjeOcS X-Received: by 2002:a17:906:4a48:: with SMTP id a8mr5299179ejv.472.1623443927606; Fri, 11 Jun 2021 13:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623443927; cv=none; d=google.com; s=arc-20160816; b=qo29kzqUdxvTgtTAFTkMc7a3GVJhKilKGSyEubyBoLStiu3Osx34/kTekzq7oC7y7+ aXuOf76aFdG0YrG8GeSz0Z0RPtJR8hK2tNHgc7zIKzQGkoOdA6Bq49VMiaMlgEOwIWro 1vZIzhDoHVeL1hAwk3uruLF5O9ppye8ss5+IpE6Yhzz/L4TFrNQhVq53DUBaD82rz1sb 7YiKuis4CAVM74UP/tPr1odgxI4Gh2Km7DTmBC9+SFSaes0kPjVe0o0spYtwrwpDgLfA gDH7YonkUvAHRpqoPabV4ka15prgytox1QLPpS+DFkNkU91IEQmPC74wNAT+nCoT2dzD pnZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=9uIk9dZFM83XUGVxAlJiDzPBa3uHiY1dQHhkvXdJEps=; b=ioW3PZkCFa9vEsyLg6cPDNzeF7/VwTDZAhttI+ozrFujN2uL2EMVGB6+qcS7tgBsDI +oRe6/bpItBcydCRClB+ZCtaOaAYYlCOeSFmCroWJ08+eQIQKSjx2FAf7MbCeafPbAo7 sZe/keYL+ck4KsqL7ldcBU6xVZeF5miyGZcy5ZM6dO17jfE2VG+8K8jOXlKXgCBZbiQ1 +4ZAwbcp85eKnFCEyU9wapiWbp5TmtyAFmpyY5FbmDgsfc4qXteqsLk9Nk0nLZrY/1+o zT5wa1qrmhBr2OIKuMUFN3kvqFu4ouu6DJz0mPigBSJCJCtu3OlpwU2YbXkhClUnq/fp 8x7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="kPjmcX+/"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x2si5799490eju.99.2021.06.11.13.38.47; Fri, 11 Jun 2021 13:38:47 -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=@gmail.com header.s=20161025 header.b="kPjmcX+/"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E2A11689AA0; Fri, 11 Jun 2021 23:38:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D92716899A2 for ; Fri, 11 Jun 2021 23:38:42 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id r5so10393970lfr.5 for ; Fri, 11 Jun 2021 13:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PgGWjxD93RILpjWuwQZ6Dd/BNfDTkb1ct8AqHYeZL8c=; b=kPjmcX+/32KUwo/ODh6TOXhi08bzaidZH42yi050xTfan2e439aknKfpaGJ12uU5uN VYqUV+ZbTeBiyggSZAbSAy5IHGuM7xttdpBz98B6uVDwY7xrusIamHIjstQpDgrauQaK 5tE0LiovmkWukLlP7MY7WaEaxj0Xiywdnaq30hHNppuiRjp8pQew/gQ5izkw9GRLzA8t IYqQrmE2kr1jtsxEj/o1Tq+z4F2/dGSfAdfKXjpXdcX1koGR/Z4tfBbYLdG4TKIj3dSi qoj15dctJw6Nf9kIu1BSiy4dbduCaPcu2E0XnjUixlZs6Fw7VJrn9/G3tnWwwB6aT7Cs 4rPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PgGWjxD93RILpjWuwQZ6Dd/BNfDTkb1ct8AqHYeZL8c=; b=slshLvbwkFGVZFdCKnOKWz0qsHgMvHjxWVTrV9RFi0cG6gUWXIs/0S+durIhiNJrjM rqG63q6OCjpXMkZqYD4S5FwSg9NjE+Uti08g1krPlhYPBRXOOENZWx5D9Kl+XzQMcZE2 GTBV2paRNA9PTR9NtMEcRyun7PDbMabBgkiFVw6YPTSHqH1I7xyLDfn3DrcCHbZTZhaF +uCZ9cmkFwqBqXZcXzb01cDSCcBL6noNSrgMvtGsBRHh9GN+7wv7hTgrxYivvJLP00Iu kzrZP2VnOuqvNsUzx8JFhZ+Jd8tk6+hPQokDWkCOY1iDowLpsyg6jrbYmr4gwqu+Ny1O hZIw== X-Gm-Message-State: AOAM532yS2atGFCHk7BR68FCnVbQNkSA2MOvfV/6YDrnZTITU+L5U1DH 6DHK8s1FdJJnQEsBBfJxTDGoeUlAoCMiSQ== X-Received: by 2002:a05:6512:3f9a:: with SMTP id x26mr3973712lfa.75.1623443921738; Fri, 11 Jun 2021 13:38:41 -0700 (PDT) Received: from localhost.localdomain ([196.196.203.214]) by smtp.gmail.com with ESMTPSA id t27sm845561ljo.130.2021.06.11.13.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:38:41 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Jun 2021 22:30:56 +0200 Message-Id: <20210611203104.1692-26-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210611203104.1692-1-dcnieho@gmail.com> References: <20210611203104.1692-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 25/33] avdevice/dshow: move audio format helpers 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 Cc: Diederick Niehorster Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WNObjRlEbWul Needs to be moved up in file for upcoming implementation of avdevice_capabilities_create. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 34c7b63220..4605bd6f8e 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -75,6 +75,26 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others } +static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt) +{ + switch (sample_fmt) { + case AV_SAMPLE_FMT_U8: return AV_CODEC_ID_PCM_U8; + case AV_SAMPLE_FMT_S16: return AV_CODEC_ID_PCM_S16LE; + case AV_SAMPLE_FMT_S32: return AV_CODEC_ID_PCM_S32LE; + default: return AV_CODEC_ID_NONE; /* Should never happen. */ + } +} + +static enum AVSampleFormat sample_fmt_bits_per_sample(int bits) +{ + switch (bits) { + case 8: return AV_SAMPLE_FMT_U8; + case 16: return AV_SAMPLE_FMT_S16; + case 32: return AV_SAMPLE_FMT_S32; + default: return AV_SAMPLE_FMT_NONE; /* Should never happen. */ + } +} + static enum AVColorRange dshow_color_range(DXVA2_ExtendedFormat* fmt_info) { switch (fmt_info->NominalRange) @@ -1629,26 +1649,6 @@ static int dshow_control_message(AVFormatContext *avctx, int type, void *data, s return ret; } -static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt) -{ - switch (sample_fmt) { - case AV_SAMPLE_FMT_U8: return AV_CODEC_ID_PCM_U8; - case AV_SAMPLE_FMT_S16: return AV_CODEC_ID_PCM_S16LE; - case AV_SAMPLE_FMT_S32: return AV_CODEC_ID_PCM_S32LE; - default: return AV_CODEC_ID_NONE; /* Should never happen. */ - } -} - -static enum AVSampleFormat sample_fmt_bits_per_sample(int bits) -{ - switch (bits) { - case 8: return AV_SAMPLE_FMT_U8; - case 16: return AV_SAMPLE_FMT_S16; - case 32: return AV_SAMPLE_FMT_S32; - default: return AV_SAMPLE_FMT_NONE; /* Should never happen. */ - } -} - static int dshow_add_device(AVFormatContext *avctx, enum dshowDeviceType devtype)