本文整理汇总了C++中date_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ date_Init函数的具体用法?C++ date_Init怎么用?C++ date_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了date_Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:chouquette,项目名称:vlc,代码行数:56,代码来源:rawvideo.c
示例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;
}
开发者ID:andronmobi,项目名称:vlc-parrot-asteroid,代码行数:56,代码来源:audio.c
示例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;
}
开发者ID:839687571,项目名称:vlc-2.2.1.32-2013,代码行数:32,代码来源:smf.c
示例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;
}
开发者ID:FLYKingdom,项目名称:vlc,代码行数:38,代码来源:cdg.c
示例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;
}
开发者ID:IAPark,项目名称:vlc,代码行数:29,代码来源:timecode.c
示例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 );
}
开发者ID:RodrigoNieves,项目名称:vlc,代码行数:11,代码来源:packet.c
示例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;
}
开发者ID:maniacs-m,项目名称:vlc,代码行数:51,代码来源:audio.c
示例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;
}
开发者ID:shanewfx,项目名称:vlc-arib,代码行数:58,代码来源:fluidsynth.c
示例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 );
}
开发者ID:iamnpc,项目名称:myfaplayer,代码行数:17,代码来源:common.c
示例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;
}
开发者ID:mstorsjo,项目名称:vlc,代码行数:40,代码来源:mjpeg.c
示例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 );
}
开发者ID:chouquette,项目名称:vlc,代码行数:46,代码来源:mpg123.c
示例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;
}
开发者ID:9034725985,项目名称:vlc,代码行数:45,代码来源:dts.c
示例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;
}
开发者ID:RicoP,项目名称:vlcfork,代码行数:44,代码来源:a52.c
示例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;
}
开发者ID:etix,项目名称:vlc,代码行数:38,代码来源:dts.c
示例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;
}
开发者ID:IAPark,项目名称:vlc,代码行数:36,代码来源:a52.c
示例16: Open
static int Open(vlc_object_t *object)
{
demux_t *demux = (demux_t*)object;
/* Detect the image type */
const image_format_t *img;
const uint8_t *peek;
int peek_size = 0;
for (int i = 0; ; i++) {
img = &formats[i];
if (!img->codec)
return VLC_EGENERIC;
if (img->detect) {
if (img->detect(demux->s))
break;
} else {
if (peek_size < img->marker_size)
peek_size = stream_Peek(demux->s, &peek, img->marker_size);
if (peek_size >= img->marker_size &&
!memcmp(peek, img->marker, img->marker_size))
break;
}
}
msg_Dbg(demux, "Detected image: %s",
vlc_fourcc_GetDescription(VIDEO_ES, img->codec));
if( img->codec == VLC_CODEC_MXPEG )
{
return VLC_EGENERIC; //let avformat demux this file
}
/* Load and if selected decode */
es_format_t fmt;
es_format_Init(&fmt, VIDEO_ES, img->codec);
fmt.video.i_chroma = fmt.i_codec;
block_t *data = Load(demux);
if (data && var_InheritBool(demux, "image-decode")) {
char *string = var_InheritString(demux, "image-chroma");
vlc_fourcc_t chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES, string);
free(string);
data = Decode(demux, &fmt.video, chroma, data);
fmt.i_codec = fmt.video.i_chroma;
}
fmt.i_id = var_InheritInteger(demux, "image-id");
fmt.i_group = var_InheritInteger(demux, "image-group");
if (var_InheritURational(demux,
&fmt.video.i_frame_rate,
&fmt.video.i_frame_rate_base,
"image-fps") ||
fmt.video.i_frame_rate <= 0 || fmt.video.i_frame_rate_base <= 0) {
msg_Err(demux, "Invalid frame rate, using 10/1 instead");
fmt.video.i_frame_rate = 10;
fmt.video.i_frame_rate_base = 1;
}
/* If loadind failed, we still continue to avoid mis-detection
* by other demuxers. */
if (!data)
msg_Err(demux, "Failed to load the image");
/* */
demux_sys_t *sys = malloc(sizeof(*sys));
if (!sys) {
if (data)
block_Release(data);
es_format_Clean(&fmt);
return VLC_ENOMEM;
}
sys->data = data;
sys->es = es_out_Add(demux->out, &fmt);
sys->duration = CLOCK_FREQ * var_InheritFloat(demux, "image-duration");
sys->is_realtime = var_InheritBool(demux, "image-realtime");
sys->pts_origin = sys->is_realtime ? mdate() : 0;
sys->pts_next = VLC_TS_INVALID;
date_Init(&sys->pts, fmt.video.i_frame_rate, fmt.video.i_frame_rate_base);
date_Set(&sys->pts, 0);
es_format_Clean(&fmt);
demux->pf_demux = Demux;
demux->pf_control = Control;
demux->p_sys = sys;
return VLC_SUCCESS;
}
开发者ID:jomanmuk,项目名称:vlc-2.2,代码行数:89,代码来源:image.c
示例17: ProcessInitialHeader
/*****************************************************************************
* ProcessInitialHeader: processes the inital Opus header packet.
*****************************************************************************/
static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket )
{
int err;
unsigned char new_stream_map[8];
decoder_sys_t *p_sys = p_dec->p_sys;
OpusHeader *p_header = &p_sys->header;
if( !opus_header_parse((unsigned char *)p_oggpacket->packet,p_oggpacket->bytes,p_header) )
{
msg_Err( p_dec, "cannot read Opus header" );
return VLC_EGENERIC;
}
msg_Dbg( p_dec, "Opus audio with %d channels", p_header->channels);
if((p_header->channels>2 && p_header->channel_mapping==0) ||
(p_header->channels>8 && p_header->channel_mapping==1) ||
p_header->channel_mapping>1)
{
msg_Err( p_dec, "Unsupported channel mapping" );
return VLC_EGENERIC;
}
/* Setup the format */
p_dec->fmt_out.audio.i_physical_channels =
p_dec->fmt_out.audio.i_original_channels =
pi_channels_maps[p_header->channels];
p_dec->fmt_out.audio.i_channels = p_header->channels;
p_dec->fmt_out.audio.i_rate = 48000;
if( p_header->channels>2 && p_header->channels<9 )
{
static const uint32_t *pi_ch[6] = { pi_3channels_in, pi_4channels_in,
pi_5channels_in, pi_6channels_in,
pi_7channels_in, pi_8channels_in };
uint8_t pi_chan_table[AOUT_CHAN_MAX];
aout_CheckChannelReorder( pi_ch[p_header->channels-3], NULL,
p_dec->fmt_out.audio.i_physical_channels,
pi_chan_table );
for(int i=0;i<p_header->channels;i++)
new_stream_map[pi_chan_table[i]]=p_header->stream_map[i];
}
/* Opus decoder init */
p_sys->p_st = opus_multistream_decoder_create( 48000, p_header->channels,
p_header->nb_streams, p_header->nb_coupled,
p_header->channels>2?new_stream_map:p_header->stream_map,
&err );
if( !p_sys->p_st || err!=OPUS_OK )
{
msg_Err( p_dec, "decoder initialization failed" );
return VLC_EGENERIC;
}
#ifdef OPUS_SET_GAIN
if( opus_multistream_decoder_ctl( p_sys->p_st,OPUS_SET_GAIN(p_header->gain) ) != OPUS_OK )
{
msg_Err( p_dec, "OPUS_SET_GAIN failed" );
opus_multistream_decoder_destroy( p_sys->p_st );
return VLC_EGENERIC;
}
#endif
date_Init( &p_sys->end_date, 48000, 1 );
return VLC_SUCCESS;
}
开发者ID:MSalmo,项目名称:vlc,代码行数:70,代码来源:opus.c
示例18: date_Get
/*****************************************************************************
* DecodeFrame: decodes an lpcm frame.
****************************************************************************
* Beware, this function must be fed with complete frames (PES packet).
*****************************************************************************/
static void *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
unsigned int i_rate = 0, i_original_channels = 0, i_channels = 0, i_bits = 0;
int i_frame_length;
if( !pp_block || !*pp_block ) return NULL;
p_block = *pp_block;
*pp_block = NULL; /* So the packet doesn't get re-sent */
/* Date management */
if( p_block->i_pts > 0 &&
p_block->i_pts != date_Get( &p_sys->end_date ) )
{
date_Set( &p_sys->end_date, p_block->i_pts );
}
if( !date_Get( &p_sys->end_date ) )
{
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
return NULL;
}
if( p_block->i_buffer <= p_sys->i_header_size )
{
msg_Err(p_dec, "frame is too short");
block_Release( p_block );
return NULL;
}
int i_ret;
unsigned i_padding = 0;
aob_group_t p_aob_group[2];
switch( p_sys->i_type )
{
case LPCM_VOB:
i_ret = VobHeader( &i_rate, &i_channels, &i_original_channels, &i_bits,
p_block->p_buffer );
break;
case LPCM_AOB:
i_ret = AobHeader( &i_rate, &i_channels, &i_original_channels, &i_bits, &i_padding,
p_aob_group,
p_block->p_buffer );
break;
case LPCM_BD:
i_ret = BdHeader( &i_rate, &i_channels, &i_original_channels, &i_bits,
p_block->p_buffer );
break;
default:
assert(0);
}
if( i_ret || p_block->i_buffer <= p_sys->i_header_size + i_padding )
{
msg_Warn( p_dec, "no frame sync or too small frame" );
block_Release( p_block );
return NULL;
}
/* Set output properties */
if( p_dec->fmt_out.audio.i_rate != i_rate )
{
date_Init( &p_sys->end_date, i_rate, 1 );
date_Set( &p_sys->end_date, p_block->i_pts );
}
p_dec->fmt_out.audio.i_rate = i_rate;
p_dec->fmt_out.audio.i_channels = i_channels;
p_dec->fmt_out.audio.i_original_channels = i_original_channels;
p_dec->fmt_out.audio.i_physical_channels = i_original_channels & AOUT_CHAN_PHYSMASK;
i_frame_length = (p_block->i_buffer - p_sys->i_header_size - i_padding) / i_channels * 8 / i_bits;
if( p_sys->b_packetizer )
{
p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date );
p_block->i_length =
date_Increment( &p_sys->end_date, i_frame_length ) -
p_block->i_pts;
/* Just pass on the incoming frame */
return p_block;
}
else
{
/* */
if( i_bits == 16 )
{
p_dec->fmt_out.i_codec = VLC_CODEC_S16B;
p_dec->fmt_out.audio.i_bitspersample = 16;
}
else
{
//.........这里部分代码省略.........
开发者ID:shanewfx,项目名称:vlc-arib,代码行数:101,代码来源:lpcm.c
示例19: OpenDecoder
//.........这里部分代码省略.........
/* Allocate the memory needed to store the decoder's structure */
p_sys = malloc(sizeof(*p_sys));
if( unlikely(p_sys == NULL) )
return VLC_ENOMEM;
p_sys->prev = NULL;
switch( p_dec->fmt_in.i_codec )
{
case VLC_FOURCC('i','m','a', '4'): /* IMA ADPCM */
p_sys->codec = ADPCM_IMA_QT;
break;
case VLC_CODEC_ADPCM_IMA_WAV: /* IMA ADPCM */
p_sys->codec = ADPCM_IMA_WAV;
break;
case VLC_CODEC_ADPCM_MS: /* MS ADPCM */
p_sys->codec = ADPCM_MS;
break;
case VLC_CODEC_ADPCM_DK4: /* Duck DK4 ADPCM */
p_sys->codec = ADPCM_DK4;
break;
case VLC_CODEC_ADPCM_DK3: /* Duck DK3 ADPCM */
p_sys->codec = ADPCM_DK3;
break;
case VLC_FOURCC('X','A','J', 0): /* EA ADPCM */
p_sys->codec = ADPCM_EA;
p_sys->prev = calloc( 2 * p_dec->fmt_in.audio.i_channels,
sizeof( int16_t ) );
if( unlikely(p_sys->prev == NULL) )
{
free( p_sys );
return VLC_ENOMEM;
}
break;
}
if( p_dec->fmt_in.audio.i_blockalign <= 0 )
{
p_sys->i_block = (p_sys->codec == ADPCM_IMA_QT) ?
34 * p_dec->fmt_in.audio.i_channels : 1024;
msg_Warn( p_dec, "block size undefined, using %zu", p_sys->i_block );
}
else
{
p_sys->i_block = p_dec->fmt_in.audio.i_blockalign;
}
/* calculate samples per block */
switch( p_sys->codec )
{
case ADPCM_IMA_QT:
p_sys->i_samplesperblock = 64;
break;
case ADPCM_IMA_WAV:
p_sys->i_samplesperblock =
2 * ( p_sys->i_block - 4 * p_dec->fmt_in.audio.i_channels ) /
p_dec->fmt_in.audio.i_channels;
break;
case ADPCM_MS:
p_sys->i_samplesperblock =
2 * (p_sys->i_block - 7 * p_dec->fmt_in.audio.i_channels) /
p_dec->fmt_in.audio.i_channels + 2;
break;
case ADPCM_DK4:
p_sys->i_samplesperblock =
2 * (p_sys->i_block - 4 * p_dec->fmt_in.audio.i_channels) /
p_dec->fmt_in.audio.i_channels + 1;
break;
case ADPCM_DK3:
p_dec->fmt_in.audio.i_channels = 2;
p_sys->i_samplesperblock = ( 4 * ( p_sys->i_block - 16 ) + 2 )/ 3;
break;
case ADPCM_EA:
p_sys->i_samplesperblock =
2 * (p_sys->i_block - p_dec->fmt_in.audio.i_channels) /
p_dec->fmt_in.audio.i_channels;
}
msg_Dbg( p_dec, "format: samplerate:%d Hz channels:%d bits/sample:%d "
"blockalign:%zu samplesperblock:%zu",
p_dec->fmt_in.audio.i_rate, p_dec->fmt_in.audio.i_channels,
p_dec->fmt_in.audio.i_bitspersample, p_sys->i_block,
p_sys->i_samplesperblock );
p_dec->p_sys = p_sys;
p_dec->fmt_out.i_cat = AUDIO_ES;
p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
p_dec->fmt_out.audio.i_rate = p_dec->fmt_in.audio.i_rate;
p_dec->fmt_out.audio.i_channels = p_dec->fmt_in.audio.i_channels;
p_dec->fmt_out.audio.i_physical_channels =
p_dec->fmt_out.audio.i_original_channels =
pi_channels_maps[p_dec->fmt_in.audio.i_channels];
date_Init( &p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1 );
date_Set( &p_sys->end_date, 0 );
p_dec->pf_decode_audio = DecodeBlock;
return VLC_SUCCESS;
}
开发者ID:9034725985,项目名称:vlc,代码行数:101,代码来源:adpcm.c
示例20: dirac_encoder_init
/****************************************************************************
* Encode: the whole thing
****************************************************************************
* This function spits out encapsulation units.
****************************************************************************/
static block_t *Encode( encoder_t *p_enc, picture_t *p_pic )
{
encoder_sys_t *p_sys = p_enc->p_sys;
block_t *p_block, *p_output_chain = NULL;
int i_plane, i_line, i_width, i_src_stride;
uint8_t *p_dst;
if( !p_pic ) return NULL;
/* we only know if the sequence is interlaced when the first
* picture arrives, so final setup is done here */
/* XXX todo, detect change of interlace */
p_sys->ctx.src_params.topfieldfirst = p_pic->b_top_field_first;
p_sys->ctx.src_params.source_sampling = !p_pic->b_progressive;
if( p_sys->b_auto_field_coding )
p_sys->ctx.enc_params.picture_coding_mode = !p_pic->b_progressive;
if( !p_sys->p_dirac )
{
date_t date;
/* Initialise the encoder with the encoder context */
p_sys->p_dirac = dirac_encoder_init( &p_sys->ctx, 0 );
if( !p_sys->p_dirac )
{
msg_Err( p_enc, "Failed to initialize dirac encoder" );
return NULL;
}
date_Init( &date, p_enc->fmt_in.video.i_frame_rate, p_enc->fmt_in.video.i_frame_rate_base );
#if DIRAC_RESEARCH_VERSION_ATLEAST(1,0,2)
int i_delayinpics = dirac_encoder_pts_offset( p_sys->p_dirac );
i_delayinpics /= p_sys->ctx.enc_params.picture_coding_mode + 1;
date_Increment( &date, i_delayinpics );
#else
date_Increment( &date, 1 );
#endif
p_sys->i_pts_offset = date_Get( &date );
/* picture_coding_mode = 1 == FIELD_CODING, two pictures are produced
* for each frame input. Calculate time between fields for offsetting
* the second field later. */
if( 1 == p_sys->ctx.enc_params.picture_coding_mode )
{
date_Set( &date, 0 );
date_Increment( &date, 1 );
p_sys->i_field_time = date_Get( &date ) / 2;
}
}
/* Copy input picture into encoder input buffer (stride by stride) */
/* Would be lovely to just pass the picture in, but there is noway for the
* library to free it */
p_dst = p_sys->p_buffer_in;
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
uint8_t *p_src = p_pic->p[i_plane].p_pixels;
i_width = p_pic->p[i_plane].i_visible_pitch;
i_src_stride = p_pic->p[i_plane].i_pitch;
for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
{
|
请发表评论