#include <xvid.h>#include <unistd.h>#include "common.h"#include "avcodec.h"

Go to the source code of this file.
Data Structures | |
| struct | xvid_context |
| struct | xvid_ff_pass1 |
Defines | |
| #define | BUFFER_SIZE 1024 |
| #define | BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x)) |
| #define | BUFFER_CAT(x) (&((x)[strlen(x)])) |
Typedefs | |
| typedef struct xvid_context | xvid_context_t |
| typedef struct xvid_ff_pass1 | xvid_ff_pass1_t |
Functions | |
| int | xvid_strip_vol_header (AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len) |
| int | xvid_ff_2pass (void *ref, int opt, void *p1, void *p2) |
| void | xvid_correct_framerate (AVCodecContext *avctx) |
| int | ff_xvid_encode_init (AVCodecContext *avctx) |
| int | ff_xvid_encode_frame (AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) |
| int | ff_xvid_encode_close (AVCodecContext *avctx) |
| static int | xvid_ff_2pass_create (xvid_plg_create_t *param, void **handle) |
| static int | xvid_ff_2pass_destroy (xvid_context_t *ref, xvid_plg_destroy_t *param) |
| static int | xvid_ff_2pass_before (xvid_context_t *ref, xvid_plg_data_t *param) |
| static int | xvid_ff_2pass_after (xvid_context_t *ref, xvid_plg_data_t *param) |
Variables | |
| AVCodec | xvid_encoder |
| #define BUFFER_CAT | ( | x | ) | (&((x)[strlen(x)])) |
Definition at line 36 of file xvidff.c.
Referenced by xvid_ff_2pass_after(), and xvid_ff_2pass_create().
| #define BUFFER_REMAINING | ( | x | ) | (BUFFER_SIZE - strlen(x)) |
Definition at line 35 of file xvidff.c.
Referenced by xvid_ff_2pass_after(), and xvid_ff_2pass_create().
| typedef struct xvid_context xvid_context_t |
| typedef struct xvid_ff_pass1 xvid_ff_pass1_t |
| int ff_xvid_encode_close | ( | AVCodecContext * | avctx | ) |
Destroys the private context for the encoder. All buffers are freed, and the XviD encoder context is destroyed.
| avctx | AVCodecContext pointer to context |
Definition at line 474 of file xvidff.c.
References av_free(), xvid_context::encoder_handle, AVCodecContext::extradata, xvid_context::inter_matrix, xvid_context::intra_matrix, NULL, xvid_context::old_twopassbuffer, AVCodecContext::priv_data, xvid_context::twopassbuffer, and xvid_context::twopassfile.

| int ff_xvid_encode_frame | ( | AVCodecContext * | avctx, | |
| unsigned char * | frame, | |||
| int | buf_size, | |||
| void * | data | |||
| ) |
Encodes a single frame.
| avctx | AVCodecContext pointer to context | |
| frame | Pointer to encoded frame buffer | |
| buf_size | Size of encoded frame buffer | |
| data | Pointer to AVFrame of unencoded frame |
Definition at line 377 of file xvidff.c.
References av_log(), AV_LOG_ERROR, xvid_context::encoded_picture, xvid_context::encoder_handle, FF_B_TYPE, FF_I_TYPE, FF_P_TYPE, FF_QP2LAMBDA, FF_S_TYPE, xvid_context::inter_matrix, xvid_context::intra_matrix, xvid_context::me_flags, NULL, xvid_context::old_twopassbuffer, picture, AVCodecContext::pix_fmt, PIX_FMT_YUV420P, AVCodecContext::priv_data, xvid_context::qscale, xvid_context::quicktime_format, AVCodecContext::stats_out, xvid_context::twopassbuffer, xvid_context::vol_flags, xvid_context::vop_flags, and xvid_strip_vol_header().

| int ff_xvid_encode_init | ( | AVCodecContext * | avctx | ) |
Creates the private context for the encoder. All buffers are allocated, settings are loaded from the user, and the encoder context created.
| avctx | AVCodecContext pointer to context |
Definition at line 84 of file xvidff.c.
References av_log(), AV_LOG_ERROR, av_malloc(), AVCodecContext::b_quant_factor, AVCodecContext::b_quant_offset, AVCodecContext::bit_rate, BUFFER_SIZE, CODEC_FLAG_4MV, CODEC_FLAG_AC_PRED, CODEC_FLAG_CLOSED_GOP, CODEC_FLAG_GLOBAL_HEADER, CODEC_FLAG_GMC, CODEC_FLAG_GRAY, CODEC_FLAG_PASS1, CODEC_FLAG_PASS2, CODEC_FLAG_QPEL, CODEC_FLAG_QSCALE, CODEC_FLAG_TRELLIS_QUANT, AVCodecContext::codec_id, CODEC_ID_MPEG4, AVCodecContext::codec_tag, AVCodecContext::coded_frame, xvid_ff_pass1::context, AVRational::den, xvid_context::encoded_picture, xvid_context::encoder_handle, AVCodecContext::extradata, AVCodecContext::extradata_size, AVCodecContext::flags, AVCodecContext::gop_size, has_altivec(), AVCodecContext::height, AVCodecContext::inter_matrix, xvid_context::inter_matrix, AVCodecContext::intra_matrix, xvid_context::intra_matrix, AVCodecContext::lumi_masking, AVCodecContext::max_b_frames, AVCodecContext::mb_decision, ME_EPZS, xvid_context::me_flags, ME_FULL, ME_LOG, AVCodecContext::me_method, ME_PHODS, ME_X1, ME_ZERO, AVCodecContext::mpeg_quant, NULL, AVRational::num, xvid_context::old_twopassbuffer, AVCodecContext::priv_data, AVCodecContext::qmax, AVCodecContext::qmin, xvid_context::qscale, xvid_context::quicktime_format, AVCodecContext::stats_in, AVCodecContext::time_base, xvid_context::twopassbuffer, xvid_context::twopassfile, xvid_ff_pass1::version, xvid_context::vol_flags, xvid_context::vop_flags, AVCodecContext::width, xvid_context::xsize, xvid_correct_framerate(), xvid_ff_2pass(), and xvid_context::ysize.

