1 /*
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
23
31
36 };
37
38 #define START_CODE 0x000001
39
44
45 static int av1_split(
const uint8_t *buf,
int buf_size,
void *logctx)
46 {
48 const uint8_t *ptr = buf, *end = buf + buf_size;
49
50 while (ptr < end) {
53 break;
54
57 return ptr - buf;
58 }
61 }
62
63 return 0;
64 }
65
67 {
68 const uint8_t *ptr = buf, *end = buf + buf_size;
70 int has_sps = 0;
71 int has_pps = 0;
72 int nalu_type;
73
74 while (ptr < end) {
76 if ((
state & 0xFFFFFF00) != 0x100)
77 break;
78 nalu_type =
state & 0x1F;
80 has_sps = 1;
82 has_pps = 1;
83 /* else if (nalu_type == 0x01 ||
84 * nalu_type == 0x02 ||
85 * nalu_type == 0x05) {
86 * }
87 */
90 nalu_type != 0x0f) {
91 if (has_sps) {
92 while (ptr - 4 > buf && ptr[-5] == 0)
93 ptr--;
94 return ptr - 4 - buf;
95 }
96 }
97 }
98
99 return 0;
100 }
101
102 // Split after the parameter sets at the beginning of the stream if they exist.
104 {
105 const uint8_t *ptr = buf, *end = buf + buf_size;
107 int has_vps = 0;
108 int has_sps = 0;
109 int has_pps = 0;
110 int nut;
111
112 while (ptr < end) {
115 break;
116 nut = (
state >> 1) & 0x3F;
118 has_vps = 1;
120 has_sps = 1;
122 has_pps = 1;
125 if (has_vps && has_sps) {
126 while (ptr - 4 > buf && ptr[-5] == 0)
127 ptr--;
128 return ptr - 4 - buf;
129 }
130 }
131 }
132 return 0;
133 }
134
136 {
138 int found = 0;
139
140 for (
int i = 0;
i < buf_size;
i++) {
142 if (
state == 0x1B3) {
143 found = 1;
144 }
else if (found &&
state != 0x1B5 && state < 0x200 && state >= 0x100)
146 }
147 return 0;
148 }
149
151 {
152 const uint8_t *ptr = buf, *end = buf + buf_size;
154
155 while (ptr < end) {
158 return ptr - 4 - buf;
159 }
160
161 return 0;
162 }
163
165 {
166 const uint8_t *ptr = buf, *end = buf + buf_size;
168 int charged = 0;
169
170 while (ptr < end) {
173 charged = 1;
175 return ptr - 4 - buf;
176 }
177
178 return 0;
179 }
180
182 {
184
186
190
195
196 switch (
ctx->par_in->codec_id) {
199 break;
205 break;
208 break;
211 break;
215 break;
218 break;
219 default:
221 }
222
225 }
226
227 return 0;
228 }
229
230 #define OFFSET(x) offsetof(RemoveExtradataContext, x)
231 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
239 };
240
246 };
247
249 .
p.
name =
"remove_extra",
253 };