FFmpeg
frame.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef AVUTIL_FRAME_H
26 #define AVUTIL_FRAME_H
27 
28 #include <stddef.h>
29 #include <stdint.h>
30 
31 #include "avutil.h"
32 #include "buffer.h"
33 #include "dict.h"
34 #include "rational.h"
35 #include "samplefmt.h"
36 #include "pixfmt.h"
37 #include "version.h"
38 
39 
125 
131 
137 
144 
145 #if FF_API_FRAME_QP
146 
153 
160 #endif
161 };
162 
163 enum AVActiveFormatDescription {
164  AV_AFD_SAME = 8,
165  AV_AFD_4_3 = 9,
166  AV_AFD_16_9 = 10,
167  AV_AFD_14_9 = 11,
168  AV_AFD_4_3_SP_14_9 = 13,
169  AV_AFD_16_9_SP_14_9 = 14,
170  AV_AFD_SP_4_3 = 15,
171 };
172 
173 
180 typedef struct AVFrameSideData {
181  enum AVFrameSideDataType type;
182  uint8_t *data;
183  int size;
184  AVDictionary *metadata;
185  AVBufferRef *buf;
187 
218 typedef struct AVFrame {
219 #define AV_NUM_DATA_POINTERS 8
220 
232  uint8_t *data[AV_NUM_DATA_POINTERS];
233 
249  int linesize[AV_NUM_DATA_POINTERS];
250 
265  uint8_t **extended_data;
266 
276  int width, height;
285 
291  int format;
292 
297 
301  enum AVPictureType pict_type;
302 
307 
311  int64_t pts;
312 
313 #if FF_API_PKT_PTS
314 
318  attribute_deprecated
319  int64_t pkt_pts;
320 #endif
321 
327  int64_t pkt_dts;
328 
337 
341  int quality;
342 
346  void *opaque;
347 
348 #if FF_API_ERROR_FRAME
349 
352  attribute_deprecated
353  uint64_t error[AV_NUM_DATA_POINTERS];
354 #endif
355 
361 
366 
371 
376 
387 
392 
396  uint64_t channel_layout;
397 
410  AVBufferRef *buf[AV_NUM_DATA_POINTERS];
411 
429 
430  AVFrameSideData **side_data;
431  int nb_side_data;
432 
444 #define AV_FRAME_FLAG_CORRUPT (1 << 0)
445 
448 #define AV_FRAME_FLAG_DISCARD (1 << 2)
449 
456  int flags;
457 
463  enum AVColorRange color_range;
464 
465  enum AVColorPrimaries color_primaries;
466 
467  enum AVColorTransferCharacteristic color_trc;
468 
474  enum AVColorSpace colorspace;
475 
476  enum AVChromaLocation chroma_location;
477 
484 
490  int64_t pkt_pos;
491 
498  int64_t pkt_duration;
499 
506 
515 #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
516 #define FF_DECODE_ERROR_MISSING_REFERENCE 2
517 
523  int channels;
524 
532  int pkt_size;
533 
534 #if FF_API_FRAME_QP
535 
538  attribute_deprecated
539  int8_t *qscale_table;
543  attribute_deprecated
544  int qstride;
545 
546  attribute_deprecated
547  int qscale_type;
548 
549  attribute_deprecated
550  AVBufferRef *qp_table_buf;
551 #endif
552 
557 
568 
577  size_t crop_top;
578  size_t crop_bottom;
579  size_t crop_left;
580  size_t crop_right;
597 } AVFrame;
598 
599 #if FF_API_FRAME_GET_SET
600 
604 attribute_deprecated
605 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
606 attribute_deprecated
607 void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
608 attribute_deprecated
609 int64_t av_frame_get_pkt_duration (const AVFrame *frame);
610 attribute_deprecated
611 void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
612 attribute_deprecated
613 int64_t av_frame_get_pkt_pos (const AVFrame *frame);
614 attribute_deprecated
615 void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
616 attribute_deprecated
617 int64_t av_frame_get_channel_layout (const AVFrame *frame);
618 attribute_deprecated
619 void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
620 attribute_deprecated
621 int av_frame_get_channels (const AVFrame *frame);
622 attribute_deprecated
623 void av_frame_set_channels (AVFrame *frame, int val);
624 attribute_deprecated
625 int av_frame_get_sample_rate (const AVFrame *frame);
626 attribute_deprecated
627 void av_frame_set_sample_rate (AVFrame *frame, int val);
628 attribute_deprecated
629 AVDictionary *av_frame_get_metadata (const AVFrame *frame);
630 attribute_deprecated
631 void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
632 attribute_deprecated
633 int av_frame_get_decode_error_flags (const AVFrame *frame);
634 attribute_deprecated
635 void av_frame_set_decode_error_flags (AVFrame *frame, int val);
636 attribute_deprecated
637 int av_frame_get_pkt_size(const AVFrame *frame);
638 attribute_deprecated
639 void av_frame_set_pkt_size(AVFrame *frame, int val);
640 #if FF_API_FRAME_QP
641 attribute_deprecated
642 int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
643 attribute_deprecated
644 int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
645 #endif
646 attribute_deprecated
647 enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
648 attribute_deprecated
649 void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val);
650 attribute_deprecated
651 enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
652 attribute_deprecated
653 void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
654 #endif
655 
660 const char *av_get_colorspace_name(enum AVColorSpace val);
661 
672 AVFrame *av_frame_alloc(void);
673 
681 void av_frame_free(AVFrame **frame);
682 
698 int av_frame_ref(AVFrame *dst, const AVFrame *src);
699 
707 AVFrame *av_frame_clone(const AVFrame *src);
708 
712 void av_frame_unref(AVFrame *frame);
713 
721 void av_frame_move_ref(AVFrame *dst, AVFrame *src);
722 
746 int av_frame_get_buffer(AVFrame *frame, int align);
747 
760 int av_frame_is_writable(AVFrame *frame);
761 
773 int av_frame_make_writable(AVFrame *frame);
774 
786 int av_frame_copy(AVFrame *dst, const AVFrame *src);
787 
796 int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
797 
806 AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
807 
818  enum AVFrameSideDataType type,
819  int size);
820 
834  enum AVFrameSideDataType type,
835  AVBufferRef *buf);
836 
842  enum AVFrameSideDataType type);
843 
849 
850 
854 enum {
864 };
865 
882 int av_frame_apply_cropping(AVFrame *frame, int flags);
883 
887 const char *av_frame_side_data_name(enum AVFrameSideDataType type);
888 
893 #endif /* AVUTIL_FRAME_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition: frame.h:113
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
Definition: frame.h:490
void * opaque
for some private data of the user
Definition: frame.h:346
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:428
Content light level (based on CTA-861.3).
Definition: frame.h:136
int repeat_pict
When decoding, this signals how much the picture must be delayed.
Definition: frame.h:360
Convenience header that includes libavutil&#39;s core.
Mastering display metadata associated with a video frame.
Definition: frame.h:119
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:580
attribute_deprecated int8_t * qscale_table
QP table.
Definition: frame.h:539
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:444
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:732
Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unalig...
Definition: frame.h:863
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
Definition: frame.h:556
Public dictionary API.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:189
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:473
attribute_deprecated int qstride
QP store stride.
Definition: frame.h:544
AVBufferRef * private_ref
AVBufferRef for internal use by a single libav* library.
Definition: frame.h:596
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:441
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:311
The data is the AVPanScan struct defined in libavcodec.
Definition: frame.h:52
Structure to hold side data for an AVFrame.
Definition: frame.h:180
AVDictionary * metadata
metadata.
Definition: frame.h:505
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:365
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:496
The data represents the AVSphericalMapping structure defined in libavutil/spherical.h.
Definition: frame.h:130
AVColorPrimaries
Chromaticity coordinates of the source primaries.
Definition: pixfmt.h:420
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: frame.h:89
Metadata relevant to a downmix procedure.
Definition: frame.h:72
Implementation-specific description of the format of AV_FRAME_QP_TABLE_DATA.
Definition: frame.h:152
Definition: dict.c:30
attribute_deprecated int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame)
Accessors for some AVFrame fields.
int av_frame_apply_cropping(AVFrame *frame, int flags)
Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ crop_bottom fields...
Definition: frame.c:873
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
struct AVFrameSideData AVFrameSideData
Structure to hold side data for an AVFrame.
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:58
struct AVFrame AVFrame
This structure describes decoded (raw) audio or video data.
Libavutil version macros.
The GOP timecode in 25 bit timecode format.
Definition: frame.h:124
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
Definition: frame.c:790
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:396
int channels
number of audio channels, only used for audio.
Definition: frame.h:523
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:456
int display_picture_number
picture number in display order
Definition: frame.h:336
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.
Definition: frame.h:424
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
Definition: frame.c:688
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
Definition: frame.h:96
AVBufferRef * av_frame_get_plane_buffer(AVFrame *frame, int plane)
Get the buffer reference a given data plane is stored in.
Definition: frame.c:657
AVFrameSideDataType
Definition: frame.h:48
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
Definition: frame.h:341
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:143
const char * av_get_colorspace_name(enum AVColorSpace val)
Get the name of a colorspace.
Definition: frame.c:122
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:538
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:291
int coded_picture_number
picture number in bitstream order
Definition: frame.h:332
int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown...
Definition: frame.h:498
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:84
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:592
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:306
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...
Definition: frame.c:803
int64_t reordered_opaque
reordered opaque 64 bits (generally an integer or a double precision float PTS but can be anything)...
Definition: frame.h:386
int sample_rate
Sample rate of the audio data.
Definition: frame.h:391
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
Definition: frame.c:720
Rational number (pair of numerator and denominator).
Definition: rational.h:58
int palette_has_changed
Tell user application that palette has changed from previous frame.
Definition: frame.h:375
refcounted data buffer API
AVPictureType
Definition: avutil.h:272
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
Definition: frame.h:483
int decode_error_flags
decode error flags of the frame, set to a combination of FF_DECODE_ERROR_xxx flags if the decoder pro...
Definition: frame.h:514
const char * av_frame_side_data_name(enum AVFrameSideDataType type)
Definition: frame.c:817
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:322
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:551
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
Definition: frame.c:609
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
Definition: frame.h:319
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
Definition: frame.h:327
A reference to a data buffer.
Definition: buffer.h:81
Utilties for rational number calculation.
pixel format definitions
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:370
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: frame.h:567
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:296
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:518
Recommmends skipping the specified number of samples.
Definition: frame.h:108
ReplayGain information in the form of the AVReplayGain struct.
Definition: frame.h:76
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:265
int pkt_size
size of the corresponding packet containing the compressed frame.
Definition: frame.h:532
Stereoscopic 3d metadata.
Definition: frame.h:63
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:284
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
Definition: frame.h:67
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:652
Raw QP table data.
Definition: frame.h:159