Go to the documentation of this file.
34 if (avpkt->
size < 0) {
39 av_log(avctx,
AV_LOG_ERROR,
"Invalid minimum required packet size %"PRId64
" (max allowed is %d)\n",
44 if (avctx && 2*min_size <
size) {
90 frame->channel_layout =
src->channel_layout;
92 frame->nb_samples =
s->frame_size;
102 src->nb_samples,
s->channels,
s->sample_fmt)) < 0)
105 frame->nb_samples -
src->nb_samples,
106 s->channels,
s->sample_fmt)) < 0)
127 int needs_realloc = !user_pkt.
data;
132 av_log(avctx,
AV_LOG_ERROR,
"This encoder requires using the avcodec_send_frame() API.\n");
146 "with more than %d channels, but extended_data is not set.\n",
158 frame = extended_frame;
172 av_log(avctx,
AV_LOG_ERROR,
"more samples than frame size (avcodec_encode_audio2)\n");
183 frame = padded_frame;
199 if (*got_packet_ptr) {
222 avpkt->
buf = user_pkt.
buf;
224 }
else if (!avpkt->
buf) {
232 if (needs_realloc && avpkt->
data) {
241 if (
ret < 0 || !*got_packet_ptr) {
265 int needs_realloc = !user_pkt.
data;
270 av_log(avctx,
AV_LOG_ERROR,
"This encoder requires using the avcodec_send_frame() API.\n");
274 if(CONFIG_FRAME_THREAD_ENCODER &&
311 avpkt->
buf = user_pkt.
buf;
313 }
else if (!avpkt->
buf) {
321 if (!*got_packet_ptr)
326 if (needs_realloc && avpkt->
data) {
336 if (
ret < 0 || !*got_packet_ptr)
374 if (
ret >= 0 && *got_packet) {
440 if (
ret >= 0 && !got_packet)
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
int frame_size
Number of samples per channel in an audio frame.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
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 AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
int av_buffer_realloc(AVBufferRef **pbuf, int size)
Reallocate a given buffer.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
int capabilities
Codec capabilities.
void * frame_thread_encoder
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int avcodec_is_open(AVCodecContext *s)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int(* encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, const struct AVSubtitle *sub)
int av_codec_is_encoder(const AVCodec *codec)
const struct AVCodec * codec
int flags
AV_CODEC_FLAG_*.
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...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVPacket * buffer_pkt
buffers for using new encode/decode API through legacy API
@ 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.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
int64_t max_pixels
The number of pixels per image to maximally accept.
int ff_alloc_packet(AVPacket *avpkt, int size)
static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
Pad last frame with silence.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
struct AVCodecInternal * internal
Private context used for internal data.
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int(* receive_packet)(AVCodecContext *avctx, AVPacket *avpkt)
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
char * stats_out
pass1 encoding statistics output buffer
enum AVSampleFormat sample_fmt
audio sample format
#define AV_NUM_DATA_POINTERS
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint8_t * byte_buffer
temporary buffer used for encoders to store their bitstream
int(* send_frame)(AVCodecContext *avctx, const AVFrame *frame)
Encode API with decoupled packet/frame dataflow.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
int flags
A combination of AV_PKT_FLAG values.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
unsigned int byte_buffer_size
#define FF_THREAD_FRAME
Decode more than one frame at once.
int channels
number of audio channels
int(* encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode data to an AVPacket.
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.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint8_t ** extended_data
pointers to the data planes/channels.
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...
int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr)
int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
int last_audio_frame
An audio frame with less than required samples has been submitted and padded with silence.
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.
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
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
int active_thread_type
Which multithreading methods are in use by the codec.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int draining
checks API usage: after codec draining, flush is required to resume operation
enum AVMediaType codec_type
A reference to a data buffer.
int frame_number
Frame counter, set by libavcodec.
Structure to hold side data for an AVFrame.
This structure stores compressed data.
int width
picture width / height.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
uint32_t start_display_time
static int do_encode(AVCodecContext *avctx, const AVFrame *frame, int *got_packet)
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.