Commit fd598b84 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/ffmpeg/*:

  - added fourcc for SNOW and DTS.
  - added 'qscale' (fixed quantizer scale - VBR) and 'strict' (standard compliance) encoding options.
parent 766237dc
...@@ -134,13 +134,14 @@ struct encoder_sys_t ...@@ -134,13 +134,14 @@ struct encoder_sys_t
int i_noise_reduction; int i_noise_reduction;
vlc_bool_t b_mpeg4_matrix; vlc_bool_t b_mpeg4_matrix;
vlc_bool_t b_trellis; vlc_bool_t b_trellis;
int i_quality; /* for VBR */
}; };
static const char *ppsz_enc_options[] = { static const char *ppsz_enc_options[] = {
"keyint", "bframes", "vt", "qmin", "qmax", "hq", "strict_rc", "keyint", "bframes", "vt", "qmin", "qmax", "hq", "strict_rc",
"rc-buffer-size", "rc-buffer-aggressivity", "pre-me", "hurry-up", "rc-buffer-size", "rc-buffer-aggressivity", "pre-me", "hurry-up",
"interlace", "i-quant-factor", "noise-reduction", "mpeg4-matrix", "interlace", "i-quant-factor", "noise-reduction", "mpeg4-matrix",
"trellis", NULL "trellis", "qscale", "strict", NULL
}; };
/***************************************************************************** /*****************************************************************************
...@@ -274,6 +275,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -274,6 +275,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
var_Get( p_enc, ENC_CFG_PREFIX "mpeg4-matrix", &val ); var_Get( p_enc, ENC_CFG_PREFIX "mpeg4-matrix", &val );
p_sys->b_mpeg4_matrix = val.b_bool; p_sys->b_mpeg4_matrix = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "qscale", &val );
if( val.f_float < 0.01 || val.f_float > 255.0 ) val.f_float = 0;
p_sys->i_quality = (int)(FF_QP2LAMBDA * val.f_float + 0.5);
var_Get( p_enc, ENC_CFG_PREFIX "hq", &val ); var_Get( p_enc, ENC_CFG_PREFIX "hq", &val );
if( val.psz_string && *val.psz_string ) if( val.psz_string && *val.psz_string )
{ {
...@@ -295,6 +300,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -295,6 +300,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
var_Get( p_enc, ENC_CFG_PREFIX "trellis", &val ); var_Get( p_enc, ENC_CFG_PREFIX "trellis", &val );
p_sys->b_trellis = val.b_bool; p_sys->b_trellis = val.b_bool;
var_Get( p_enc, ENC_CFG_PREFIX "strict", &val );
if( val.i_int < - 1 || val.i_int > 1 ) val.i_int = 0;
p_context->strict_std_compliance = val.i_int;
if( p_enc->fmt_in.i_cat == VIDEO_ES ) if( p_enc->fmt_in.i_cat == VIDEO_ES )
{ {
if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height ) if( !p_enc->fmt_in.video.i_width || !p_enc->fmt_in.video.i_height )
...@@ -327,10 +336,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -327,10 +336,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
#if LIBAVCODEC_BUILD >= 4687 #if LIBAVCODEC_BUILD >= 4687
av_reduce( &p_context->sample_aspect_ratio.num, av_reduce( &p_context->sample_aspect_ratio.num,
&p_context->sample_aspect_ratio.den, &p_context->sample_aspect_ratio.den,
p_enc->fmt_in.video.i_aspect * p_enc->fmt_in.video.i_aspect *
(int64_t)p_context->height / p_context->width, (int64_t)p_context->height / p_context->width,
VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ ); VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
#else #else
p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) / p_context->aspect_ratio = ((float)p_enc->fmt_in.video.i_aspect) /
VOUT_ASPECT_FACTOR; VOUT_ASPECT_FACTOR;
...@@ -392,6 +401,14 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -392,6 +401,14 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->max_qdiff = 3; p_context->max_qdiff = 3;
p_context->mb_decision = p_sys->i_hq; p_context->mb_decision = p_sys->i_hq;
if( p_sys->i_quality )
{
p_context->flags |= CODEC_FLAG_QSCALE;
#if LIBAVCODEC_BUILD >= 4668
p_context->global_quality = p_sys->i_quality;
#endif
}
} }
else if( p_enc->fmt_in.i_cat == AUDIO_ES ) else if( p_enc->fmt_in.i_cat == AUDIO_ES )
{ {
...@@ -662,6 +679,8 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict ) ...@@ -662,6 +679,8 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
} }
} }
frame.quality = p_sys->i_quality;
i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out, i_out = avcodec_encode_video( p_sys->p_context, p_sys->p_buffer_out,
AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame ); AVCODEC_MAX_VIDEO_FRAME_SIZE, &frame );
......
...@@ -145,6 +145,10 @@ vlc_module_begin(); ...@@ -145,6 +145,10 @@ vlc_module_begin();
ENC_QMAX_TEXT, ENC_QMAX_LONGTEXT, VLC_TRUE ); ENC_QMAX_TEXT, ENC_QMAX_LONGTEXT, VLC_TRUE );
add_bool( ENC_CFG_PREFIX "trellis", 0, NULL, add_bool( ENC_CFG_PREFIX "trellis", 0, NULL,
ENC_TRELLIS_TEXT, ENC_TRELLIS_LONGTEXT, VLC_TRUE ); ENC_TRELLIS_TEXT, ENC_TRELLIS_LONGTEXT, VLC_TRUE );
add_float( ENC_CFG_PREFIX "qscale", 0, NULL,
ENC_QSCALE_TEXT, ENC_QSCALE_LONGTEXT, VLC_TRUE );
add_integer( ENC_CFG_PREFIX "strict", 0, NULL,
ENC_STRICT_TEXT, ENC_STRICT_LONGTEXT, VLC_TRUE );
/* demux submodule */ /* demux submodule */
add_submodule(); add_submodule();
...@@ -670,6 +674,12 @@ static struct ...@@ -670,6 +674,12 @@ static struct
VIDEO_ES, "Sierra VMD Video" }, VIDEO_ES, "Sierra VMD Video" },
#endif #endif
#if LIBAVCODEC_BUILD >= 4718
/* FFMPEG's SNOW wavelet codec */
{ VLC_FOURCC('S','N','O','W'), CODEC_ID_SNOW,
VIDEO_ES, "FFMpeg SNOW wavelet Video" },
#endif
/* /*
* Audio Codecs * Audio Codecs
*/ */
...@@ -718,6 +728,12 @@ static struct ...@@ -718,6 +728,12 @@ static struct
{ VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */ { VLC_FOURCC('a','5','2','b'), CODEC_ID_AC3, /* VLC specific hack */
AUDIO_ES, "A52 Audio (aka AC3)" }, AUDIO_ES, "A52 Audio (aka AC3)" },
#if LIBAVCODEC_BUILD >= 4718
/* DTS Audio */
{ VLC_FOURCC('d','t','s',' '), CODEC_ID_DTS,
AUDIO_ES, "DTS Audio" },
#endif
/* AAC audio */ /* AAC audio */
{ VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC, { VLC_FOURCC('m','p','4','a'), CODEC_ID_AAC,
AUDIO_ES, "MPEG AAC Audio" }, AUDIO_ES, "MPEG AAC Audio" },
......
...@@ -230,3 +230,11 @@ void E_(ClosePostproc)( decoder_t *, void * ); ...@@ -230,3 +230,11 @@ void E_(ClosePostproc)( decoder_t *, void * );
#define ENC_TRELLIS_TEXT N_( "Enable trellis quantization" ) #define ENC_TRELLIS_TEXT N_( "Enable trellis quantization" )
#define ENC_TRELLIS_LONGTEXT N_( "Allows you to enable trellis " \ #define ENC_TRELLIS_LONGTEXT N_( "Allows you to enable trellis " \
"quantization (rate distortion for block coefficients)." ) "quantization (rate distortion for block coefficients)." )
#define ENC_QSCALE_TEXT N_( "Use fixed video quantizer scale" )
#define ENC_QSCALE_LONGTEXT N_( "Allows you to specify a fixed video " \
"quantizer scale for VBR encoding (accepted values: 0.01 to 255.0)." )
#define ENC_STRICT_TEXT N_( "Strict standard compliance" )
#define ENC_STRICT_LONGTEXT N_( "Allows you to force a strict standard " \
"compliance when encoding (accepted values: -1, 0, 1)." )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment