FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
Encoding
Encoding/Decoding Library

Data Structures

struct  RcOverride
 

Macros

#define FF_MIN_BUFFER_SIZE   16384
 minimum encoding buffer size Used to avoid some checks during header writing.
 

Enumerations

enum  Motion_Est_ID {
  ME_ZERO = 1, ME_FULL, ME_LOG, ME_PHODS,
  ME_EPZS, ME_X1, ME_HEX, ME_UMH,
  ME_TESA, ME_ITER =50
}
 motion estimation type. More...
 

Functions

AVCodecavcodec_find_encoder (enum AVCodecID id)
 Find a registered encoder with a matching codec ID.
 
AVCodecavcodec_find_encoder_by_name (const char *name)
 Find a registered encoder with the specified name.
 
int attribute_deprecated avcodec_encode_audio (AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)
 Encode an audio frame from samples into buf.
 
int avcodec_encode_audio2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of audio.
 
attribute_deprecated int avcodec_encode_video (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict)
 
int avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of video.
 
int avcodec_encode_subtitle (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
 

Detailed Description

Macro Definition Documentation

#define FF_MIN_BUFFER_SIZE   16384

minimum encoding buffer size Used to avoid some checks during header writing.

Definition at line 624 of file avcodec.h.

Referenced by avcodec_encode_video(), encode_frame(), encode_nals(), encode_picture_ls(), flashsv2_encode_frame(), gif_encode_frame(), ljpeg_encode_frame(), prores_encode_frame(), svq1_encode_frame(), and xvid_encode_frame().

Enumeration Type Documentation

motion estimation type.

Enumerator:
ME_ZERO 

no search, that is use 0,0 vector whenever one is needed

ME_FULL 
ME_LOG 
ME_PHODS 
ME_EPZS 

enhanced predictive zonal search

ME_X1 

reserved for experiments

ME_HEX 

hexagon based search

ME_UMH 

uneven multi-hexagon search

ME_TESA 

transformed exhaustive search algorithm

ME_ITER 

iterative search

Definition at line 631 of file avcodec.h.

Function Documentation

AVCodec* avcodec_find_encoder ( enum AVCodecID  id)
AVCodec* avcodec_find_encoder_by_name ( const char *  name)

Find a registered encoder with the specified name.

Parameters
namename of the requested encoder
Returns
An encoder if one was found, NULL otherwise.

Definition at line 2812 of file utils.c.

Referenced by find_codec_or_die(), opt_codec(), and show_help_codec().

int attribute_deprecated avcodec_encode_audio ( AVCodecContext avctx,
uint8_t buf,
int  buf_size,
const short *  samples 
)

Encode an audio frame from samples into buf.

Deprecated:
Use avcodec_encode_audio2 instead.
Note
The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user will know how much space is needed because it depends on the value passed in buf_size as described below. In that case a lower value can be used.
Parameters
avctxthe codec context
[out]bufthe output buffer
[in]buf_sizethe output buffer size
[in]samplesthe input buffer containing the samples The number of samples read from this buffer is frame_size*channels, both of which are defined in avctx. For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of samples read from samples is equal to: buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id)) This also implies that av_get_bits_per_sample() must not return 0 for these codecs.
Returns
On error a negative value is returned, on success zero or the number of bytes used to encode the data read from the input buffer.

Definition at line 1885 of file utils.c.

int avcodec_encode_audio2 ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)

Encode a frame of audio.

Takes input samples from frame and writes the next output packet, if available, to avpkt. The output packet does not necessarily contain data for the most recent frame, as encoders can delay, split, and combine input frames internally as needed.

Parameters
avctxcodec context
avpktoutput AVPacket. The user can supply an output buffer by setting avpkt->data and avpkt->size prior to calling the function, but if the size of the user-provided data is not large enough, encoding will fail. If avpkt->data and avpkt->size are set, avpkt->destruct must also be set. All other AVPacket fields will be reset by the encoder using av_init_packet(). If avpkt->data is NULL, the encoder will allocate it. The encoder will set avpkt->size to the size of the output packet.

If this function fails or produces no output, avpkt will be freed using av_free_packet() (i.e. avpkt->destruct will be called to free the user supplied buffer).

Parameters
[in]frameAVFrame containing the raw audio data to be encoded. May be NULL when flushing an encoder that has the CODEC_CAP_DELAY capability set. If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame can have any number of samples. If it is not set, frame->nb_samples must be equal to avctx->frame_size for all frames except the last. The final frame may be smaller than avctx->frame_size.
[out]got_packet_ptrThis field is set to 1 by libavcodec if the output packet is non-empty, and to 0 if it is empty. If the function returns an error, the packet can be assumed to be invalid, and the value of got_packet_ptr is undefined and should not be used.
Returns
0 on success, negative error code on failure
Examples:
decoding_encoding.c, muxing.c, transcode_aac.c, and transcoding.c.

Definition at line 1751 of file utils.c.

Referenced by audio_encode_example(), avcodec_encode_audio(), do_audio_out(), encode_audio_frame(), encode_write_frame(), flush_encoders(), wrap(), and write_audio_frame().

attribute_deprecated int avcodec_encode_video ( AVCodecContext avctx,
uint8_t buf,
int  buf_size,
const AVFrame pict 
)
Deprecated:
use avcodec_encode_video2() instead.

Encode a video frame from pict into buf. The input picture should be stored using a specific format, namely avctx.pix_fmt.

Parameters
avctxthe codec context
[out]bufthe output buffer for the bitstream of encoded frame
[in]buf_sizethe size of the output buffer in bytes
[in]pictthe input picture to encode
Returns
On error a negative value is returned, on success zero or the number of bytes used from the output buffer.

Definition at line 1969 of file utils.c.

Referenced by filter(), and wrap().

int avcodec_encode_video2 ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int *  got_packet_ptr 
)

Encode a frame of video.

Takes input raw video data from frame and writes the next output packet, if available, to avpkt. The output packet does not necessarily contain data for the most recent frame, as encoders can delay and reorder input frames internally as needed.

Parameters
avctxcodec context
avpktoutput AVPacket. The user can supply an output buffer by setting avpkt->data and avpkt->size prior to calling the function, but if the size of the user-provided data is not large enough, encoding will fail. All other AVPacket fields will be reset by the encoder using av_init_packet(). If avpkt->data is NULL, the encoder will allocate it. The encoder will set avpkt->size to the size of the output packet. The returned data (if any) belongs to the caller, he is responsible for freeing it.

If this function fails or produces no output, avpkt will be freed using av_free_packet() (i.e. avpkt->destruct will be called to free the user supplied buffer).

Parameters
[in]frameAVFrame containing the raw video data to be encoded. May be NULL when flushing an encoder that has the CODEC_CAP_DELAY capability set.
[out]got_packet_ptrThis field is set to 1 by libavcodec if the output packet is non-empty, and to 0 if it is empty. If the function returns an error, the packet can be assumed to be invalid, and the value of got_packet_ptr is undefined and should not be used.
Returns
0 on success, negative error code on failure
Examples:
decoding_encoding.c, muxing.c, and transcoding.c.

Definition at line 2004 of file utils.c.

Referenced by avcodec_encode_video(), do_video_out(), encode_frame(), encode_write_frame(), filter_frame(), flush_encoders(), video_encode_example(), worker(), wrap(), and write_video_frame().

int avcodec_encode_subtitle ( AVCodecContext avctx,
uint8_t buf,
int  buf_size,
const AVSubtitle sub 
)

Definition at line 2085 of file utils.c.

Referenced by do_subtitle_out(), and wrap().