1 /*
2 * IAMF muxer
3 * Copyright (c) 2023 James Almer
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdint.h>
23
29
32
35
38
40 {
43 int nb_audio_elements = 0, nb_mix_presentations = 0;
45
46 for (
int i = 0;
i <
s->nb_streams;
i++) {
48 (
s->streams[
i]->codecpar->codec_tag !=
MKTAG(
'm',
'p',
'4',
'a') &&
49 s->streams[
i]->codecpar->codec_tag !=
MKTAG(
'O',
'p',
'u',
's') &&
50 s->streams[
i]->codecpar->codec_tag !=
MKTAG(
'f',
'L',
'a',
'C') &&
51 s->streams[
i]->codecpar->codec_tag !=
MKTAG(
'i',
'p',
'c',
'm'))) {
55 }
56
57 if (
s->streams[
i]->codecpar->ch_layout.nb_channels > 2) {
60 }
61
62 for (
int j = 0; j <
i; j++) {
63 if (
s->streams[
i]->id ==
s->streams[j]->id) {
66 }
67 }
68 }
69
70 if (
s->nb_stream_groups <= 1) {
73 }
74
75 for (
int i = 0;
i <
s->nb_stream_groups;
i++) {
77
79 nb_audio_elements++;
81 nb_mix_presentations++;
82 }
83 if ((nb_audio_elements < 1 || nb_audio_elements > 2) || nb_mix_presentations < 1) {
85 "one IAMF_MIX_PRESENTATION stream groups\n");
87 }
88
89 for (
int i = 0;
i <
s->nb_stream_groups;
i++) {
92 continue;
93
97 }
98
99 for (
int i = 0;
i <
s->nb_stream_groups;
i++) {
102 continue;
103
107 }
108
109 c->first_stream_id =
s->streams[0]->id;
110
111 return 0;
112 }
113
115 {
119
124
125 c->first_stream_id =
s->streams[0]->id;
126
127 return 0;
128 }
129
131 {
135
136 if (st->
id ==
c->first_stream_id)
141 c->update_extradata = 1;
142
144 }
145
147 {
152
154 return 0;
155
161
163
164 return 0;
165 }
166
168 {
171
173 }
174
186 };
187
191 .p.extensions = "iamf",
201 };