From patchwork Tue Mar 8 03:30:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jack Bruienne X-Patchwork-Id: 34641 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:4285:0:0:0:0 with SMTP id wq5csp160463nkb; Mon, 7 Mar 2022 19:30:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZeiLTeCTSbtdLI0viuU/pFYav5nhHMYABKR5wXjdfMQv55CrGQYJiTfZg0bWzSs1K2TWU X-Received: by 2002:a17:906:610:b0:6d6:e68b:136 with SMTP id s16-20020a170906061000b006d6e68b0136mr11930095ejb.332.1646710237697; Mon, 07 Mar 2022 19:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646710237; cv=none; d=google.com; s=arc-20160816; b=lTsJwZeeXmfq/rWec/XJr7buUrltnd7ZHdOeJp4tZPEaE7onAwCqoYUQxlF1ZW4bHm J8m5U31G0T5MH2cl5uNSlWT4iLfmH9I0ogs+R3jxrtevtv8vbltYDF2drjx+Z65aRv7S acpcdFwv4W4Rlkxe3/rNOckeOZWPHLjPvJNFaNVh5R9KbkT2JDCF6yToglzC5ijKlTjM vWZAbj+AwQ2Lw6HV2Mvb497IkL9YFHUUJ6T6FS6sdM1urTFWzVNqxAC/oV1bgxVwRYR1 ezVog9bjbWcdRhTL1J2ZCNv9HsmrJ+ktjqtIIu8KM8J2zaicpXc30CjfoXxvUwXdqncV MRzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:to:from:user-agent:mime-version:date:message-id :dkim-signature:delivered-to; bh=C5fQPzmucSiayxLRPY0zd8+4tNT0D8cKKC22KbF35o4=; b=cv00lPf1uj2H5IUZ+DcLE96NJTt6qxxl7u9unCtiQu5ppUifZy9zeZiFxUMYJ+ihRk VpCATAo0oD0UW/BwPRtHwOUaHAy77oiHGEJ7jhuNO1ylBejrFN5s9ptKSafw/LsMN2q8 xUc03hNVCh2Dw0s7DAfEHkzFzGCRZkWB8nSon0ORtwdSk9ifYHdSBs9VosBx2pFhvQKE CwQ9zHa6caNvfntrDOFWwePIdPLhWUzwbRmXphBlRjTYhb/nRYUeM1xXPcjqW4z93cAo 4rufDN8dmkAOgIU9ij1QLewsZVWOF/dgBWBGf3oRHHC/x6a6jzAhspo6SuP5GA/y3GtA iUUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=K7WHb6qE; 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 g15-20020a056402424f00b004139bbefb4fsi10858870edb.317.2022.03.07.19.30.37; Mon, 07 Mar 2022 19:30:37 -0800 (PST) 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=20210112 header.b=K7WHb6qE; 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 7500368B204; Tue, 8 Mar 2022 05:30:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2BEBC68AF0A for ; Tue, 8 Mar 2022 05:30:27 +0200 (EET) Received: by mail-io1-f42.google.com with SMTP id k25so3667499iok.8 for ; Mon, 07 Mar 2022 19:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to :content-language; bh=E3xtX42oPm7x8AOpjSwS8p2AqT02xymL5otvnR/ZWpU=; b=K7WHb6qEV26Z9kY663hCveqHCDIeSwU36m8G2EstwN9nn51i1bx2cKIPk4zevL0A8e UVWs2nzDE4/3JnDPXxsqAyhS2BzixN7VsMsf+mEceaRFTluBl7pj88iTcBQbCTq06x4E qYaB+8k89/pQMZNBv2mIM/lG6voDX8BBoZV+j68QUjRmsAjCxpXGXCZJVSc5uqqnRva5 qMcDIaxLhhuBfBNG78SxKQvYEwA2uKOBB1zg7svfXA1IiycAtMxf6PvMlcBVnjlZiplW 28AmuYSGTHNWHtgMW+lBDpIjVK/32UIDSDZUjvpHOSnZRivIQ6+SOCAGqqcYLkYcYhgk AgKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:content-language; bh=E3xtX42oPm7x8AOpjSwS8p2AqT02xymL5otvnR/ZWpU=; b=OBViIj6mO2iKrSHWSkgM0TLIkp93Z3O6gKAmGbsbTugHyGfpEHRk4VEtAREGSg5asm lV5i2fcAVeEsRsuOQ05/lPVJmI/x/jlyBOyOZh6Lej7rwuNNFYgFwlCdcSRpKPNwImn+ da4vk2aijvTkv/Zg3t2mygsSwqSVL73PW0/GjwS6VqKLUhCwex0K6aL0lNOfbpJM61fU D6DjRSkEhQpUdXhFMy+9wTtPRnczqlIur3QYzgw8KujFF6QNwJr0hivxMhojUfQiKr4k 0cpaaRylB4Cp08jnwHnxOAq11bUxKBfLGhD3DsMXzXZnZfBKfWjghY4Vp30oyuRADWLq EkxA== X-Gm-Message-State: AOAM533MvyKOsDmlXnB1Uhzu914alqJ2hQ9+w+3FoYc7THH1gtyn8FFX unTx4Qbd7UDnjBJgrvIQC3axy4ezpLNKqg== X-Received: by 2002:a6b:c842:0:b0:645:c339:38c7 with SMTP id y63-20020a6bc842000000b00645c33938c7mr7216828iof.26.1646710225569; Mon, 07 Mar 2022 19:30:25 -0800 (PST) Received: from [192.168.7.86] (c-68-40-205-18.hsd1.mi.comcast.net. [68.40.205.18]) by smtp.gmail.com with ESMTPSA id i3-20020a056602134300b0064620a85b6dsm612785iov.12.2022.03.07.19.30.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Mar 2022 19:30:24 -0800 (PST) Message-ID: <193e12fa-5bea-5fab-6def-a5ebd3a4be63@gmail.com> Date: Mon, 7 Mar 2022 22:30:24 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Jack Bruienne To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH v7 3/3] libavformat: Added DFPWM WAV container support 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nPCLuD5d6541 This commit adds support for storing DFPWM audio in a WAV container. It uses the WAVEFORMATEXTENSIBLE structure, following these conventions: https://gist.github.com/MCJack123/90c24b64c8e626c7f130b57e9800962c The implementation is very simple: it just adds the GUID to the list of WAV GUIDs, and modifies the WAV muxer to always use WAVEFORMATEXTENSIBLE format with that GUID. This creates a standard container format for DFPWM besides raw data. It will allow users to transfer DFPWM audio in a standard container format, with the sample rate and channel count contained in the file as opposed to being an external parameter as in the raw format. This format is already supported in my AUKit library, which is the CC analog to libav (albeit much smaller). Support in other applications is TBD. Signed-off-by: Jack Bruienne --- libavformat/riff.c | 3 +++ libavformat/riffenc.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/riff.c b/libavformat/riff.c index 0c19d3f..f098c1d 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -587,6 +587,8 @@ const AVCodecTag ff_codec_wav_tags[] = { { AV_CODEC_ID_AAC, 0xA106 }, { AV_CODEC_ID_SPEEX, 0xA109 }, { AV_CODEC_ID_FLAC, 0xF1AC }, + /* DFPWM does not have an assigned format tag; it uses a GUID in WAVEFORMATEX instead */ + { AV_CODEC_ID_DFPWM, 0xFFFE }, { AV_CODEC_ID_ADPCM_SWF, ('S' << 8) + 'F' }, /* HACK/FIXME: Does Vorbis in WAV/AVI have an (in)official ID? */ { AV_CODEC_ID_VORBIS, ('V' << 8) + 'o' }, @@ -637,5 +639,6 @@ const AVCodecGuid ff_codec_wav_guids[] = { { AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } }, { AV_CODEC_ID_MP2, { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } }, { AV_CODEC_ID_ADPCM_AGM,{ 0x82, 0xEC, 0x1F, 0x6A, 0xCA, 0xDB, 0x19, 0x45, 0xBD, 0xE7, 0x56, 0xD3, 0xB3, 0xEF, 0x98, 0x1D } }, + { AV_CODEC_ID_DFPWM, { 0x3A, 0xC1, 0xFA, 0x38, 0x81, 0x1D, 0x43, 0x61, 0xA4, 0x0D, 0xCE, 0x53, 0xCA, 0x60, 0x7C, 0xD1 } }, { AV_CODEC_ID_NONE } }; diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c index ffccfa3..96750e7 100644 --- a/libavformat/riffenc.c +++ b/libavformat/riffenc.c @@ -81,7 +81,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, par->channels == 1 && par->channel_layout && par->channel_layout != AV_CH_LAYOUT_MONO || par->channels == 2 && par->channel_layout && par->channel_layout != AV_CH_LAYOUT_STEREO || par->sample_rate > 48000 || - par->codec_id == AV_CODEC_ID_EAC3 || + par->codec_id == AV_CODEC_ID_EAC3 || par->codec_id == AV_CODEC_ID_DFPWM || av_get_bits_per_sample(par->codec_id) > 16; if (waveformatextensible) @@ -188,7 +188,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, /* dwChannelMask */ avio_wl32(pb, write_channel_mask ? par->channel_layout : 0); /* GUID + next 3 */ - if (par->codec_id == AV_CODEC_ID_EAC3) { + if (par->codec_id == AV_CODEC_ID_EAC3 || par->codec_id == AV_CODEC_ID_DFPWM) { ff_put_guid(pb, ff_get_codec_guid(par->codec_id, ff_codec_wav_guids)); } else { avio_wl32(pb, par->codec_tag);