Go to the documentation of this file.
96 "changes, but PARAM_CHANGE side data was sent to it.\n");
110 val = bytestream_get_le32(&
data);
111 if (val <= 0 || val > INT_MAX) {
122 avctx->
width = bytestream_get_le32(&
data);
261 dc->pts_correction_num_faulty_dts += dts <=
dc->pts_correction_last_dts;
262 dc->pts_correction_last_dts = dts;
264 dc->pts_correction_last_dts = reordered_pts;
267 dc->pts_correction_num_faulty_pts += reordered_pts <=
dc->pts_correction_last_pts;
268 dc->pts_correction_last_pts = reordered_pts;
270 dc->pts_correction_last_pts = dts;
272 if ((
dc->pts_correction_num_faulty_pts<=
dc->pts_correction_num_faulty_dts || dts ==
AV_NOPTS_VALUE)
285 uint32_t discard_padding = 0;
286 uint8_t skip_reason = 0;
287 uint8_t discard_reason = 0;
290 if (side && side->
size >= 10) {
316 *discarded_samples +=
frame->nb_samples;
322 *discarded_samples +=
frame->nb_samples;
335 frame->pts += diff_ts;
337 frame->pkt_dts += diff_ts;
338 if (
frame->duration >= diff_ts)
339 frame->duration -= diff_ts;
351 if (discard_padding > 0 && discard_padding <= frame->nb_samples) {
352 if (discard_padding ==
frame->nb_samples) {
353 *discarded_samples +=
frame->nb_samples;
360 frame->duration = diff_ts;
365 (
int)discard_padding,
frame->nb_samples);
366 frame->nb_samples -= discard_padding;
384 int got_frame, consumed;
460 "Stop draining and force EOF.\n");
503 if (!sd || !sd->
size)
506 if (!avci->icc.avctx) {
527 frame->color_primaries = prim;
529 frame->color_trc = trc;
560 if (!
frame->ch_layout.nb_channels) {
565 if (!
frame->sample_rate)
577 while (!
frame->buf[0]) {
641 #if FF_API_INTERLACED_FRAME
656 if (
frame->private_ref) {
684 if (
dc->draining_started)
687 if (avpkt && !avpkt->
size && avpkt->
data)
697 dc->draining_started = 1;
711 if (
frame->crop_left >= INT_MAX -
frame->crop_right ||
712 frame->crop_top >= INT_MAX -
frame->crop_bottom ||
716 "Invalid cropping information set by a decoder: "
718 "(frame size %dx%d). This is a bug, please report it\n",
721 frame->crop_left = 0;
722 frame->crop_right = 0;
724 frame->crop_bottom = 0;
748 frame->sample_rate <= 0)
758 "This is a bug, please report it.\n");
790 #if FF_API_DROPCHANGED
828 " drop count: %d \n",
845 memset(sub, 0,
sizeof(*sub));
849 #define UTF8_MAX_BYTES 4
854 iconv_t cd = (iconv_t)-1;
883 outb = buf_pkt->
data;
884 outl = buf_pkt->
size;
886 if (iconv(cd, &inb, &inl, &outb, &outl) == (
size_t)-1 ||
887 iconv(cd,
NULL,
NULL, &outb, &outl) == (
size_t)-1 ||
888 outl >= buf_pkt->
size || inl != 0) {
894 buf_pkt->
size -= outl;
895 memset(buf_pkt->
data + buf_pkt->
size, 0, outl);
902 if (cd != (iconv_t)-1)
914 uint32_t codepoint,
min;
918 GET_UTF8(codepoint, *(
byte++),
return 0;);
919 min =
byte - str == 1 ? 0 :
byte - str == 2 ? 0x80 :
920 1 << (5 * (
byte - str) - 4);
921 if (codepoint < min || codepoint >= 0x110000 ||
922 codepoint == 0xFFFE ||
923 codepoint >= 0xD800 && codepoint <= 0xDFFF )
931 int *got_sub_ptr,
const AVPacket *avpkt)
986 "Invalid UTF-8 in decoded subtitles text; "
987 "maybe missing -sub_charenc option\n");
1023 if (
config->pix_fmt == fmt[n])
1046 if (
config->pix_fmt == fmt[n])
1078 "required for hardware accelerated decoding.\n");
1083 if (device_ctx->
type != dev_type) {
1166 *out_frames_ref = frames_ref;
1197 "hwaccel initialisation returned error.\n",
1241 choices =
av_memdup(fmt, (n + 1) *
sizeof(*choices));
1249 user_choice = avctx->
get_format(avctx, choices);
1259 "get_format() callback.\n");
1266 for (
i = 0;
i < n;
i++) {
1267 if (choices[
i] == user_choice)
1272 "%s not in possible list.\n",
desc->name);
1301 if (frames_ctx->
format != user_choice) {
1303 "does not match the format of the provided frames "
1304 "context.\n",
desc->name);
1307 }
else if (
config->methods &
1314 "does not match the type of the provided device "
1315 "context.\n",
desc->name);
1318 }
else if (
config->methods &
1321 }
else if (
config->methods &
1326 "missing configuration.\n",
desc->name);
1341 "get_format() without it.\n",
desc->name);
1342 for (
i = 0;
i < n;
i++) {
1343 if (choices[
i] == user_choice)
1346 for (;
i + 1 < n;
i++)
1347 choices[
i] = choices[
i + 1];
1371 const uint8_t *side_metadata;
1380 static const struct {
1398 static const struct {
1411 #if FF_API_FRAME_PKT
1427 memcpy(frame_sd->
data, packet_sd,
size);
1440 memcpy(frame_sd->
data, packet_sd,
size);
1475 memcpy(frame_sd->
data, packet_sd->
data, packet_sd->
size);
1485 #if FF_API_FRAME_PKT
1500 frame->sample_aspect_ratio) < 0) {
1502 frame->sample_aspect_ratio.num,
1503 frame->sample_aspect_ratio.den);
1520 for (
i = 0;
i < num_planes;
i++) {
1526 av_log(avctx,
AV_LOG_ERROR,
"Buffer returned by get_buffer2() did not zero unused plane pointers\n");
1564 frame->private_ref = fdd_buf;
1572 int override_dimensions = 1;
1585 if (
frame->width <= 0 ||
frame->height <= 0) {
1588 override_dimensions = 0;
1649 av_log(avctx,
AV_LOG_WARNING,
"Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
1654 if (!
frame->data[0])
1704 "supported with subtitles codecs\n");
1708 "subtitles character encoding will be ignored\n",
1719 iconv_t cd = iconv_open(
"UTF-8", avctx->
sub_charenc);
1720 if (cd == (iconv_t)-1) {
1723 "with input character encoding \"%s\"\n", avctx->
sub_charenc);
1729 "conversion needs a libavcodec built with iconv support "
1730 "for this codec\n");
1737 dc->pts_correction_num_faulty_pts =
1738 dc->pts_correction_num_faulty_dts = 0;
1739 dc->pts_correction_last_pts =
1740 dc->pts_correction_last_dts = INT64_MIN;
1745 "gray decoding requested but not enabled at configuration time\n");
1752 dc->side_data_pref_mask = ~0ULL;
1773 dc->side_data_pref_mask |= 1ULL <<
val;
1788 #if FF_API_DROPCHANGED
1810 if (
dc->side_data_pref_mask & (1ULL <<
type))
1835 return sd ? 0 :
AVERROR(ENOMEM);
1871 return *mdm ? 0 :
AVERROR(ENOMEM);
1883 return *clm ? 0 :
AVERROR(ENOMEM);
1910 if (
hwaccel->free_frame_priv) {
1924 if (!*hwaccel_picture_private)
1938 dc->pts_correction_last_pts =
1939 dc->pts_correction_last_dts = INT64_MIN;
1943 dc->nb_draining_errors = 0;
1944 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
@ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
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...
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf, AVFrameSideData **psd)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
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...
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.
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
@ AV_CODEC_HW_CONFIG_METHOD_INTERNAL
The codec supports this format by some internal method.
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.
@ AV_PKT_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1:2014.
uint8_t * subtitle_header
@ 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
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)
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.
int64_t pts_correction_num_faulty_dts
Number of incorrect PTS values so far.
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().
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
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 ...
#define AV_CODEC_FLAG_COPY_OPAQUE
static int64_t guess_correct_pts(DecodeContext *dc, int64_t reordered_pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
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.
static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame)
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.
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
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.
static int side_data_pref(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type)
Check side data preference and clear existing side data from frame if needed.
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)
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 has_b_frames
Size of the frame reordering buffer in the decoder.
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
int * side_data_prefer_packet
Decoding only.
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.
#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
@ AV_FRAME_CROP_UNALIGNED
Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unalig...
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 ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
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
Character encoding of the input subtitles file.
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.
@ FF_CODEC_CB_TYPE_DECODE_SUB
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.
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.
int64_t pts_correction_last_dts
PTS of the last 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
static const struct @71 sd_global_map[]
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
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_NB
The number of side data types.
@ 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 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]
@ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
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 extra_hw_frames
Video decoding only.
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)
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
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.
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...
uint64_t side_data_pref_mask
DTS of the last frame.
unsigned nb_side_data_prefer_packet
Number of entries in side_data_prefer_packet.
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)
static void uninit(AVBSFContext *ctx)
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)
@ 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
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.
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.
@ AV_CODEC_HW_CONFIG_METHOD_AD_HOC
The codec supports this format by some ad-hoc method.
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.
static const char * hwaccel
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
#define AV_INPUT_BUFFER_PADDING_SIZE
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
@ AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX
The codec supports this format via the hw_frames_ctx interface.
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)
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
@ 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_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
int64_t pts_correction_num_faulty_pts
int width
picture width / height.
void * hwaccel_priv
Per-frame private data for hwaccels.
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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