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
41
42 #define CHECK_CHANNELS_CONSISTENCY(frame) \
43 av_assert2(!(frame)->channel_layout || \
44 (frame)->channels == \
45 av_get_channel_layout_nb_channels((frame)->channel_layout))
46
48
50 {
52
54
58
59 return 0;
60 }
61
63 {
66
69
71 }
72
74 {
75 static const char *
const name[] = {
83 };
87 }
88
90 {
93
94 memset(frame, 0, sizeof(*frame));
95
105 frame->
format = -1;
/* unknown */
112 }
113
115 {
117
121 }
122
124 {
125 int i;
126
129 }
131
133 }
134
136 {
138
139 if (!frame)
141
144
146 }
147
149 {
150 if (!frame || !*frame)
151 return;
152
155 }
156
158 {
161
162 if (!desc)
164
167
169 for(i=1; i<=
align; i+=i) {
172 if (ret < 0)
174 if (!(frame->
linesize[0] & (align-1)))
175 break;
176 }
177
178 for (i = 0; i < 4 && frame->
linesize[i]; i++)
180 }
181
182 for (i = 0; i < 4 && frame->
linesize[i]; i++) {
184 if (i == 1 || i == 2)
186
189 goto fail;
190
192 }
197 goto fail;
199 }
200
202
203 return 0;
204 fail:
207 }
208
210 {
211 int channels;
213 int planes;
215
218
220 planes = planar ? channels : 1;
221
226 align);
227 if (ret < 0)
229 }
230
240 }
242 } else
244
247 if (!frame->
buf[i]) {
250 }
252 }
258 }
260 }
261 return 0;
262
263 }
264
266 {
269
274
276 }
277
279 {
281
288
290 if (ret < 0)
292
293 /* duplicate the frame data if it's not refcounted */
296 if (ret < 0)
298
300 if (ret < 0)
302
304 }
305
306 /* ref the buffers */
309 continue;
313 goto fail;
314 }
315 }
316
322 goto fail;
323 }
325
330 goto fail;
331 }
332 }
333 }
334
335 /* duplicate extended data */
338
339 if (!ch) {
341 goto fail;
342 }
344
348 goto fail;
349 }
351 } else
353
356
357 return 0;
358
359 fail:
362 }
363
365 {
367
368 if (!ret)
370
373
375 }
376
378 {
379 int i;
380
382
390
392 }
393
395 {
399 memset(src, 0, sizeof(*src));
401 }
402
404 {
406
407 /* assume non-refcounted frames are not writable */
409 return 0;
410
416
418 }
419
421 {
422 AVFrame tmp;
424
427
429 return 0;
430
431 memset(&tmp, 0, sizeof(tmp));
439 if (ret < 0)
441
443 if (ret < 0) {
446 }
447
449 if (ret < 0) {
452 }
453
455
456 *frame = tmp;
459
460 return 0;
461 }
462
464 {
465 int i;
466
477 #if FF_API_AVFRAME_LAVC
479 #endif
497
499
501
507 continue;
510 if (!sd_dst) {
513 }
516 }
517
527 }
528 }
529
530 return 0;
531 }
532
534 {
536 int planes, i;
537
540 if (!channels)
544 } else
545 planes = 4;
546
547 if (plane < 0 || plane >= planes || !frame->
extended_data[plane])
550
555 }
560 }
562 }
563
567 {
569
572
575 if (!tmp)
578
580 if (!ret)
582
587 }
588
591
593
595 }
596
599 {
600 int i;
601
605 }
607 }
608
610 {
612 int i, planes;
613
617
619 for (i = 0; i < planes; i++)
622
623 memcpy(src_data, src->
data,
sizeof(src_data));
627
628 return 0;
629 }
630
632 {
635 int planes = planar ? channels : 1;
636 int i;
637
642
644
645 for (i = 0; i < planes; i++)
648
651
652 return 0;
653 }
654
656 {
659
664
666 }
667
669 {
670 int i;
671
674 if (sd->
type == type) {
678 }
679 }
680 }
681
683 {
684 switch(type) {
693 }
695 }