summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2022-03-15 20:31:45 +0100
committerMarton Balint <cus@passwd.hu>2022-03-15 23:19:24 +0100
commit92f27c6728fe08c36b3e09cc64421b8c7388634b (patch)
tree4eb252b6235ed0d2c24db3287ba1ca0eb4305c3d /libavutil
parent580f7b6c3ac4ee196c7a78641fe65da7a68b6971 (diff)
avutil/channel_layout: fix av_channel_layout_describe_bprint with custom and ambisonic channels
bp->len cannot be used to detect if try_describe_ambisonic was successful because the bprint buffer might contain other data as well. Also describing an invalid ambisonic layout should not return 0 but AVERROR(EINVAL) instead, so change try_describe_ambisonic to actually return error on invalid ambisonics. This also allows us to fix the first issue. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/channel_layout.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index c61d612fd8..f107a2dbd8 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -690,14 +690,14 @@ static int ambisonic_order(const AVChannelLayout *channel_layout)
/**
* If the custom layout is n-th order standard-order ambisonic, with optional
* extra non-diegetic channels at the end, write its string description in bp.
- * Return a negative error code on error.
+ * Return a negative error code otherwise.
*/
static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout *channel_layout)
{
int nb_ambi_channels;
int order = ambisonic_order(channel_layout);
if (order < 0)
- return 0;
+ return order;
av_bprintf(bp, "ambisonic %d", order);
@@ -749,8 +749,8 @@ int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout,
case AV_CHANNEL_ORDER_CUSTOM:
if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM) {
int res = try_describe_ambisonic(bp, channel_layout);
- if (res < 0 || bp->len)
- return res;
+ if (res >= 0)
+ return 0;
}
if (channel_layout->nb_channels)
av_bprintf(bp, "%d channels (", channel_layout->nb_channels);