Message ID | 20220315203013.14304-4-cus@passwd.hu |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/4] avutil/channel_layout: print channels using av_channel_name_bprint in av_channel_layout_describe_bprint | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_aarch64_jetson | success | Make finished |
andriy/make_fate_aarch64_jetson | success | Make fate finished |
andriy/configure_armv7_RPi4 | warning | Failed to apply patch |
On 3/15/2022 5:30 PM, Marton Balint wrote: > 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> > --- > libavutil/channel_layout.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c > index 8406089fe0..be511dcf68 100644 > --- a/libavutil/channel_layout.c > +++ b/libavutil/channel_layout.c > @@ -687,14 +687,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); > > @@ -736,7 +736,7 @@ 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) > + if (res >= 0) > return res; return 0. The doxy for av_channel_layout_describe_bprint() does not define values > 0. > } > if (channel_layout->nb_channels)
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 8406089fe0..be511dcf68 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -687,14 +687,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); @@ -736,7 +736,7 @@ 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) + if (res >= 0) return res; } if (channel_layout->nb_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> --- libavutil/channel_layout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)