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
49 #if FF_API_FRAME_QP
51 {
53
55
61
62 return 0;
63 }
64
66 {
71
74
76 }
77 #endif
78
80 {
81 static const char *
const name[] = {
89 };
93 }
94
96 {
99
100 memset(frame, 0, sizeof(*frame));
101
111 frame->
format = -1;
/* unknown */
118 }
119
121 {
123
127 }
128
130 {
131 int i;
132
135 }
137
139 }
140
142 {
144
145 if (!frame)
147
150
152 }
153
155 {
156 if (!frame || !*frame)
157 return;
158
161 }
162
164 {
166 int ret, i;
167
168 if (!desc)
170
172 return ret;
173
175 for(i=1; i<=
align; i+=i) {
178 if (ret < 0)
179 return ret;
180 if (!(frame->
linesize[0] & (align-1)))
181 break;
182 }
183
184 for (i = 0; i < 4 && frame->
linesize[i]; i++)
186 }
187
188 for (i = 0; i < 4 && frame->
linesize[i]; i++) {
190 if (i == 1 || i == 2)
192
196
198 }
205 }
206
208
209 return 0;
213 }
214
216 {
217 int channels;
219 int planes;
220 int ret, i;
221
224
226 planes = planar ? channels : 1;
227
232 align);
233 if (ret < 0)
234 return ret;
235 }
236
246 }
248 } else
250
253 if (!frame->
buf[i]) {
256 }
258 }
264 }
266 }
267 return 0;
268
269 }
270
272 {
275
280
282 }
283
285 {
286 int i;
287
315
317
318 #if FF_API_ERROR_FRAME
322 #endif
323
329 continue;
330 if (force_copy) {
333 if (!sd_dst) {
336 }
338 } else {
340 if (!sd_dst) {
343 }
348 }
351 }
353 }
354
355 #if FF_API_FRAME_QP
367 }
368 }
370 #endif
371
372 return 0;
373 }
374
376 {
377 int i, ret = 0;
378
385
387 if (ret < 0)
388 return ret;
389
390 /* duplicate the frame data if it's not refcounted */
393 if (ret < 0)
394 return ret;
395
397 if (ret < 0)
399
400 return ret;
401 }
402
403 /* ref the buffers */
406 continue;
411 }
412 }
413
420 }
422
428 }
429 }
430 }
431
432 /* duplicate extended data */
435
436 if (!ch) {
439 }
441
446 }
448 } else
450
453
454 return 0;
455
458 return ret;
459 }
460
462 {
464
465 if (!ret)
467
470
471 return ret;
472 }
473
475 {
476 int i;
477
478 if (!frame)
479 return;
480
482
489 #if FF_API_FRAME_QP
491 #endif
492
494 }
495
497 {
501 memset(src, 0, sizeof(*src));
503 }
504
506 {
507 int i, ret = 1;
508
509 /* assume non-refcounted frames are not writable */
511 return 0;
512
518
519 return ret;
520 }
521
523 {
524 AVFrame tmp;
525 int ret;
526
529
531 return 0;
532
533 memset(&tmp, 0, sizeof(tmp));
541 if (ret < 0)
542 return ret;
543
545 if (ret < 0) {
547 return ret;
548 }
549
551 if (ret < 0) {
553 return ret;
554 }
555
557
558 *frame = tmp;
561
562 return 0;
563 }
564
566 {
568 }
569
571 {
573 int planes, i;
574
577 if (!channels)
581 } else
582 planes = 4;
583
584 if (plane < 0 || plane >= planes || !frame->
extended_data[plane])
587
592 }
597 }
599 }
600
604 {
606
609
612 if (!tmp)
615
617 if (!ret)
619
620 if (size > 0) {
625 }
626
629 }
631
633
634 return ret;
635 }
636
639 {
640 int i;
641
645 }
647 }
648
650 {
652 int i, planes;
653
657
659 for (i = 0; i < planes; i++)
662
663 memcpy(src_data, src->
data,
sizeof(src_data));
667
668 return 0;
669 }
670
672 {
675 int planes = planar ? channels : 1;
676 int i;
677
682
684
685 for (i = 0; i < planes; i++)
688
691
692 return 0;
693 }
694
696 {
699
704
706 }
707
709 {
710 int i;
711
714 if (sd->
type == type) {
718 }
719 }
720 }
721
723 {
724 switch(type) {
738 }
740 }
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
const char const char void * val
#define AV_NUM_DATA_POINTERS
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
attribute_deprecated int qscale_type
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder Code outside libavutil shou...
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
memory handling functions
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
void * opaque
for some private data of the user
int nb_extended_buf
Number of elements in extended_buf.
int repeat_pict
When decoding, this signals how much the picture must be delayed.
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above ...
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type)
void av_frame_set_pkt_duration(AVFrame *frame, int64_t val)
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Mastering display metadata associated with a video frame.
static void wipe_side_data(AVFrame *frame)
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_set_pkt_size(AVFrame *frame, int val)
int8_t * av_frame_get_qp_table(AVFrame *f, int *stride, int *type)
Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
attribute_deprecated int8_t * qscale_table
QP table Not to be accessed directly from outside libavutil.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int frame_copy_video(AVFrame *dst, const AVFrame *src)
AVColorSpace
YUV colorspace type.
attribute_deprecated int qstride
QP store stride Not to be accessed directly from outside libavutil.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
The data is the AVPanScan struct defined in libavcodec.
Structure to hold side data for an AVFrame.
AVDictionary * metadata
metadata.
int interlaced_frame
The content of the picture is interlaced.
void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val)
AVColorRange
MPEG vs JPEG YUV range.
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Metadata relevant to a downmix procedure.
attribute_deprecated uint64_t error[AV_NUM_DATA_POINTERS]
AVFrameSideData ** side_data
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int width
width and height of the video frame
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define MAKE_ACCESSORS(str, name, type, field)
static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
ATSC A53 Part 4 Closed Captions.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
enum AVColorSpace colorspace
YUV colorspace type.
simple assert() macros that are a bit more flexible than ISO C assert().
The GOP timecode in 25 bit timecode format.
static int get_audio_buffer(AVFrame *frame, int align)
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
reference-counted frame API
uint64_t channel_layout
Channel layout of the audio data.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int channels
number of audio channels, only used for audio.
audio channel layout utility functions
enum AVPictureType pict_type
Picture type of the frame.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int display_picture_number
picture number in display order
AVBufferRef ** extended_buf
For planar audio which requires more than AV_NUM_DATA_POINTERS AVBufferRef pointers, this array will hold all the references which cannot fit into AVFrame.buf.
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
void av_frame_set_pkt_pos(AVFrame *frame, int64_t val)
AVBufferRef * qp_table_buf
Not to be accessed directly from outside libavutil.
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int av_buffer_is_writable(const AVBufferRef *buf)
const char * av_get_colorspace_name(enum AVColorSpace val)
Get the name of a colorspace.
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define FF_ARRAY_ELEMS(a)
const AVS_VideoInfo int align
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int coded_picture_number
picture number in bitstream order
int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown...
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int get_video_buffer(AVFrame *frame, int align)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t * data
The data buffer.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Copy samples from src to dst.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
If side data of the supplied type exists in the frame, free it and remove it from the frame...
int64_t reordered_opaque
reordered opaque 64bit (generally an integer or a double precision float PTS but can be anything)...
int sample_rate
Sample rate of the audio data.
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
Get the required buffer size for the given audio parameters.
rational number numerator/denominator
int palette_has_changed
Tell user application that palette has changed from previous frame.
refcounted data buffer API
enum AVChromaLocation chroma_location
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base Code outside libavutil should...
int decode_error_flags
decode error flags of the frame, set to a combination of FF_DECODE_ERROR_xxx flags if the decoder pro...
static int frame_copy_audio(AVFrame *dst, const AVFrame *src)
const char * av_frame_side_data_name(enum AVFrameSideDataType type)
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
int size
Size of data in bytes.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
enum AVFrameSideDataType type
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
A reference to a data buffer.
GLint GLenum GLboolean GLsizei stride
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define CHECK_CHANNELS_CONSISTENCY(frame)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define FF_ENABLE_DEPRECATION_WARNINGS
int top_field_first
If the content is interlaced, is top field displayed first.
int key_frame
1 -> keyframe, 0-> not
enum AVColorPrimaries color_primaries
static void * av_mallocz_array(size_t nmemb, size_t size)
static void free_side_data(AVFrameSideData **ptr_sd)
enum AVColorTransferCharacteristic color_trc
Recommmends skipping the specified number of samples.
#define av_malloc_array(a, b)
ReplayGain information in the form of the AVReplayGain struct.
uint8_t ** extended_data
pointers to the data planes/channels.
static void get_frame_defaults(AVFrame *frame)
int pkt_size
size of the corresponding packet containing the compressed frame.
Stereoscopic 3d metadata.
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_CEIL_RSHIFT(a, b)