FFmpeg
Functions
encode.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "encode.h"
#include "frame_thread_encoder.h"
#include "internal.h"

Go to the source code of this file.

Functions

int ff_alloc_packet (AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
 Check AVPacket size and allocate data. More...
 
int avcodec_default_get_encode_buffer (AVCodecContext *avctx, AVPacket *avpkt, int flags)
 The default callback for AVCodecContext.get_encode_buffer(). More...
 
int ff_get_encode_buffer (AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
 Get a buffer for a packet. More...
 
static int pad_last_frame (AVCodecContext *s, AVFrame *frame, const AVFrame *src)
 Pad last frame with silence. More...
 
int avcodec_encode_subtitle (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
 
int ff_encode_get_frame (AVCodecContext *avctx, AVFrame *frame)
 Called by encoders to get the next frame for encoding. More...
 
static int encode_simple_internal (AVCodecContext *avctx, AVPacket *avpkt)
 
static int encode_simple_receive_packet (AVCodecContext *avctx, AVPacket *avpkt)
 
static int encode_receive_packet_internal (AVCodecContext *avctx, AVPacket *avpkt)
 
static int encode_send_frame_internal (AVCodecContext *avctx, const AVFrame *src)
 
int attribute_align_arg avcodec_send_frame (AVCodecContext *avctx, const AVFrame *frame)
 Supply a raw video or audio frame to the encoder. More...
 
int attribute_align_arg avcodec_receive_packet (AVCodecContext *avctx, AVPacket *avpkt)
 Read encoded data from the encoder. More...
 
int ff_encode_preinit (AVCodecContext *avctx)
 

Function Documentation

◆ ff_alloc_packet()

int ff_alloc_packet ( AVCodecContext avctx,
AVPacket avpkt,
int64_t  size 
)

Check AVPacket size and allocate data.

Encoders supporting AVCodec.encode2() can use this as a convenience to obtain a big enough buffer for the encoded bitstream.

Parameters
avctxthe AVCodecContext of the encoder
avpktThe AVPacket: on success, avpkt->data will point to a buffer of size at least size; the packet will not be refcounted. This packet must be initially blank.
sizean upper bound of the size of the packet to encode
Returns
non negative on success, negative error code on failure

Definition at line 34 of file encode.c.

Referenced by aac_encode_frame(), alac_encode_frame(), amr_wb_encode_frame(), cfhd_encode_frame(), cinepak_encode_frame(), encode_frame(), encode_png(), encode_superframe(), ff_mpv_encode_picture(), ffat_encode(), flashsv2_encode_frame(), flashsv_encode_frame(), gif_encode_frame(), hap_encode(), ilbc_encode_frame(), libopenjpeg_encode_frame(), libopus_encode(), ljpeg_encode_frame(), magy_encode_frame(), mlp_encode_frame(), MPA_encode_frame(), opus_encode_frame(), pcx_encode_frame(), prores_encode_frame(), qtrle_encode_frame(), roq_encode_frame(), rpza_encode_frame(), smc_encode_frame(), sunrast_encode_frame(), svq1_encode_frame(), targa_encode_frame(), tta_encode_frame(), twolame_encode_frame(), utvideo_encode_frame(), vorbis_encode_frame(), wavpack_encode_frame(), xbm_encode_frame(), and xvid_encode_frame().

◆ ff_get_encode_buffer()

int ff_get_encode_buffer ( AVCodecContext avctx,
AVPacket avpkt,
int64_t  size,
int  flags 
)

◆ pad_last_frame()

static int pad_last_frame ( AVCodecContext s,
AVFrame frame,
const AVFrame src 
)
static

Pad last frame with silence.

Definition at line 112 of file encode.c.

Referenced by encode_send_frame_internal().

◆ ff_encode_get_frame()

int ff_encode_get_frame ( AVCodecContext avctx,
AVFrame frame 
)

Called by encoders to get the next frame for encoding.

Parameters
frameAn empty frame to be filled with data.
Returns
0 if a new reference has been successfully written to frame AVERROR(EAGAIN) if no data is currently available AVERROR_EOF if end of stream has been reached, so no more data will be available

Definition at line 157 of file encode.c.

Referenced by eb_receive_packet(), encode_simple_internal(), ff_amf_receive_packet(), ff_nvenc_receive_packet(), ff_vaapi_encode_receive_packet(), librav1e_receive_packet(), mf_receive_packet(), and v4l2_receive_packet().

◆ encode_simple_internal()

static int encode_simple_internal ( AVCodecContext avctx,
AVPacket avpkt 
)
static

Definition at line 172 of file encode.c.

Referenced by encode_simple_receive_packet().

◆ encode_simple_receive_packet()

static int encode_simple_receive_packet ( AVCodecContext avctx,
AVPacket avpkt 
)
static

Definition at line 261 of file encode.c.

Referenced by encode_receive_packet_internal().

◆ encode_receive_packet_internal()

static int encode_receive_packet_internal ( AVCodecContext avctx,
AVPacket avpkt 
)
static

Definition at line 274 of file encode.c.

Referenced by avcodec_receive_packet(), and avcodec_send_frame().

◆ encode_send_frame_internal()

static int encode_send_frame_internal ( AVCodecContext avctx,
const AVFrame src 
)
static

Definition at line 308 of file encode.c.

Referenced by avcodec_send_frame().

◆ ff_encode_preinit()

int ff_encode_preinit ( AVCodecContext avctx)

Definition at line 409 of file encode.c.

Referenced by avcodec_open2().