From patchwork Thu Dec 16 13:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 32658 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp424349iog; Thu, 16 Dec 2021 05:23:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4ZviwKaAaw+eMcwMRXpKh6VuavDeTJJCPWXR3E+/cAmrB4PmQtC8QYSuSJ0NOtrTFtxWm X-Received: by 2002:a17:906:dc8d:: with SMTP id cs13mr15534419ejc.323.1639661028353; Thu, 16 Dec 2021 05:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639661028; cv=none; d=google.com; s=arc-20160816; b=jPTvGcXHsqQ03wHSdFMcLDNTmIOZnVS8tFIqxKxeUcjUMNDK2vc4wB3ktvI3NlJ6w0 onOvVaiJZqrq+YikGZbk6WV1x8mJ3kO0pK2lbbM8CUCQXUDCYQ0eHk0BjIBJ5WUFoBBE eS0rBMdI8gLqDcgojM7jTxhGAs8D8Wa/0e4txe0mxlQjq+ri3H6TQJioc/axoSE6j0oa nr03g7db0xhMBEO1sTuxWv+tLHVmz63oJ/V7reFB2gTg9ruSm/IaoJH9EuWvohFv5GK3 G1RX9Rjx5Jy43mIAzuN+He777KZU4aTtuYCXOkRo/Xi153NCIG9XNLSKzxtsB96yAWYa nbVw== 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:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=NfgPqKKFp1minEKTn7uoiOqqBNHEtytJozEQxqWPVlc=; b=f0cWUu1/iXPfG0MICRcrG9pYik/Zpa9HeIom45I2AcAu17JRLkWrTCZX+HKeGOF6NG KDo9FfsnlR2wSzpHJnI5eaqXfD2QWGgRJUji1XZXzWSLAt3AnXLlV1B7iU/FUBcN/UjE BIn1muwWHVPFPOitloqHD2B0srr6/Fdt3ex5nBcGLVprub20SKoyozWNqa2Pzu6nzajJ +VubUw8x0oeyEDfcSOi8+aq6OrxSG8cYkVnibGqna+HvtC3+I+60OkrbUsPSAQuN9O41 9z2rz16Irca6BhaRfzQD5Msh5X9T1FmV5wWtbbWsb4yaM44UUmgqH9o3mmLD1vgI7MKW EsDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=W7KzFikx; 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 l16si4624716ejo.393.2021.12.16.05.23.36; Thu, 16 Dec 2021 05:23:48 -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=W7KzFikx; 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 7347768AF2C; Thu, 16 Dec 2021 15:23:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF82668AEF8 for ; Thu, 16 Dec 2021 15:22:57 +0200 (EET) Received: by mail-ua1-f52.google.com with SMTP id 30so47084489uag.13 for ; Thu, 16 Dec 2021 05:22:57 -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=RJa/zrDc7YqruoPc1QYBQu4YEsanYUkZRIl72UqLKSU=; b=W7KzFikxpXYvY+hLYSeNdDkQtpPLW+pGlDMeYPqENFvosa1rVQ5oE77mVcQYzh83jW RBDdAgWYsPlak+r7X7yxeZIJ5oC/3HEydoRUfbjFW5ouDmQrPmTApGkGTCsNnsK/2wEF UQ+iL2U4cqBIvqUT8xo642rjAcUoGFKro6D0OBcGEVKrF7E9B+8VnxLZ4x0pi/5gkXZ/ nkmYJXpWba0tdzP0/T7ZLRPJKtNuxMT+aw99crk3l0DJsiQEHcmFwrUE7ir+cNCKbMLn sAxgkTO+cFNXbxCbYqPuI6unU22et1bTOzYQITeO1YFPv+/3v+7Tof4wXdB2THVlLLtn UGYw== 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=RJa/zrDc7YqruoPc1QYBQu4YEsanYUkZRIl72UqLKSU=; b=g5N4szW15kYHNplB9Sj+2UpJO5IV1i6oAHG1pQPGPQhkZKuPGvG0z17Kqhgvek82/t dHPjaj3t+LZI94FlbmLVm7F09qNirpXmNNbE3QVm0aQzOoPKna1ABJxTuvUxpDyf5z78 VQ6n01Cj2cm3URS4LK8eJEgbaAirlyAse/cd2EGi4QS6GEJrtXK3Wc3AuhIjMdxtSL/M pxMFaFErOxAkCZOzjNqWzzwrFH3tQSqG96+14V8x7AVXjQWxtas9/ReSD4xJm/P3hWsK huhNSKtokESoYhss+PMuKZJxwt2uqvw61XRS2u1mMdno3VUzR/5QnagsdXShzYg5rZko 6a5w== X-Gm-Message-State: AOAM530wOh74xoiCOg2JxB7ZdxWqxL2/yyVWygHmKVcBQJK1QgaVHyBD KZLhR30cnmgGDAyMZrwsAw1VpL15t/gB3A== X-Received: by 2002:ab0:224e:: with SMTP id z14mr11847742uan.97.1639660975969; Thu, 16 Dec 2021 05:22:55 -0800 (PST) Received: from localhost.localdomain ([181.170.250.138]) by smtp.gmail.com with ESMTPSA id 6sm1082605vkq.23.2021.12.16.05.22.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 05:22:55 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 10:21:51 -0300 Message-Id: <20211216132151.8216-3-jamrial@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216132151.8216-1-jamrial@gmail.com> References: <20211216132151.8216-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 002/279 v2] fate: add a channel_layout API test 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: 7b9gfBavfZPT Signed-off-by: James Almer --- Changes since last time: - Added and adapted some tests to cover the new additions to the API. - Now using the AVBPrint variants of some functions. libavutil/Makefile | 1 + libavutil/tests/channel_layout.c | 233 +++++++++++++++++++++++++++++++ tests/fate/libavutil.mak | 4 + tests/ref/fate/channel_layout | 98 +++++++++++++ 4 files changed, 336 insertions(+) create mode 100644 libavutil/tests/channel_layout.c create mode 100644 tests/ref/fate/channel_layout diff --git a/libavutil/Makefile b/libavutil/Makefile index 529046dbc8..8915575cfa 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -219,6 +219,7 @@ TESTPROGS = adler32 \ bprint \ cast5 \ camellia \ + channel_layout \ color_utils \ cpu \ crc \ diff --git a/libavutil/tests/channel_layout.c b/libavutil/tests/channel_layout.c new file mode 100644 index 0000000000..73ed0a6666 --- /dev/null +++ b/libavutil/tests/channel_layout.c @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2021 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/channel_layout.c" + +#define CHANNEL_LAYOUT_FROM_MASK(layout, x) \ + av_channel_layout_uninit(&layout); \ + if (!av_channel_layout_from_mask(&layout, x)) \ + av_channel_layout_describe_bprint(&layout, &bp); + +#define CHANNEL_LAYOUT_FROM_STRING(layout, x) \ + av_channel_layout_uninit(&layout); \ + if (!av_channel_layout_from_string(&layout, x)) \ + av_channel_layout_describe_bprint(&layout, &bp); + +#define CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(layout, x) \ + ret = av_channel_layout_channel_from_index(&layout, x); \ + if (ret < 0) \ + ret = -1 + +#define CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(layout, x) \ + ret = av_channel_layout_index_from_channel(&layout, x); \ + if (ret < 0) \ + ret = -1 + +#define CHANNEL_LAYOUT_CHANNEL_FROM_STRING(layout, x) \ + ret = av_channel_layout_channel_from_string(&layout, x); \ + if (ret < 0) \ + ret = -1 + +#define CHANNEL_LAYOUT_INDEX_FROM_STRING(layout, x) \ + ret = av_channel_layout_index_from_string(&layout, x); \ + if (ret < 0) \ + ret = -1 + +int main(void) +{ + AVChannelLayout surround = { 0 }; + AVChannelLayout custom = { 0 }; + AVBPrint bp; + int ret; + + av_bprint_init(&bp, 64, AV_BPRINT_SIZE_AUTOMATIC); + + printf("Testing av_channel_name\n"); + av_channel_name_bprint(&bp, AV_CHAN_FRONT_LEFT); + printf("With AV_CHAN_FRONT_LEFT: %27s\n", bp.str); + av_channel_name_bprint(&bp, AV_CHAN_FRONT_RIGHT); + printf("With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str); + av_channel_name_bprint(&bp, 63); + printf("With 63: %43s\n", bp.str); + + printf("Testing av_channel_description\n"); + av_channel_description_bprint(&bp, AV_CHAN_FRONT_LEFT); + printf("With AV_CHAN_FRONT_LEFT: %27s\n", bp.str); + av_channel_description_bprint(&bp, AV_CHAN_FRONT_RIGHT); + printf("With AV_CHAN_FRONT_RIGHT: %26s\n", bp.str); + av_channel_description_bprint(&bp, 63); + printf("With 63: %43s\n", bp.str); + + printf("\nTesting av_channel_from_string\n"); + printf("With \"FL\": %41d\n", av_channel_from_string("FL")); + printf("With \"FR\": %41d\n", av_channel_from_string("FR")); + printf("With \"USR63\": %38d\n", av_channel_from_string("USR63")); + + printf("\n==Native layouts==\n"); + + printf("\nTesting av_channel_layout_from_string\n"); + CHANNEL_LAYOUT_FROM_STRING(surround, "0x3f"); + printf("With \"0x3f\": %39s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "6c"); + printf("With \"6c\": %41s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "6C"); + printf("With \"6C\": %41s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "6"); + printf("With \"6\": %42s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "6 channels"); + printf("With \"6 channels\": %33s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "FL|FR|FC|LFE|BL|BR"); + printf("With \"FL|FR|FC|LFE|BL|BR\": %25s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "5.1"); + printf("With \"5.1\": %40s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "FL|FR|USR63"); + printf("With \"FL|FR|USR63\": %32s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "FL|FR|FC|LFE|SL|SR"); + printf("With \"FL|FR|FC|LFE|SL|SR\": %25s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(surround, "5.1(side)"); + printf("With \"5.1(side)\": %34s\n", bp.str); + + printf("\nTesting av_channel_layout_from_mask\n"); + CHANNEL_LAYOUT_FROM_MASK(surround, AV_CH_LAYOUT_5POINT1); + printf("With AV_CH_LAYOUT_5POINT1: %25s\n", bp.str); + + printf("\nTesting av_channel_layout_channel_from_index\n"); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 0); + printf("On 5.1(side) layout with 0: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 1); + printf("On 5.1(side) layout with 1: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 2); + printf("On 5.1(side) layout with 2: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 3); + printf("On 5.1(side) layout with 3: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 4); + printf("On 5.1(side) layout with 4: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 5); + printf("On 5.1(side) layout with 5: %24d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(surround, 6); + printf("On 5.1(side) layout with 6: %24d\n", ret); + + printf("\nTesting av_channel_layout_index_from_channel\n"); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_FRONT_LEFT); + printf("On 5.1(side) layout with AV_CHAN_FRONT_LEFT: %7d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_FRONT_RIGHT); + printf("On 5.1(side) layout with AV_CHAN_FRONT_RIGHT: %6d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_FRONT_CENTER); + printf("On 5.1(side) layout with AV_CHAN_FRONT_CENTER: %5d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_LOW_FREQUENCY); + printf("On 5.1(side) layout with AV_CHAN_LOW_FREQUENCY: %4d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_SIDE_LEFT); + printf("On 5.1(side) layout with AV_CHAN_SIDE_LEFT: %8d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_SIDE_RIGHT); + printf("On 5.1(side) layout with AV_CHAN_SIDE_RIGHT: %7d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(surround, AV_CHAN_BACK_CENTER); + printf("On 5.1(side) layout with AV_CHAN_BACK_CENTER: %6d\n", ret); + + printf("\nTesting av_channel_layout_channel_from_string\n"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "FL"); + printf("On 5.1(side) layout with \"FL\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "FR"); + printf("On 5.1(side) layout with \"FR\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "FC"); + printf("On 5.1(side) layout with \"FC\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "LFE"); + printf("On 5.1(side) layout with \"LFE\": %20d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "SL"); + printf("On 5.1(side) layout with \"SL\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "SR"); + printf("On 5.1(side) layout with \"SR\": %21d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(surround, "BC"); + printf("On 5.1(side) layout with \"BC\": %21d\n", ret); + + printf("\nTesting av_channel_layout_index_from_string\n"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "FL"); + printf("On 5.1(side) layout with \"FL\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "FR"); + printf("On 5.1(side) layout with \"FR\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "FC"); + printf("On 5.1(side) layout with \"FC\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "LFE"); + printf("On 5.1(side) layout with \"LFE\": %20d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "SL"); + printf("On 5.1(side) layout with \"SL\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "SR"); + printf("On 5.1(side) layout with \"SR\": %21d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(surround, "BC"); + printf("On 5.1(side) layout with \"BC\": %21d\n", ret); + + printf("\n==Custom layouts==\n"); + + printf("\nTesting av_channel_layout_from_string\n"); + CHANNEL_LAYOUT_FROM_STRING(custom, "FL|FR|FC|BL|BR|LFE"); + printf("With \"FL|FR|FC|BL|BR|LFE\": %25s\n", bp.str); + CHANNEL_LAYOUT_FROM_STRING(custom, "FR|FL|USR63"); + printf("With \"FR|FL|USR63\" layout: %25s\n", bp.str); + + av_strlcpy(custom.u.map[2].name, "CUS", sizeof(custom.u.map[2].name)); + printf("\nTesting av_channel_layout_index_from_string\n"); + CHANNEL_LAYOUT_INDEX_FROM_STRING(custom, "FR"); + printf("On \"FR|FL|USR63\" layout with \"FR\": %17d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(custom, "FL"); + printf("On \"FR|FL|USR63\" layout with \"FL\": %17d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(custom, "USR63"); + printf("On \"FR|FL|USR63\" layout with \"USR63\": %14d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(custom, "CUS"); + printf("On \"FR|FL|USR63\" layout with custom label \"CUS\": %3d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_STRING(custom, "BC"); + printf("On \"FR|FL|USR63\" layout with \"BC\": %17d\n", ret); + + printf("\nTesting av_channel_layout_channel_from_string\n"); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(custom, "FR"); + printf("On \"FR|FL|USR63\" layout with \"FR\": %17d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(custom, "FL"); + printf("On \"FR|FL|USR63\" layout with \"FL\": %17d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(custom, "USR63"); + printf("On \"FR|FL|USR63\" layout with \"USR63\": %14d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(custom, "CUS"); + printf("On \"FR|FL|USR63\" layout with custom label \"CUS\": %3d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_STRING(custom, "BC"); + printf("On \"FR|FL|USR63\" layout with \"BC\": %17d\n", ret); + + printf("\nTesting av_channel_layout_index_from_channel\n"); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(custom, AV_CHAN_FRONT_RIGHT); + printf("On \"FR|FL|USR63\" layout with AV_CHAN_FRONT_RIGHT: %2d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(custom, AV_CHAN_FRONT_LEFT); + printf("On \"FR|FL|USR63\" layout with AV_CHAN_FRONT_LEFT: %3d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(custom, 63); + printf("On \"FR|FL|USR63\" layout with 63: %19d\n", ret); + CHANNEL_LAYOUT_INDEX_FROM_CHANNEL(custom, AV_CHAN_BACK_CENTER); + printf("On \"FR|FL|USR63\" layout with AV_CHAN_BACK_CENTER: %2d\n", ret); + + printf("\nTesting av_channel_layout_channel_from_index\n"); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(custom, 0); + printf("On \"FR|FL|USR63\" layout with 0: %20d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(custom, 1); + printf("On \"FR|FL|USR63\" layout with 1: %20d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(custom, 2); + printf("On \"FR|FL|USR63\" layout with 2: %20d\n", ret); + CHANNEL_LAYOUT_CHANNEL_FROM_INDEX(custom, 3); + printf("On \"FR|FL|USR63\" layout with 3: %20d\n", ret); + + av_channel_layout_uninit(&surround); + av_channel_layout_uninit(&custom); + av_bprint_finalize(&bp, NULL); + + return 0; +} diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak index 1ec9ed00ad..c32cf2e706 100644 --- a/tests/fate/libavutil.mak +++ b/tests/fate/libavutil.mak @@ -23,6 +23,10 @@ fate-cast5: libavutil/tests/cast5$(EXESUF) fate-cast5: CMD = run libavutil/tests/cast5$(EXESUF) fate-cast5: CMP = null +FATE_LIBAVUTIL += fate-channel_layout +fate-channel_layout: libavutil/tests/channel_layout$(EXESUF) +fate-channel_layout: CMD = run libavutil/tests/channel_layout$(EXESUF) + FATE_LIBAVUTIL += fate-audio_fifo fate-audio_fifo: libavutil/tests/audio_fifo$(EXESUF) fate-audio_fifo: CMD = run libavutil/tests/audio_fifo$(EXESUF) diff --git a/tests/ref/fate/channel_layout b/tests/ref/fate/channel_layout new file mode 100644 index 0000000000..1b42d5d983 --- /dev/null +++ b/tests/ref/fate/channel_layout @@ -0,0 +1,98 @@ +Testing av_channel_name +With AV_CHAN_FRONT_LEFT: FL +With AV_CHAN_FRONT_RIGHT: FR +With 63: USR63 +Testing av_channel_description +With AV_CHAN_FRONT_LEFT: front left +With AV_CHAN_FRONT_RIGHT: front right +With 63: user 63 + +Testing av_channel_from_string +With "FL": 0 +With "FR": 1 +With "USR63": 63 + +==Native layouts== + +Testing av_channel_layout_from_string +With "0x3f": 5.1 +With "6c": 5.1 +With "6C": 6 channels +With "6": 6 channels +With "6 channels": 6 channels +With "FL|FR|FC|LFE|BL|BR": 5.1 +With "5.1": 5.1 +With "FL|FR|USR63": FL|FR|USR63 +With "FL|FR|FC|LFE|SL|SR": 5.1(side) +With "5.1(side)": 5.1(side) + +Testing av_channel_layout_from_mask +With AV_CH_LAYOUT_5POINT1: 5.1(side) + +Testing av_channel_layout_channel_from_index +On 5.1(side) layout with 0: 0 +On 5.1(side) layout with 1: 1 +On 5.1(side) layout with 2: 2 +On 5.1(side) layout with 3: 3 +On 5.1(side) layout with 4: 9 +On 5.1(side) layout with 5: 10 +On 5.1(side) layout with 6: -1 + +Testing av_channel_layout_index_from_channel +On 5.1(side) layout with AV_CHAN_FRONT_LEFT: 0 +On 5.1(side) layout with AV_CHAN_FRONT_RIGHT: 1 +On 5.1(side) layout with AV_CHAN_FRONT_CENTER: 2 +On 5.1(side) layout with AV_CHAN_LOW_FREQUENCY: 3 +On 5.1(side) layout with AV_CHAN_SIDE_LEFT: 4 +On 5.1(side) layout with AV_CHAN_SIDE_RIGHT: 5 +On 5.1(side) layout with AV_CHAN_BACK_CENTER: -1 + +Testing av_channel_layout_channel_from_string +On 5.1(side) layout with "FL": 0 +On 5.1(side) layout with "FR": 1 +On 5.1(side) layout with "FC": 2 +On 5.1(side) layout with "LFE": 3 +On 5.1(side) layout with "SL": 9 +On 5.1(side) layout with "SR": 10 +On 5.1(side) layout with "BC": -1 + +Testing av_channel_layout_index_from_string +On 5.1(side) layout with "FL": 0 +On 5.1(side) layout with "FR": 1 +On 5.1(side) layout with "FC": 2 +On 5.1(side) layout with "LFE": 3 +On 5.1(side) layout with "SL": 4 +On 5.1(side) layout with "SR": 5 +On 5.1(side) layout with "BC": -1 + +==Custom layouts== + +Testing av_channel_layout_from_string +With "FL|FR|FC|BL|BR|LFE": FL|FR|FC|BL|BR|LFE +With "FR|FL|USR63" layout: FR|FL|USR63 + +Testing av_channel_layout_index_from_string +On "FR|FL|USR63" layout with "FR": 0 +On "FR|FL|USR63" layout with "FL": 1 +On "FR|FL|USR63" layout with "USR63": 2 +On "FR|FL|USR63" layout with custom label "CUS": 2 +On "FR|FL|USR63" layout with "BC": -1 + +Testing av_channel_layout_channel_from_string +On "FR|FL|USR63" layout with "FR": 1 +On "FR|FL|USR63" layout with "FL": 0 +On "FR|FL|USR63" layout with "USR63": 63 +On "FR|FL|USR63" layout with custom label "CUS": 63 +On "FR|FL|USR63" layout with "BC": -1 + +Testing av_channel_layout_index_from_channel +On "FR|FL|USR63" layout with AV_CHAN_FRONT_RIGHT: 0 +On "FR|FL|USR63" layout with AV_CHAN_FRONT_LEFT: 1 +On "FR|FL|USR63" layout with 63: 2 +On "FR|FL|USR63" layout with AV_CHAN_BACK_CENTER: -1 + +Testing av_channel_layout_channel_from_index +On "FR|FL|USR63" layout with 0: 1 +On "FR|FL|USR63" layout with 1: 0 +On "FR|FL|USR63" layout with 2: 63 +On "FR|FL|USR63" layout with 3: -1