Remove the channel_layout stuff

This commit is contained in:
Henrik Rydgård 2024-04-11 12:19:11 +02:00
parent e871133fe6
commit 416ba81d20
10 changed files with 4 additions and 336 deletions

View file

@ -391,7 +391,6 @@
<ClInclude Include="..\ext\at3_standalone\atrac3plus.h" />
<ClInclude Include="..\ext\at3_standalone\atrac3plus_data.h" />
<ClInclude Include="..\ext\at3_standalone\avcodec.h" />
<ClInclude Include="..\ext\at3_standalone\channel_layout.h" />
<ClInclude Include="..\ext\at3_standalone\compat.h" />
<ClInclude Include="..\ext\at3_standalone\fft.h" />
<ClInclude Include="..\ext\at3_standalone\float_dsp.h" />
@ -605,7 +604,6 @@
<ClCompile Include="..\ext\at3_standalone\atrac3plusdec.cpp" />
<ClCompile Include="..\ext\at3_standalone\atrac3plusdsp.cpp" />
<ClCompile Include="..\ext\at3_standalone\get_bits.cpp" />
<ClCompile Include="..\ext\at3_standalone\channel_layout.cpp" />
<ClCompile Include="..\ext\at3_standalone\compat.cpp" />
<ClCompile Include="..\ext\at3_standalone\fft.cpp" />
<ClCompile Include="..\ext\at3_standalone\float_dsp.cpp" />
@ -1045,6 +1043,7 @@
<ClCompile Include="x64Emitter.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="..\ext\at3_standalone\CMakeLists.txt" />
<Text Include="..\ext\at3_standalone\README.txt" />
<Text Include="..\ext\libpng17\CMakeLists.txt" />
</ItemGroup>

View file

@ -557,9 +557,6 @@
<ClInclude Include="..\ext\at3_standalone\mathematics.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\ext\at3_standalone\channel_layout.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
<ClInclude Include="..\ext\at3_standalone\at3_decoders.h">
<Filter>ext\at3_standalone</Filter>
</ClInclude>
@ -1050,9 +1047,6 @@
<ClCompile Include="..\ext\at3_standalone\avcodec.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\ext\at3_standalone\channel_layout.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
<ClCompile Include="..\ext\at3_standalone\atrac.cpp">
<Filter>ext\at3_standalone</Filter>
</ClCompile>
@ -1192,6 +1186,9 @@
<Text Include="..\ext\at3_standalone\README.txt">
<Filter>ext\at3_standalone</Filter>
</Text>
<Text Include="..\ext\at3_standalone\CMakeLists.txt">
<Filter>ext\at3_standalone</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<None Include="..\ext\basis_universal\basisu_transcoder_tables_astc.inc">

View file

