47 *filename = tempnam(
".", prefix);
49 size_t len = strlen(prefix) + 12;
58 fd =
avpriv_open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444);
60 snprintf(*filename, len,
"/tmp/%sXXXXXX", prefix);
61 fd = mkstemp(*filename);
63 snprintf(*filename, len,
"./%sXXXXXX", prefix);
64 fd = mkstemp(*filename);
79 xvid_plg_create_t xvid_plg_create = { 0 };
80 xvid_plugin_2pass2_t xvid_2pass2 = { 0 };
89 static const char frame_types[] =
" ipbs";
95 snprintf(tmp,
sizeof(tmp),
"%c %d %d %d %d %d %d\n",
103 write(fd, tmp, strlen(tmp));
108 xvid_2pass2.version = XVID_MAKE_VERSION(1, 1, 0);
109 xvid_2pass2.filename = tmp_name;
115 xvid_plg_create.version = XVID_MAKE_VERSION(1, 1, 0);
118 xvid_plg_create.param = &xvid_2pass2;
120 if (xvid_plugin_2pass2(
NULL, XVID_PLG_CREATE, &xvid_plg_create,
130 xvid_plg_data_t xvid_plg_data = { 0 };
132 xvid_plg_data.version = XVID_MAKE_VERSION(1, 1, 0);
133 xvid_plg_data.width = s->
width;
134 xvid_plg_data.height = s->
height;
135 xvid_plg_data.mb_width = s->
mb_width;
139 xvid_plg_data.min_quant[0] = s->
avctx->
qmin;
140 xvid_plg_data.min_quant[1] = s->
avctx->
qmin;
141 xvid_plg_data.min_quant[2] = s->
avctx->
qmin;
142 xvid_plg_data.max_quant[0] = s->
avctx->
qmax;
143 xvid_plg_data.max_quant[1] = s->
avctx->
qmax;
144 xvid_plg_data.max_quant[2] = s->
avctx->
qmax;
145 xvid_plg_data.bquant_offset = 0;
146 xvid_plg_data.bquant_ratio = 100;
150 xvid_plg_data.length =
151 xvid_plg_data.stats.length = (s->
frame_bits + 7) / 8;
153 xvid_plg_data.quant = s->
qscale;
156 XVID_PLG_AFTER, &xvid_plg_data,
NULL)) {
158 "xvid_plugin_2pass2(handle, XVID_PLG_AFTER, ...) FAILED\n");
164 xvid_plg_data.quant = 0;
166 XVID_PLG_BEFORE, &xvid_plg_data,
NULL)) {
168 "xvid_plugin_2pass2(handle, XVID_PLG_BEFORE, ...) FAILED\n");
187 xvid_plg_destroy_t xvid_plg_destroy;
190 &xvid_plg_destroy,
NULL);
int frame_bits
bits used for the current frame
RateControlContext rc_context
contains stuff only accessed in ratecontrol.c
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int mb_num
number of MBs of a picture
Macro definitions for various function/variable attributes.
common functions for use with the Xvid wrappers
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
int mb_height
number of MBs horizontally & vertically
int num_entries
number of RateControlEntries
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int qmax
maximum quantizer
int rc_max_rate
maximum bitrate
av_cold void ff_xvid_rate_control_uninit(MpegEncContext *s)
int rc_buffer_size
decoder bitstream buffer size
float dry_run_qscale
for xvid rc
common internal API header
int bit_rate
the average bitrate
static av_always_inline av_const long int lrintf(float x)
Libavcodec external API header.
int qmin
minimum quantizer
int height
picture size. must be a multiple of 16
int last_picture_number
for xvid rc
float b_quant_offset
qscale offset between IP and B-frames
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
struct AVCodecContext * avctx
void * non_lavc_opaque
context for non lavc rc code (for example xvid)
av_cold int ff_xvid_rate_control_init(MpegEncContext *s)
int ff_tempfile(const char *prefix, char **filename)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
float ff_xvid_rate_estimate_qscale(MpegEncContext *s, int dry_run)