2002-04-10 23:23:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
|
|
|
|
#ifdef USE_LIBAVCODEC
|
|
|
|
|
|
|
|
#include "../mp_msg.h"
|
|
|
|
#include "../help_mp.h"
|
|
|
|
|
|
|
|
#include "codec-cfg.h"
|
|
|
|
#include "stream.h"
|
|
|
|
#include "demuxer.h"
|
|
|
|
#include "stheader.h"
|
|
|
|
|
|
|
|
#include "aviwrite.h"
|
|
|
|
|
2002-04-13 19:14:34 +00:00
|
|
|
#include "img_format.h"
|
|
|
|
#include "mp_image.h"
|
2002-04-10 23:23:36 +00:00
|
|
|
#include "vf.h"
|
|
|
|
|
2002-07-08 21:34:24 +00:00
|
|
|
#ifdef HAVE_DIVX4ENCORE
|
2002-04-10 23:23:36 +00:00
|
|
|
#include "divx4_vbr.h"
|
2002-07-08 21:34:24 +00:00
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2002-08-25 23:19:38 +00:00
|
|
|
extern char* passtmpfile;
|
2002-04-10 23:23:36 +00:00
|
|
|
extern int pass;
|
2002-08-28 22:45:48 +00:00
|
|
|
extern void mencoder_write_chunk(aviwrite_stream_t *s,int len,unsigned int flags);
|
2002-04-10 23:23:36 +00:00
|
|
|
|
|
|
|
//===========================================================================//
|
|
|
|
|
|
|
|
#ifdef USE_LIBAVCODEC_SO
|
2002-08-14 21:43:49 +00:00
|
|
|
#include <ffmpeg/avcodec.h>
|
2002-04-10 23:23:36 +00:00
|
|
|
#else
|
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
#endif
|
|
|
|
|
2002-04-21 21:38:53 +00:00
|
|
|
#if LIBAVCODEC_BUILD < 4601
|
|
|
|
#error your version of libavcodec is too old, get a newer one, and dont send a bugreport, THIS IS NO BUG
|
|
|
|
#endif
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
#if LIBAVCODEC_BUILD < 4624
|
2002-08-25 21:43:22 +00:00
|
|
|
#warning your version of libavcodec is old, u might want to get a newer one
|
|
|
|
#endif
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
extern int avcodec_inited;
|
|
|
|
|
|
|
|
/* video options */
|
2002-09-29 17:53:14 +00:00
|
|
|
static char *lavc_param_vcodec = "mpeg4";
|
2002-04-10 23:23:36 +00:00
|
|
|
static int lavc_param_vbitrate = -1;
|
2002-08-25 21:43:22 +00:00
|
|
|
static int lavc_param_vrate_tolerance = 1000*8;
|
2002-04-10 23:23:36 +00:00
|
|
|
static int lavc_param_vhq = 0; /* default is realtime encoding */
|
|
|
|
static int lavc_param_v4mv = 0;
|
2002-04-11 02:54:42 +00:00
|
|
|
static int lavc_param_vme = 4;
|
2002-04-10 23:23:36 +00:00
|
|
|
static int lavc_param_vqscale = 0;
|
2002-08-25 21:43:22 +00:00
|
|
|
static int lavc_param_vqmin = 2;
|
|
|
|
static int lavc_param_vqmax = 31;
|
2002-04-10 23:23:36 +00:00
|
|
|
static int lavc_param_vqdiff = 3;
|
|
|
|
static float lavc_param_vqcompress = 0.5;
|
|
|
|
static float lavc_param_vqblur = 0.5;
|
2002-08-25 21:43:22 +00:00
|
|
|
static float lavc_param_vb_qfactor = 1.25;
|
|
|
|
static float lavc_param_vb_qoffset = 1.25;
|
|
|
|
static float lavc_param_vi_qfactor = 0.8;
|
|
|
|
static float lavc_param_vi_qoffset = 0.0;
|
2002-04-17 13:30:05 +00:00
|
|
|
static int lavc_param_vmax_b_frames = 0;
|
2002-04-10 23:23:36 +00:00
|
|
|
static int lavc_param_keyint = -1;
|
2002-04-21 21:38:53 +00:00
|
|
|
static int lavc_param_vpass = 0;
|
|
|
|
static int lavc_param_vrc_strategy = 2;
|
|
|
|
static int lavc_param_vb_strategy = 0;
|
2002-06-01 02:11:24 +00:00
|
|
|
static int lavc_param_luma_elim_threshold = 0;
|
|
|
|
static int lavc_param_chroma_elim_threshold = 0;
|
2002-05-29 21:34:29 +00:00
|
|
|
static int lavc_param_packet_size= 0;
|
|
|
|
static int lavc_param_strict= 0;
|
|
|
|
static int lavc_param_data_partitioning= 0;
|
2002-06-18 01:39:26 +00:00
|
|
|
static int lavc_param_gray=0;
|
2002-08-25 21:43:22 +00:00
|
|
|
static float lavc_param_rc_qsquish=1.0;
|
|
|
|
static float lavc_param_rc_qmod_amp=0;
|
|
|
|
static int lavc_param_rc_qmod_freq=0;
|
|
|
|
static char *lavc_param_rc_override_string=NULL;
|
|
|
|
static char *lavc_param_rc_eq="tex^qComp";
|
|
|
|
static int lavc_param_rc_buffer_size=0;
|
|
|
|
static float lavc_param_rc_buffer_aggressivity=1.0;
|
|
|
|
static int lavc_param_rc_max_rate=0;
|
|
|
|
static int lavc_param_rc_min_rate=0;
|
|
|
|
static float lavc_param_rc_initial_cplx=0;
|
2002-08-07 00:08:57 +00:00
|
|
|
static int lavc_param_mpeg_quant=0;
|
2002-08-30 00:38:42 +00:00
|
|
|
static int lavc_param_fdct=0;
|
2002-09-29 23:21:57 +00:00
|
|
|
static int lavc_param_idct=0;
|
2002-09-13 20:46:23 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4623
|
|
|
|
static float lavc_param_aspect=0.0;
|
|
|
|
#endif
|
2002-09-23 15:46:16 +00:00
|
|
|
static float lavc_param_lumi_masking= 0.0;
|
2002-09-24 11:23:23 +00:00
|
|
|
static float lavc_param_dark_masking= 0.0;
|
2002-09-23 15:46:16 +00:00
|
|
|
static float lavc_param_temporal_cplx_masking= 0.0;
|
|
|
|
static float lavc_param_spatial_cplx_masking= 0.0;
|
|
|
|
static float lavc_param_p_masking= 0.0;
|
|
|
|
static int lavc_param_normalize_aqp= 0;
|
2002-09-26 00:48:25 +00:00
|
|
|
static int lavc_param_interlaced_dct= 0;
|
2002-04-10 23:23:36 +00:00
|
|
|
|
|
|
|
#include "cfgparser.h"
|
|
|
|
|
|
|
|
#ifdef USE_LIBAVCODEC
|
|
|
|
struct config lavcopts_conf[]={
|
|
|
|
{"vcodec", &lavc_param_vcodec, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
|
|
|
{"vbitrate", &lavc_param_vbitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
|
|
|
|
{"vratetol", &lavc_param_vrate_tolerance, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
|
|
|
|
{"vhq", &lavc_param_vhq, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
|
|
{"v4mv", &lavc_param_v4mv, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
|
|
{"vme", &lavc_param_vme, CONF_TYPE_INT, CONF_RANGE, 0, 5, NULL},
|
|
|
|
{"vqscale", &lavc_param_vqscale, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
|
|
|
|
{"vqmin", &lavc_param_vqmin, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
|
|
|
|
{"vqmax", &lavc_param_vqmax, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
|
|
|
|
{"vqdiff", &lavc_param_vqdiff, CONF_TYPE_INT, CONF_RANGE, 1, 31, NULL},
|
|
|
|
{"vqcomp", &lavc_param_vqcompress, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
|
|
|
|
{"vqblur", &lavc_param_vqblur, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL},
|
2002-08-25 21:43:22 +00:00
|
|
|
{"vb_qfactor", &lavc_param_vb_qfactor, CONF_TYPE_FLOAT, CONF_RANGE, -31.0, 31.0, NULL},
|
2002-04-17 13:30:05 +00:00
|
|
|
{"vmax_b_frames", &lavc_param_vmax_b_frames, CONF_TYPE_INT, CONF_RANGE, 0, FF_MAX_B_FRAMES, NULL},
|
2002-04-21 21:38:53 +00:00
|
|
|
{"vpass", &lavc_param_vpass, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
|
2002-08-25 21:43:22 +00:00
|
|
|
#if LIBAVCODEC_BUILD < 4620
|
2002-04-21 21:38:53 +00:00
|
|
|
{"vrc_strategy", &lavc_param_vrc_strategy, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
2002-04-21 21:38:53 +00:00
|
|
|
{"vb_strategy", &lavc_param_vb_strategy, CONF_TYPE_INT, CONF_RANGE, 0, 1, NULL},
|
2002-05-29 21:34:29 +00:00
|
|
|
#ifdef CODEC_FLAG_PART
|
|
|
|
{"vb_qoffset", &lavc_param_vb_qoffset, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 31.0, NULL},
|
2002-08-18 01:07:37 +00:00
|
|
|
{"vlelim", &lavc_param_luma_elim_threshold, CONF_TYPE_INT, CONF_RANGE, -99, 99, NULL},
|
2002-08-17 20:48:23 +00:00
|
|
|
{"vcelim", &lavc_param_chroma_elim_threshold, CONF_TYPE_INT, CONF_RANGE, -99, 99, NULL},
|
2002-05-29 21:34:29 +00:00
|
|
|
{"vpsize", &lavc_param_packet_size, CONF_TYPE_INT, CONF_RANGE, 0, 100000000, NULL},
|
|
|
|
{"vstrict", &lavc_param_strict, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
|
|
|
{"vdpart", &lavc_param_data_partitioning, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL},
|
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
{"keyint", &lavc_param_keyint, CONF_TYPE_INT, 0, 0, 0, NULL},
|
2002-06-18 01:39:26 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4614
|
|
|
|
{"gray", &lavc_param_gray, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG_PART, NULL},
|
2002-08-07 00:08:57 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4619
|
|
|
|
{"mpeg_quant", &lavc_param_mpeg_quant, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
|
|
|
{"vi_qfactor", &lavc_param_vi_qfactor, CONF_TYPE_FLOAT, CONF_RANGE, -31.0, 31.0, NULL},
|
|
|
|
{"vi_qoffset", &lavc_param_vi_qoffset, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 31.0, NULL},
|
|
|
|
{"vqsquish", &lavc_param_rc_qsquish, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 99.0, NULL},
|
|
|
|
{"vqmod_amp", &lavc_param_rc_qmod_amp, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 99.0, NULL},
|
|
|
|
{"vqmod_freq", &lavc_param_rc_qmod_freq, CONF_TYPE_INT, 0, 0, 0, NULL},
|
|
|
|
{"vrc_eq", &lavc_param_rc_eq, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
|
|
|
{"vrc_override", &lavc_param_rc_override_string, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
|
|
|
{"vrc_maxrate", &lavc_param_rc_max_rate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
|
|
|
|
{"vrc_minrate", &lavc_param_rc_min_rate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
|
|
|
|
{"vrc_buf_size", &lavc_param_rc_min_rate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
|
|
|
|
{"vrc_buf_aggressivity", &lavc_param_rc_buffer_aggressivity, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 99.0, NULL},
|
|
|
|
{"vrc_init_cplx", &lavc_param_rc_initial_cplx, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 9999999.0, NULL},
|
2002-08-30 00:38:42 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4621
|
|
|
|
{"vfdct", &lavc_param_fdct, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
|
2002-09-13 20:46:23 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4623
|
|
|
|
{"aspect", &lavc_param_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, NULL},
|
2002-09-23 15:46:16 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4625
|
|
|
|
{"lumi_mask", &lavc_param_lumi_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
|
|
|
{"tcplx_mask", &lavc_param_temporal_cplx_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
|
|
|
{"scplx_mask", &lavc_param_spatial_cplx_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
|
|
|
{"p_mask", &lavc_param_p_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
|
|
|
{"naq", &lavc_param_normalize_aqp, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
2002-09-24 11:23:23 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4626
|
|
|
|
{"dark_mask", &lavc_param_dark_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
2002-09-26 00:48:25 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4627
|
|
|
|
{"ildct", &lavc_param_interlaced_dct, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
2002-09-29 23:21:57 +00:00
|
|
|
#endif
|
|
|
|
#if LIBAVCODEC_BUILD >= 4629
|
|
|
|
{"idct", &lavc_param_idct, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL},
|
2002-06-18 01:39:26 +00:00
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
{NULL, NULL, 0, 0, 0, 0, NULL}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct vf_priv_s {
|
|
|
|
aviwrite_stream_t* mux;
|
2002-09-19 09:47:37 +00:00
|
|
|
AVCodecContext *context;
|
2002-04-10 23:23:36 +00:00
|
|
|
AVCodec *codec;
|
2002-08-25 21:43:22 +00:00
|
|
|
FILE *stats_file;
|
2002-04-10 23:23:36 +00:00
|
|
|
};
|
|
|
|
|
2002-08-25 21:43:22 +00:00
|
|
|
#define stats_file (vf->priv->stats_file)
|
2002-04-10 23:23:36 +00:00
|
|
|
#define mux_v (vf->priv->mux)
|
|
|
|
#define lavc_venc_context (vf->priv->context)
|
|
|
|
|
|
|
|
static int config(struct vf_instance_s* vf,
|
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt){
|
2002-08-25 21:43:22 +00:00
|
|
|
int size, i;
|
|
|
|
void *p;
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
mux_v->bih->biWidth=width;
|
|
|
|
mux_v->bih->biHeight=height;
|
|
|
|
mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
|
|
|
|
|
|
|
|
printf("videocodec: libavcodec (%dx%d fourcc=%x [%.4s])\n",
|
|
|
|
mux_v->bih->biWidth, mux_v->bih->biHeight, mux_v->bih->biCompression,
|
|
|
|
(char *)&mux_v->bih->biCompression);
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->width = width;
|
|
|
|
lavc_venc_context->height = height;
|
2002-04-18 15:23:34 +00:00
|
|
|
if (lavc_param_vbitrate > 16000) /* != -1 */
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->bit_rate = lavc_param_vbitrate;
|
2002-04-18 15:23:34 +00:00
|
|
|
else if (lavc_param_vbitrate >= 0) /* != -1 */
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->bit_rate = lavc_param_vbitrate*1000;
|
2002-04-10 23:23:36 +00:00
|
|
|
else
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->bit_rate = 800000; /* default */
|
|
|
|
lavc_venc_context->bit_rate_tolerance= lavc_param_vrate_tolerance*1000;
|
|
|
|
lavc_venc_context->frame_rate = (float)mux_v->h.dwRate/mux_v->h.dwScale * FRAME_RATE_BASE;
|
|
|
|
lavc_venc_context->qmin= lavc_param_vqmin;
|
|
|
|
lavc_venc_context->qmax= lavc_param_vqmax;
|
|
|
|
lavc_venc_context->max_qdiff= lavc_param_vqdiff;
|
|
|
|
lavc_venc_context->qcompress= lavc_param_vqcompress;
|
|
|
|
lavc_venc_context->qblur= lavc_param_vqblur;
|
|
|
|
lavc_venc_context->max_b_frames= lavc_param_vmax_b_frames;
|
|
|
|
lavc_venc_context->b_quant_factor= lavc_param_vb_qfactor;
|
|
|
|
lavc_venc_context->rc_strategy= lavc_param_vrc_strategy;
|
|
|
|
lavc_venc_context->b_frame_strategy= lavc_param_vb_strategy;
|
2002-05-29 21:34:29 +00:00
|
|
|
#ifdef CODEC_FLAG_PART
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->b_quant_offset= lavc_param_vb_qoffset;
|
|
|
|
lavc_venc_context->luma_elim_threshold= lavc_param_luma_elim_threshold;
|
|
|
|
lavc_venc_context->chroma_elim_threshold= lavc_param_chroma_elim_threshold;
|
|
|
|
lavc_venc_context->rtp_payload_size= lavc_param_packet_size;
|
|
|
|
if(lavc_param_packet_size )lavc_venc_context->rtp_mode=1;
|
|
|
|
lavc_venc_context->strict_std_compliance= lavc_param_strict;
|
2002-05-29 21:34:29 +00:00
|
|
|
#endif
|
2002-08-25 21:43:22 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->i_quant_factor= lavc_param_vi_qfactor;
|
|
|
|
lavc_venc_context->i_quant_offset= lavc_param_vi_qoffset;
|
|
|
|
lavc_venc_context->rc_qsquish= lavc_param_rc_qsquish;
|
|
|
|
lavc_venc_context->rc_qmod_amp= lavc_param_rc_qmod_amp;
|
|
|
|
lavc_venc_context->rc_qmod_freq= lavc_param_rc_qmod_freq;
|
|
|
|
lavc_venc_context->rc_eq= lavc_param_rc_eq;
|
|
|
|
lavc_venc_context->rc_max_rate= lavc_param_rc_max_rate*1000;
|
|
|
|
lavc_venc_context->rc_min_rate= lavc_param_rc_min_rate*1000;
|
|
|
|
lavc_venc_context->rc_buffer_size= lavc_param_rc_buffer_size*1000;
|
|
|
|
lavc_venc_context->rc_buffer_aggressivity= lavc_param_rc_buffer_aggressivity;
|
|
|
|
lavc_venc_context->rc_initial_cplx= lavc_param_rc_initial_cplx;
|
2002-08-30 00:38:42 +00:00
|
|
|
|
2002-08-25 21:43:22 +00:00
|
|
|
p= lavc_param_rc_override_string;
|
|
|
|
for(i=0; p; i++){
|
|
|
|
int start, end, q;
|
|
|
|
int e=sscanf(p, "%d,%d,%d", &start, &end, &q);
|
|
|
|
if(e!=3){
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"error parsing vrc_q\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->rc_override=
|
|
|
|
realloc(lavc_venc_context->rc_override, sizeof(RcOverride)*(i+1));
|
|
|
|
lavc_venc_context->rc_override[i].start_frame= start;
|
|
|
|
lavc_venc_context->rc_override[i].end_frame = end;
|
2002-08-25 21:43:22 +00:00
|
|
|
if(q>0){
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->rc_override[i].qscale= q;
|
|
|
|
lavc_venc_context->rc_override[i].quality_factor= 1.0;
|
2002-08-25 21:43:22 +00:00
|
|
|
}
|
|
|
|
else{
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->rc_override[i].qscale= 0;
|
|
|
|
lavc_venc_context->rc_override[i].quality_factor= -q/100.0;
|
2002-08-25 21:43:22 +00:00
|
|
|
}
|
|
|
|
p= strchr(p, '/');
|
|
|
|
if(p) p++;
|
|
|
|
}
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->rc_override_count=i;
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
|
|
|
|
2002-08-07 00:08:57 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4619
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->mpeg_quant=lavc_param_mpeg_quant;
|
2002-08-07 00:08:57 +00:00
|
|
|
#endif
|
2002-08-30 00:38:42 +00:00
|
|
|
|
|
|
|
#if LIBAVCODEC_BUILD >= 4621
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->dct_algo= lavc_param_fdct;
|
2002-08-30 00:38:42 +00:00
|
|
|
#endif
|
2002-09-29 23:21:57 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4629
|
|
|
|
lavc_venc_context->idct_algo= lavc_param_idct;
|
|
|
|
#endif
|
2002-08-30 00:38:42 +00:00
|
|
|
|
2002-09-23 15:46:16 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4625
|
|
|
|
lavc_venc_context->lumi_masking= lavc_param_lumi_masking;
|
|
|
|
lavc_venc_context->temporal_cplx_masking= lavc_param_temporal_cplx_masking;
|
|
|
|
lavc_venc_context->spatial_cplx_masking= lavc_param_spatial_cplx_masking;
|
|
|
|
lavc_venc_context->p_masking= lavc_param_p_masking;
|
|
|
|
#endif
|
2002-09-24 11:23:23 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4626
|
|
|
|
lavc_venc_context->dark_masking= lavc_param_dark_masking;
|
|
|
|
#endif
|
2002-09-23 15:46:16 +00:00
|
|
|
|
2002-09-13 20:46:23 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4623
|
|
|
|
if (lavc_param_aspect != 0.0)
|
|
|
|
{
|
|
|
|
/* 625 means CIF */
|
|
|
|
if (lavc_param_aspect == (float)(4.0/3.0))
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->aspect_ratio_info = FF_ASPECT_4_3_625;
|
2002-09-13 20:46:23 +00:00
|
|
|
else if (lavc_param_aspect == (float)(16.0/9.0))
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->aspect_ratio_info = FF_ASPECT_16_9_625;
|
2002-09-13 20:46:23 +00:00
|
|
|
else if (lavc_param_aspect == (float)(221.0/100.0))
|
|
|
|
{
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->aspect_ratio_info = FF_ASPECT_EXTENDED;
|
|
|
|
lavc_venc_context->aspected_width = 221;
|
|
|
|
lavc_venc_context->aspected_height = 100;
|
2002-09-13 20:46:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Unsupported aspect ratio (%f)\n", lavc_param_aspect);
|
|
|
|
}
|
2002-09-19 09:47:37 +00:00
|
|
|
mp_dbg(MSGT_MENCODER, MSGL_DBG2, "aspect_ratio_info: %d\n", lavc_venc_context->aspect_ratio_info);
|
|
|
|
mp_dbg(MSGT_MENCODER, MSGL_DBG2, "par_width: %d\n", lavc_venc_context->aspected_width);
|
|
|
|
mp_dbg(MSGT_MENCODER, MSGL_DBG2, "par_height: %d\n", lavc_venc_context->aspected_height);
|
2002-09-13 20:46:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
/* keyframe interval */
|
|
|
|
if (lavc_param_keyint >= 0) /* != -1 */
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->gop_size = lavc_param_keyint;
|
2002-04-10 23:23:36 +00:00
|
|
|
else
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->gop_size = 250; /* default */
|
2002-04-10 23:23:36 +00:00
|
|
|
|
|
|
|
if (lavc_param_vhq)
|
|
|
|
{
|
|
|
|
printf("High quality encoding selected (non real time)!\n");
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags = CODEC_FLAG_HQ;
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
else
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags = 0;
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2002-04-22 02:00:23 +00:00
|
|
|
/* 4mv is currently buggy with B frames */
|
|
|
|
if (lavc_param_vmax_b_frames > 0 && lavc_param_v4mv) {
|
|
|
|
printf("4MV with B-Frames not yet supported -> 4MV disabled\n");
|
|
|
|
lavc_param_v4mv = 0;
|
|
|
|
}
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|= lavc_param_v4mv ? CODEC_FLAG_4MV : 0;
|
2002-05-29 21:34:29 +00:00
|
|
|
#ifdef CODEC_FLAG_PART
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|= lavc_param_data_partitioning;
|
2002-05-29 21:34:29 +00:00
|
|
|
#endif
|
2002-06-18 01:39:26 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4614
|
2002-09-19 09:47:37 +00:00
|
|
|
if(lavc_param_gray) lavc_venc_context->flags|= CODEC_FLAG_GRAY;
|
2002-06-18 01:39:26 +00:00
|
|
|
#endif
|
|
|
|
|
2002-09-23 15:46:16 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4625
|
|
|
|
if(lavc_param_normalize_aqp) lavc_venc_context->flags|= CODEC_FLAG_NORMALIZE_AQP;
|
|
|
|
#endif
|
2002-09-26 00:48:25 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4627
|
|
|
|
if(lavc_param_interlaced_dct) lavc_venc_context->flags|= CODEC_FLAG_INTERLACED_DCT;
|
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2002-04-21 21:38:53 +00:00
|
|
|
/* lavc internal 2pass bitrate control */
|
2002-07-08 21:34:24 +00:00
|
|
|
#ifdef HAVE_DIVX4ENCORE
|
|
|
|
switch(lavc_param_vpass){
|
|
|
|
#else
|
|
|
|
switch(lavc_param_vpass?lavc_param_vpass:pass){
|
|
|
|
#endif
|
2002-08-25 21:43:22 +00:00
|
|
|
case 1:
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|= CODEC_FLAG_PASS1;
|
2002-08-25 21:52:31 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
2002-08-25 21:43:22 +00:00
|
|
|
stats_file= fopen(passtmpfile, "w");
|
|
|
|
if(stats_file==NULL){
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
|
|
|
|
return 0;
|
|
|
|
}
|
2002-08-25 21:52:31 +00:00
|
|
|
#endif
|
2002-08-25 21:43:22 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|= CODEC_FLAG_PASS2;
|
2002-08-25 21:52:31 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
2002-08-25 21:43:22 +00:00
|
|
|
stats_file= fopen(passtmpfile, "r");
|
|
|
|
if(stats_file==NULL){
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fseek(stats_file, 0, SEEK_END);
|
|
|
|
size= ftell(stats_file);
|
|
|
|
fseek(stats_file, 0, SEEK_SET);
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->stats_in= malloc(size + 1);
|
|
|
|
lavc_venc_context->stats_in[size]=0;
|
2002-08-25 21:43:22 +00:00
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
if(fread(lavc_venc_context->stats_in, size, 1, stats_file)<1){
|
2002-08-25 21:43:22 +00:00
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: reading from filename=%s\n", passtmpfile);
|
|
|
|
return 0;
|
2002-08-25 21:52:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-08-25 21:43:22 +00:00
|
|
|
break;
|
2002-07-08 21:34:24 +00:00
|
|
|
}
|
2002-04-21 21:38:53 +00:00
|
|
|
|
2002-04-14 23:16:55 +00:00
|
|
|
#ifdef ME_ZERO
|
|
|
|
// workaround Juanjo's stupid incompatible change:
|
2002-04-10 23:23:36 +00:00
|
|
|
motion_estimation_method = lavc_param_vme;
|
2002-04-14 23:16:55 +00:00
|
|
|
#else
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->me_method = ME_ZERO+lavc_param_vme;
|
2002-04-14 23:16:55 +00:00
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
|
|
|
|
/* fixed qscale :p */
|
|
|
|
if (lavc_param_vqscale)
|
|
|
|
{
|
|
|
|
printf("Using constant qscale = %d (VBR)\n", lavc_param_vqscale);
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags |= CODEC_FLAG_QSCALE;
|
|
|
|
lavc_venc_context->quality = lavc_param_vqscale;
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
|
2002-07-08 21:34:24 +00:00
|
|
|
#ifdef HAVE_DIVX4ENCORE
|
2002-04-10 23:23:36 +00:00
|
|
|
switch(pass){
|
|
|
|
case 1:
|
|
|
|
if (VbrControl_init_2pass_vbr_analysis(passtmpfile, 5) == -1){
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
|
|
|
|
pass=0;
|
2002-04-22 02:00:23 +00:00
|
|
|
}
|
2002-04-10 23:23:36 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (VbrControl_init_2pass_vbr_encoding(passtmpfile,
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->bit_rate,
|
2002-04-10 23:23:36 +00:00
|
|
|
(float)mux_v->h.dwRate/mux_v->h.dwScale,
|
|
|
|
100, /* crispness */
|
|
|
|
5) == -1){
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"2pass failed: filename=%s\n", passtmpfile);
|
|
|
|
pass=0;
|
2002-04-15 13:39:48 +00:00
|
|
|
} else
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|=CODEC_FLAG_QSCALE|CODEC_FLAG_TYPE; // VBR
|
2002-04-10 23:23:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-07-08 21:34:24 +00:00
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
if (avcodec_open(lavc_venc_context, vf->priv->codec) != 0) {
|
2002-04-10 23:23:36 +00:00
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantOpenCodec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
if (lavc_venc_context->codec->encode == NULL) {
|
2002-04-10 23:23:36 +00:00
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,"avcodec init failed (ctx->codec->encode == NULL)!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-08-25 21:43:22 +00:00
|
|
|
|
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
|
|
|
/* free second pass buffer, its not needed anymore */
|
2002-09-19 09:47:37 +00:00
|
|
|
if(lavc_venc_context->stats_in) free(lavc_venc_context->stats_in);
|
|
|
|
lavc_venc_context->stats_in= NULL;
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int control(struct vf_instance_s* vf, int request, void* data){
|
|
|
|
|
|
|
|
return CONTROL_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|
|
|
switch(fmt){
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
case IMGFMT_I420:
|
2002-09-13 20:46:23 +00:00
|
|
|
return VFCAP_CSP_SUPPORTED | VFCAP_ACCEPT_STRIDE;
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-10 22:18:32 +00:00
|
|
|
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
2002-04-10 23:23:36 +00:00
|
|
|
int out_size;
|
|
|
|
AVPicture lavc_venc_picture;
|
|
|
|
|
|
|
|
lavc_venc_picture.data[0]=mpi->planes[0];
|
|
|
|
lavc_venc_picture.data[1]=mpi->planes[1];
|
|
|
|
lavc_venc_picture.data[2]=mpi->planes[2];
|
|
|
|
lavc_venc_picture.linesize[0]=mpi->stride[0];
|
|
|
|
lavc_venc_picture.linesize[1]=mpi->stride[1];
|
|
|
|
lavc_venc_picture.linesize[2]=mpi->stride[2];
|
|
|
|
|
2002-07-08 21:34:24 +00:00
|
|
|
#ifdef HAVE_DIVX4ENCORE
|
2002-04-10 23:23:36 +00:00
|
|
|
if(pass==2){ // handle 2-pass:
|
2002-09-19 09:47:37 +00:00
|
|
|
lavc_venc_context->flags|=CODEC_FLAG_QSCALE; // enable VBR
|
|
|
|
lavc_venc_context->quality=VbrControl_get_quant();
|
|
|
|
lavc_venc_context->key_frame=VbrControl_get_intra();
|
|
|
|
lavc_venc_context->gop_size=0x3fffffff;
|
|
|
|
out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
|
2002-04-10 23:23:36 +00:00
|
|
|
&lavc_venc_picture);
|
2002-09-19 09:47:37 +00:00
|
|
|
VbrControl_update_2pass_vbr_encoding(lavc_venc_context->mv_bits,
|
|
|
|
lavc_venc_context->i_tex_bits+lavc_venc_context->p_tex_bits,
|
2002-04-10 23:23:36 +00:00
|
|
|
8*out_size);
|
2002-07-08 21:34:24 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2002-09-19 09:47:37 +00:00
|
|
|
out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
|
2002-04-10 23:23:36 +00:00
|
|
|
&lavc_venc_picture);
|
2002-07-08 21:34:24 +00:00
|
|
|
#ifdef HAVE_DIVX4ENCORE
|
2002-04-10 23:23:36 +00:00
|
|
|
if(pass==1){
|
2002-09-19 09:47:37 +00:00
|
|
|
VbrControl_update_2pass_vbr_analysis(lavc_venc_context->key_frame,
|
|
|
|
lavc_venc_context->mv_bits,
|
|
|
|
lavc_venc_context->i_tex_bits+lavc_venc_context->p_tex_bits,
|
|
|
|
8*out_size, lavc_venc_context->quality);
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
2002-07-08 21:34:24 +00:00
|
|
|
#endif
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
mencoder_write_chunk(mux_v,out_size,lavc_venc_context->key_frame?0x10:0);
|
2002-08-25 21:43:22 +00:00
|
|
|
|
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
|
|
|
/* store stats if there are any */
|
2002-09-19 09:47:37 +00:00
|
|
|
if(lavc_venc_context->stats_out && stats_file)
|
|
|
|
fprintf(stats_file, "%s", lavc_venc_context->stats_out);
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
2002-09-10 22:18:32 +00:00
|
|
|
return 1;
|
2002-04-10 23:23:36 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 02:50:47 +00:00
|
|
|
static void uninit(struct vf_instance_s* vf){
|
2002-09-19 09:47:37 +00:00
|
|
|
avcodec_close(lavc_venc_context);
|
2002-08-25 21:43:22 +00:00
|
|
|
|
|
|
|
#if LIBAVCODEC_BUILD >= 4620
|
2002-08-25 21:52:31 +00:00
|
|
|
if(stats_file) fclose(stats_file);
|
|
|
|
|
2002-08-25 21:43:22 +00:00
|
|
|
/* free rc_override */
|
2002-09-19 09:47:37 +00:00
|
|
|
if(lavc_venc_context->rc_override) free(lavc_venc_context->rc_override);
|
|
|
|
lavc_venc_context->rc_override= NULL;
|
2002-08-25 21:43:22 +00:00
|
|
|
#endif
|
2002-09-19 09:47:37 +00:00
|
|
|
|
|
|
|
if(vf->priv->context) free(vf->priv->context);
|
|
|
|
vf->priv->context= NULL;
|
2002-04-11 02:50:47 +00:00
|
|
|
}
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
//===========================================================================//
|
|
|
|
|
|
|
|
static int vf_open(vf_instance_t *vf, char* args){
|
2002-04-11 02:50:47 +00:00
|
|
|
vf->uninit=uninit;
|
2002-04-10 23:23:36 +00:00
|
|
|
vf->config=config;
|
|
|
|
vf->control=control;
|
|
|
|
vf->query_format=query_format;
|
|
|
|
vf->put_image=put_image;
|
|
|
|
vf->priv=malloc(sizeof(struct vf_priv_s));
|
|
|
|
memset(vf->priv,0,sizeof(struct vf_priv_s));
|
2002-08-28 22:45:48 +00:00
|
|
|
vf->priv->mux=(aviwrite_stream_t*)args;
|
2002-04-10 23:23:36 +00:00
|
|
|
|
2002-05-05 00:31:40 +00:00
|
|
|
/* XXX: hack: some of the MJPEG decoder DLL's needs exported huffman
|
|
|
|
table, so we define a zero-table, also lavc mjpeg encoder is putting
|
|
|
|
huffman tables into the stream, so no problem */
|
|
|
|
if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "mjpeg"))
|
|
|
|
{
|
|
|
|
mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+28);
|
|
|
|
memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+28);
|
|
|
|
mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+28;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mux_v->bih=malloc(sizeof(BITMAPINFOHEADER));
|
|
|
|
memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER));
|
|
|
|
mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
|
|
|
|
}
|
2002-04-10 23:23:36 +00:00
|
|
|
mux_v->bih->biWidth=0;
|
|
|
|
mux_v->bih->biHeight=0;
|
|
|
|
mux_v->bih->biPlanes=1;
|
|
|
|
mux_v->bih->biBitCount=24;
|
|
|
|
if (!lavc_param_vcodec)
|
|
|
|
{
|
2002-05-05 00:31:40 +00:00
|
|
|
printf("No libavcodec codec specified! It's required!\n");
|
2002-04-10 23:23:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcasecmp(lavc_param_vcodec, "mpeg1") || !strcasecmp(lavc_param_vcodec, "mpeg1video"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('m', 'p', 'g', '1');
|
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "h263") || !strcasecmp(lavc_param_vcodec, "h263p"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('h', '2', '6', '3');
|
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "rv10"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('R', 'V', '1', '0');
|
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "mjpeg"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('M', 'J', 'P', 'G');
|
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "mpeg4"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('D', 'I', 'V', 'X');
|
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "msmpeg4"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('d', 'i', 'v', '3');
|
2002-05-04 18:18:10 +00:00
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "msmpeg4v2"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('M', 'P', '4', '2');
|
2002-06-18 01:39:26 +00:00
|
|
|
else if (!strcasecmp(lavc_param_vcodec, "wmv1"))
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC('W', 'M', 'V', '1');
|
2002-04-10 23:23:36 +00:00
|
|
|
else
|
|
|
|
mux_v->bih->biCompression = mmioFOURCC(lavc_param_vcodec[0],
|
|
|
|
lavc_param_vcodec[1], lavc_param_vcodec[2], lavc_param_vcodec[3]); /* FIXME!!! */
|
|
|
|
|
|
|
|
if (!avcodec_inited){
|
|
|
|
avcodec_init();
|
|
|
|
avcodec_register_all();
|
|
|
|
avcodec_inited=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
vf->priv->codec = (AVCodec *)avcodec_find_encoder_by_name(lavc_param_vcodec);
|
|
|
|
if (!vf->priv->codec) {
|
|
|
|
mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_MissingLAVCcodec, lavc_param_vcodec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-09-19 09:47:37 +00:00
|
|
|
#if LIBAVCODEC_BUILD >= 4624
|
|
|
|
vf->priv->context = avcodec_alloc_context();
|
|
|
|
#else
|
|
|
|
vf->priv->context = malloc(sizeof(AVCodecContext));
|
|
|
|
memset(vf->priv->context, 0, sizeof(AVCodecContext));
|
|
|
|
#endif
|
|
|
|
|
2002-04-10 23:23:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
vf_info_t ve_info_lavc = {
|
|
|
|
"libavcodec encoder",
|
|
|
|
"lavc",
|
2002-07-08 21:34:24 +00:00
|
|
|
"A'rpi, Alex, Michael",
|
2002-04-10 23:23:36 +00:00
|
|
|
"for internal use by mencoder",
|
|
|
|
vf_open
|
|
|
|
};
|
|
|
|
|
|
|
|
//===========================================================================//
|
|
|
|
#endif
|