@ -39,7 +39,6 @@ public:
if (!codecOpen_) {
ctx_->block_align = inbytes;
ctx_->channels = 2;
ctx_->channel_layout = ctx_->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
int retval;
if (audioType_ == PSP_CODEC_AT3PLUS) {
retval = avcodec_open2(ctx_, &ff_atrac3p_decoder, nullptr);

View file

@ -120,7 +120,6 @@ AT3_STANDALONE_FILES := \
${SRC}/ext/at3_standalone/atrac3plusdsp.cpp \
${SRC}/ext/at3_standalone/avcodec.cpp \
${SRC}/ext/at3_standalone/get_bits.cpp \
${SRC}/ext/at3_standalone/channel_layout.cpp \
${SRC}/ext/at3_standalone/compat.cpp \
${SRC}/ext/at3_standalone/fft.cpp \
${SRC}/ext/at3_standalone/float_dsp.cpp \

View file

@ -13,7 +13,6 @@ set(ALL_SOURCE_FILES
${SRC_DIR}/atrac3plusdsp.cpp
${SRC_DIR}/avcodec.cpp
${SRC_DIR}/get_bits.cpp
${SRC_DIR}/channel_layout.cpp
${SRC_DIR}/compat.cpp
${SRC_DIR}/fft.cpp
${SRC_DIR}/float_dsp.cpp

View file

@ -37,7 +37,6 @@
#include <stdint.h>
#include <string.h>
#include "channel_layout.h"
#include "float_dsp.h"
#include "avcodec.h"
#include "get_bits.h"
@ -61,7 +60,6 @@ struct ATRAC3PContext {
int num_channel_blocks; ///< number of channel blocks
uint8_t channel_blocks[5]; ///< channel configuration descriptor
uint64_t my_channel_layout; ///< current channel layout
};
int atrac3p_decode_close(AVCodecContext *avctx)
@ -80,31 +78,25 @@ static int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) {
memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks));
switch (avctx->channels) {
case 1:
if (avctx->channel_layout != AV_CH_FRONT_LEFT)
avctx->channel_layout = AV_CH_LAYOUT_MONO;
ctx->num_channel_blocks = 1;
ctx->channel_blocks[0] = CH_UNIT_MONO;
break;
case 2:
avctx->channel_layout = AV_CH_LAYOUT_STEREO;
ctx->num_channel_blocks = 1;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
break;
case 3:
avctx->channel_layout = AV_CH_LAYOUT_SURROUND;
ctx->num_channel_blocks = 2;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
ctx->channel_blocks[1] = CH_UNIT_MONO;
break;
case 4:
avctx->channel_layout = AV_CH_LAYOUT_4POINT0;
ctx->num_channel_blocks = 3;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
ctx->channel_blocks[1] = CH_UNIT_MONO;
ctx->channel_blocks[2] = CH_UNIT_MONO;
break;
case 6:
avctx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
ctx->num_channel_blocks = 4;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
ctx->channel_blocks[1] = CH_UNIT_MONO;
@ -112,7 +104,6 @@ static int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) {
ctx->channel_blocks[3] = CH_UNIT_MONO;
break;
case 7:
avctx->channel_layout = AV_CH_LAYOUT_6POINT1_BACK;
ctx->num_channel_blocks = 5;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
ctx->channel_blocks[1] = CH_UNIT_MONO;
@ -121,7 +112,6 @@ static int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) {
ctx->channel_blocks[4] = CH_UNIT_MONO;
break;
case 8:
avctx->channel_layout = AV_CH_LAYOUT_7POINT1;
ctx->num_channel_blocks = 5;
ctx->channel_blocks[0] = CH_UNIT_STEREO;
ctx->channel_blocks[1] = CH_UNIT_MONO;
@ -162,8 +152,6 @@ int atrac3p_decode_init(AVCodecContext *avctx)
if ((ret = set_channel_params(ctx, avctx)) < 0)
return ret;
ctx->my_channel_layout = avctx->channel_layout;
ctx->ch_units = (Atrac3pChanUnitCtx *)av_mallocz_array(ctx->num_channel_blocks, sizeof(*ctx->ch_units));
if (!ctx->ch_units) {

View file

@ -26,9 +26,6 @@
#include "avcodec.h"
#include "compat.h"
#include "channel_layout.h"
#include "compat.h"
#include "avcodec.h"
#include "mem.h"
#include <stdlib.h>
@ -98,27 +95,6 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void *options)
}
ret = 0;
/* validate channel layout from the decoder */
if (avctx->channel_layout) {
int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
if (!avctx->channels)
avctx->channels = channels;
else if (channels != avctx->channels) {
char buf[512] = "";
av_log(AV_LOG_WARNING,
"Channel layout '%s' with %d channels does not match specified number of channels %d: "
"ignoring specified channel layout\n",
buf, channels, avctx->channels);
avctx->channel_layout = 0;
}
}
if (avctx->channels && avctx->channels < 0 ||
avctx->channels > FF_SANE_NB_CHANNELS) {
ret = AVERROR(EINVAL);
goto free_and_end;
}
end:
return ret;

View file

@ -23,7 +23,6 @@
#include <errno.h>
#include "compat.h"
#include "channel_layout.h"
#include "mem.h"
enum AVCodecID {
@ -103,13 +102,6 @@ typedef struct AVCodecContext {
* Used by some WAV based audio codecs.
*/
int block_align;
/**
* Audio channel layout.
* - encoding: set by user.
* - decoding: set by user, may be overwritten by libavcodec.
*/
uint64_t channel_layout;
} AVCodecContext;
/**

View file

@ -1,152 +0,0 @@
/*
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
* 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
*/
/**
* @file
* audio channel layout utility functions
*/
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stddef.h>
#include "channel_layout.h"
#include "compat.h"
#include "mathematics.h"
struct channel_name {
const char *name;
const char *description;
};
static const struct channel_name channel_names[] = {
{ "FL", "front left" },
{ "FR", "front right" },
{ "FC", "front center" },
{ "LFE", "low frequency" },
{ "BL", "back left" },
{ "BR", "back right" },
{ "FLC", "front left-of-center" },
{ "FRC", "front right-of-center" },
{ "BC", "back center" },
{ "SL", "side left" },
{ "SR", "side right" },
{ "TC", "top center" },
{ "TFL", "top front left" },
{ "TFC", "top front center" },
{ "TFR", "top front right" },
{ "TBL", "top back left" },
{ "TBC", "top back center" },
{ "TBR", "top back right" },
{ "DL", "downmix left" },
{ "DR", "downmix right" },
{ "WL", "wide left" },
{ "WR", "wide right" },
{ "SDL", "surround direct left" },
{ "SDR", "surround direct right" },
{ "LFE2", "low frequency 2" },
};
static const char *get_channel_name(int channel_id)
{
if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
return NULL;
return channel_names[channel_id].name;
}
static const struct {
const char *name;
int nb_channels;
uint64_t layout;
} channel_layout_map[] = {
{ "mono", 1, AV_CH_LAYOUT_MONO },
{ "stereo", 2, AV_CH_LAYOUT_STEREO },
};
static uint64_t get_channel_layout_single(const char *name, int name_len)
{
int i;
char *end;
int64_t layout;
for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) {
if (strlen(channel_layout_map[i].name) == name_len &&
!memcmp(channel_layout_map[i].name, name, name_len))
return channel_layout_map[i].layout;
}
for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++)
if (channel_names[i].name &&
strlen(channel_names[i].name) == name_len &&
!memcmp(channel_names[i].name, name, name_len))
return (int64_t)1 << i;
errno = 0;
i = strtol(name, &end, 10);
if (!errno && (end + 1 - name == name_len && *end == 'c'))
return av_get_default_channel_layout(i);
errno = 0;
layout = strtoll(name, &end, 0);
if (!errno && end - name == name_len)
return FFMAX(layout, 0);
return 0;
}
uint64_t av_get_channel_layout(const char *name)
{
const char *n, *e;
const char *name_end = name + strlen(name);
int64_t layout = 0, layout_single;
for (n = name; n < name_end; n = e + 1) {
for (e = n; e < name_end && *e != '+' && *e != '|'; e++);
layout_single = get_channel_layout_single(n, e - n);
if (!layout_single)
return 0;
layout |= layout_single;
}
return layout;
}
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
{
return av_popcount64(channel_layout);
}
int64_t av_get_default_channel_layout(int nb_channels) {
int i;
for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++)
if (nb_channels == channel_layout_map[i].nb_channels)
return channel_layout_map[i].layout;
return 0;
}
int av_get_channel_layout_channel_index(uint64_t channel_layout,
uint64_t channel)
{
if (!(channel_layout & channel) ||
av_get_channel_layout_nb_channels(channel) != 1)
return AVERROR(EINVAL);
channel_layout &= channel - 1;
return av_get_channel_layout_nb_channels(channel_layout);
}

