Commit 557f5d1c authored by Rafaël Carré's avatar Rafaël Carré

Remove dirac.c

Comment says:
"NB, this is a temporary encoder only module until schroedinger
offers superior encoding quality than dirac-research"

http://diracvideo.org/2012/01/schroedinger-1-0-11/ says:
"Schrödinger outperforms dirac-research in most encoding situations,
both in terms of encoding speed and visual quality."
parent 1a774ee2
......@@ -2670,11 +2670,6 @@ dnl theora decoder plugin
dnl
PKG_ENABLE_MODULES_VLC([THEORA], [], [ogg theoradec >= 1.0 theoraenc], [experimental theora codec], [auto])
dnl
dnl dirac encoder plugin
dnl
PKG_ENABLE_MODULES_VLC([DIRAC], [], [dirac >= 0.10.0], [dirac encoder], [auto])
dnl
dnl schroedinger decoder plugin (for dirac format video)
dnl
......
......@@ -84,7 +84,6 @@ $Id$
* demux_cdg: Demuxer for CD-G files (Karaoke)
* demux_stl: EBU STL subtitles demuxer
* demuxdump: Pseudo-demuxer that dumps the stream
* dirac: BBC Dirac codec
* diracsys: BBC Dirac demuxer
* direct2d: video output module using the Direct2D API
* direct3d: video output module using the Direct3D API
......
......@@ -388,13 +388,6 @@ codec_LTLIBRARIES += $(LTLIBx26410b)
### Misc encoders ###
libdirac_plugin_la_SOURCES = codec/dirac.c
libdirac_plugin_la_CFLAGS = $(AM_CFLAGS) $(DIRAC_CFLAGS)
libdirac_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
libdirac_plugin_la_LIBADD = $(DIRAC_LIBS)
EXTRA_LTLIBRARIES += libdirac_plugin.la
codec_LTLIBRARIES += $(LTLIBdirac)
libfdkaac_plugin_la_SOURCES = codec/fdkaac.c
libfdkaac_plugin_la_CFLAGS = $(AM_CFLAGS) $(FDKAAC_CFLAGS)
libfdkaac_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
......
/*****************************************************************************
* dirac.c: Dirac encoder module making use of libdirac (dirac-research).
* (http://www.bbc.co.uk/rd/projects/dirac/index.shtml)
* ##
* ## NB, this is a temporary encoder only module until schroedinger
* ## offers superior encoding quality than dirac-research
* ##
*****************************************************************************
* Copyright (C) 2004-2008 VLC authors and VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Rewritten: David Flynn <davidf at rd.bbc.co.uk>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <limits.h>
#include <assert.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_sout.h>
#include <vlc_picture.h>
#include <libdirac_encoder/dirac_encoder.h>
#ifndef DIRAC_RESEARCH_VERSION_ATLEAST
# define DIRAC_RESEARCH_VERSION_ATLEAST(x,y,z) 0
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int OpenEncoder( vlc_object_t *p_this );
static void CloseEncoder( vlc_object_t *p_this );
static block_t *Encode( encoder_t *p_enc, picture_t *p_pict );
#define ENC_CFG_PREFIX "sout-dirac-"
#define ENC_QUALITY_FACTOR "quality"
#define ENC_QUALITY_FACTOR_TEXT N_("Constant quality factor")
#define ENC_QUALITY_FACTOR_LONGTEXT N_("If bitrate=0, use this value for constant quality")
#define ENC_TARGETRATE "bitrate"
#define ENC_TARGETRATE_TEXT N_("CBR bitrate (kbps)")
#define ENC_TARGETRATE_LONGTEXT N_("A value > 0 enables constant bitrate mode")
#define ENC_LOSSLESS "lossless"
#define ENC_LOSSLESS_TEXT N_("Enable lossless coding")
#define ENC_LOSSLESS_LONGTEXT N_("Lossless coding ignores bitrate and quality settings, " \
"allowing for perfect reproduction of the original")
#define ENC_PREFILTER "prefilter"
#define ENC_PREFILTER_TEXT N_("Prefilter")
#define ENC_PREFILTER_LONGTEXT N_("Enable adaptive prefiltering")
static const char *const enc_prefilter_list[] =
{ "none", "cwm", "rectlp", "diaglp" };
static const char *const enc_prefilter_list_text[] =
{ N_("None"), N_("Centre Weighted Median"),
N_("Rectangular Linear Phase"), N_("Diagonal Linear Phase") };
#define ENC_PREFILTER_STRENGTH "prefilter-strength"
#define ENC_PREFILTER_STRENGTH_TEXT N_("Amount of prefiltering")
#define ENC_PREFILTER_STRENGTH_LONGTEXT N_("Higher value implies more prefiltering")
#define ENC_CHROMAFMT "chroma-fmt"
#define ENC_CHROMAFMT_TEXT N_("Chroma format")
#define ENC_CHROMAFMT_LONGTEXT N_("Picking chroma format will force a " \
"conversion of the video into that format")
static const char *const enc_chromafmt_list[] =
{ "420", "422", "444" };
static const char *const enc_chromafmt_list_text[] =
{ N_("4:2:0"), N_("4:2:2"), N_("4:4:4") };
#define ENC_L1SEP "l1-sep"
#define ENC_L1SEP_TEXT N_("Distance between 'P' frames")
#define ENC_L1SEP_LONGTEXT ENC_L1SEP_TEXT
#define ENC_L1NUM "num-l1"
#define ENC_L1NUM_TEXT N_("Number of 'P' frames per GOP")
#define ENC_L1NUM_LONGTEXT ENC_L1NUM_TEXT
#define ENC_CODINGMODE "coding-mode"
#define ENC_CODINGMODE_TEXT N_("Picture coding mode")
#define ENC_CODINGMODE_LONGTEXT N_("Field coding is where interlaced fields are coded" \
" separately as opposed to a pseudo-progressive frame")
static const char *const enc_codingmode_list[] =
{ "auto", "progressive", "field" };
static const char *const enc_codingmode_list_text[] =
{ N_("auto - let encoder decide based upon input (Best)"),
N_("force coding frame as single picture"),
N_("force coding frame as separate interlaced fields"),
};
#define ENC_MCBLK_WIDTH "mc-blk-width"
#define ENC_MCBLK_WIDTH_TEXT N_("Width of motion compensation blocks")
#define ENC_MCBLK_WIDTH_LONGTEXT ""
#define ENC_MCBLK_HEIGHT "mc-blk-height"
#define ENC_MCBLK_HEIGHT_TEXT N_("Height of motion compensation blocks")
#define ENC_MCBLK_HEIGHT_LONGTEXT ""
/* also known as XBSEP and YBSEP */
#define ENC_MCBLK_OVERLAP "mc-blk-overlap"
#define ENC_MCBLK_OVERLAP_TEXT N_("Block overlap (%)")
#define ENC_MCBLK_OVERLAP_LONGTEXT N_("Amount that each motion block should " \
"be overlapped by its neighbours")
/* advanced option only */
#define ENC_MCBLK_XBLEN "mc-blk-xblen"
#define ENC_MCBLK_XBLEN_TEXT N_("xblen")
#define ENC_MCBLK_XBLEN_LONGTEXT N_("Total horizontal block length including overlaps")
/* advanded option only */
#define ENC_MCBLK_YBLEN "mc-blk-yblen"
#define ENC_MCBLK_YBLEN_TEXT N_("yblen")
#define ENC_MCBLK_YBLEN_LONGTEXT N_("Total vertical block length including overlaps")
#define ENC_MVPREC "mv-prec"
#define ENC_MVPREC_TEXT N_("Motion vector precision")
#define ENC_MVPREC_LONGTEXT N_("Motion vector precision in pels.")
static const char *const enc_mvprec_list[] =
{ "1", "1/2", "1/4", "1/8" };
#define ENC_ME_SIMPLESEARCH "me-simple-search"
#define ENC_ME_SIMPLESEARCH_TEXT N_("Simple ME search area x:y")
#define ENC_ME_SIMPLESEARCH_LONGTEXT N_("(Not recommended) Perform a simple (non hierarchical " \
"block matching motion vector search with search range " \
"of +/-x, +/-y")
#define ENC_ME_COMBINED "me-combined"
#define ENC_ME_COMBINED_TEXT N_("Three component motion estimation")
#define ENC_ME_COMBINED_LONGTEXT N_("Use chroma as part of the motion estimation process")
#define ENC_DWTINTRA "dwt-intra"
#define ENC_DWTINTRA_TEXT N_("Intra picture DWT filter")
#define ENC_DWTINTRA_LONGTEXT ENC_DWTINTRA_TEXT
#define ENC_DWTINTER "dwt-inter"
#define ENC_DWTINTER_TEXT N_("Inter picture DWT filter")
#define ENC_DWTINTER_LONGTEXT ENC_DWTINTER_TEXT
#define ENC_DWTDEPTH "dwt-depth"
#define ENC_DWTDEPTH_TEXT N_("Number of DWT iterations")
#define ENC_DWTDEPTH_LONGTEXT N_("Also known as DWT levels")
/* advanced option only */
#define ENC_MULTIQUANT "multi-quant"
#define ENC_MULTIQUANT_TEXT N_("Enable multiple quantizers")
#define ENC_MULTIQUANT_LONGTEXT N_("Enable multiple quantizers per subband (one per codeblock)")
/* advanced option only */
#define ENC_SPARTITION "spartition"
#define ENC_SPARTITION_TEXT N_("Enable spatial partitioning")
#define ENC_SPARTITION_LONGTEXT ENC_SPARTITION_TEXT
#define ENC_NOAC "noac"
#define ENC_NOAC_TEXT N_("Disable arithmetic coding")
#define ENC_NOAC_LONGTEXT N_("Use variable length codes instead, useful for very high bitrates")
/* visual modelling */
/* advanced option only */
#define ENC_CPD "cpd"
#define ENC_CPD_TEXT N_("cycles per degree")
#define ENC_CPD_LONGTEXT ENC_CPD_TEXT
static const char *const ppsz_enc_options[] = {
ENC_QUALITY_FACTOR, ENC_TARGETRATE, ENC_LOSSLESS, ENC_PREFILTER, ENC_PREFILTER_STRENGTH,
ENC_CHROMAFMT, ENC_L1SEP, ENC_L1NUM, ENC_CODINGMODE,
ENC_MCBLK_WIDTH, ENC_MCBLK_HEIGHT, ENC_MCBLK_OVERLAP,
ENC_MVPREC, ENC_ME_SIMPLESEARCH, ENC_ME_COMBINED,
ENC_DWTINTRA, ENC_DWTINTER, ENC_DWTDEPTH,
ENC_MULTIQUANT, ENC_SPARTITION, ENC_NOAC,
ENC_CPD,
NULL
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin()
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_VCODEC )
set_description( N_("Dirac video encoder using dirac-research library") )
set_shortname( "Dirac" )
set_capability( "encoder", 100 )
set_callbacks( OpenEncoder, CloseEncoder )
add_float( ENC_CFG_PREFIX ENC_QUALITY_FACTOR, 5.5,
ENC_QUALITY_FACTOR_TEXT, ENC_QUALITY_FACTOR_LONGTEXT, false )
change_float_range(0., 10.);
add_integer( ENC_CFG_PREFIX ENC_TARGETRATE, -1,
ENC_TARGETRATE_TEXT, ENC_TARGETRATE_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_bool( ENC_CFG_PREFIX ENC_LOSSLESS, false,
ENC_LOSSLESS_TEXT, ENC_LOSSLESS_LONGTEXT, false )
add_string( ENC_CFG_PREFIX ENC_PREFILTER, "diaglp",
ENC_PREFILTER_TEXT, ENC_PREFILTER_LONGTEXT, false )
change_string_list( enc_prefilter_list, enc_prefilter_list_text );
add_integer( ENC_CFG_PREFIX ENC_PREFILTER_STRENGTH, 1,
ENC_PREFILTER_STRENGTH_TEXT, ENC_PREFILTER_STRENGTH_LONGTEXT, false )
change_integer_range(0, 10);
add_string( ENC_CFG_PREFIX ENC_CHROMAFMT, "420",
ENC_CHROMAFMT_TEXT, ENC_CHROMAFMT_LONGTEXT, false )
change_string_list( enc_chromafmt_list, enc_chromafmt_list_text );
add_integer( ENC_CFG_PREFIX ENC_L1SEP, -1,
ENC_L1SEP_TEXT, ENC_L1SEP_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_integer( ENC_CFG_PREFIX ENC_L1NUM, -1,
ENC_L1NUM_TEXT, ENC_L1NUM_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_string( ENC_CFG_PREFIX ENC_CODINGMODE, "auto",
ENC_CODINGMODE_TEXT, ENC_CODINGMODE_LONGTEXT, false )
change_string_list( enc_codingmode_list, enc_codingmode_list_text );
add_string( ENC_CFG_PREFIX ENC_MVPREC, "1/2",
ENC_MVPREC_TEXT, ENC_MVPREC_LONGTEXT, false )
change_string_list( enc_mvprec_list, enc_mvprec_list );
add_integer( ENC_CFG_PREFIX ENC_MCBLK_WIDTH, -1,
ENC_MCBLK_WIDTH_TEXT, ENC_MCBLK_WIDTH_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_integer( ENC_CFG_PREFIX ENC_MCBLK_HEIGHT, -1,
ENC_MCBLK_HEIGHT_TEXT, ENC_MCBLK_HEIGHT_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_integer( ENC_CFG_PREFIX ENC_MCBLK_OVERLAP, -1,
ENC_MCBLK_OVERLAP_TEXT, ENC_MCBLK_OVERLAP_LONGTEXT, false )
change_integer_range(-1, 100);
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_MCBLK_XBLEN, -1,
ENC_MCBLK_XBLEN_TEXT, ENC_MCBLK_XBLEN_LONGTEXT, true )
change_integer_range(-1, INT_MAX);
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_MCBLK_YBLEN, -1,
ENC_MCBLK_YBLEN_TEXT, ENC_MCBLK_YBLEN_LONGTEXT, true )
change_integer_range(-1, INT_MAX);
add_string( ENC_CFG_PREFIX ENC_ME_SIMPLESEARCH, "",
ENC_ME_SIMPLESEARCH_TEXT, ENC_ME_SIMPLESEARCH_LONGTEXT, false )
#if DIRAC_RESEARCH_VERSION_ATLEAST(1,0,1)
add_bool( ENC_CFG_PREFIX ENC_ME_COMBINED, true,
ENC_ME_COMBINED_TEXT, ENC_ME_COMBINED_LONGTEXT, false )
#endif
add_integer( ENC_CFG_PREFIX ENC_DWTINTRA, -1,
ENC_DWTINTRA_TEXT, ENC_DWTINTRA_LONGTEXT, false )
change_integer_range(-1, 6);
add_integer( ENC_CFG_PREFIX ENC_DWTINTER, -1,
ENC_DWTINTER_TEXT, ENC_DWTINTER_LONGTEXT, false )
change_integer_range(-1, 6);
add_integer( ENC_CFG_PREFIX ENC_DWTDEPTH, -1,
ENC_DWTDEPTH_TEXT, ENC_DWTDEPTH_LONGTEXT, false )
change_integer_range(-1, 4);
/* advanced option only */
/* NB, unforunately vlc doesn't have a concept of 'don't care' */
add_integer( ENC_CFG_PREFIX ENC_MULTIQUANT, -1,
ENC_MULTIQUANT_TEXT, ENC_MULTIQUANT_LONGTEXT, true )
change_integer_range(-1, 1);
/* advanced option only */
/* NB, unforunately vlc doesn't have a concept of 'don't care' */
add_integer( ENC_CFG_PREFIX ENC_SPARTITION, -1,
ENC_SPARTITION_TEXT, ENC_SPARTITION_LONGTEXT, true )
change_integer_range(-1, 1);
add_bool( ENC_CFG_PREFIX ENC_NOAC, false,
ENC_NOAC_TEXT, ENC_NOAC_LONGTEXT, false )
/* advanced option only */
add_float( ENC_CFG_PREFIX ENC_CPD, -1,
ENC_CPD_TEXT, ENC_CPD_LONGTEXT, true )
change_integer_range(-1, INT_MAX);
vlc_module_end()
/*****************************************************************************
* picture_pts_t : store pts alongside picture number, not carried through
* encoder
*****************************************************************************/
struct picture_pts_t
{
bool b_empty; /* entry is invalid */
uint32_t u_pnum; /* dirac picture number */
mtime_t i_pts; /* associated pts */
};
/*****************************************************************************
* encoder_sys_t : dirac encoder descriptor
*****************************************************************************/
#define PTS_TLB_SIZE 256
struct encoder_sys_t
{
dirac_encoder_t *p_dirac;
dirac_encoder_context_t ctx;
bool b_auto_field_coding;
uint8_t *p_buffer_in;
int i_buffer_in;
uint32_t i_input_picnum;
block_fifo_t *p_dts_fifo;
int i_buffer_out;
uint8_t *p_buffer_out;
block_t *p_chain;
struct picture_pts_t pts_tlb[PTS_TLB_SIZE];
mtime_t i_pts_offset;
mtime_t i_field_time;
};
static struct
{
unsigned int i_height;
int i_approx_fps;
VideoFormat i_vf;
} dirac_format_guess[] = {
/* Important: Keep this list ordered in ascending picture height */
{1, 0, VIDEO_FORMAT_CUSTOM},
{120, 15, VIDEO_FORMAT_QSIF525},
{144, 12, VIDEO_FORMAT_QCIF},
{240, 15, VIDEO_FORMAT_SIF525},
{288, 12, VIDEO_FORMAT_CIF},
{480, 30, VIDEO_FORMAT_SD_480I60},
{480, 15, VIDEO_FORMAT_4SIF525},
{576, 12, VIDEO_FORMAT_4CIF},
{576, 25, VIDEO_FORMAT_SD_576I50},
{720, 50, VIDEO_FORMAT_HD_720P50},
{720, 60, VIDEO_FORMAT_HD_720P60},
{1080, 24, VIDEO_FORMAT_DIGI_CINEMA_2K24},
{1080, 25, VIDEO_FORMAT_HD_1080I50},
{1080, 30, VIDEO_FORMAT_HD_1080I60},
{1080, 50, VIDEO_FORMAT_HD_1080P50},
{1080, 60, VIDEO_FORMAT_HD_1080P60},
{2160, 24, VIDEO_FORMAT_DIGI_CINEMA_4K24},
{2160, 50, VIDEO_FORMAT_UHDTV_4K50},
{2160, 60, VIDEO_FORMAT_UHDTV_4K60},
{3840, 50, VIDEO_FORMAT_UHDTV_8K50},
{3840, 60, VIDEO_FORMAT_UHDTV_8K60},
{0, 0, 0},
};
/*****************************************************************************
* ResetPTStlb: Purge all entries in @p_dec@'s PTS-tlb
*****************************************************************************/
static void ResetPTStlb( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
for( int i=0; i<PTS_TLB_SIZE; i++)
{
p_sys->pts_tlb[i].b_empty = true;
}
}
/*****************************************************************************
* StorePicturePTS: Store the PTS value for a particular picture number
*****************************************************************************/
static void StorePicturePTS( encoder_t *p_enc, uint32_t u_pnum, mtime_t i_pts )
{
encoder_sys_t *p_sys = p_enc->p_sys;
for( int i=0; i<PTS_TLB_SIZE; i++ )
{
if( p_sys->pts_tlb[i].b_empty )
{
p_sys->pts_tlb[i].u_pnum = u_pnum;
p_sys->pts_tlb[i].i_pts = i_pts;
p_sys->pts_tlb[i].b_empty = false;
return;
}
}
msg_Err( p_enc, "Could not store PTS %"PRId64" for frame %u", i_pts, u_pnum );
}
/*****************************************************************************
* GetPicturePTS: Retrieve the PTS value for a particular picture number
*****************************************************************************/
static mtime_t GetPicturePTS( encoder_t *p_enc, uint32_t u_pnum )
{
encoder_sys_t *p_sys = p_enc->p_sys;
for( int i=0; i<PTS_TLB_SIZE; i++ )
{
if( !p_sys->pts_tlb[i].b_empty &&
p_sys->pts_tlb[i].u_pnum == u_pnum )
{
p_sys->pts_tlb[i].b_empty = true;
return p_sys->pts_tlb[i].i_pts;
}
}
msg_Err( p_enc, "Could not retrieve PTS for picture %u", u_pnum );
return 0;
}
/*****************************************************************************
* OpenEncoder: probe the encoder and return score
*****************************************************************************/
static int OpenEncoder( vlc_object_t *p_this )
{
encoder_t *p_enc = (encoder_t *)p_this;
encoder_sys_t *p_sys;
int i_tmp;
float f_tmp;
char *psz_tmp;
if( p_enc->fmt_out.i_codec != VLC_CODEC_DIRAC &&
!p_enc->b_force )
{
return VLC_EGENERIC;
}
if( !p_enc->fmt_in.video.i_frame_rate || !p_enc->fmt_in.video.i_frame_rate_base ||
!p_enc->fmt_in.video.i_visible_height || !p_enc->fmt_in.video.i_visible_width )
{
msg_Err( p_enc, "Framerate and picture dimensions must be non-zero" );
return VLC_EGENERIC;
}
/* Allocate the memory needed to store the decoder's structure */
if( ( p_sys = calloc( 1, sizeof(*p_sys) ) ) == NULL )
return VLC_ENOMEM;
p_enc->p_sys = p_sys;
p_enc->pf_encode_video = Encode;
p_enc->fmt_out.i_codec = VLC_CODEC_DIRAC;
p_enc->fmt_out.i_cat = VIDEO_ES;
if( ( p_sys->p_dts_fifo = block_FifoNew() ) == NULL )
{
CloseEncoder( p_this );
return VLC_ENOMEM;
}
ResetPTStlb( p_enc );
/* guess the video format based upon number of lines and picture height */
int i = 0;
VideoFormat guessed_video_fmt = VIDEO_FORMAT_CUSTOM;
/* Pick the dirac_video_format in this order of preference:
* 1. an exact match in frame height and an approximate fps match
* 2. the previous preset with a smaller number of lines.
*/
do
{
if( dirac_format_guess[i].i_height > p_enc->fmt_in.video.i_height )
{
guessed_video_fmt = dirac_format_guess[i-1].i_vf;
break;
}
if( dirac_format_guess[i].i_height != p_enc->fmt_in.video.i_height )
continue;
int src_fps = p_enc->fmt_in.video.i_frame_rate / p_enc->fmt_in.video.i_frame_rate_base;
int delta_fps = abs( dirac_format_guess[i].i_approx_fps - src_fps );
if( delta_fps > 2 )
continue;
guessed_video_fmt = dirac_format_guess[i].i_vf;
break;
} while( dirac_format_guess[++i].i_height );
dirac_encoder_context_init( &p_sys->ctx, guessed_video_fmt );
/* constants set from the input video format */
p_sys->ctx.src_params.frame_rate.numerator = p_enc->fmt_in.video.i_frame_rate;
p_sys->ctx.src_params.frame_rate.denominator = p_enc->fmt_in.video.i_frame_rate_base;
unsigned u_asr_num, u_asr_den;
vlc_ureduce( &u_asr_num, &u_asr_den,
p_enc->fmt_in.video.i_sar_num,
p_enc->fmt_in.video.i_sar_den, 0 );
p_sys->ctx.src_params.pix_asr.numerator = u_asr_num;
p_sys->ctx.src_params.pix_asr.denominator = u_asr_den;
config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
psz_tmp = var_GetString( p_enc, ENC_CFG_PREFIX ENC_CHROMAFMT );
if( !psz_tmp )
goto error;
else if( !strcmp( psz_tmp, "420" ) ) {
p_enc->fmt_in.i_codec = VLC_CODEC_I420;
p_enc->fmt_in.video.i_bits_per_pixel = 12;
p_sys->ctx.src_params.chroma = format420;
}
else if( !strcmp( psz_tmp, "422" ) ) {
p_enc->fmt_in.i_codec = VLC_CODEC_I422;
p_enc->fmt_in.video.i_bits_per_pixel = 16;
p_sys->ctx.src_params.chroma = format422;
}
else if( !strcmp( psz_tmp, "444" ) ) {
p_enc->fmt_in.i_codec = VLC_CODEC_I444;
p_enc->fmt_in.video.i_bits_per_pixel = 24;
p_sys->ctx.src_params.chroma = format444;
}
else {
msg_Err( p_enc, "Invalid chroma format: %s", psz_tmp );
free( psz_tmp );
goto error;
}
free( psz_tmp );
picture_t picture;
picture_Setup( &picture, p_enc->fmt_in.i_codec,
p_enc->fmt_in.video.i_width,
p_enc->fmt_in.video.i_height,
p_enc->fmt_in.video.i_sar_num,
p_enc->fmt_in.video.i_sar_den );
switch( p_enc->fmt_in.i_codec )
{
case VLC_CODEC_I420:
p_sys->i_buffer_in = picture.format.i_visible_width * picture.format.i_visible_height * 3 / 2;
break;
case VLC_CODEC_I422:
p_sys->i_buffer_in = picture.format.i_visible_width * picture.format.i_visible_height * 2;
break;
case VLC_CODEC_I444:
p_sys->i_buffer_in = picture.format.i_visible_width * picture.format.i_visible_height * 3;
break;
}
p_sys->ctx.src_params.width = picture.format.i_visible_width;
p_sys->ctx.src_params.height = picture.format.i_visible_height;
p_sys->ctx.enc_params.qf = var_GetFloat( p_enc, ENC_CFG_PREFIX ENC_QUALITY_FACTOR );
/* use bitrate from sout-transcode-vb in kbps */
p_sys->ctx.enc_params.trate = p_enc->fmt_out.i_bitrate / 1000;
i_tmp = var_GetInteger( p_enc, ENC_CFG_PREFIX ENC_TARGETRATE );
if( i_tmp > -1 )
p_sys->ctx.enc_params.trate = i_tmp;
p_enc->fmt_out.i_bitrate = p_sys->ctx.enc_params.trate * 1000;
p_sys->ctx.enc_params.lossless = var_GetBool( p_enc, ENC_CFG_PREFIX ENC_LOSSLESS );
psz_tmp = var_GetString( p_enc, ENC_CFG_PREFIX ENC_PREFILTER );
if( !psz_tmp )
goto error;
else if( !strcmp( psz_tmp, "none" ) ) {
p_sys->ctx.enc_params.prefilter = NO_PF;
}
else if( !strcmp( psz_tmp, "cwm" ) ) {
p_sys->ctx.enc_params.prefilter = CWM;
}
else if( !strcmp( psz_tmp, "rectlp" ) ) {
p_sys->ctx.enc_params.prefilter = RECTLP;
}
else if( !strcmp( psz_tmp, "diaglp" ) ) {
p_sys->ctx.enc_params.prefilter = DIAGLP;
}
else {
msg_Err( p_enc, "Invalid prefilter: %s", psz_tmp );
free( psz_tmp );
goto error;
}
free( psz_tmp );
p_sys->ctx.enc_params.prefilter_strength =
var_GetInteger( p_enc, ENC_CFG_PREFIX ENC_PREFILTER_STRENGTH );
i_tmp = var_GetInteger( p_enc, ENC_CFG_PREFIX ENC_L1SEP );
if( i_tmp > -1 )
p_sys->ctx.enc_params.L1_sep = i_tmp;
i_tmp = var_GetInteger( p_enc, ENC_CFG_PREFIX ENC_L1NUM );
if( i_tmp > -1 )
p_sys->ctx.enc_params.num_L1 = i_tmp;
psz_tmp = var_GetString( p_enc, ENC_CFG_PREFIX ENC_CODINGMODE );
if( !psz_tmp )
goto error;
else if( !strcmp( psz_tmp, "auto" ) ) {
p_sys->b_auto_field_coding = true;
}
else if( !strcmp( psz_tmp, "progressive" ) ) {