Commit 8d9ba243 authored by Anuradha Suraparaju's avatar Anuradha Suraparaju Committed by Jean-Baptiste Kempf

Add Dirac encoding support using the Schroedinger library

Modified-by and Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
parent 9862639c
......@@ -62,6 +62,8 @@ Codecs:
* Support for 9bits and 10bits H.264/AVC decoding
* Support for Lagarith Lossless video codec
* Support for 20-bits PCM and DAT-12 (digital magnetic tapes) from RTP
* New module for Dirac encoding, using the faster libschroedinger
The Schroedinger module should be prefered to the Dirac one
Demuxers:
* New images demuxer supporting jpeg, png, targa, xcf, git, tiff, bmp, pcx, lbm
......
......@@ -2879,7 +2879,7 @@ PKG_ENABLE_MODULES_VLC([DIRAC], [], [dirac >= 0.10.0], [dirac encoder], [auto])
dnl
dnl schroedinger decoder plugin (for dirac format video)
dnl
PKG_ENABLE_MODULES_VLC([SCHROEDINGER], [], [schroedinger-1.0 >= 1.0.6], [dirac decoder using schroedinger], [auto])
PKG_ENABLE_MODULES_VLC([SCHROEDINGER], [], [schroedinger-1.0 >= 1.0.10], [dirac decoder and encoder using schroedinger], [auto])
dnl
dnl PNG decoder module
......
......@@ -3,10 +3,11 @@
* (http://www.bbc.co.uk/rd/projects/dirac/index.shtml)
* (http://diracvideo.org)
*****************************************************************************
* Copyright (C) 2008-2010 the VideoLAN team
* Copyright (C) 2008-2011 the VideoLAN team
*
* Authors: Jonathan Rosser <jonathan.rosser@gmail.com>
* David Flynn <davidf at rd dot bbc.co.uk>
* Anuradha Suraparaju <asuraparaju at gmail dot com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -26,14 +27,16 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <assert.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
#include <vlc_sout.h>
#include <vlc_codec.h> /* decoder_DeletePicture */
#include <schroedinger/schro.h>
......@@ -42,6 +45,316 @@
*****************************************************************************/
static int OpenDecoder ( vlc_object_t * );
static void CloseDecoder ( vlc_object_t * );
static int OpenEncoder ( vlc_object_t * );
static void CloseEncoder ( vlc_object_t * );
#define ENC_CFG_PREFIX "sout-schro-"
#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_RATE_CONTROL "rate-control"
#define ENC_RATE_CONTROL_TEXT N_("Rate control method")
#define ENC_RATE_CONTROL_LONGTEXT N_("Method used to encode the video sequence")
static const char *enc_rate_control_list[] = {
"constant_noise_threshold",
"constant_bitrate",
"low_delay",
"lossless",
"constant_lambda",
"constant_error",
"constant_quality"
};
static const char *enc_rate_control_list_text[] = {
N_("Constant noise threshold mode"),
N_("Constant bitrate mode (CBR)"),
N_("Low Delay mode"),
N_("Lossless mode"),
N_("Constant lambda mode"),
N_("Constant error mode"),
N_("Constant quality mode")
};
#define ENC_GOP_STRUCTURE "gop-structure"
#define ENC_GOP_STRUCTURE_TEXT N_("GOP structure")
#define ENC_GOP_STRUCTURE_LONGTEXT N_("GOP structure used to encode the video sequence")
static const char *enc_gop_structure_list[] = {
"adaptive",
"intra_only",
"backref",
"chained_backref",
"biref",
"chained_biref"
};
static const char *enc_gop_structure_list_text[] = {
N_("No fixed gop structure. A picture can be intra or inter and refer to previous or future pictures."),
N_("I-frame only sequence"),
N_("Inter pictures refere to previous pictures only"),
N_("Inter pictures refere to previous pictures only"),
N_("Inter pictures can refer to previous or future pictures"),
N_("Inter pictures can refer to previous or future pictures")
};
#define ENC_QUALITY "quality"
#define ENC_QUALITY_TEXT N_("Constant quality factor")
#define ENC_QUALITY_LONGTEXT N_("Quality factor to use in constant quality mode")
#define ENC_NOISE_THRESHOLD "noise-threshold"
#define ENC_NOISE_THRESHOLD_TEXT N_("Noise Threshold")
#define ENC_NOISE_THRESHOLD_LONGTEXT N_("Noise threshold to use in constant noise threshold mode")
#define ENC_BITRATE "bitrate"
#define ENC_BITRATE_TEXT N_("CBR bitrate (kbps)")
#define ENC_BITRATE_LONGTEXT N_("Target bitrate in kbps when encoding in constant bitrate mode")
#define ENC_MAX_BITRATE "max-bitrate"
#define ENC_MAX_BITRATE_TEXT N_("Maximum bitrate (kbps)")
#define ENC_MAX_BITRATE_LONGTEXT N_("Maximum bitrate in kbps when encoding in constant bitrate mode")
#define ENC_MIN_BITRATE "min-bitrate"
#define ENC_MIN_BITRATE_TEXT N_("Minimum bitrate (kbps)")
#define ENC_MIN_BITRATE_LONGTEXT N_("Minimum bitrate in kbps when encoding in constant bitrate mode")
#define ENC_AU_DISTANCE "gop-length"
#define ENC_AU_DISTANCE_TEXT N_("GOP length")
#define ENC_AU_DISTANCE_LONGTEXT N_("Number of pictures between successive sequenence headers i.e. length of the group of pictures")
#define ENC_PREFILTER "filtering"
#define ENC_PREFILTER_TEXT N_("Prefilter")
#define ENC_PREFILTER_LONGTEXT N_("Enable adaptive prefiltering")
static const char *enc_filtering_list[] = {
"none",
"center_weighted_median",
"gaussian",
"add_noise",
"adaptive_gaussian",
"lowpass"
};
static const char *enc_filtering_list_text[] = {
N_("No pre-filtering"),
N_("Centre Weighted Median"),
N_("Gaussian Low Pass Filter"),
N_("Add Noise"),
N_("Gaussian Adaptive Low Pass Filter"),
N_("Low Pass Ffilter"),
};
#define ENC_PREFILTER_STRENGTH "filter-value"
#define ENC_PREFILTER_STRENGTH_TEXT N_("Amount of prefiltering")
#define ENC_PREFILTER_STRENGTH_LONGTEXT N_("Higher value implies more prefiltering")
#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"),
};
/* advanced option only */
#define ENC_MCBLK_SIZE "motion-block-size"
#define ENC_MCBLK_SIZE_TEXT N_("Size of motion compensation blocks")
static const char *enc_block_size_list[] = {
"automatic",
"small",
"medium",
"large"
};
static const char *const enc_block_size_list_text[] =
{ N_("automatic - let encoder decide based upon input (Best)"),
N_("small - use small motion compensation blocks"),
N_("medium - use medium motion compensation blocks"),
N_("large - use large motion compensation blocks"),
};
/* advanced option only */
#define ENC_MCBLK_OVERLAP "motion-block-overlap"
#define ENC_MCBLK_OVERLAP_TEXT N_("Overlap of motion compensation blocks")
static const char *enc_block_overlap_list[] = {
"automatic",
"none",
"partial",
"full"
};
static const char *const enc_block_overlap_list_text[] =
{ N_("automatic - let encoder decide based upon input (Best)"),
N_("none - Motion compensation blocks do not overlap"),
N_("partial - Motion compensation blocks only partially overlap"),
N_("full - Motion compensation blocks fully overlap"),
};
#define ENC_MVPREC "mv-precision"
#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" };
/* advanced option only */
#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 "intra-wavelet"
#define ENC_DWTINTRA_TEXT N_("Intra picture DWT filter")
#define ENC_DWTINTER "inter-wavelet"
#define ENC_DWTINTER_TEXT N_("Inter picture DWT filter")
static const char *enc_wavelet_list[] = {
"desl_dubuc_9_7",
"le_gall_5_3",
"desl_dubuc_13_7",
"haar_0",
"haar_1",
"fidelity",
"daub_9_7"
};
static const char *enc_wavelet_list_text[] = {
"Deslauriers-Dubuc (9,7)",
"LeGall (5,3)",
"Deslauriers-Dubuc (13,7)",
"Haar with no shift",
"Haar with single shift per level",
"Fidelity filter",
"Daubechies (9,7) integer approximation"
};
#define ENC_DWTDEPTH "transform-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 "enable-multiquant"
#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_NOAC "enable-noarith"
#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_PWT "perceptual-weighting"
#define ENC_PWT_TEXT N_("perceptual weighting method")
static const char *enc_perceptual_weighting_list[] = {
"none",
"ccir959",
"moo",
"manos_sakrison"
};
/* advanced option only */
#define ENC_PDIST "perceptual-distance"
#define ENC_PDIST_TEXT N_("perceptual distance")
#define ENC_PDIST_LONGTEXT N_("perceptual distance to calculate perceptual weight")
/* advanced option only */
#define ENC_HSLICES "horiz-slices"
#define ENC_HSLICES_TEXT N_("Horizontal slices per frame")
#define ENC_HSLICES_LONGTEXT N_("Number of horizontal slices per frame in low delay mode")
/* advanced option only */
#define ENC_VSLICES "vert-slices"
#define ENC_VSLICES_TEXT N_("Vertical slices per frame")
#define ENC_VSLICES_LONGTEXT N_("Number of vertical slices per frame in low delay mode")
/* advanced option only */
#define ENC_SCBLK_SIZE "codeblock-size"
#define ENC_SCBLK_SIZE_TEXT N_("Size of code blocks in each subband")
static const char *enc_codeblock_size_list[] = {
"automatic",
"small",
"medium",
"large",
"full"
};
static const char *const enc_codeblock_size_list_text[] =
{ N_("automatic - let encoder decide based upon input (Best)"),
N_("small - use small code blocks"),
N_("medium - use medium sized code blocks"),
N_("large - use large code blocks"),
N_("full - One code block per subband"),
};
/* advanced option only */
#define ENC_ME_HIERARCHICAL "enable-hierarchical-me"
#define ENC_ME_HIERARCHICAL_TEXT N_("Enable hierarchical Motion Estimation")
/* advanced option only */
#define ENC_ME_DOWNSAMPLE_LEVELS "downsample-levels"
#define ENC_ME_DOWNSAMPLE_LEVELS_TEXT N_("Number of levels of downsampling")
#define ENC_ME_DOWNSAMPLE_LEVELS_LONGTEXT N_("Number of levels of downsampling in hierarchical motion estimation mode")
/* advanced option only */
#define ENC_ME_GLOBAL_MOTION "enable-global-me"
#define ENC_ME_GLOBAL_MOTION_TEXT N_("Enable Global Motion Estimation")
/* advanced option only */
#define ENC_ME_PHASECORR "enable-phasecorr-me"
#define ENC_ME_PHASECORR_TEXT N_("Enable Phase Correlation Estimation")
/* advanced option only */
#define ENC_SCD "enable-scd"
#define ENC_SCD_TEXT N_("Enable Scene Change Detection")
/* advanced option only */
#define ENC_FORCE_PROFILE "force-profile"
#define ENC_FORCE_PROFILE_TEXT N_("Force Profile")
static const char *enc_profile_list[] = {
"auto",
"vc2_low_delay",
"vc2_simple",
"vc2_main",
"main"
};
static const char *const enc_profile_list_text[] =
{ N_("automatic - let encoder decide based upon input (Best)"),
N_("VC2 Low Delay Profile"),
N_("VC2 Simple Profile"),
N_("VC2 Main Profile"),
N_("Main Profile"),
};
static const char *const const ppsz_enc_options[] = {
ENC_RATE_CONTROL, ENC_GOP_STRUCTURE, ENC_QUALITY, ENC_NOISE_THRESHOLD, ENC_BITRATE,
ENC_MIN_BITRATE, ENC_MAX_BITRATE, ENC_AU_DISTANCE, ENC_CHROMAFMT,
ENC_PREFILTER, ENC_PREFILTER_STRENGTH, ENC_CODINGMODE, ENC_MCBLK_SIZE,
ENC_MCBLK_OVERLAP, ENC_MVPREC, ENC_ME_COMBINED, ENC_DWTINTRA, ENC_DWTINTER,
ENC_DWTDEPTH, ENC_MULTIQUANT, ENC_NOAC, ENC_PWT, ENC_PDIST, ENC_HSLICES,
ENC_VSLICES, ENC_SCBLK_SIZE, ENC_ME_HIERARCHICAL, ENC_ME_DOWNSAMPLE_LEVELS,
ENC_ME_GLOBAL_MOTION, ENC_ME_PHASECORR, ENC_SCD, ENC_FORCE_PROFILE,
NULL
};
/* Module declaration */
vlc_module_begin ()
set_category( CAT_INPUT )
......@@ -51,8 +364,163 @@ vlc_module_begin ()
set_capability( "decoder", 200 )
set_callbacks( OpenDecoder, CloseDecoder )
add_shortcut( "schroedinger" )
/* encoder */
add_submodule()
set_section( N_("Encoding") , NULL )
set_description( N_("Dirac video encoder using libschroedinger") )
set_capability( "encoder", 110 )
set_callbacks( OpenEncoder, CloseEncoder )
add_shortcut( "schroedinger", "schro" )
add_string( ENC_CFG_PREFIX ENC_RATE_CONTROL, NULL,
ENC_RATE_CONTROL_TEXT, ENC_RATE_CONTROL_LONGTEXT, false )
change_string_list( enc_rate_control_list, enc_rate_control_list_text, 0 );
add_float( ENC_CFG_PREFIX ENC_QUALITY, -1.,
ENC_QUALITY_TEXT, ENC_QUALITY_LONGTEXT, false )
change_float_range(-1., 10.);
add_float( ENC_CFG_PREFIX ENC_NOISE_THRESHOLD, -1.,
ENC_NOISE_THRESHOLD_TEXT, ENC_NOISE_THRESHOLD_LONGTEXT, false )
change_float_range(-1., 100.);
add_integer( ENC_CFG_PREFIX ENC_BITRATE, -1,
ENC_BITRATE_TEXT, ENC_BITRATE_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_integer( ENC_CFG_PREFIX ENC_MAX_BITRATE, -1,
ENC_MAX_BITRATE_TEXT, ENC_MAX_BITRATE_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_integer( ENC_CFG_PREFIX ENC_MIN_BITRATE, -1,
ENC_MIN_BITRATE_TEXT, ENC_MIN_BITRATE_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
add_string( ENC_CFG_PREFIX ENC_GOP_STRUCTURE, NULL,
ENC_GOP_STRUCTURE_TEXT, ENC_GOP_STRUCTURE_LONGTEXT, false )
change_string_list( enc_gop_structure_list, enc_gop_structure_list_text, 0 );
add_integer( ENC_CFG_PREFIX ENC_AU_DISTANCE, -1,
ENC_AU_DISTANCE_TEXT, ENC_AU_DISTANCE_LONGTEXT, false )
change_integer_range(-1, INT_MAX);
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, 0 );
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, 0 );
add_string( ENC_CFG_PREFIX ENC_MVPREC, NULL,
ENC_MVPREC_TEXT, ENC_MVPREC_LONGTEXT, false )
change_string_list( enc_mvprec_list, enc_mvprec_list, 0 );
/* advanced option only */
add_string( ENC_CFG_PREFIX ENC_MCBLK_SIZE, NULL,
ENC_MCBLK_SIZE_TEXT, ENC_MCBLK_SIZE_TEXT, true )
change_string_list( enc_block_size_list, enc_block_size_list_text, 0 );
/* advanced option only */
add_string( ENC_CFG_PREFIX ENC_MCBLK_OVERLAP, NULL,
ENC_MCBLK_OVERLAP_TEXT, ENC_MCBLK_OVERLAP_TEXT, true )
change_string_list( enc_block_overlap_list, enc_block_overlap_list_text, 0 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_ME_COMBINED, -1,
ENC_ME_COMBINED_TEXT, ENC_ME_COMBINED_LONGTEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_ME_HIERARCHICAL, -1,
ENC_ME_HIERARCHICAL_TEXT, ENC_ME_HIERARCHICAL_TEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_ME_DOWNSAMPLE_LEVELS, -1,
ENC_ME_DOWNSAMPLE_LEVELS_TEXT, ENC_ME_DOWNSAMPLE_LEVELS_LONGTEXT, true )
change_integer_range(-1, 8 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_ME_GLOBAL_MOTION, -1,
ENC_ME_GLOBAL_MOTION_TEXT, ENC_ME_GLOBAL_MOTION_TEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_ME_PHASECORR, -1,
ENC_ME_PHASECORR_TEXT, ENC_ME_PHASECORR_TEXT, true )
change_integer_range(-1, 1 );
add_string( ENC_CFG_PREFIX ENC_DWTINTRA, NULL,
ENC_DWTINTRA_TEXT, ENC_DWTINTRA_TEXT, false )
change_string_list( enc_wavelet_list, enc_wavelet_list_text, 0 );
add_string( ENC_CFG_PREFIX ENC_DWTINTER, NULL,
ENC_DWTINTER_TEXT, ENC_DWTINTER_TEXT, false )
change_string_list( enc_wavelet_list, enc_wavelet_list_text, 0 );
add_integer( ENC_CFG_PREFIX ENC_DWTDEPTH, -1,
ENC_DWTDEPTH_TEXT, ENC_DWTDEPTH_LONGTEXT, false )
change_integer_range(-1, SCHRO_LIMIT_ENCODER_TRANSFORM_DEPTH );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_MULTIQUANT, -1,
ENC_MULTIQUANT_TEXT, ENC_MULTIQUANT_LONGTEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_string( ENC_CFG_PREFIX ENC_SCBLK_SIZE, NULL,
ENC_SCBLK_SIZE_TEXT, ENC_SCBLK_SIZE_TEXT, true )
change_string_list( enc_codeblock_size_list, enc_codeblock_size_list_text, 0 );
add_string( ENC_CFG_PREFIX ENC_PREFILTER, NULL,
ENC_PREFILTER_TEXT, ENC_PREFILTER_LONGTEXT, false )
change_string_list( enc_filtering_list, enc_filtering_list_text, 0 );
add_float( ENC_CFG_PREFIX ENC_PREFILTER_STRENGTH, -1.,
ENC_PREFILTER_STRENGTH_TEXT, ENC_PREFILTER_STRENGTH_LONGTEXT, false )
change_float_range(-1., 100.0);
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_SCD, -1,
ENC_SCD_TEXT, ENC_SCD_TEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_string( ENC_CFG_PREFIX ENC_PWT, NULL,
ENC_PWT_TEXT, ENC_PWT_TEXT, true )
change_string_list( enc_perceptual_weighting_list, enc_perceptual_weighting_list, 0 );
/* advanced option only */
add_float( ENC_CFG_PREFIX ENC_PDIST, -1,
ENC_PDIST_TEXT, ENC_PDIST_LONGTEXT, true )
change_float_range(-1., 100.);
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_NOAC, -1,
ENC_NOAC_TEXT, ENC_NOAC_LONGTEXT, true )
change_integer_range(-1, 1 );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_HSLICES, -1,
ENC_HSLICES_TEXT, ENC_HSLICES_LONGTEXT, true )
change_integer_range(-1, INT_MAX );
/* advanced option only */
add_integer( ENC_CFG_PREFIX ENC_VSLICES, -1,
ENC_VSLICES_TEXT, ENC_VSLICES_LONGTEXT, true )
change_integer_range(-1, INT_MAX );
/* advanced option only */
add_string( ENC_CFG_PREFIX ENC_FORCE_PROFILE, NULL,
ENC_FORCE_PROFILE_TEXT, ENC_FORCE_PROFILE_TEXT, true )
change_string_list( enc_profile_list, enc_profile_list_text, 0 );
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -392,3 +860,742 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
}
}
}
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static block_t *Encode( encoder_t *p_enc, picture_t *p_pict );
/*****************************************************************************
* picture_pts_t : store pts alongside picture number, not carried through
* encoder
*****************************************************************************/
struct picture_pts_t
{
mtime_t i_pts; /* associated pts */
uint32_t u_pnum; /* dirac picture number */
bool b_empty; /* entry is invalid */
};
/*****************************************************************************
* encoder_sys_t : Schroedinger encoder descriptor
*****************************************************************************/
#define SCHRO_PTS_TLB_SIZE 256
struct encoder_sys_t
{
/*
* Schro properties
*/
SchroEncoder *p_schro;
SchroVideoFormat *p_format;
int started;
bool b_auto_field_coding;
uint32_t i_input_picnum;
block_fifo_t *p_dts_fifo;
block_t *p_chain;
struct picture_pts_t pts_tlb[SCHRO_PTS_TLB_SIZE];
mtime_t i_pts_offset;
mtime_t i_field_time;
bool b_eos_signalled;
bool b_eos_pulled;
};
static struct
{
unsigned int i_height;
int i_approx_fps;
SchroVideoFormatEnum i_vf;
} schro_format_guess[] = {
/* Important: Keep this list ordered in ascending picture height */
{1, 0, SCHRO_VIDEO_FORMAT_CUSTOM},
{120, 15, SCHRO_VIDEO_FORMAT_QSIF},
{144, 12, SCHRO_VIDEO_FORMAT_QCIF},
{240, 15, SCHRO_VIDEO_FORMAT_SIF},
{288, 12, SCHRO_VIDEO_FORMAT_CIF},
{480, 30, SCHRO_VIDEO_FORMAT_SD480I_60},
{480, 15, SCHRO_VIDEO_FORMAT_4SIF},
{576, 12, SCHRO_VIDEO_FORMAT_4CIF},
{576, 25, SCHRO_VIDEO_FORMAT_SD576I_50},
{720, 50, SCHRO_VIDEO_FORMAT_HD720P_50},
{720, 60, SCHRO_VIDEO_FORMAT_HD720P_60},
{1080, 24, SCHRO_VIDEO_FORMAT_DC2K_24},
{1080, 25, SCHRO_VIDEO_FORMAT_HD1080I_50},
{1080, 30, SCHRO_VIDEO_FORMAT_HD1080I_60},
{1080, 50, SCHRO_VIDEO_FORMAT_HD1080P_50},
{1080, 60, SCHRO_VIDEO_FORMAT_HD1080P_60},
{2160, 24, SCHRO_VIDEO_FORMAT_DC4K_24},
{0, 0, 0},
};
/*****************************************************************************
* ResetPTStlb: Purge all entries in @p_enc@'s PTS-tlb
*****************************************************************************/
static void ResetPTStlb( encoder_t *p_enc )
{
encoder_sys_t *p_sys = p_enc->p_sys;
for( int i = 0; i < SCHRO_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<SCHRO_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 < SCHRO_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;