From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C1CA142FAE for ; Thu, 13 Jan 2022 02:53:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8DFFE68BACD; Thu, 13 Jan 2022 04:09:46 +0200 (EET) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A086E68BAB3 for ; Thu, 13 Jan 2022 04:09:44 +0200 (EET) Received: by mail-qk1-f175.google.com with SMTP id 193so4896282qkh.13 for ; Wed, 12 Jan 2022 18:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6izMkkDTDt+RiTuuWxI8KKpOmDWEG36v4TGqUQrMmak=; b=HencLT8Q9R2NonppA7/sszUbnp8Ty4ywwEs4PzVGoEjxQ52w8HJPeS7bPjv4lK10Mg Low3d2/ieIBQP849QzOh7kiCeuaJcbFsF6K6HsY4jm3dNvcx+oT+3keB3YUgVgWNWm16 mebaKjmrquiFOOSp1kMn3En5ydea7Jfto35uzZG91f18+i2K/Wv1ojG4hYe2RCpvxbW/ bClEHpM3OQrFyRkr4vt7mLdmMdDanRaJNUkOLMfu1rGFMlfHeMjEmYm/GPNy+jK9oqJ8 kPjy6zoBaY2v8xGjPDI82lZvnGS2GM8NbYYKZcbBCo/f/226GckUS4Flv1kIlcOI6wvk o+0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6izMkkDTDt+RiTuuWxI8KKpOmDWEG36v4TGqUQrMmak=; b=pKmK3zvqxBodg0WaWydFXi48BvuzHqh0oYbUY9CnwMaZvyv7JC8ffIqbeRBIWP/icN HsXfCfUUWNLQn98SO4K0i4CpQwSjHBr/NPBjaMIr203Yg81uRcWGrrC3W6L1UapTk4gS voH4YANyRrffTVExgQ7IQVwGxnhRG4SepOChKJDQJhdzhqU03pembUNXhOKtY3Wht/Gc jWAxRI9Pqu4DJ58JXSlJClPWonvIwwHUrzgQqXUjjeVBKR/Dq/+N1L+ZfTxHcbeREink 70jLw3FKTzDgIx+INbPbY75TQVzbZaCeZSp51aXlyYsa2b47SsbKfAW/bfn3WYHDse9v JZpA== X-Gm-Message-State: AOAM533XNIH6JZFuk24AcStwnolS7NKOem92YIH5i9mEeHMeFPd2nBEm C1E+1e2ivjHdGHFD+cpXWAL92VrWHA4= X-Google-Smtp-Source: ABdhPJzxipcEd+AnzJZgyrQgL9cgNhddDuo5Y0xvJlBe/nAfdEr8u7KCphIjCh4mzBJIadzAQCkQew== X-Received: by 2002:a05:620a:240f:: with SMTP id d15mr1861415qkn.370.1642039782919; Wed, 12 Jan 2022 18:09:42 -0800 (PST) Received: from localhost.localdomain ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id u6sm1068031qko.83.2022.01.12.18.09.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 18:09:42 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Jan 2022 23:09:13 -0300 Message-Id: <20220113020913.870-12-jamrial@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220113015101.4-1-jamrial@gmail.com> References: <20220113015101.4-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 281/281] mov: Implement spatial audio 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Vittorio Giovara As defined by Google's Spatial Audio RFC. Signed-off-by: Vittorio Giovara Signed-off-by: Anton Khirnov Signed-off-by: James Almer --- libavformat/mov.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index e307df8e3c..d6d287262d 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7193,6 +7193,100 @@ cleanup: return ret; } +static int mov_read_SA3D(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVStream *st; + int i, version, type; + int ambisonic_order, channel_order, normalization, channel_count; + + if (c->fc->nb_streams < 1) + return 0; + + st = c->fc->streams[c->fc->nb_streams - 1]; + + if (atom.size < 16) { + av_log(c->fc, AV_LOG_ERROR, "SA3D audio box too small\n"); + return AVERROR_INVALIDDATA; + } + + version = avio_r8(pb); + if (version) { + av_log(c->fc, AV_LOG_WARNING, "Unsupported SA3D box version %d\n", version); + return 0; + } + + type = avio_r8(pb); + if (type) { + av_log(c->fc, AV_LOG_WARNING, + "Unsupported ambisonic type %d\n", type); + return 0; + } + + ambisonic_order = avio_rb32(pb); + + channel_order = avio_r8(pb); + if (channel_order) { + av_log(c->fc, AV_LOG_WARNING, + "Unsupported channel_order %d\n", channel_order); + return 0; + } + + normalization = avio_r8(pb); + if (normalization) { + av_log(c->fc, AV_LOG_WARNING, + "Unsupported normalization %d\n", normalization); + return 0; + } + + channel_count = avio_rb32(pb); + if (channel_count != (ambisonic_order + 1) * (ambisonic_order + 1)) { + av_log(c->fc, AV_LOG_ERROR, + "Invalid number of channels (%d / %d)\n", + channel_count, ambisonic_order); + return 0; + } + + for (i = 0; i < channel_count; i++) { + if (i != avio_rb32(pb)) { + av_log(c->fc, AV_LOG_WARNING, + "Ambisonic channel reordering is not supported\n"); + return 0; + } + } + + av_channel_layout_uninit(&st->codecpar->ch_layout); + st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_AMBISONIC; + st->codecpar->ch_layout.nb_channels = channel_count; + + return 0; +} + +static int mov_read_SAND(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + AVStream *st; + int version; + + if (c->fc->nb_streams < 1) + return 0; + + st = c->fc->streams[c->fc->nb_streams - 1]; + + if (atom.size < 5) { + av_log(c->fc, AV_LOG_ERROR, "Empty SAND audio box\n"); + return AVERROR_INVALIDDATA; + } + + version = avio_r8(pb); + if (version) { + av_log(c->fc, AV_LOG_WARNING, "Unsupported SAND box version %d\n", version); + return 0; + } + + st->disposition |= AV_DISPOSITION_NON_DIEGETIC; + + return 0; +} + static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('A','C','L','R'), mov_read_aclr }, { MKTAG('A','P','R','G'), mov_read_avid }, @@ -7292,6 +7386,8 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('d','v','v','C'), mov_read_dvcc_dvvc }, { MKTAG('d','v','w','C'), mov_read_dvcc_dvvc }, { MKTAG('k','i','n','d'), mov_read_kind }, +{ MKTAG('S','A','3','D'), mov_read_SA3D }, /* ambisonic audio box */ +{ MKTAG('S','A','N','D'), mov_read_SAND }, /* non diegetic audio box */ { 0, NULL } }; -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".