mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 01:40:04 +01:00
avcodec/libmpeghdec: Check channel layouts generically
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -68,75 +68,36 @@ static av_cold int mpegh3dadec_close(AVCodecContext *avctx)
|
|||||||
// https://github.com/Fraunhofer-IIS/mpeghdec/wiki/MPEG-H-decoder-target-layouts
|
// https://github.com/Fraunhofer-IIS/mpeghdec/wiki/MPEG-H-decoder-target-layouts
|
||||||
static av_cold int channel_layout_to_cicp(const AVChannelLayout *layout)
|
static av_cold int channel_layout_to_cicp(const AVChannelLayout *layout)
|
||||||
{
|
{
|
||||||
const AVChannelLayout layout_7point2point3 =
|
// different from AV_CH_LAYOUT_7POINT2POINT3
|
||||||
(AVChannelLayout) AV_CHANNEL_LAYOUT_MASK(
|
#define CH_LAYOUT_7POINT2POINT3 AV_CH_LAYOUT_5POINT1POINT2 | AV_CH_SIDE_SURROUND_LEFT | \
|
||||||
12, (AV_CH_LAYOUT_5POINT1POINT2 | AV_CH_SIDE_SURROUND_LEFT |
|
AV_CH_SIDE_SURROUND_RIGHT | AV_CH_TOP_BACK_CENTER | \
|
||||||
AV_CH_SIDE_SURROUND_RIGHT | AV_CH_TOP_BACK_CENTER |
|
AV_CH_LOW_FREQUENCY_2
|
||||||
AV_CH_LOW_FREQUENCY_2));
|
#define CH_LAYOUT_5POINT1POINT6 AV_CH_LAYOUT_5POINT1POINT4_BACK | \
|
||||||
const AVChannelLayout layout_5point1point6 =
|
AV_CH_TOP_FRONT_CENTER | AV_CH_TOP_CENTER
|
||||||
(AVChannelLayout) AV_CHANNEL_LAYOUT_MASK(
|
#define CH_LAYOUT_7POINT1POINT6 AV_CH_LAYOUT_7POINT1POINT4_BACK | \
|
||||||
12, (AV_CH_LAYOUT_5POINT1POINT4_BACK | AV_CH_TOP_FRONT_CENTER |
|
AV_CH_TOP_FRONT_CENTER | AV_CH_TOP_CENTER
|
||||||
AV_CH_TOP_CENTER));
|
static const uint64_t channel_layout_masks[] = {
|
||||||
const AVChannelLayout layout_7point1point6 =
|
0,
|
||||||
(AVChannelLayout) AV_CHANNEL_LAYOUT_MASK(
|
AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO,
|
||||||
14, (AV_CH_LAYOUT_7POINT1POINT4_BACK | AV_CH_TOP_FRONT_CENTER |
|
AV_CH_LAYOUT_SURROUND, AV_CH_LAYOUT_4POINT0,
|
||||||
AV_CH_TOP_CENTER));
|
AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_5POINT1,
|
||||||
|
AV_CH_LAYOUT_7POINT1_WIDE, 0,
|
||||||
if (!av_channel_layout_compare(layout,
|
AV_CH_LAYOUT_2_1, AV_CH_LAYOUT_2_2,
|
||||||
&(AVChannelLayout) AV_CHANNEL_LAYOUT_MONO)) {
|
AV_CH_LAYOUT_6POINT1, AV_CH_LAYOUT_7POINT1,
|
||||||
return 1;
|
AV_CH_LAYOUT_22POINT2, AV_CH_LAYOUT_5POINT1POINT2,
|
||||||
} else if (!av_channel_layout_compare(
|
CH_LAYOUT_7POINT2POINT3, AV_CH_LAYOUT_5POINT1POINT4_BACK,
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_STEREO)) {
|
CH_LAYOUT_5POINT1POINT6, CH_LAYOUT_7POINT1POINT6,
|
||||||
return 2;
|
AV_CH_LAYOUT_7POINT1POINT4_BACK,
|
||||||
} else if (!av_channel_layout_compare(
|
};
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_SURROUND)) {
|
for (size_t i = 0; i < FF_ARRAY_ELEMS(channel_layout_masks); ++i) {
|
||||||
return 3;
|
if (channel_layout_masks[i]) {
|
||||||
} else if (!av_channel_layout_compare(
|
AVChannelLayout ch_layout;
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_4POINT0)) {
|
av_channel_layout_from_mask(&ch_layout, channel_layout_masks[i]);
|
||||||
return 4;
|
if (!av_channel_layout_compare(layout, &ch_layout))
|
||||||
} else if (!av_channel_layout_compare(
|
return i;
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT0)) {
|
|
||||||
return 5;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT1)) {
|
|
||||||
return 6;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_7POINT1_WIDE)) {
|
|
||||||
return 7;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_2_1)) {
|
|
||||||
return 9;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_2_2)) {
|
|
||||||
return 10;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_6POINT1)) {
|
|
||||||
return 11;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_7POINT1)) {
|
|
||||||
return 12;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout, &(AVChannelLayout) AV_CHANNEL_LAYOUT_22POINT2)) {
|
|
||||||
return 13;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout,
|
|
||||||
&(AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT1POINT2)) {
|
|
||||||
return 14;
|
|
||||||
} else if (!av_channel_layout_compare(layout, &layout_7point2point3)) {
|
|
||||||
return 15;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout,
|
|
||||||
&(AVChannelLayout) AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK)) {
|
|
||||||
return 16;
|
|
||||||
} else if (!av_channel_layout_compare(layout, &layout_5point1point6)) {
|
|
||||||
return 17;
|
|
||||||
} else if (!av_channel_layout_compare(layout, &layout_7point1point6)) {
|
|
||||||
return 18;
|
|
||||||
} else if (!av_channel_layout_compare(
|
|
||||||
layout,
|
|
||||||
&(AVChannelLayout) AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK)) {
|
|
||||||
return 19;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user