1 /*
2 *
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
29
30 #define MAKE_ACCESSORS(str, name, type, field) \
31 type av_##name##_get_##field(const str *s) { return s->field; } \
32 void av_##name##_set_##field(str *s, type v) { s->field = v; }
33
43
44 #define CHECK_CHANNELS_CONSISTENCY(frame) \
45 av_assert2(!(frame)->channel_layout || \
46 (frame)->channels == \
47 av_get_channel_layout_nb_channels((frame)->channel_layout))
48
50
52 {
54
56
60
61 return 0;
62 }
63
65 {
68
70 return NULL;
71
73 }
74
76 {
79
80 memset(frame, 0, sizeof(*frame));
81
91 frame->
format = -1;
/* unknown */
93 }
94
96 {
98
99 if (!frame)
100 return NULL;
101
104
106 }
107
109 {
110 if (!frame || !*frame)
111 return;
112
115 }
116
118 {
121
122 if (!desc)
124
127
129 for(i=1; i<=
align; i+=i) {
132 if (ret < 0)
134 if (!(frame->
linesize[0] & (align-1)))
135 break;
136 }
137
138 for (i = 0; i < 4 && frame->
linesize[i]; i++)
140 }
141
142 for (i = 0; i < 4 && frame->
linesize[i]; i++) {
144 if (i == 1 || i == 2)
146
149 goto fail;
150
152 }
157 goto fail;
159 }
160
162
163 return 0;
164 fail:
167 }
168
170 {
173 int planes = planar ? channels : 1;
175
180 align);
181 if (ret < 0)
183 }
184
194 }
196 } else
198
201 if (!frame->
buf[i]) {
204 }
206 }
212 }
214 }
215 return 0;
216
217 }
218
220 {
223
228
230 }
231
233 {
235
242
244 if (ret < 0)
246
247 /* duplicate the frame data if it's not refcounted */
250 if (ret < 0)
252
258 } else {
261 }
262 return 0;
263 }
264
265 /* ref the buffers */
268 continue;
272 goto fail;
273 }
274 }
275
281 goto fail;
282 }
284
289 goto fail;
290 }
291 }
292 }
293
294 /* duplicate extended data */
297
298 if (!ch) {
300 goto fail;
301 }
303
307 goto fail;
308 }
310 } else
312
315
316 return 0;
317
318 fail:
321 }
322
324 {
326
327 if (!ret)
328 return NULL;
329
332
334 }
335
337 {
338 int i;
339
344 }
346
354
356 }
357
359 {
363 memset(src, 0, sizeof(*src));
365 }
366
368 {
370
371 /* assume non-refcounted frames are not writable */
373 return 0;
374
380
382 }
383
385 {
386 AVFrame tmp;
388
391
393 return 0;
394
395 memset(&tmp, 0, sizeof(tmp));
403 if (ret < 0)
405
411 } else {
414 }
415
417 if (ret < 0) {
420 }
421
423
424 *frame = tmp;
427
428 return 0;
429 }
430
432 {
433 int i;
434
445 #if FF_API_AVFRAME_LAVC
447 #endif
459
461
463
468 if (!sd_dst) {
473 }
476 }
479 }
480
490 }
491 }
492
493 return 0;
494 }
495
497 {
499 int planes, i;
500
503 if (!channels)
504 return NULL;
507 } else
508 planes = 4;
509
510 if (plane < 0 || plane >= planes || !frame->
extended_data[plane])
511 return NULL;
513
516 if (data >= buf->
data && data < buf->data + buf->
size)
518 }
521 if (data >= buf->
data && data < buf->data + buf->
size)
523 }
524 return NULL;
525 }
526
530 {
532
534 return NULL;
535
538 if (!tmp)
539 return NULL;
541
543 if (!ret)
544 return NULL;
545
549 return NULL;
550 }
551
554
556
558 }
559
562 {
563 int i;
564
568 }
569 return NULL;
570 }