summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-03-25 16:46:46 -0300
committerJames Almer <jamrial@gmail.com>2022-03-25 17:10:39 -0300
commitf2967490f16393cc9c3c1a74db1672ada129e06f (patch)
treebe662ef8eb13b7161822fc31506b84705ea47c47 /libavutil
parent7602b4e4c219c681ec243a0c81bb8db12b070888 (diff)
avutil/channel_layout: return earlier on UNSPEC layouts in av_channel_layout_subset()
No point running all 64 iterations in the loop to never write anything to ret. Also make ambisonic layouts check its mask too while at it. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/channel_layout.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index c28b8928da..21b70173b7 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -989,12 +989,16 @@ uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout,
uint64_t ret = 0;
int i;
- if (channel_layout->order == AV_CHANNEL_ORDER_NATIVE)
+ switch (channel_layout->order) {
+ case AV_CHANNEL_ORDER_NATIVE:
+ case AV_CHANNEL_ORDER_AMBISONIC:
return channel_layout->u.mask & mask;
-
- for (i = 0; i < 64; i++)
- if (mask & (1ULL << i) && av_channel_layout_index_from_channel(channel_layout, i) >= 0)
- ret |= (1ULL << i);
+ case AV_CHANNEL_ORDER_CUSTOM:
+ for (i = 0; i < 64; i++)
+ if (mask & (1ULL << i) && av_channel_layout_index_from_channel(channel_layout, i) >= 0)
+ ret |= (1ULL << i);
+ break;
+ }
return ret;
}