OpenFFmpeg
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 
169 
176 
182 };
183 
184 enum AVActiveFormatDescription {
185  AV_AFD_SAME = 8,
186  AV_AFD_4_3 = 9,
187  AV_AFD_16_9 = 10,
188  AV_AFD_14_9 = 11,
189  AV_AFD_4_3_SP_14_9 = 13,
190  AV_AFD_16_9_SP_14_9 = 14,
191  AV_AFD_SP_4_3 = 15,
192 };
193 
194 
201 typedef struct AVFrameSideData {
202  enum AVFrameSideDataType type;
203  uint8_t *data;
204  int size;
205  AVDictionary *metadata;
206  AVBufferRef *buf;
208 
229 typedef struct AVRegionOfInterest {
230  uint32_t self_size;
231  int top;
232  int bottom;
233  int left;
234  int right;
235  AVRational qoffset;
237 
268 typedef struct AVFrame {
269 #define AV_NUM_DATA_POINTERS 8
270 
282  uint8_t *data[AV_NUM_DATA_POINTERS];
283 
299  int linesize[AV_NUM_DATA_POINTERS];
300 
315  uint8_t **extended_data;
316 
326  int width, height;
335 
341  int format;
342 
347 
351  enum AVPictureType pict_type;
352 
357 
361  int64_t pts;
362 
363 #if FF_API_PKT_PTS
364 
368  attribute_deprecated
369  int64_t pkt_pts;
370 #endif
371 
377  int64_t pkt_dts;
378 
387 
391  int quality;
392 
396  void *opaque;
397 
398 #if FF_API_ERROR_FRAME
399 
402  attribute_deprecated
403  uint64_t error[AV_NUM_DATA_POINTERS];
404 #endif
405 
411 
416 
421 
426 
436 
441 
445  uint64_t channel_layout;
446 
459  AVBufferRef *buf[AV_NUM_DATA_POINTERS];
460 
478 
479  AVFrameSideData **side_data;
480  int nb_side_data;
481 
493 #define AV_FRAME_FLAG_CORRUPT (1 << 0)
494 
497 #define AV_FRAME_FLAG_DISCARD (1 << 2)
498 
505  int flags;
506 
512  enum AVColorRange color_range;
513 
514  enum AVColorPrimaries color_primaries;
515 
516  enum AVColorTransferCharacteristic color_trc;
517 
523  enum AVColorSpace colorspace;
524 
525  enum AVChromaLocation chroma_location;
526 
533 
539  int64_t pkt_pos;
540 
547  int64_t pkt_duration;
548 
555 
564 #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
565 #define FF_DECODE_ERROR_MISSING_REFERENCE 2
566 
572  int channels;
573 
581  int pkt_size;
582 
583 #if FF_API_FRAME_QP
584 
587  attribute_deprecated
588  int8_t *qscale_table;
592  attribute_deprecated
593  int qstride;
594 
595  attribute_deprecated
596  int qscale_type;
597 
598  attribute_deprecated
599  AVBufferRef *qp_table_buf;
600 #endif
601 
606 
617 
626  size_t crop_top;
627  size_t crop_bottom;
628  size_t crop_left;
629  size_t crop_right;
646 } AVFrame;
647 
648 #if FF_API_FRAME_GET_SET
649 
653 attribute_deprecated
654 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
655 attribute_deprecated
656 void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
657 attribute_deprecated
658 int64_t av_frame_get_pkt_duration (const AVFrame *frame);
659 attribute_deprecated
660 void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
661 attribute_deprecated
662 int64_t av_frame_get_pkt_pos (const AVFrame *frame);
663 attribute_deprecated
664 void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
665 attribute_deprecated
666 int64_t av_frame_get_channel_layout (const AVFrame *frame);
667 attribute_deprecated
668 void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
669 attribute_deprecated
670 int av_frame_get_channels (const AVFrame *frame);
671 attribute_deprecated
672 void av_frame_set_channels (AVFrame *frame, int val);
673 attribute_deprecated
674 int av_frame_get_sample_rate (const AVFrame *frame);
675 attribute_deprecated
676 void av_frame_set_sample_rate (AVFrame *frame, int val);
677 attribute_deprecated
678 AVDictionary *av_frame_get_metadata (const AVFrame *frame);
679 attribute_deprecated
680 void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
681 attribute_deprecated
682 int av_frame_get_decode_error_flags (const AVFrame *frame);
683 attribute_deprecated
684 void av_frame_set_decode_error_flags (AVFrame *frame, int val);
685 attribute_deprecated
686 int av_frame_get_pkt_size(const AVFrame *frame);
687 attribute_deprecated
688 void av_frame_set_pkt_size(AVFrame *frame, int val);
689 #if FF_API_FRAME_QP
690 attribute_deprecated
691 int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
692 attribute_deprecated
693 int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
694 #endif
695 attribute_deprecated
696 enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
697 attribute_deprecated
698 void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val);
699 attribute_deprecated
700 enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
701 attribute_deprecated
702 void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
703 #endif
704 
709 const char *av_get_colorspace_name(enum AVColorSpace val);
710 
721 AVFrame *av_frame_alloc(void);
722 
730 void av_frame_free(AVFrame **frame);
731 
747 int av_frame_ref(AVFrame *dst, const AVFrame *src);
748 
756 AVFrame *av_frame_clone(const AVFrame *src);
757 
761 void av_frame_unref(AVFrame *frame);
762 
770 void av_frame_move_ref(AVFrame *dst, AVFrame *src);
771 
795 int av_frame_get_buffer(AVFrame *frame, int align);
796 
809 int av_frame_is_writable(AVFrame *frame);
810 
822 int av_frame_make_writable(AVFrame *frame);
823 
835 int av_frame_copy(AVFrame *dst, const AVFrame *src);
836 
845 int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
846 
855 AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
856 
867  enum AVFrameSideDataType type,
868  int size);
869 
883  enum AVFrameSideDataType type,
884  AVBufferRef *buf);
885 
891  enum AVFrameSideDataType type);
892 
898 
899 
903 enum {
913 };
914 
931 int av_frame_apply_cropping(AVFrame *frame, int flags);
932 
936 const char *av_frame_side_data_name(enum AVFrameSideDataType type);
937 
942 #endif /* AVUTIL_FRAME_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:268
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:539
void * opaque
for some private data of the user
Definition: frame.h:396
int nb_extended_buf
Number of elements in extended_buf.
Definition: frame.h:477
Content light level (based on CTA-861.3).
Definition: frame.h:136
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:168
int repeat_pict
When decoding, this signals how much the picture must be delayed.
Definition: frame.h:410
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:582
attribute_deprecated int8_t * qscale_table
QP table.
Definition: frame.h:588
AVColorTransferCharacteristic
Color Transfer Characteristic.
Definition: pixfmt.h:464
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:734
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
Definition: frame.h:605
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:493
attribute_deprecated int qstride
QP store stride.
Definition: frame.h:593
AVBufferRef * private_ref
AVBufferRef for internal use by a single libav* library.
Definition: frame.h:645
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:443
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:361
The data is the AVPanScan struct defined in libavcodec.
Definition: frame.h:52
HDR dynamic metadata associated with a video frame.
Definition: frame.h:175
Structure to hold side data for an AVFrame.
Definition: frame.h:201
AVDictionary * metadata
metadata.
Definition: frame.h:554
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:415
AVColorRange
MPEG vs JPEG YUV range.
Definition: pixfmt.h:516
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:440
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:881
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.
Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unalig...
Definition: frame.h:912
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:792
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:445
struct AVRegionOfInterest AVRegionOfInterest
Structure to hold Region Of Interest.
int channels
number of audio channels, only used for audio.
Definition: frame.h:572
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:505
int display_picture_number
picture number in display order
Definition: frame.h:386
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:473
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:690
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:659
AVFrameSideDataType
Definition: frame.h:48
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
Definition: frame.h:391
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:143
Structure to hold Region Of Interest.
Definition: frame.h:229
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:540
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:341
int coded_picture_number
picture number in bitstream order
Definition: frame.h:382
int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown...
Definition: frame.h:547
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:594
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:356
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:805
int64_t reordered_opaque
reordered opaque 64 bits (generally an integer or a double precision float PTS but can be anything)...
Definition: frame.h:435
int sample_rate
Sample rate of the audio data.
Definition: frame.h:440
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
Definition: frame.c:722
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
Definition: frame.h:181
int palette_has_changed
Tell user application that palette has changed from previous frame.
Definition: frame.h:425
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:532
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:563
const char * av_frame_side_data_name(enum AVFrameSideDataType type)
Definition: frame.c:819
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
Definition: frame.c:324
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:553
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
Definition: frame.c:611
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
Definition: frame.h:369
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
Definition: frame.h:377
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:420
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: frame.h:616
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:346
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:538
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:315
int pkt_size
size of the corresponding packet containing the compressed frame.
Definition: frame.h:581
Stereoscopic 3d metadata.
Definition: frame.h:63
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:334
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:654
Raw QP table data.
Definition: frame.h:159