Go to the documentation of this file.
43 #include "libavutil/ffversion.h"
58 return FFMPEG_CONFIGURATION;
63 #define LICENSE_PREFIX "libavcodec license: "
71 for (
i = 0;
i < count;
i++) {
84 for (
i = 0;
i < count;
i++) {
112 switch (
ctx->codec_type) {
121 if (bits_per_sample) {
122 bit_rate =
ctx->sample_rate * (int64_t)
ctx->channels;
123 if (bit_rate > INT64_MAX / bits_per_sample) {
126 bit_rate *= bits_per_sample;
145 if (!codec && !avctx->
codec) {
149 if (codec && avctx->
codec && codec != avctx->
codec) {
151 "but %s passed to avcodec_open2()\n", avctx->
codec->
name, codec->
name);
155 codec = avctx->
codec;
167 avctx->
codec = codec;
275 "The %s '%s' is experimental but experimental codecs are not enabled, "
276 "add '-strict %d' if you want to use it.\n",
300 av_log(avctx,
AV_LOG_WARNING,
"Warning: not compiled with thread support, using thread emulation\n");
346 "Channel layout '%s' with %d channels does not match specified number of channels %d: "
347 "ignoring specified channel layout\n",
362 #if FF_API_AVCTX_TIMEBASE
390 "that doesn't support it\n");
429 for (
i = 0;
i <
sub->num_rects;
i++) {
441 memset(
sub, 0,
sizeof(*
sub));
454 if (CONFIG_FRAME_THREAD_ENCODER &&
516 return str ?
str :
"unknown";
522 const char *codec_name;
531 if (!buf || buf_size <= 0)
551 enc->
refs, enc->
refs > 1 ?
"s" :
"");
588 if (strcmp(col, pri) || strcmp(col, trc)) {
590 av_bprintf(&bprint,
"%s/%s/%s, ", col, pri, trc);
596 const char *field_order =
"progressive";
598 field_order =
"top first";
600 field_order =
"bottom first";
602 field_order =
"top coded first (swapped)";
604 field_order =
"bottom coded first (swapped)";
614 if (
len == bprint.len) {
615 bprint.str[
len - 1] =
'\0';
618 if (bprint.len - 2 < bprint.size) {
621 bprint.str[bprint.len] =
'\0';
628 av_bprintf(&bprint,
"%s%dx%d", new_line ? separator :
", ",
644 display_aspect_ratio.
num, display_aspect_ratio.
den);
715 return !!
s->internal;
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
int(* func)(AVBPrint *dst, const char *in, const char *arg)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
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
uint64_t channel_layout
Audio channel layout.
enum AVColorSpace colorspace
YUV colorspace type.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
int sample_rate
samples per second
const AVClass * priv_class
AVClass for the private context.
static float sub(float src0, float src1)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int capabilities
Codec capabilities.
int depth
Number of bits in the component.
enum AVFieldOrder field_order
Field order.
void * frame_thread_encoder
static const char * unknown_if_null(const char *str)
uint8_t * subtitle_header
Header containing style information for text subtitles.
#define AV_LOG_VERBOSE
Detailed information.
const char * avcodec_profile_name(enum AVCodecID codec_id, int profile)
Return a name for the specified profile, if available.
int ff_thread_init(AVCodecContext *avctx)
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
int avcodec_is_open(AVCodecContext *s)
void(* flush)(struct AVCodecContext *)
Flush buffers.
int qmax
maximum quantizer
enum AVMediaType codec_type
void av_fifo_reset(AVFifoBuffer *f)
Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
const char * av_chroma_location_name(enum AVChromaLocation location)
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
static int ff_mutex_unlock(AVMutex *mutex)
const char * av_color_space_name(enum AVColorSpace space)
const struct AVCodec * codec
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
static int64_t get_bit_rate(AVCodecContext *ctx)
int initial_padding
Audio only.
int refs
number of reference frames
int flags
AV_CODEC_FLAG_*.
static void unlock_avcodec(const AVCodec *codec)
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
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.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define FF_CODEC_PROPERTY_LOSSLESS
#define LIBAVCODEC_VERSION_MICRO
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
av_cold int ff_frame_thread_encoder_init(AVCodecContext *avctx)
Initialize frame thread encoder.
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
int(* uninit)(AVCodecContext *avctx)
Uninitialize the hwaccel private data.
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout)
Append a description of a channel layout to a bprint buffer.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t max_pixels
The number of pixels per image to maximally accept.
int64_t rc_max_rate
maximum bitrate
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
void ff_thread_free(AVCodecContext *avctx)
#define FF_CODEC_PROPERTY_FILM_GRAIN
const char * av_color_range_name(enum AVColorRange range)
int av_log_get_level(void)
Get the current log level.
#define LIBAVCODEC_VERSION_INT
Describe the class of an AVClass context structure.
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
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.
Rational number (pair of numerator and denominator).
struct AVCodecInternal * internal
Private context used for internal data.
int64_t bit_rate
the average bitrate
int trailing_padding
Audio only.
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
const char * avcodec_license(void)
Return the libavcodec license.
void av_opt_free(void *obj)
Free all allocated objects in obj.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
unsigned avcodec_version(void)
Return the LIBAVCODEC_VERSION_INT constant.
int skip_samples_multiplier
@ 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
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVPacket * last_pkt_props
Properties (timestamps+side data) extracted from the last packet passed for decoding.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int av_codec_is_decoder(const AVCodec *codec)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
const OptionDef options[]
void * hwaccel_priv_data
hwaccel-specific private data
int(* close)(struct AVCodecContext *)
enum AVSampleFormat sample_fmt
audio sample format
#define AV_MUTEX_INITIALIZER
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
@ AVCHROMA_LOC_UNSPECIFIED
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
static AVMutex codec_mutex
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static void encode(AVCodecContext *ctx, AVFrame *frame, AVPacket *pkt, FILE *output)
static void lock_avcodec(const AVCodec *codec)
int64_t pts_correction_last_pts
Number of incorrect DTS values so far.
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
static int ff_mutex_lock(AVMutex *mutex)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
unsigned int byte_buffer_size
int ff_encode_preinit(AVCodecContext *avctx)
#define FF_THREAD_FRAME
Decode more than one frame at once.
int channels
number of audio channels
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
int av_codec_is_encoder(const AVCodec *codec)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int avcodec_default_execute2(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
#define i(width, name, range_min, range_max)
unsigned properties
Properties of the stream that gets decoded.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
int64_t pts_correction_last_dts
PTS of the last frame.
int ff_decode_preinit(AVCodecContext *avctx)
Perform decoder initialization and validation.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
uint8_t * dump_separator
dump format separator.
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...
const char * name
Name of the codec implementation.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVBufferRef * hw_device_ctx
A reference to the AVHWDeviceContext describing the device which will be used by a hardware encoder/d...
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
int caps_internal
Internal codec capabilities.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal codec state / flush internal buffers.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int needs_close
If this is set, then AVCodec->close (if existing) needs to be called for the parent AVCodecContext.
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
main external API structure.
int active_thread_type
Which multithreading methods are in use by the codec.
const AVCodecDescriptor * codec_descriptor
AVCodecDescriptor.
int qmin
minimum quantizer
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
av_cold void ff_frame_thread_encoder_free(AVCodecContext *avctx)
int draining
checks API usage: after codec draining, flush is required to resume operation
int coded_width
Bitstream width / height, may be different from width/height e.g.
enum AVMediaType codec_type
const char av_codec_ffversion[]
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.
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
int frame_number
Frame counter, set by libavcodec.
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define FF_MAX_EXTRADATA_SIZE
Maximum size in bytes of extradata.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
const char * avcodec_configuration(void)
Return the libavcodec build-time configuration.
int(* init)(struct AVCodecContext *)
@ AV_CODEC_ID_PCM_S8_PLANAR
int width
picture width / height.
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
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.
#define FF_SANE_NB_CHANNELS
char * codec_whitelist
',' separated list of allowed decoders.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
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 AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
#define av_fourcc2str(fourcc)