FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
encode.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/samplefmt.h"
#include "avcodec.h"
#include "frame_thread_encoder.h"
#include "internal.h"

Go to the source code of this file.

Functions

int ff_alloc_packet2 (AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
 Check AVPacket size and/or allocate data. More...
 
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. More...
 
int attribute_align_arg avcodec_encode_audio2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of audio. More...
 
int attribute_align_arg avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of video. More...
 
int avcodec_encode_subtitle (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
 
static int do_encode (AVCodecContext *avctx, const AVFrame *frame, int *got_packet)
 
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...
 

Function Documentation

int ff_alloc_packet2 ( AVCodecContext avctx,
AVPacket avpkt,
int64_t  size,
int64_t  min_size 
)

Check AVPacket size and/or allocate data.

Encoders supporting AVCodec.encode2() can use this as a convenience to ensure the output packet data is large enough, whether provided by the user or allocated in this function.

Parameters
avctxthe AVCodecContext of the encoder
avpktthe AVPacket If avpkt->data is already set, avpkt->size is checked to ensure it is large enough. If avpkt->data is NULL, a new buffer is allocated. avpkt->size is set to the specified size. All other AVPacket fields will be reset with av_init_packet().
sizethe minimum required packet size
min_sizeThis is a hint to the allocation algorithm, which indicates to what minimal size the caller might later shrink the packet to. Encoders often allocate packets which are larger than the amount of data that is written into them as the exact amount is not known at the time of allocation. min_size represents the size a packet might be shrunk to by the caller. Can be set to 0. setting this roughly correctly allows the allocation code to choose between several allocation strategies to improve speed slightly.
Returns
non negative on success, negative error code on failure

Definition at line 32 of file encode.c.

Referenced by a64multi_encode_frame(), aac_encode_frame(), adpcm_encode_frame(), adx_encode_frame(), alac_encode_frame(), amf_copy_buffer(), amr_wb_encode_frame(), aptx_encode_frame(), avui_encode_frame(), bmp_encode_frame(), cinepak_encode_frame(), cng_encode_frame(), dnxhd_encode_picture(), dvvideo_encode_frame(), encode_apng(), encode_frame(), encode_nals(), encode_picture_ls(), encode_png(), encode_superframe(), ff_alloc_packet(), ff_mpv_encode_picture(), ffat_encode(), fits_encode_frame(), flac_encode_frame(), flashsv2_encode_frame(), flashsv_encode_frame(), g722_encode_frame(), g723_1_encode_frame(), gif_encode_frame(), hap_encode(), ilbc_encode_frame(), libcodec2_encode(), libgsm_encode_frame(), libkvazaar_encode(), libopenjpeg_encode_frame(), libopus_encode(), libshine_encode_frame(), libvorbis_encode_frame(), libwebp_anim_encode_frame(), libwebp_encode_frame(), libx265_encode_frame(), ljpeg_encode_frame(), magy_encode_frame(), mlp_encode_frame(), mp3lame_encode_frame(), MPA_encode_frame(), omx_encode_frame(), opus_encode_frame(), pam_encode_frame(), pcm_encode_frame(), pcx_encode_frame(), pnm_encode_frame(), process_output_surface(), prores_encode_frame(), qtrle_encode_frame(), ra144_encode_frame(), raw_encode(), roq_dpcm_encode_frame(), roq_encode_frame(), s302m_encode2_frame(), sbc_encode_frame(), storeframe(), sunrast_encode_frame(), svc_encode_frame(), svq1_encode_frame(), targa_encode_frame(), tta_encode_frame(), twolame_encode_frame(), utvideo_encode_frame(), v308_encode_frame(), v408_encode_frame(), v410_encode_frame(), vorbis_encode_frame(), vtenc_cm_to_avpacket(), wavpack_encode_frame(), XAVS_frame(), xbm_encode_frame(), xface_encode_frame(), xvid_encode_frame(), xwd_encode_frame(), y41p_encode_frame(), and yuv4_encode_frame().

int ff_alloc_packet ( AVPacket avpkt,
int  size 
)

Definition at line 73 of file encode.c.

static int pad_last_frame ( AVCodecContext s,
AVFrame **  dst,
const AVFrame src 
)
static

Pad last frame with silence.

Definition at line 81 of file encode.c.

Referenced by avcodec_encode_audio2().

static int do_encode ( AVCodecContext avctx,
const AVFrame frame,
int got_packet 
)
static

Definition at line 359 of file encode.c.

Referenced by avcodec_receive_packet(), and avcodec_send_frame().