Go to the documentation of this file.
84 "changes, but PARAM_CHANGE side data was sent to it.\n");
95 #if FF_API_OLD_CHANNEL_LAYOUT
97 if (
flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
100 val = bytestream_get_le32(&
data);
101 if (val <= 0 || val > INT_MAX) {
111 if (
flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
120 if (
flags & (AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT |
121 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)) {
131 val = bytestream_get_le32(&
data);
132 if (val <= 0 || val > INT_MAX) {
143 avctx->
width = bytestream_get_le32(&
data);
277 int64_t reordered_pts, int64_t dts)
282 ctx->pts_correction_num_faulty_dts += dts <=
ctx->pts_correction_last_dts;
283 ctx->pts_correction_last_dts = dts;
285 ctx->pts_correction_last_dts = reordered_pts;
288 ctx->pts_correction_num_faulty_pts += reordered_pts <=
ctx->pts_correction_last_pts;
289 ctx->pts_correction_last_pts = reordered_pts;
291 ctx->pts_correction_last_pts = dts;
293 if ((
ctx->pts_correction_num_faulty_pts<=
ctx->pts_correction_num_faulty_dts || dts ==
AV_NOPTS_VALUE)
306 uint32_t discard_padding = 0;
307 uint8_t skip_reason = 0;
308 uint8_t discard_reason = 0;
311 if (side && side->
size >= 10) {
337 *discarded_samples +=
frame->nb_samples;
343 *discarded_samples +=
frame->nb_samples;
356 frame->pts += diff_ts;
358 frame->pkt_dts += diff_ts;
359 if (
frame->duration >= diff_ts)
360 frame->duration -= diff_ts;
372 if (discard_padding > 0 && discard_padding <= frame->nb_samples) {
373 if (discard_padding ==
frame->nb_samples) {
374 *discarded_samples +=
frame->nb_samples;
381 frame->duration = diff_ts;
386 (
int)discard_padding,
frame->nb_samples);
387 frame->nb_samples -= discard_padding;
405 int got_frame, consumed;
480 "Stop draining and force EOF.\n");
523 if (!sd || !sd->
size)
526 if (!avci->icc.avctx) {
547 frame->color_primaries = prim;
549 frame->color_trc = trc;
580 if (!
frame->ch_layout.nb_channels) {
585 #if FF_API_OLD_CHANNEL_LAYOUT
587 if (!
frame->channel_layout)
590 if (!
frame->channels)
594 if (!
frame->sample_rate)
604 int64_t discarded_samples = 0;
606 while (!
frame->buf[0]) {
632 int64_t discarded_samples = 0;
669 #if FF_API_INTERLACED_FRAME
679 #if FF_API_PKT_DURATION
690 if (
frame->private_ref) {
718 if (
dc->draining_started)
721 if (avpkt && !avpkt->
size && avpkt->
data)
731 dc->draining_started = 1;
745 if (
frame->crop_left >= INT_MAX -
frame->crop_right ||
746 frame->crop_top >= INT_MAX -
frame->crop_bottom ||
750 "Invalid cropping information set by a decoder: "
752 "(frame size %dx%d). This is a bug, please report it\n",
755 frame->crop_left = 0;
756 frame->crop_right = 0;
758 frame->crop_bottom = 0;
782 frame->sample_rate <= 0)
792 "This is a bug, please report it.\n");
823 #if FF_API_AVCTX_FRAME_NUMBER
829 #if FF_API_DROPCHANGED
867 " drop count: %d \n",
884 memset(sub, 0,
sizeof(*sub));
888 #define UTF8_MAX_BYTES 4
893 iconv_t cd = (iconv_t)-1;
922 outb = buf_pkt->
data;
923 outl = buf_pkt->
size;
925 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
926 iconv(cd,
NULL,
NULL, &outb, &outl) == (
size_t)-1 ||
927 outl >= buf_pkt->
size || inl != 0) {
933 buf_pkt->
size -= outl;
934 memset(buf_pkt->
data + buf_pkt->
size, 0, outl);
941 if (cd != (iconv_t)-1)
953 uint32_t codepoint,
min;
957 GET_UTF8(codepoint, *(
byte++),
return 0;);
958 min =
byte - str == 1 ? 0 :
byte - str == 2 ? 0x80 :
959 1 << (5 * (
byte - str) - 4);
960 if (codepoint < min || codepoint >= 0x110000 ||
961 codepoint == 0xFFFE ||
962 codepoint >= 0xD800 && codepoint <= 0xDFFF )
970 int *got_sub_ptr,
const AVPacket *avpkt)
1025 "Invalid UTF-8 in decoded subtitles text; "
1026 "maybe missing -sub_charenc option\n");
1035 #if FF_API_AVCTX_FRAME_NUMBER
1067 if (
config->pix_fmt == fmt[n])
1090 if (
config->pix_fmt == fmt[n])
1122 "required for hardware accelerated decoding.\n");
1127 if (device_ctx->
type != dev_type) {
1210 *out_frames_ref = frames_ref;
1237 if (hwaccel->
init) {
1238 err = hwaccel->
init(avctx);
1241 "hwaccel initialisation returned error.\n",
1285 choices =
av_memdup(fmt, (n + 1) *
sizeof(*choices));
1293 user_choice = avctx->
get_format(avctx, choices);
1303 "get_format() callback.\n");
1310 for (
i = 0;
i < n;
i++) {
1311 if (choices[
i] == user_choice)
1316 "%s not in possible list.\n",
desc->name);
1345 if (frames_ctx->
format != user_choice) {
1347 "does not match the format of the provided frames "
1348 "context.\n",
desc->name);
1351 }
else if (
config->methods &
1358 "does not match the type of the provided device "
1359 "context.\n",
desc->name);
1362 }
else if (
config->methods &
1365 }
else if (
config->methods &
1370 "missing configuration.\n",
desc->name);
1375 "initialisation.\n",
desc->name);
1385 "get_format() without it.\n",
desc->name);
1386 for (
i = 0;
i < n;
i++) {
1387 if (choices[
i] == user_choice)
1390 for (;
i + 1 < n;
i++)
1391 choices[
i] = choices[
i + 1];
1415 const uint8_t *side_metadata;
1424 static const struct {
1442 static const struct {
1454 #if FF_API_FRAME_PKT
1470 memcpy(frame_sd->
data, packet_sd,
size);
1483 memcpy(frame_sd->
data, packet_sd,
size);
1518 memcpy(frame_sd->
data, packet_sd->
data, packet_sd->
size);
1528 #if FF_API_FRAME_PKT
1534 #if FF_API_REORDERED_OPAQUE
1536 frame->reordered_opaque = avctx->reordered_opaque;
1548 frame->sample_aspect_ratio) < 0) {
1550 frame->sample_aspect_ratio.num,
1551 frame->sample_aspect_ratio.den);
1568 for (
i = 0;
i < num_planes;
i++) {
1574 av_log(avctx,
AV_LOG_ERROR,
"Buffer returned by get_buffer2() did not zero unused plane pointers\n");
1612 frame->private_ref = fdd_buf;
1620 int override_dimensions = 1;
1633 if (
frame->width <= 0 ||
frame->height <= 0) {
1636 override_dimensions = 0;
1645 #if FF_API_OLD_CHANNEL_LAYOUT
1706 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
1711 if (!
frame->data[0])
1760 "supported with subtitles codecs\n");
1764 "subtitles character encoding will be ignored\n",
1775 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1776 if (cd == (iconv_t)-1) {
1779 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1785 "conversion needs a libavcodec built with iconv support "
1786 "for this codec\n");
1801 "gray decoding requested but not enabled at configuration time\n");
1815 #if FF_API_DROPCHANGED
1861 if (!*hwaccel_picture_private)
1880 dc->nb_draining_errors = 0;
1881 dc->draining_started = 0;
const AVPacketSideData * ff_get_coded_side_data(const AVCodecContext *avctx, enum AVPacketSideDataType type)
Get side data of the given type from a decoding context.
int av_samples_copy(uint8_t *const *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.
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
#define FF_ENABLE_DEPRECATION_WARNINGS
int(* receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame)
Decode API with decoupled packet/frame dataflow.
AVCodecParameters * par_in
Parameters of the input stream.
static int hwaccel_init(AVCodecContext *avctx, const FFHWAccel *hwaccel)
#define AV_LOG_WARNING
Something somehow does not look correct.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
static enum AVPixelFormat hw_pix_fmt
AVPixelFormat
Pixel format.
#define AV_EF_EXPLODE
abort decoding on minor error detection
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
Callback to negotiate the pixel format.
int ff_icc_profile_read_primaries(FFIccContext *s, cmsHPROFILE profile, AVColorPrimariesDesc *out_primaries)
Read the color primaries and white point coefficients encoded by an ICC profile, and return the raw v...
enum AVColorSpace colorspace
YUV colorspace type.
AVColorTransferCharacteristic
Color Transfer Characteristic.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
static int apply_cropping(AVCodecContext *avctx, AVFrame *frame)
int sample_rate
samples per second
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Struct that contains both white point location and primaries location, providing the complete descrip...
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
#define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL
HWAccel is experimental and is thus avoided in favor of non experimental codecs.
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
int skip_samples
Number of audio samples to skip at the start of the next decoded frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define AV_CODEC_FLAG_UNALIGNED
Allow decoders to produce frames with data planes that are not aligned to CPU requirements (e....
const struct AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
const char * name
Name of the codec described by this descriptor.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
static void * ff_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(FFRefStructOpaque opaque, void *obj))
A wrapper around ff_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame)
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
AVHWAccel p
The public AVHWAccel.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This struct stores per-frame lavc-internal data and is attached to it via private_ref.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
This structure describes decoded (raw) audio or video data.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
int capabilities
Codec capabilities.
int(* frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Fill the given hw_frames context with current codec parameters.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int capabilities
Hardware accelerated codec capabilities.
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
uint8_t * subtitle_header
Header containing style information for text subtitles.
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
void(* hwaccel_priv_free)(void *priv)
#define FF_HW_SIMPLE_CALL(avctx, function)
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
#define FF_SUB_CHARENC_MODE_PRE_DECODER
the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv
enum AVChannelOrder order
Channel order used in this layout.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx, const enum AVPixelFormat *fmt)
int avcodec_is_open(AVCodecContext *s)
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
int nb_channels
Number of channels in this layout.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static DecodeContext * decode_ctx(AVCodecInternal *avci)
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
#define FF_SUB_CHARENC_MODE_AUTOMATIC
libavcodec will select the mode itself
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.
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
void ff_hwaccel_uninit(AVCodecContext *avctx)
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
uint8_t max_lowres
maximum value for lowres supported by the decoder
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
int(* alloc_frame)(AVCodecContext *avctx, AVFrame *frame)
Allocate a custom buffer.
#define AV_CODEC_FLAG_COPY_OPAQUE
const struct AVCodec * codec
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
AVChannelLayout ch_layout
Audio channel layout.
int ff_icc_context_init(FFIccContext *s, void *avctx)
Initializes an FFIccContext.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define FF_SUB_CHARENC_MODE_DO_NOTHING
do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for inst...
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
void(* post_process_opaque_free)(void *opaque)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int ff_decode_frame_props_from_pkt(const AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
Set various frame properties from the provided packet.
union AVChannelLayout::@332 u
Details about which channels are present in this layout.
static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
static int64_t guess_correct_pts(AVCodecContext *ctx, int64_t reordered_pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
int64_t max_samples
The number of samples per frame to maximally accept.
char * ass
0 terminated ASS/SSA compatible event line.
int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of a plane of an image with...
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
#define AV_CODEC_FLAG_DROPCHANGED
Don't output frames whose parameters differ from first decoded frame in stream.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int64_t pts_correction_num_faulty_pts
Current statistics for PTS correction.
int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame)
avcodec_receive_frame() implementation for decoders.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
int has_b_frames
Size of the frame reordering buffer in the decoder.
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
static void get_subtitle_defaults(AVSubtitle *sub)
void * post_process_opaque
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame)
AVPacket * buffer_pkt
Temporary buffers for newly received or not yet output packets/frames.
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
#define AV_CEIL_RSHIFT(a, b)
int priv_data_size
Size of the private data to allocate in AVCodecInternal.hwaccel_priv_data.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define AVERROR_INPUT_CHANGED
Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base_in
The timebase used for the timestamps of the input packets.
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
enum AVPixelFormat pix_fmt
For decoders, a hardware pixel format which that decoder may be able to decode to if suitable hardwar...
int64_t pts
Same as packet pts, in AV_TIME_BASE.
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm)
Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description.
int64_t max_pixels
The number of pixels per image to maximally accept.
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
void * opaque
for some private data of the user
const struct FFHWAccel * hwaccel
If this configuration uses a hwaccel, a pointer to it.
int(* decode)(struct AVCodecContext *avctx, struct AVFrame *frame, int *got_frame_ptr, struct AVPacket *avpkt)
Decode to an AVFrame.
static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
static void decode_data_free(void *opaque, uint8_t *data)
int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, enum AVHWDeviceType dev_type)
Make sure avctx.hw_frames_ctx is set.
int draining_started
The caller has submitted a NULL packet on input.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
int changed_frames_dropped
char * sub_charenc
DTS of the last frame.
AVCodecInternal * ff_decode_internal_alloc(void)
#define AV_CODEC_FLAG2_SKIP_MANUAL
Do not skip samples and export skip information as frame side data.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
static int utf8_check(const uint8_t *str)
@ AV_FRAME_DATA_SPHERICAL
The data represents the AVSphericalMapping structure defined in libavutil/spherical....
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void ff_decode_flush_buffers(AVCodecContext *avctx)
int apply_cropping
Video decoding only.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Rational number (pair of numerator and denominator).
struct AVCodecInternal * internal
Private context used for internal data.
enum AVPacketSideDataType type
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
static void * ff_refstruct_allocz(size_t size)
Equivalent to ff_refstruct_alloc_ext(size, 0, NULL, NULL)
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
#define AV_CODEC_FLAG2_ICC_PROFILES
Generate/parse ICC profiles on encode/decode, as appropriate for the type of file.
int ff_icc_profile_detect_transfer(FFIccContext *s, cmsHPROFILE profile, enum AVColorTransferCharacteristic *out_trc)
Attempt detecting the transfer characteristic that best approximates the transfer function encoded by...
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
#define FF_HW_HAS_CB(avctx, function)
#define AVPACKET_IS_EMPTY(pkt)
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AVCOL_RANGE_UNSPECIFIED
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AV_FRAME_CROP_UNALIGNED
Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unalig...
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
#define attribute_align_arg
int av_codec_is_decoder(const AVCodec *codec)
int lowres
low resolution decoding, 1-> 1/2 size, 2->1/4 size
int(* init)(AVCodecContext *avctx)
Initialize the hwaccel private data.
int flags2
AV_CODEC_FLAG2_*.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Submit a new frame to a decoding thread.
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
int(* post_process)(void *logctx, AVFrame *frame)
The callback to perform some delayed processing on the frame right before it is returned to the calle...
void * hwaccel_priv_data
hwaccel-specific private data
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
@ AV_PKT_DATA_DYNAMIC_HDR10_PLUS
HDR10+ dynamic metadata associated with a video frame.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define FF_CODEC_CAP_SETS_FRAME_PROPS
Codec handles output frame properties internally instead of letting the internal logic derive them fr...
struct AVBSFContext * bsf
enum AVSampleFormat sample_fmt
audio sample format
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed.
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int frame_validate(AVCodecContext *avctx, AVFrame *frame)
static const av_always_inline FFCodec * ffcodec(const AVCodec *codec)
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
static int fill_frame_props(const AVCodecContext *avctx, AVFrame *frame)
@ AVCHROMA_LOC_UNSPECIFIED
uint32_t end_display_time
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict)
Unpack a dictionary from side_data.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
int flags
A combination of AV_PKT_FLAG values.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
const struct AVCodecHWConfigInternal *const * hw_configs
Array of pointers to hardware configurations supported by the codec, or NULL if no hardware supported...
static int detect_colorspace(av_unused AVCodecContext *c, av_unused AVFrame *f)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_LOG_INFO
Standard information.
#define FF_THREAD_FRAME
Decode more than one frame at once.
@ AV_FRAME_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
const char * name
Name of the hardware accelerated codec.
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
unsigned caps_internal
Internal codec capabilities FF_CODEC_CAP_*.
static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
static const struct @59 sd_global_map[]
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
enum AVPacketSideDataType packet
int64_t pts_correction_last_dts
PTS of the last frame.
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
void(* free_frame_priv)(FFRefStructOpaque hwctx, void *data)
Callback to free the hwaccel-specific frame data.
int(* decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle *sub, int *got_frame_ptr, const struct AVPacket *avpkt)
Decode subtitle data to an AVSubtitle.
int sub_charenc_mode
Subtitles character encoding mode.
This struct describes a set or pool of "hardware" frames (i.e.
int64_t frame_num
Frame counter, set by libavcodec.
int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, AVBufferRef *device_ref, enum AVPixelFormat hw_pix_fmt, AVBufferRef **out_frames_ref)
Create and return a AVHWFramesContext with values adequate for hardware decoding.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
#define AV_INPUT_BUFFER_PADDING_SIZE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt)
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
main external API structure.
int active_thread_type
Which multithreading methods are in use by the codec.
static int recode_subtitle(AVCodecContext *avctx, const AVPacket **outpkt, const AVPacket *inpkt, AVPacket *buf_pkt)
@ AV_CODEC_HW_CONFIG_METHOD_INTERNAL
The codec supports this format by some internal method.
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_PKT_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
@ FF_CODEC_CB_TYPE_RECEIVE_FRAME
unsigned cb_type
This field determines the type of the codec (decoder/encoder) and also the exact callback cb implemen...
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
int draining
checks API usage: after codec draining, flush is required to resume operation
enum AVFrameSideDataType frame
const char * bsfs
Decoding only, a comma-separated list of bitstream filters to apply to packets before decoding.
#define FF_DISABLE_DEPRECATION_WARNINGS
int coded_width
Bitstream width / height, may be different from width/height e.g.
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
int initial_pool_size
Initial size of the frame pool.
enum AVMediaType codec_type
#define AV_FRAME_FLAG_DISCARD
A flag to mark the frames which need to be decoded, but shouldn't be output.
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
@ AV_PKT_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
A reference to a data buffer.
#define AV_CODEC_EXPORT_DATA_MVS
Export motion vectors through frame side data.
int ff_icc_profile_sanitize(FFIccContext *s, cmsHPROFILE profile)
Sanitize an ICC profile to try and fix badly broken values.
int ff_attach_decode_data(AVFrame *frame)
AVChannelLayout initial_ch_layout
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define AV_CODEC_FLAG2_EXPORT_MVS
Export motion vectors through frame side data.
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
int width
picture width / height.
void * hwaccel_priv
Per-frame private data for hwaccels.
attribute_deprecated int frame_number
Frame counter, set by libavcodec.
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static av_cold int uninit(AVCodecContext *avctx)
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so,...
AVCodecHWConfig public
This is the structure which will be returned to the user by avcodec_get_hw_config().
static int decode_bsfs_init(AVCodecContext *avctx)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
enum AVPixelFormat pix_fmt
Supported pixel format.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
#define FF_REGET_BUFFER_FLAG_READONLY
the returned buffer does not need to be writable
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
#define FF_SUB_CHARENC_MODE_IGNORE
neither convert the subtitles, nor check them for valid UTF-8