Commit 0ea5cbd5 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/theora.c: new --sout-theora-quality option.

parent c7d155f6
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*****************************************************************************/ *****************************************************************************/
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#include <vlc/sout.h>
#include <ogg/ogg.h> #include <ogg/ogg.h>
...@@ -80,6 +81,11 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict ); ...@@ -80,6 +81,11 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
#define ENC_QUALITY_TEXT N_("Encoding quality")
#define ENC_QUALITY_LONGTEXT N_( \
"Allows you to specify a quality between 1 (low) and 10 (high), instead " \
"of specifying a particular bitrate. This will produce a VBR stream." )
vlc_module_begin(); vlc_module_begin();
set_description( _("Theora video decoder") ); set_description( _("Theora video decoder") );
set_capability( "decoder", 100 ); set_capability( "decoder", 100 );
...@@ -97,8 +103,16 @@ vlc_module_begin(); ...@@ -97,8 +103,16 @@ vlc_module_begin();
set_capability( "encoder", 100 ); set_capability( "encoder", 100 );
set_callbacks( OpenEncoder, CloseEncoder ); set_callbacks( OpenEncoder, CloseEncoder );
add_shortcut( "theora" ); add_shortcut( "theora" );
# define ENC_CFG_PREFIX "sout-theora-"
add_integer( ENC_CFG_PREFIX "quality", 2, NULL, ENC_QUALITY_TEXT,
ENC_QUALITY_LONGTEXT, VLC_FALSE );
vlc_module_end(); vlc_module_end();
static const char *ppsz_enc_options[] = {
"quality", NULL
};
/***************************************************************************** /*****************************************************************************
* OpenDecoder: probe the decoder and return score * OpenDecoder: probe the decoder and return score
*****************************************************************************/ *****************************************************************************/
...@@ -440,6 +454,8 @@ static int OpenEncoder( vlc_object_t *p_this ) ...@@ -440,6 +454,8 @@ static int OpenEncoder( vlc_object_t *p_this )
{ {
encoder_t *p_enc = (encoder_t *)p_this; encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys = p_enc->p_sys; encoder_sys_t *p_sys = p_enc->p_sys;
vlc_value_t val;
int i_quality;
if( p_enc->fmt_out.i_codec != VLC_FOURCC('t','h','e','o') && if( p_enc->fmt_out.i_codec != VLC_FOURCC('t','h','e','o') &&
!p_enc->b_force ) !p_enc->b_force )
...@@ -469,6 +485,13 @@ static int OpenEncoder( vlc_object_t *p_this ) ...@@ -469,6 +485,13 @@ static int OpenEncoder( vlc_object_t *p_this )
p_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0'); p_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0');
p_enc->fmt_out.i_codec = VLC_FOURCC('t','h','e','o'); p_enc->fmt_out.i_codec = VLC_FOURCC('t','h','e','o');
sout_ParseCfg( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
var_Get( p_enc, ENC_CFG_PREFIX "quality", &val );
i_quality = val.i_int;
if( i_quality > 10 ) i_quality = 10;
if( i_quality < 0 ) i_quality = 0;
#define frame_x_offset 0 #define frame_x_offset 0
#define frame_y_offset 0 #define frame_y_offset 0
#define video_hzn 25 #define video_hzn 25
...@@ -498,7 +521,7 @@ static int OpenEncoder( vlc_object_t *p_this ) ...@@ -498,7 +521,7 @@ static int OpenEncoder( vlc_object_t *p_this )
} }
p_sys->ti.target_bitrate = p_enc->fmt_out.i_bitrate; p_sys->ti.target_bitrate = p_enc->fmt_out.i_bitrate;
p_sys->ti.quality = video_q; p_sys->ti.quality = ((float)i_quality) * 6.3;
p_sys->ti.dropframes_p = 0; p_sys->ti.dropframes_p = 0;
p_sys->ti.quick_p = 1; p_sys->ti.quick_p = 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