#include <xvid.h>
#include <unistd.h>
#include "avcodec.h"
#include "internal.h"
#include "libavutil/file.h"
#include "libavutil/cpu.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libxvid.h"
#include "mpegvideo.h"
Go to the source code of this file.
Data Structures | |
struct | xvid_context |
Structure for the private Xvid context. More... | |
struct | xvid_ff_pass1 |
Structure for the private first-pass plugin. More... | |
Defines | |
#define | BUFFER_SIZE 1024 |
Buffer management macros. | |
#define | BUFFER_REMAINING(x) (BUFFER_SIZE - strlen(x)) |
#define | BUFFER_CAT(x) (&((x)[strlen(x)])) |
Functions | |
static int | xvid_ff_2pass_create (xvid_plg_create_t *param, void **handle) |
Initialize the two-pass plugin and context. | |
static int | xvid_ff_2pass_destroy (struct xvid_context *ref, xvid_plg_destroy_t *param) |
Destroy the two-pass plugin context. | |
static int | xvid_ff_2pass_before (struct xvid_context *ref, xvid_plg_data_t *param) |
Enable fast encode mode during the first pass. | |
static int | xvid_ff_2pass_after (struct xvid_context *ref, xvid_plg_data_t *param) |
Capture statistic data and write it during first pass. | |
static int | xvid_ff_2pass (void *ref, int cmd, void *p1, void *p2) |
Dispatch function for our custom plugin. | |
static int | xvid_strip_vol_header (AVCodecContext *avctx, AVPacket *pkt, unsigned int header_len, unsigned int frame_len) |
Routine to create a global VO/VOL header for MP4 container. | |
static void | xvid_correct_framerate (AVCodecContext *avctx) |
Routine to correct a possibly erroneous framerate being fed to us. | |
static av_cold int | xvid_encode_init (AVCodecContext *avctx) |
Create the private context for the encoder. | |
static int | xvid_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *picture, int *got_packet) |
Encode a single frame. | |
static av_cold int | xvid_encode_close (AVCodecContext *avctx) |
Destroy the private context for the encoder. | |
Variables | |
AVCodec | ff_libxvid_encoder |
Xvid codec definition for libavcodec. |
Definition in file libxvid.c.
#define BUFFER_CAT | ( | x | ) | (&((x)[strlen(x)])) |
Definition at line 44 of file libxvid.c.
Referenced by xvid_ff_2pass_after(), and xvid_ff_2pass_create().
#define BUFFER_REMAINING | ( | x | ) | (BUFFER_SIZE - strlen(x)) |
Definition at line 43 of file libxvid.c.
Referenced by xvid_ff_2pass_after(), and xvid_ff_2pass_create().
static void xvid_correct_framerate | ( | AVCodecContext * | avctx | ) | [static] |
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 295 of file libxvid.c.
Referenced by xvid_encode_init().
static av_cold int xvid_encode_close | ( | AVCodecContext * | avctx | ) | [static] |
Destroy the private context for the encoder.
All buffers are freed, and the Xvid encoder context is destroyed.
avctx | AVCodecContext pointer to context |
static int xvid_encode_frame | ( | AVCodecContext * | avctx, | |
AVPacket * | pkt, | |||
const AVFrame * | picture, | |||
int * | got_packet | |||
) | [static] |
Encode 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 |
static av_cold int xvid_encode_init | ( | AVCodecContext * | avctx | ) | [static] |
Create 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 |
static int xvid_ff_2pass | ( | void * | ref, | |
int | cmd, | |||
void * | p1, | |||
void * | p2 | |||
) | [static] |
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 218 of file libxvid.c.
Referenced by xvid_encode_init().
static int xvid_ff_2pass_after | ( | struct xvid_context * | ref, | |
xvid_plg_data_t * | param | |||
) | [static] |
Capture statistic data and write it during first pass.
ref | Context pointer for the plugin | |
param | Statistic data |
Definition at line 182 of file libxvid.c.
Referenced by xvid_ff_2pass().
static int xvid_ff_2pass_before | ( | struct xvid_context * | ref, | |
xvid_plg_data_t * | param | |||
) | [static] |
Enable fast encode mode during the first pass.
Definition at line 139 of file libxvid.c.
Referenced by xvid_ff_2pass().
static int xvid_ff_2pass_create | ( | xvid_plg_create_t * | param, | |
void ** | handle | |||
) | [static] |
Initialize the two-pass plugin and context.
param | Input construction parameter structure | |
handle | Private context handle |
Definition at line 92 of file libxvid.c.
Referenced by xvid_ff_2pass().
static int xvid_ff_2pass_destroy | ( | struct xvid_context * | ref, | |
xvid_plg_destroy_t * | param | |||
) | [static] |
Destroy the two-pass plugin context.
ref | Context pointer for the plugin | |
param | Destrooy context |
Definition at line 123 of file libxvid.c.
Referenced by xvid_ff_2pass().
static int xvid_strip_vol_header | ( | AVCodecContext * | avctx, | |
AVPacket * | pkt, | |||
unsigned int | header_len, | |||
unsigned int | frame_len | |||
) | [static] |
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 255 of file libxvid.c.
Referenced by xvid_encode_frame().
Initial value:
{ .name = "libxvid", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_MPEG4, .priv_data_size = sizeof(struct xvid_context), .init = xvid_encode_init, .encode2 = xvid_encode_frame, .close = xvid_encode_close, .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV420P, PIX_FMT_NONE }, .long_name = NULL_IF_CONFIG_SMALL("libxvidcore MPEG-4 part 2"), }