36 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
43 if (avctx && 2*min_size < size) {
140 if (!frame->
buf[0]) {
153 if (CONFIG_FRAME_THREAD_ENCODER &&
161 ret = avctx->
codec->
encode2(avctx, avpkt, frame, &got_packet);
171 if (!ret && got_packet) {
200 if (ret < 0 || !got_packet)
363 #if FF_API_OLD_ENCDEC 383 else if (ret ==
AVERROR(EAGAIN)) {
404 avpkt->
buf = user_pkt.
buf;
420 "API cannot return all the packets for this encoder. " 421 "Some packets will be dropped. Update your code to the " 422 "new encoding API to fix this.\n");
static int compat_encode(AVCodecContext *avctx, AVPacket *avpkt, int *got_packet, const AVFrame *frame)
const struct AVCodec * codec
int(* receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt)
Encode API with decoupled frame/packet dataflow.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
int av_codec_is_encoder(const AVCodec *codec)
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
#define AV_LOG_WARNING
Something somehow does not look correct.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Macro definitions for various function/variable attributes.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
enum AVSampleFormat sample_fmt
audio sample format
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int(* encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt, const struct AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
void * frame_thread_encoder
Structure to hold side data for an AVFrame.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet_ptr)
#define AVERROR_EOF
End of file.
char * stats_out
pass1 encoding statistics output buffer
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
int active_thread_type
Which multithreading methods are in use by the codec.
int avcodec_is_open(AVCodecContext *s)
int capabilities
Codec capabilities.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int flags
AV_CODEC_FLAG_*.
simple assert() macros that are a bit more flexible than ISO C assert().
int64_t max_pixels
The number of pixels per image to maximally accept.
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int flags
A combination of AV_PKT_FLAG values.
reference-counted frame API
uint64_t channel_layout
Channel layout of the audio data.
common internal API header
int channels
number of audio channels, only used for audio.
#define FF_THREAD_FRAME
Decode more than one frame at once.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
int width
picture width / height.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int draining
checks API usage: after codec draining, flush is required to resume operation
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int frame_size
Number of samples per channel in an audio frame.
static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt)
Libavcodec external API header.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
int av_samples_copy(uint8_t **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.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
AVPacket * compat_encode_packet
int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
common internal api header.
int(* encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
uint32_t start_display_time
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
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...
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src)
Pad last frame with silence.
int channels
number of audio channels
struct AVCodecInternal * internal
Private context used for internal data.
unsigned int byte_buffer_size
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int frame_number
Frame counter, set by libavcodec.
static float sub(float src0, float src1)
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
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
uint8_t ** extended_data
pointers to the data planes/channels.
static int encode_simple_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
This structure stores compressed data.
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
int last_audio_frame
An audio frame with less than required samples has been submitted and padded with silence...