| void xvid_correct_framerate | ( | AVCodecContext * | avctx | ) |
Routine to correct a possibly erroneous framerate being fed to us. XviD currently chokes on framerates where the ticks per frame is extremely large. This function works to correct problems in this area by estimating a new framerate and taking the simpler fraction of the two presented.
| avctx | Context that contains the framerate to correct. |
Definition at line 548 of file xvidff.c.
References av_log(), AV_LOG_DEBUG, AVRational::den, ff_gcd(), AVRational::num, and AVCodecContext::time_base.
Referenced by ff_xvid_encode_init().

| int xvid_ff_2pass | ( | void * | ref, | |
| int | cmd, | |||
| void * | p1, | |||
| void * | p2 | |||
| ) |
Dispatch function for our custom plugin. This handles the dispatch for the XviD plugin. It passes data on to other functions for actual processing.
| ref | Context pointer for the plugin | |
| cmd | The task given for us to complete | |
| p1 | First parameter (varies) | |
| p2 | Second parameter (varies) |
Definition at line 740 of file xvidff.c.
References xvid_ff_2pass_after(), xvid_ff_2pass_before(), xvid_ff_2pass_create(), and xvid_ff_2pass_destroy().
Referenced by ff_xvid_encode_init().

| static int xvid_ff_2pass_after | ( | xvid_context_t * | ref, | |
| xvid_plg_data_t * | param | |||
| ) | [static] |
Captures statistic data and writes it during first pass.
| ref | Context pointer for the plugin | |
| param | Statistic data |
Definition at line 704 of file xvidff.c.
References BUFFER_CAT, BUFFER_REMAINING, NULL, and xvid_context::twopassbuffer.
Referenced by xvid_ff_2pass().
| static int xvid_ff_2pass_before | ( | xvid_context_t * | ref, | |
| xvid_plg_data_t * | param | |||
| ) | [static] |
Enables fast encode mode during the first pass.
| ref | Context pointer for the plugin | |
| param | Frame data |
Definition at line 661 of file xvidff.c.
Referenced by xvid_ff_2pass().
| static int xvid_ff_2pass_create | ( | xvid_plg_create_t * | param, | |
| void ** | handle | |||
| ) | [static] |
Initializes the two-pass plugin and context.
| param | Input construction parameter structure | |
| handle | Private context handle |
Definition at line 614 of file xvidff.c.
References BUFFER_CAT, BUFFER_REMAINING, xvid_ff_pass1::context, NULL, and xvid_context::twopassbuffer.
Referenced by xvid_ff_2pass().
| static int xvid_ff_2pass_destroy | ( | xvid_context_t * | ref, | |
| xvid_plg_destroy_t * | param | |||
| ) | [static] |
Destroys the two-pass plugin context.
| ref | Context pointer for the plugin | |
| param | Destrooy context |
Definition at line 645 of file xvidff.c.
References NULL, and xvid_context::twopassbuffer.
Referenced by xvid_ff_2pass().
| int xvid_strip_vol_header | ( | AVCodecContext * | avctx, | |
| unsigned char * | frame, | |||
| unsigned int | header_len, | |||
| unsigned int | frame_len | |||
| ) |
Routine to create a global VO/VOL header for MP4 container. What we do here is extract the header from the XviD bitstream as it is encoded. We also strip the repeated headers from the bitstream when a global header is requested for MPEG-4 ISO compliance.
| avctx | AVCodecContext pointer to context | |
| frame | Pointer to encoded frame data | |
| header_len | Length of header to search | |
| frame_len | Length of encoded frame data |
Definition at line 508 of file xvidff.c.
References av_malloc(), AVCodecContext::extradata, AVCodecContext::extradata_size, memcpy, and NULL.
Referenced by ff_xvid_encode_frame().

Initial value:
{
"xvid",
CODEC_TYPE_VIDEO,
CODEC_ID_XVID,
sizeof(xvid_context_t),
ff_xvid_encode_init,
ff_xvid_encode_frame,
ff_xvid_encode_close
}
Definition at line 766 of file xvidff.c.
Referenced by avcodec_register_all().
1.5.5