History

avutil/channel_layout: add av_channel_layout_custom_init()

Marton Balint committed 2 years ago

Commit 4569b861 parent 0748d2b4 files · +42 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/channel_layout.c +20 −0
  3. libavutil/channel_layout.h +17 −0
  4. libavutil/version.h +2 −2
doc/APIchanges+3−0
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 · 1 unmodified line
22
33 API changes, most recent first:
44
5+2024-02-xx - xxxxxxxxxx - lavu 58.37.100 - channel_layout.h
6+ Add av_channel_layout_custom_init().
7+
58 2024-02-04 - xxxxxxxxxx - lavc 60.39.100 - packet.h
69 Add AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT.
710
libavutil/channel_layout.c+20−0
@@ -398,6 +398,26 @@ int av_get_standard_channel_layout(unsigned index, uint64_t *layout, · 397 unmodified lines
398398 FF_ENABLE_DEPRECATION_WARNINGS
399399 #endif
400400
401+int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
402+{
403+ AVChannelCustom *map;
404+
405+ if (nb_channels <= 0)
406+ return AVERROR(EINVAL);
407+
408+ map = av_calloc(nb_channels, sizeof(*channel_layout->u.map));
409+ if (!map)
410+ return AVERROR(ENOMEM);
411+ for (int i = 0; i < nb_channels; i++)
412+ map[i].id = AV_CHAN_UNKNOWN;
413+
414+ channel_layout->order = AV_CHANNEL_ORDER_CUSTOM;
415+ channel_layout->nb_channels = nb_channels;
416+ channel_layout->u.map = map;
417+
418+ return 0;
419+}
420+
401421 int av_channel_layout_from_mask(AVChannelLayout *channel_layout,
402422 uint64_t mask)
403423 {
libavutil/channel_layout.h+17−0
@@ -617,6 +617,23 @@ void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_i · 616 unmodified lines
617617 */
618618 enum AVChannel av_channel_from_string(const char *name);
619619
620+/**
621+ * Initialize a custom channel layout with the specified number of channels.
622+ * The channel map will be allocated and the designation of all channels will
623+ * be set to AV_CHAN_UNKNOWN.
624+ *
625+ * This is only a convenience helper function, a custom channel layout can also
626+ * be constructed without using this.
627+ *
628+ * @param channel_layout the layout structure to be initialized
629+ * @param nb_channels the number of channels
630+ *
631+ * @return 0 on success
632+ * AVERROR(EINVAL) if the number of channels <= 0
633+ * AVERROR(ENOMEM) if the channel map could not be allocated
634+ */
635+int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels);
636+
620637 /**
621638 * Initialize a native channel layout from a bitmask indicating which channels
622639 * are present.
libavutil/version.h+2−2
@@ -79,8 +79,8 @@ · 78 unmodified lines
7979 */
8080
8181 #define LIBAVUTIL_VERSION_MAJOR 58
82−#define LIBAVUTIL_VERSION_MINOR 36
83−#define LIBAVUTIL_VERSION_MICRO 101
82+#define LIBAVUTIL_VERSION_MINOR 37
83+#define LIBAVUTIL_VERSION_MICRO 100
8484
8585 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
8686 LIBAVUTIL_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t