View file

@ -1,129 +0,0 @@
/*
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
* Copyright (c) 2008 Peter Ross
*
* 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
*/
#ifndef AVUTIL_CHANNEL_LAYOUT_H
#define AVUTIL_CHANNEL_LAYOUT_H
#include <stdint.h>
/**
* @file
* audio channel layout utility functions
*/
/**
* @addtogroup lavu_audio
* @{
*/
/**
* @defgroup channel_masks Audio channel masks
*
* A channel layout is a 64-bits integer with a bit set for every channel.
* The number of bits set must be equal to the number of channels.
* The value 0 means that the channel layout is not known.
* @note this data structure is not powerful enough to handle channels
* combinations that have the same channel multiple times, such as
* dual-mono.
*
* @{
*/
#define AV_CH_FRONT_LEFT 0x00000001
#define AV_CH_FRONT_RIGHT 0x00000002
#define AV_CH_FRONT_CENTER 0x00000004
#define AV_CH_LOW_FREQUENCY 0x00000008
#define AV_CH_BACK_LEFT 0x00000010
#define AV_CH_BACK_RIGHT 0x00000020
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
#define AV_CH_BACK_CENTER 0x00000100
#define AV_CH_SIDE_LEFT 0x00000200
#define AV_CH_SIDE_RIGHT 0x00000400
#define AV_CH_TOP_CENTER 0x00000800
#define AV_CH_TOP_FRONT_LEFT 0x00001000
#define AV_CH_TOP_FRONT_CENTER 0x00002000
#define AV_CH_TOP_FRONT_RIGHT 0x00004000
#define AV_CH_TOP_BACK_LEFT 0x00008000
#define AV_CH_TOP_BACK_CENTER 0x00010000
#define AV_CH_TOP_BACK_RIGHT 0x00020000
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL
/** Channel mask value used for AVCodecContext.request_channel_layout
to indicate that the user requests the channel order of the decoder output
to be the native codec channel order. */
#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
/**
* @}
* @defgroup channel_mask_c Audio channel layouts
* @{
* */
#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
#define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT)
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
/**
* Return the number of channels in the channel layout.
*/
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
/**
* Return default channel layout for a given number of channels.
*/
int64_t av_get_default_channel_layout(int nb_channels);
/**
* @}
* @}
*/
#endif /* AVUTIL_CHANNEL_LAYOUT_H */