本文整理汇总了C++中date_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ date_Init函数的具体用法?C++ date_Init怎么用?C++ date_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenCommon
/**
* Common initialization for decoder and packetizer
*/
static int OpenCommon( decoder_t *p_dec, bool b_packetizer )
{
const vlc_chroma_description_t *dsc =
vlc_fourcc_GetChromaDescription( p_dec->fmt_in.i_codec );
if( dsc == NULL || dsc->plane_count == 0 )
return VLC_EGENERIC;
if( p_dec->fmt_in.video.i_width <= 0 || p_dec->fmt_in.video.i_height == 0 )
{
msg_Err( p_dec, "invalid display size %dx%d",
p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height );
return VLC_EGENERIC;
}
/* Allocate the memory needed to store the decoder's structure */
decoder_sys_t *p_sys = calloc(1, sizeof(*p_sys));
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
if( !p_dec->fmt_in.video.i_visible_width )
p_dec->fmt_in.video.i_visible_width = p_dec->fmt_in.video.i_width;
if( !p_dec->fmt_in.video.i_visible_height )
p_dec->fmt_in.video.i_visible_height = p_dec->fmt_in.video.i_height;
if ( !b_packetizer )
es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
date_Init( &p_sys->pts, p_dec->fmt_out.video.i_frame_rate,
p_dec->fmt_out.video.i_frame_rate_base );
if( p_dec->fmt_out.video.i_frame_rate == 0 ||
p_dec->fmt_out.video.i_frame_rate_base == 0)
{
msg_Warn( p_dec, "invalid frame rate %d/%d, using 25 fps instead",
p_dec->fmt_out.video.i_frame_rate,
p_dec->fmt_out.video.i_frame_rate_base);
date_Init( &p_sys->pts, 25, 1 );
}
for( unsigned i = 0; i < dsc->plane_count; i++ )
{
unsigned pitch = p_dec->fmt_in.video.i_width * dsc->pixel_size
* dsc->p[i].w.num / dsc->p[i].w.den;
unsigned lines = p_dec->fmt_in.video.i_height
* dsc->p[i].h.num / dsc->p[i].h.den;
p_sys->pitches[i] = pitch;
p_sys->lines[i] = lines;
p_sys->size += pitch * lines;
}
p_dec->p_sys = p_sys;
return VLC_SUCCESS;
}
示例2: InitAudioDec
/*****************************************************************************
* InitAudioDec: initialize audio decoder
*****************************************************************************
* The avcodec codec will be opened, some memory allocated.
*****************************************************************************/
int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec *p_codec, int i_codec_id, const char *psz_namecodec )
{
decoder_sys_t *p_sys;
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
{
return VLC_ENOMEM;
}
p_codec->type = AVMEDIA_TYPE_AUDIO;
p_context->codec_type = AVMEDIA_TYPE_AUDIO;
p_context->codec_id = i_codec_id;
p_context->get_buffer = GetAudioBuf;
p_sys->p_context = p_context;
p_sys->p_codec = p_codec;
p_sys->i_codec_id = i_codec_id;
p_sys->psz_namecodec = psz_namecodec;
p_sys->b_delayed_open = true;
// Initialize decoder extradata
InitDecoderConfig( p_dec, p_context);
/* ***** Open the codec ***** */
if( ffmpeg_OpenCodec( p_dec ) < 0 )
{
msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
free( p_sys->p_context->extradata );
free( p_sys );
return VLC_EGENERIC;
}
p_sys->i_reject_count = 0;
p_sys->b_extract = false;
p_sys->i_previous_channels = 0;
p_sys->i_previous_layout = 0;
/* */
p_dec->fmt_out.i_cat = AUDIO_ES;
/* Try to set as much information as possible but do not trust it */
SetupOutputFormat( p_dec, false );
date_Set( &p_sys->end_date, 0 );
if( p_dec->fmt_out.audio.i_rate )
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
else if( p_dec->fmt_in.audio.i_rate )
date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
return VLC_SUCCESS;
}
示例3: SeekSet0
static int SeekSet0 (demux_t *demux)
{
stream_t *stream = demux->s;
demux_sys_t *sys = demux->p_sys;
/* Default SMF tempo is 120BPM, i.e. half a second per quarter note */
date_Init (&sys->pts, sys->ppqn * 2, 1);
date_Set (&sys->pts, VLC_TS_0);
sys->pulse = 0;
sys->tick = VLC_TS_0;
for (unsigned i = 0; i < sys->trackc; i++)
{
mtrk_t *tr = sys->trackv + i;
tr->offset = 0;
tr->next = 0;
/* Why 0xF6 (Tuning Calibration)?
* Because it has zero bytes of data, so the parser will detect the
* error if the first event uses running status. */
tr->running_event = 0xF6;
if (stream_Seek (stream, tr->start)
|| ReadDeltaTime (stream, tr))
{
msg_Err (demux, "fatal parsing error");
return -1;
}
}
return 0;
}
示例4: Open
/*****************************************************************************
* Open: check file and initializes structures
*****************************************************************************/
static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
/* Identify cdg file by extension, as there is no simple way to
* detect it */
if( !demux_IsPathExtension( p_demux, ".cdg" ) && !demux_IsForced( p_demux, "cdg" ) )
return VLC_EGENERIC;
/* CDG file size has to be multiple of CDG_FRAME_SIZE (it works even
* if size is unknown ie 0) */
// if( (stream_Size( p_demux->s ) % CDG_FRAME_SIZE) != 0 )
// {
// msg_Err( p_demux, "Reject CDG file based on its size" );
// return VLC_EGENERIC;
// }
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
/* */
es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_CDG );
p_sys->fmt.video.i_width = 300-2*6;
p_sys->fmt.video.i_height = 216-2*12 ;
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
/* There is CDG_FRAME_RATE frames per second */
date_Init( &p_sys->pts, CDG_FRAME_RATE, 1 );
date_Set( &p_sys->pts, 1 );
return VLC_SUCCESS;
}
示例5: Open
static int Open (vlc_object_t *obj)
{
demux_t *demux = (demux_t *)obj;
demux_sys_t *sys = vlc_malloc(obj, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
es_format_t fmt;
es_format_Init (&fmt, SPU_ES, VLC_CODEC_ITU_T140);
sys->es = es_out_Add (demux->out, &fmt);
unsigned num, den;
if (var_InheritURational (demux, &num, &den, "timecode-fps")
|| !num || !den)
{
msg_Err (demux, "invalid frame rate");
return VLC_EGENERIC;
}
date_Init (&sys->date, num, den);
date_Set (&sys->date, VLC_TS_0);
sys->next_time = VLC_TS_INVALID;
demux->p_sys = sys;
demux->pf_demux = Demux;
demux->pf_control = Control;
return VLC_SUCCESS;
}
示例6: aout_FifoInit
/**
* Initializes the members of a FIFO.
*/
static void aout_FifoInit( aout_fifo_t *p_fifo, uint32_t i_rate )
{
assert( i_rate != 0);
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
date_Init( &p_fifo->end_date, i_rate, 1 );
date_Set( &p_fifo->end_date, VLC_TS_INVALID );
}
示例7: InitAudioDec
/*****************************************************************************
* InitAudioDec: initialize audio decoder
*****************************************************************************
* The avcodec codec will be opened, some memory allocated.
*****************************************************************************/
int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
const AVCodec *p_codec )
{
decoder_sys_t *p_sys;
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys = p_sys = malloc(sizeof(*p_sys)) ) == NULL )
{
return VLC_ENOMEM;
}
p_context->refcounted_frames = true;
p_sys->p_context = p_context;
p_sys->p_codec = p_codec;
p_sys->b_delayed_open = true;
// Initialize decoder extradata
InitDecoderConfig( p_dec, p_context);
/* ***** Open the codec ***** */
if( OpenAudioCodec( p_dec ) < 0 )
{
free( p_sys );
return VLC_EGENERIC;
}
p_sys->i_reject_count = 0;
p_sys->b_extract = false;
p_sys->i_previous_channels = 0;
p_sys->i_previous_layout = 0;
/* */
p_dec->fmt_out.i_cat = AUDIO_ES;
/* Try to set as much information as possible but do not trust it */
SetupOutputFormat( p_dec, false );
date_Set( &p_sys->end_date, VLC_TS_INVALID );
if( p_dec->fmt_out.audio.i_rate )
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
else if( p_dec->fmt_in.audio.i_rate )
date_Init( &p_sys->end_date, p_dec->fmt_in.audio.i_rate, 1 );
p_dec->pf_decode_audio = DecodeAudio;
p_dec->pf_flush = Flush;
return VLC_SUCCESS;
}
示例8: Open
static int Open (vlc_object_t *p_this)
{
decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys;
if (p_dec->fmt_in.i_codec != VLC_CODEC_MIDI)
return VLC_EGENERIC;
char *font_path = var_CreateGetNonEmptyString (p_this, "soundfont");
if (font_path == NULL)
{
msg_Err (p_this, "sound fonts file required for synthesis");
return VLC_EGENERIC;
}
p_dec->pf_decode_audio = DecodeBlock;
p_sys = p_dec->p_sys = malloc (sizeof (*p_sys));
if (p_sys == NULL)
{
free (font_path);
return VLC_ENOMEM;
}
p_sys->settings = new_fluid_settings ();
p_sys->synth = new_fluid_synth (p_sys->settings);
/* FIXME: I bet this is not thread-safe */
p_sys->soundfont = fluid_synth_sfload (p_sys->synth, font_path, 1);
free (font_path);
if (p_sys->soundfont == -1)
{
msg_Err (p_this, "cannot load sound fonts file");
Close (p_this);
return VLC_EGENERIC;
}
p_dec->fmt_out.i_cat = AUDIO_ES;
p_dec->fmt_out.audio.i_rate = 44100;
p_dec->fmt_out.audio.i_channels = 2;
p_dec->fmt_out.audio.i_original_channels =
p_dec->fmt_out.audio.i_physical_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
if (HAVE_FPU)
{
p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
p_dec->fmt_out.audio.i_bitspersample = 32;
p_sys->fixed = false;
}
else
{
p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
p_dec->fmt_out.audio.i_bitspersample = 16;
p_sys->fixed = true;
}
date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1);
date_Set (&p_sys->end_date, 0);
return VLC_SUCCESS;
}
示例9: aout_FifoInit
/*****************************************************************************
* aout_FifoInit : initialize the members of a FIFO
*****************************************************************************/
void aout_FifoInit( aout_instance_t * p_aout, aout_fifo_t * p_fifo,
uint32_t i_rate )
{
AOUT_ASSERT_FIFO_LOCKED;
if( i_rate == 0 )
{
msg_Err( p_aout, "initialising fifo with zero divider" );
}
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
date_Init( &p_fifo->end_date, i_rate, 1 );
}
示例10: Open
/*****************************************************************************
* Open:
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
if( p_dec->fmt_in.i_codec != VLC_CODEC_MJPG )
return VLC_EGENERIC;
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
if( !p_dec->p_sys )
return VLC_ENOMEM;
p_sys->i_next_block_flags = 0;
if( p_dec->fmt_in.video.i_frame_rate &&
p_dec->fmt_in.video.i_frame_rate_base )
{
date_Init( &p_sys->date, p_dec->fmt_in.video.i_frame_rate,
p_dec->fmt_in.video.i_frame_rate_base );
}
else
date_Init( &p_sys->date, 30000, 1001 );
es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
/* Misc init */
packetizer_Init( &p_sys->packetizer,
p_mjpg_startcode, sizeof(p_mjpg_startcode), startcode_Find,
NULL, 0, 295,
PacketizeReset, PacketizeParse, PacketizeValidate, p_dec );
p_dec->pf_packetize = Packetize;
p_dec->pf_flush = PacketizeFlush;
p_dec->pf_get_cc = NULL;
return VLC_SUCCESS;
}
示例11: UpdateAudioFormat
static int UpdateAudioFormat( decoder_t *p_dec )
{
int i_err;
decoder_sys_t *p_sys = p_dec->p_sys;
struct mpg123_frameinfo frame_info;
/* Get details about the stream */
i_err = mpg123_info( p_sys->p_handle, &frame_info );
if( i_err != MPG123_OK )
{
msg_Err( p_dec, "mpg123_info failed: %s",
mpg123_plain_strerror( i_err ) );
return VLC_EGENERIC;
}
p_dec->fmt_out.i_bitrate = frame_info.bitrate * 1000;
switch( frame_info.mode )
{
case MPG123_M_DUAL:
p_dec->fmt_out.audio.i_chan_mode = AOUT_CHANMODE_DUALMONO;
/* fall through */
case MPG123_M_STEREO:
case MPG123_M_JOINT:
p_dec->fmt_out.audio.i_physical_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
break;
case MPG123_M_MONO:
p_dec->fmt_out.audio.i_physical_channels = AOUT_CHAN_CENTER;
break;
default:
return VLC_EGENERIC;
}
aout_FormatPrepare( &p_dec->fmt_out.audio );
/* Date management */
if( p_dec->fmt_out.audio.i_rate != frame_info.rate )
{
p_dec->fmt_out.audio.i_rate = frame_info.rate;
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, 0 );
}
return decoder_UpdateAudioFormat( p_dec );
}
示例12: msg_Info
/*****************************************************************************
* GetOutBuffer:
*****************************************************************************/
static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer )
{
decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t *p_buf;
if( p_dec->fmt_out.audio.i_rate != p_sys->i_rate )
{
msg_Info( p_dec, "DTS channels:%d samplerate:%d bitrate:%d",
p_sys->i_channels, p_sys->i_rate, p_sys->i_bit_rate );
date_Init( &p_sys->end_date, p_sys->i_rate, 1 );
date_Set( &p_sys->end_date, p_sys->i_pts );
}
p_dec->fmt_out.audio.i_rate = p_sys->i_rate;
p_dec->fmt_out.audio.i_channels = p_sys->i_channels;
/* Hack for DTS S/PDIF filter which needs to pad the DTS frames */
p_dec->fmt_out.audio.i_bytes_per_frame =
__MAX( p_sys->i_frame_size, p_sys->i_frame_length * 4 );
p_dec->fmt_out.audio.i_frame_length = p_sys->i_frame_length;
p_dec->fmt_out.audio.i_original_channels = p_sys->i_channels_conf;
p_dec->fmt_out.audio.i_physical_channels =
p_sys->i_channels_conf & AOUT_CHAN_PHYSMASK;
p_dec->fmt_out.i_bitrate = p_sys->i_bit_rate;
if( p_sys->b_packetizer )
{
block_t *p_sout_buffer = GetSoutBuffer( p_dec );
p_buf = p_sout_buffer ? p_sout_buffer->p_buffer : NULL;
*pp_out_buffer = p_sout_buffer;
}
else
{
block_t *p_aout_buffer = GetAoutBuffer( p_dec );
p_buf = p_aout_buffer ? p_aout_buffer->p_buffer : NULL;
*pp_out_buffer = p_aout_buffer;
}
return p_buf;
}
示例13: msg_Dbg
/*****************************************************************************
* GetOutBuffer:
*****************************************************************************/
static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer )
{
decoder_sys_t *p_sys = p_dec->p_sys;
uint8_t *p_buf;
if( p_dec->fmt_out.audio.i_rate != p_sys->frame.i_rate )
{
msg_Dbg( p_dec, "A/52 channels:%d samplerate:%d bitrate:%d",
p_sys->frame.i_channels, p_sys->frame.i_rate, p_sys->frame.i_bitrate );
date_Init( &p_sys->end_date, p_sys->frame.i_rate, 1 );
date_Set( &p_sys->end_date, p_sys->i_pts );
}
p_dec->fmt_out.audio.i_rate = p_sys->frame.i_rate;
p_dec->fmt_out.audio.i_channels = p_sys->frame.i_channels;
if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->frame.i_size )
p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->frame.i_size;
p_dec->fmt_out.audio.i_frame_length = p_sys->frame.i_samples;
p_dec->fmt_out.audio.i_original_channels = p_sys->frame.i_channels_conf;
p_dec->fmt_out.audio.i_physical_channels =
p_sys->frame.i_channels_conf & AOUT_CHAN_PHYSMASK;
p_dec->fmt_out.i_bitrate = p_sys->frame.i_bitrate;
if( p_sys->b_packetizer )
{
block_t *p_sout_buffer = GetSoutBuffer( p_dec );
p_buf = p_sout_buffer ? p_sout_buffer->p_buffer : NULL;
*pp_out_buffer = p_sout_buffer;
}
else
{
aout_buffer_t *p_aout_buffer = GetAoutBuffer( p_dec );
p_buf = p_aout_buffer ? p_aout_buffer->p_buffer : NULL;
*pp_out_buffer = p_aout_buffer;
}
return p_buf;
}
示例14: msg_Dbg
static block_t *GetOutBuffer( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( !p_sys->b_date_set
|| p_dec->fmt_out.audio.i_rate != p_sys->dts.i_rate )
{
msg_Dbg( p_dec, "DTS samplerate:%d bitrate:%d",
p_sys->dts.i_rate, p_sys->dts.i_bitrate );
date_Init( &p_sys->end_date, p_sys->dts.i_rate, 1 );
date_Set( &p_sys->end_date, p_sys->i_pts );
p_sys->b_date_set = true;
}
p_dec->fmt_out.audio.i_rate = p_sys->dts.i_rate;
if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->dts.i_frame_size )
p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->dts.i_frame_size;
p_dec->fmt_out.audio.i_frame_length = p_sys->dts.i_frame_length;
p_dec->fmt_out.audio.i_original_channels = p_sys->dts.i_original_channels;
p_dec->fmt_out.audio.i_physical_channels =
p_sys->dts.i_original_channels & AOUT_CHAN_PHYSMASK;
p_dec->fmt_out.audio.i_channels =
popcount( p_dec->fmt_out.audio.i_physical_channels );
p_dec->fmt_out.i_bitrate = p_sys->dts.i_bitrate;
block_t *p_block = block_Alloc( p_sys->i_input_size );
if( p_block == NULL )
return NULL;
p_block->i_nb_samples = p_sys->dts.i_frame_length;
p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date );
p_block->i_length =
date_Increment( &p_sys->end_date, p_block->i_nb_samples ) - p_block->i_pts;
return p_block;
}
示例15: msg_Dbg
static block_t *GetOutBuffer( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( !p_sys->b_date_set
|| p_dec->fmt_out.audio.i_rate != p_sys->frame.i_rate )
{
msg_Dbg( p_dec, "A/52 channels:%d samplerate:%d bitrate:%d",
p_sys->frame.i_channels, p_sys->frame.i_rate, p_sys->frame.i_bitrate );
date_Init( &p_sys->end_date, p_sys->frame.i_rate, 1 );
date_Set( &p_sys->end_date, p_sys->i_pts );
p_sys->b_date_set = true;
}
p_dec->fmt_out.audio.i_rate = p_sys->frame.i_rate;
p_dec->fmt_out.audio.i_channels = p_sys->frame.i_channels;
if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->frame.i_size )
p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->frame.i_size;
p_dec->fmt_out.audio.i_frame_length = p_sys->frame.i_samples;
p_dec->fmt_out.audio.i_chan_mode = p_sys->frame.i_chan_mode;
p_dec->fmt_out.audio.i_physical_channels = p_sys->frame.i_channels_conf;
p_dec->fmt_out.i_bitrate = p_sys->frame.i_bitrate;
block_t *p_block = block_Alloc( p_sys->frame.i_size );
if( p_block == NULL )
return NULL;
p_block->i_nb_samples = p_sys->frame.i_samples;
p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date );
p_block->i_length =
date_Increment( &p_sys->end_date, p_block->i_nb_samples ) - p_block->i_pts;
return p_block;
}