本文整理汇总了C++中INT64_C函数的典型用法代码示例。如果您正苦于以下问题:C++ INT64_C函数的具体用法?C++ INT64_C怎么用?C++ INT64_C使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INT64_C函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Control
/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( access_t *p_access, int i_query, va_list args )
{
access_sys_t *p_sys = p_access->p_sys;
input_title_t ***ppp_title;
int i;
switch( i_query )
{
/* */
case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK:
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
*va_arg( args, bool* ) = true;
break;
/* */
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = INT64_C(1000)
* var_InheritInteger(p_access, "disc-caching");
break;
/* */
case ACCESS_SET_PAUSE_STATE:
break;
case ACCESS_GET_TITLE_INFO:
ppp_title = va_arg( args, input_title_t*** );
*va_arg( args, int* ) = p_sys->i_titles;
/* Duplicate title infos */
*ppp_title = malloc( sizeof(input_title_t **) * p_sys->i_titles );
for( i = 0; i < p_sys->i_titles; i++ )
{
(*ppp_title)[i] = vlc_input_title_Duplicate( p_sys->title[i] );
}
break;
case ACCESS_SET_TITLE:
i = va_arg( args, int );
if( i != p_access->info.i_title )
{
/* Update info */
p_access->info.i_update |=
INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT|INPUT_UPDATE_SIZE;
p_access->info.i_title = i;
p_access->info.i_seekpoint = 0;
p_access->info.i_size = p_sys->title[i]->i_size;
p_access->info.i_pos = 0;
/* Next sector to read */
p_sys->i_sector = p_sys->p_sectors[1+i];
}
break;
case ACCESS_SET_SEEKPOINT:
{
input_title_t *t = p_sys->title[p_access->info.i_title];
i = va_arg( args, int );
if( t->i_seekpoint > 0 )
{
p_access->info.i_update |= INPUT_UPDATE_SEEKPOINT;
p_access->info.i_seekpoint = i;
p_sys->i_sector = p_sys->p_sectors[1+p_access->info.i_title] +
t->seekpoint[i]->i_byte_offset / VCD_DATA_SIZE;
p_access->info.i_pos = (uint64_t)(p_sys->i_sector -
p_sys->p_sectors[1+p_access->info.i_title]) *VCD_DATA_SIZE;
}
return VLC_SUCCESS;
}
case ACCESS_SET_PRIVATE_ID_STATE:
case ACCESS_GET_CONTENT_TYPE:
return VLC_EGENERIC;
default:
msg_Warn( p_access, "unimplemented query in control" );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
开发者ID:CSRedRat,项目名称:vlc,代码行数:87,代码来源:vcd.c
示例2: VCDReadBlock
/*****************************************************************************
VCDRead: reads VCD_BLOCKS_ONCE from the VCD and returns that.
NULL is returned if something went wrong.
*****************************************************************************/
static block_t *
VCDReadBlock( access_t * p_access )
{
vcdplayer_t *p_vcdplayer= (vcdplayer_t *)p_access->p_sys;
const int i_blocks = p_vcdplayer->i_blocks_per_read;
block_t *p_block;
int i_read;
uint8_t *p_buf;
dbg_print( (INPUT_DBG_LSN), "lsn: %lu",
(long unsigned int) p_vcdplayer->i_lsn );
/* Allocate a block for the reading */
if( !( p_block = block_Alloc( i_blocks * M2F2_SECTOR_SIZE ) ) )
{
msg_Err( p_access, "cannot get a new block of size: %i",
i_blocks * M2F2_SECTOR_SIZE );
block_Release( p_block );
return NULL;
}
p_buf = (uint8_t *) p_block->p_buffer;
for ( i_read = 0 ; i_read < i_blocks ; i_read++ )
{
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
p_access->info.i_pos += M2F2_SECTOR_SIZE;
switch ( read_status ) {
case READ_END:
/* End reached. Return NULL to indicated this. */
/* We also set the postion to the end so the higher level
(demux?) doesn't try to keep reading. If everything works out
right this shouldn't have to happen.
*/
#if 0
if( p_access->info.i_pos != p_access->info.i_size ) {
msg_Warn( p_access,
"At end but pos (%llu) is not size (%llu). Adjusting.",
p_access->info.i_pos, p_access->info.i_size );
p_access->info.i_pos = p_access->info.i_size;
}
#endif
block_Release( p_block );
return NULL;
case READ_ERROR:
/* Some sort of error. Should we increment lsn? to skip block? */
block_Release( p_block );
return NULL;
case READ_STILL_FRAME:
/* FIXME The below should be done in an event thread.
Until then...
*/
#if 1
msleep( INT64_C(1000) * *p_buf );
VCDSetOrigin(p_access, p_vcdplayer->origin_lsn,
p_vcdplayer->i_track, &(p_vcdplayer->play_item));
// p_vcd->in_still = false;
dbg_print(INPUT_DBG_STILL, "still wait time done");
#endif
block_Release( p_block );
return NULL;
default:
case READ_BLOCK:
/* Read buffer */
break;
}
p_buf += M2F2_SECTOR_SIZE;
/* Update seekpoint */
if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type )
{
size_t i_entry = p_vcdplayer->play_item.num+1;
lsn_t i_lsn = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry);
if ( p_vcdplayer->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LSN )
{
dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC),
"entry change to %zu, current LSN %u >= end %u",
i_entry, p_vcdplayer->i_lsn, i_lsn);
p_vcdplayer->play_item.num = i_entry;
VCDSetOrigin( p_access, i_lsn, p_vcdplayer->i_track,
&(p_vcdplayer->play_item) );
}
}
}
return p_block;
}
开发者ID:BtbN,项目名称:vlc,代码行数:98,代码来源:access.c
示例3: sout_MuxSendBuffer
/*****************************************************************************
* sout_MuxSendBuffer:
*****************************************************************************/
int sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
block_t *p_buffer )
{
block_FifoPut( p_input->p_fifo, p_buffer );
if( p_mux->p_sout->i_out_pace_nocontrol )
{
mtime_t current_date = mdate();
if ( current_date > p_buffer->i_dts )
msg_Warn( p_mux, "late buffer for mux input (%"PRId64")",
current_date - p_buffer->i_dts );
}
if( p_mux->b_waiting_stream )
{
const int64_t i_caching = var_GetInteger( p_mux->p_sout, "sout-mux-caching" ) * INT64_C(1000);
if( p_mux->i_add_stream_start < 0 )
p_mux->i_add_stream_start = p_buffer->i_dts;
/* Wait until we have enought data before muxing */
if( p_mux->i_add_stream_start < 0 ||
p_buffer->i_dts < p_mux->i_add_stream_start + i_caching )
return VLC_SUCCESS;
p_mux->b_waiting_stream = false;
}
return p_mux->pf_mux( p_mux );
}
开发者ID:loganjeon,项目名称:vlc,代码行数:31,代码来源:stream_output.c
示例4: x11grab_read_packet
/**
* Grab a frame from x11 (public device demuxer API).
*
* @param s1 Context from avformat core
* @param pkt Packet holding the brabbed frame
* @return frame size in bytes
*/
static int
x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
{
struct x11_grab *s = s1->priv_data;
Display *dpy = s->dpy;
XImage *image = s->image;
int x_off = s->x_off;
int y_off = s->y_off;
int screen;
Window root;
int follow_mouse = s->follow_mouse;
int64_t curtime, delay;
struct timespec ts;
/* Calculate the time of the next frame */
s->time_frame += INT64_C(1000000);
/* wait based on the frame rate */
for(;;) {
curtime = av_gettime();
delay = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) {
s->time_frame += INT64_C(1000000);
}
break;
}
ts.tv_sec = delay / 1000000;
ts.tv_nsec = (delay % 1000000) * 1000;
nanosleep(&ts, NULL);
}
av_init_packet(pkt);
pkt->data = image->data;
pkt->size = s->frame_size;
pkt->pts = curtime;
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
if (follow_mouse) {
int screen_w, screen_h;
int pointer_x, pointer_y, _;
Window w;
screen_w = DisplayWidth(dpy, screen);
screen_h = DisplayHeight(dpy, screen);
XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
if (follow_mouse == -1) {
// follow the mouse, put it at center of grabbing region
x_off += pointer_x - s->width / 2 - x_off;
y_off += pointer_y - s->height / 2 - y_off;
} else {
// follow the mouse, but only move the grabbing region when mouse
// reaches within certain pixels to the edge.
if (pointer_x > x_off + s->width - follow_mouse) {
x_off += pointer_x - (x_off + s->width - follow_mouse);
} else if (pointer_x < x_off + follow_mouse)
x_off -= (x_off + follow_mouse) - pointer_x;
if (pointer_y > y_off + s->height - follow_mouse) {
y_off += pointer_y - (y_off + s->height - follow_mouse);
} else if (pointer_y < y_off + follow_mouse)
y_off -= (y_off + follow_mouse) - pointer_y;
}
// adjust grabbing region position if it goes out of screen.
s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
if (s->show_region && s->region_win)
XMoveWindow(dpy, s->region_win,
s->x_off - REGION_WIN_BORDER,
s->y_off - REGION_WIN_BORDER);
}
if (s->show_region) {
if (s->region_win) {
XEvent evt;
// clean up the events, and do the initinal draw or redraw.
for (evt.type = NoEventMask; XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, &evt); );
if (evt.type)
x11grab_draw_region_win(s);
} else {
x11grab_region_win_init(s);
}
}
if(s->use_shm) {
if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes)) {
av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n");
}
} else {
if (!xget_zpixmap(dpy, root, image, x_off, y_off)) {
//.........这里部分代码省略.........
开发者ID:Tjoppen,项目名称:FFmpeg,代码行数:101,代码来源:x11grab.c
示例5: Control
/*****************************************************************************
* Control input stream
*****************************************************************************/
static int Control( access_t *p_access, int i_query, va_list args )
{
access_sys_t *p_sys = p_access->p_sys;
input_title_t ***ppp_title;
int i;
int64_t *pi64;
vlc_meta_t *p_meta;
switch( i_query )
{
case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK:
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_SIZE:
*va_arg( args, uint64_t* ) = p_sys->size;
break;
case ACCESS_GET_PTS_DELAY:
pi64 = va_arg( args, int64_t * );
*pi64 = INT64_C(1000)
* var_InheritInteger( p_access, "file-caching" );
break;
case ACCESS_SET_PAUSE_STATE:
/* nothing to do */
break;
case ACCESS_GET_TITLE_INFO:
/* return a copy of our seek points */
if( !p_sys->p_marks )
return VLC_EGENERIC;
ppp_title = va_arg( args, input_title_t*** );
*va_arg( args, int* ) = 1;
*ppp_title = malloc( sizeof( **ppp_title ) );
if( !*ppp_title )
return VLC_ENOMEM;
**ppp_title = vlc_input_title_Duplicate( p_sys->p_marks );
break;
case ACCESS_GET_TITLE:
*va_arg( args, unsigned * ) = 0;
break;
case ACCESS_GET_SEEKPOINT:
*va_arg( args, unsigned * ) = p_sys->cur_seekpoint;
break;
case ACCESS_SET_TITLE:
/* ignore - only one title */
break;
case ACCESS_SET_SEEKPOINT:
i = va_arg( args, int );
return Seek( p_access, p_sys->p_marks->seekpoint[i]->i_byte_offset );
case ACCESS_GET_META:
if( !p_sys->p_meta )
return VLC_EGENERIC;
p_meta = va_arg( args, vlc_meta_t* );
vlc_meta_Merge( p_meta, p_sys->p_meta );
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
开发者ID:Aakash-729,项目名称:vlc,代码行数:74,代码来源:vdr.c
示例6: TEST
// Load data from constant file and check for exact match.
TEST(bits, reverseBytes)
{
{
uint8_t val = 0x88, val_r;
const uint8_t val_r_ok = 0x88;
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
int8_t val = 0x66, val_r;
const int8_t val_r_ok = 0x66;
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
uint16_t val = 0x1122, val_r;
const uint16_t val_r_ok = 0x2211;
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
int16_t val = 0x1122, val_r;
const int16_t val_r_ok = 0x2211;
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
uint32_t val = UINT32_C(0x11223344), val_r;
const uint32_t val_r_ok = UINT32_C(0x44332211);
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
int32_t val = INT32_C(0x11223344), val_r;
const int32_t val_r_ok = INT32_C(0x44332211);
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
uint64_t val = UINT64_C(0x1122334455667788), val_r;
const uint64_t val_r_ok = UINT64_C(0x8877665544332211);
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
int64_t val = INT64_C(0x1122334455667766), val_r;
const int64_t val_r_ok = INT64_C(0x6677665544332211);
mrpt::reverseBytes(val, val_r);
EXPECT_EQ(val_r, val_r_ok);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, val_r_ok);
}
{
bool valTrue = true;
bool valFalse = false;
mrpt::reverseBytesInPlace(valTrue);
mrpt::reverseBytesInPlace(valFalse);
EXPECT_TRUE(valTrue);
EXPECT_FALSE(valFalse);
}
{
uint8_t val = UINT8_C(0xc1);
mrpt::reverseBytesInPlace(val);
EXPECT_EQ(val, 0xc1);
}
{
//1.0 == 0x3F800000
float val = 1;
const uint32_t val_r_ok = UINT32_C(0x803f);
mrpt::reverseBytesInPlace(val);
uint32_t val_check = *reinterpret_cast<uint32_t*>(&val);
EXPECT_EQ(val_check, val_r_ok);
}
{
//1.0 == 0x3ff0000000000000
//.........这里部分代码省略.........
开发者ID:Jarlene,项目名称:mrpt,代码行数:101,代码来源:reverse_bytes_unittest.cpp
示例7: avi_write_header
static int avi_write_header(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *stream, *video_enc;
int64_t list1, list2, strh, strf;
AVDictionaryEntry *t = NULL;
if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
AVI_MAX_STREAM_COUNT);
return -1;
}
for(n=0;n<s->nb_streams;n++) {
s->streams[n]->priv_data= av_mallocz(sizeof(AVIStream));
if(!s->streams[n]->priv_data)
return AVERROR(ENOMEM);
}
/* header list */
avi->riff_id = 0;
list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl");
/* avi header */
ffio_wfourcc(pb, "avih");
avio_wl32(pb, 14 * 4);
bitrate = 0;
video_enc = NULL;
for(n=0;n<s->nb_streams;n++) {
stream = s->streams[n]->codec;
bitrate += stream->bit_rate;
if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
video_enc = stream;
}
nb_frames = 0;
if(video_enc){
avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
} else {
avio_wl32(pb, 0);
}
avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
avio_wl32(pb, 0); /* padding */
if (!pb->seekable)
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
else
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
avi->frames_hdr_all = avio_tell(pb); /* remember this offset to fill later */
avio_wl32(pb, nb_frames); /* nb frames, filled later */
avio_wl32(pb, 0); /* initial frame */
avio_wl32(pb, s->nb_streams); /* nb streams */
avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
if(video_enc){
avio_wl32(pb, video_enc->width);
avio_wl32(pb, video_enc->height);
} else {
avio_wl32(pb, 0);
avio_wl32(pb, 0);
}
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
/* stream list */
for(i=0;i<n;i++) {
AVIStream *avist= s->streams[i]->priv_data;
list2 = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "strl");
stream = s->streams[i]->codec;
/* stream generic header */
strh = ff_start_tag(pb, "strh");
switch(stream->codec_type) {
case AVMEDIA_TYPE_SUBTITLE:
// XSUB subtitles behave like video tracks, other subtitles
// are not (yet) supported.
if (stream->codec_id != CODEC_ID_XSUB) {
av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
return AVERROR_PATCHWELCOME;
}
case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
// case AVMEDIA_TYPE_TEXT : ffio_wfourcc(pb, "txts"); break;
case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
}
if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
stream->codec_id == CODEC_ID_XSUB)
avio_wl32(pb, stream->codec_tag);
else
avio_wl32(pb, 1);
avio_wl32(pb, 0); /* flags */
avio_wl16(pb, 0); /* priority */
avio_wl16(pb, 0); /* language */
avio_wl32(pb, 0); /* initial frame */
//.........这里部分代码省略.........
开发者ID:AdamCDunlap,项目名称:hmc-robot-drivers,代码行数:101,代码来源:avienc.c
示例8: qDebug
//.........这里部分代码省略.........
volumeOptionOffset = _currentPacket->pos();
quint8 volume = MAX_INJECTOR_VOLUME;
audioPacketStream << volume;
audioPacketStream << _options.ignorePenumbra;
audioDataOffset = _currentPacket->pos();
} else {
// no samples to inject, return immediately
qDebug() << "AudioInjector::injectNextFrame() called with no samples to inject. Returning.";
return NEXT_FRAME_DELTA_ERROR_OR_FINISHED;
}
}
if (!_frameTimer->isValid()) {
// in the case where we have been restarted, the frame timer will be invalid and we need to start it back over here
_frameTimer->restart();
}
int totalBytesLeftToCopy = (_options.stereo ? 2 : 1) * AudioConstants::NETWORK_FRAME_BYTES_PER_CHANNEL;
if (!_options.loop) {
// If we aren't looping, let's make sure we don't read past the end
totalBytesLeftToCopy = std::min(totalBytesLeftToCopy, _audioData.size() - _currentSendOffset);
}
// Measure the loudness of this frame
_loudness = 0.0f;
for (int i = 0; i < totalBytesLeftToCopy; i += sizeof(int16_t)) {
_loudness += abs(*reinterpret_cast<int16_t*>(_audioData.data() + ((_currentSendOffset + i) % _audioData.size()))) /
(AudioConstants::MAX_SAMPLE_VALUE / 2.0f);
}
_loudness /= (float)(totalBytesLeftToCopy/ sizeof(int16_t));
_currentPacket->seek(0);
// pack the sequence number
_currentPacket->writePrimitive(_outgoingSequenceNumber);
_currentPacket->seek(positionOptionOffset);
_currentPacket->writePrimitive(_options.position);
_currentPacket->writePrimitive(_options.orientation);
quint8 volume = MAX_INJECTOR_VOLUME * _options.volume;
_currentPacket->seek(volumeOptionOffset);
_currentPacket->writePrimitive(volume);
_currentPacket->seek(audioDataOffset);
while (totalBytesLeftToCopy > 0) {
int bytesToCopy = std::min(totalBytesLeftToCopy, _audioData.size() - _currentSendOffset);
_currentPacket->write(_audioData.data() + _currentSendOffset, bytesToCopy);
_currentSendOffset += bytesToCopy;
totalBytesLeftToCopy -= bytesToCopy;
if (_options.loop && _currentSendOffset >= _audioData.size()) {
_currentSendOffset = 0;
}
}
// set the correct size used for this packet
_currentPacket->setPayloadSize(_currentPacket->pos());
// grab our audio mixer from the NodeList, if it exists
auto nodeList = DependencyManager::get<NodeList>();
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
if (audioMixer) {
// send off this audio packet
nodeList->sendUnreliablePacket(*_currentPacket, *audioMixer);
_outgoingSequenceNumber++;
}
if (_currentSendOffset >= _audioData.size() && !_options.loop) {
finish();
return NEXT_FRAME_DELTA_ERROR_OR_FINISHED;
}
if (!_hasSentFirstFrame) {
_hasSentFirstFrame = true;
// ask AudioInjectorManager to call us right away again to
// immediately send the first two frames so the mixer can start using the audio right away
return NEXT_FRAME_DELTA_IMMEDIATELY;
}
const int MAX_ALLOWED_FRAMES_TO_FALL_BEHIND = 7;
int64_t currentTime = _frameTimer->nsecsElapsed() / 1000;
auto currentFrameBasedOnElapsedTime = currentTime / AudioConstants::NETWORK_FRAME_USECS;
if (currentFrameBasedOnElapsedTime - _nextFrame > MAX_ALLOWED_FRAMES_TO_FALL_BEHIND) {
// If we are falling behind by more frames than our threshold, let's skip the frames ahead
qDebug() << this << "injectNextFrame() skipping ahead, fell behind by " << (currentFrameBasedOnElapsedTime - _nextFrame) << " frames";
_nextFrame = currentFrameBasedOnElapsedTime;
_currentSendOffset = _nextFrame * AudioConstants::NETWORK_FRAME_BYTES_PER_CHANNEL * (_options.stereo ? 2 : 1) % _audioData.size();
}
int64_t playNextFrameAt = ++_nextFrame * AudioConstants::NETWORK_FRAME_USECS;
return std::max(INT64_C(0), playNextFrameAt - currentTime);
}
开发者ID:toloudis,项目名称:hifi,代码行数:101,代码来源:AudioInjector.cpp
示例9: stdscan_reset
//.........这里部分代码省略.........
if (is_just_unknown(value)) { /* it's immediate but unknown */
result->oprs[operand].type |= IMMEDIATE;
result->oprs[operand].opflags |= OPFLAG_UNKNOWN;
result->oprs[operand].offset = 0; /* don't care */
result->oprs[operand].segment = NO_SEG; /* don't care again */
result->oprs[operand].wrt = NO_SEG; /* still don't care */
if(optimizing >= 0 && !(result->oprs[operand].type & STRICT)) {
/* Be optimistic */
result->oprs[operand].type |=
SBYTE16 | SBYTE32 | SBYTE64 | UDWORD64 | SDWORD64;
}
} else if (is_reloc(value)) { /* it's immediate */
result->oprs[operand].type |= IMMEDIATE;
result->oprs[operand].offset = reloc_value(value);
result->oprs[operand].segment = reloc_seg(value);
result->oprs[operand].wrt = reloc_wrt(value);
if (is_simple(value)) {
if (reloc_value(value) == 1)
result->oprs[operand].type |= UNITY;
if (optimizing >= 0 &&
!(result->oprs[operand].type & STRICT)) {
int64_t v64 = reloc_value(value);
int32_t v32 = (int32_t)v64;
int16_t v16 = (int16_t)v32;
if (v64 >= -128 && v64 <= 127)
result->oprs[operand].type |= SBYTE64;
if (v32 >= -128 && v32 <= 127)
result->oprs[operand].type |= SBYTE32;
if (v16 >= -128 && v16 <= 127)
result->oprs[operand].type |= SBYTE16;
if ((uint64_t)v64 <= UINT64_C(0xffffffff))
result->oprs[operand].type |= UDWORD64;
if (v64 >= -INT64_C(0x80000000) &&
v64 <= INT64_C(0x7fffffff))
result->oprs[operand].type |= SDWORD64;
}
}
} else { /* it's a register */
unsigned int rs;
if (value->type >= EXPR_SIMPLE || value->value != 1) {
nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = I_none;
return result;
}
/*
* check that its only 1 register, not an expression...
*/
for (i = 1; value[i].type; i++)
if (value[i].value) {
nasm_error(ERR_NONFATAL, "invalid operand type");
result->opcode = I_none;
return result;
}
/* clear overrides, except TO which applies to FPU regs */
if (result->oprs[operand].type & ~TO) {
/*
* we want to produce a warning iff the specified size
* is different from the register size
*/
rs = result->oprs[operand].type & SIZE_MASK;
开发者ID:gurry,项目名称:ProcPlay,代码行数:67,代码来源:parser.c
示例10: test_virtio_serial
static void
test_virtio_serial (void)
{
int fd, r, eh;
char tmpfile[] = "/tmp/speedtestXXXXXX";
struct sigaction sa, old_sa;
if (!virtio_serial_upload && !virtio_serial_download)
return;
/* Create a sparse file. We could upload from /dev/zero, but we
* won't get progress messages because libguestfs tests if the
* source file is a regular file.
*/
fd = mkstemp (tmpfile);
if (fd == -1)
error (EXIT_FAILURE, errno, "mkstemp: %s", tmpfile);
if (ftruncate (fd, TEST_SERIAL_MAX_SIZE) == -1)
error (EXIT_FAILURE, errno, "ftruncate");
if (close (fd) == -1)
error (EXIT_FAILURE, errno, "close");
g = guestfs_create ();
if (!g)
error (EXIT_FAILURE, errno, "guestfs_create");
if (guestfs_add_drive_scratch (g, INT64_C (100*1024*1024), -1) == -1)
exit (EXIT_FAILURE);
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
/* Make and mount a filesystem which will be used by the download test. */
if (guestfs_mkfs (g, "ext4", "/dev/sda") == -1)
exit (EXIT_FAILURE);
if (guestfs_mount (g, "/dev/sda", "/") == -1)
exit (EXIT_FAILURE);
/* Time out the upload after TEST_SERIAL_MAX_TIME seconds have passed. */
memset (&sa, 0, sizeof sa);
sa.sa_handler = stop_transfer;
sa.sa_flags = SA_RESTART;
sigaction (SIGALRM, &sa, &old_sa);
/* Get progress messages, which will tell us how much data has been
* transferred.
*/
eh = guestfs_set_event_callback (g, progress_cb, GUESTFS_EVENT_PROGRESS,
0, NULL);
if (eh == -1)
exit (EXIT_FAILURE);
if (virtio_serial_upload) {
gettimeofday (&start, NULL);
rate = -1;
operation = "upload";
alarm (max_time_override > 0 ? max_time_override : TEST_SERIAL_MAX_TIME);
/* For the upload test, upload the sparse file to /dev/null in the
* appliance. Hopefully this is mostly testing just virtio-serial.
*/
guestfs_push_error_handler (g, NULL, NULL);
r = guestfs_upload (g, tmpfile, "/dev/null");
alarm (0);
unlink (tmpfile);
guestfs_pop_error_handler (g);
/* It's possible that the upload will finish before the alarm fires,
* or that the upload will be stopped by the alarm.
*/
if (r == -1 && guestfs_last_errno (g) != EINTR) {
fprintf (stderr,
"%s: expecting upload command to return EINTR\n%s\n",
guestfs_int_program_name, guestfs_last_error (g));
exit (EXIT_FAILURE);
}
if (rate == -1) {
rate_error:
fprintf (stderr, "%s: internal error: progress callback was not called! (r=%d, errno=%d)\n",
guestfs_int_program_name,
r, guestfs_last_errno (g));
exit (EXIT_FAILURE);
}
print_rate ("virtio-serial upload rate:", rate);
}
if (virtio_serial_download) {
/* For the download test, download a sparse file within the
* appliance to /dev/null on the host.
*/
if (guestfs_touch (g, "/sparse") == -1)
exit (EXIT_FAILURE);
if (guestfs_truncate_size (g, "/sparse", TEST_SERIAL_MAX_SIZE) == -1)
exit (EXIT_FAILURE);
gettimeofday (&start, NULL);
rate = -1;
operation = "download";
//.........这里部分代码省略.........
开发者ID:AlphaStaxLLC,项目名称:libguestfs,代码行数:101,代码来源:qemu-speed-test.c
示例11: test_block_device
static void
test_block_device (void)
{
int fd;
char tmpfile[] = "/tmp/speedtestXXXXXX";
CLEANUP_FREE char **devices = NULL;
char *r;
const char *argv[4];
int t = max_time_override > 0 ? max_time_override : TEST_BLOCK_DEVICE_TIME;
char tbuf[64];
int64_t bytes_written, bytes_read;
if (!block_device_write && !block_device_read)
return;
snprintf (tbuf, sizeof tbuf, "%d", t);
g = guestfs_create ();
if (!g)
error (EXIT_FAILURE, errno, "guestfs_create");
/* Create a fully allocated backing file. Note we are not testing
* the speed of allocation on the host.
*/
fd = mkstemp (tmpfile);
if (fd == -1)
error (EXIT_FAILURE, errno, "mkstemp: %s", tmpfile);
close (fd);
if (guestfs_disk_create (g, tmpfile, "raw",
INT64_C (1024*1024*1024),
GUESTFS_DISK_CREATE_PREALLOCATION, "full",
-1) == -1)
exit (EXIT_FAILURE);
if (guestfs_add_drive (g, tmpfile) == -1)
exit (EXIT_FAILURE);
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
devices = guestfs_list_devices (g);
if (devices == NULL)
exit (EXIT_FAILURE);
if (devices[0] == NULL) {
fprintf (stderr, "%s: expected guestfs_list_devices to return at least 1 device\n",
guestfs_int_program_name);
exit (EXIT_FAILURE);
}
if (block_device_write) {
/* Test write speed. */
argv[0] = devices[0];
argv[1] = "w";
argv[2] = tbuf;
argv[3] = NULL;
r = guestfs_debug (g, "device_speed", (char **) argv);
if (r == NULL)
exit (EXIT_FAILURE);
if (sscanf (r, "%" SCNi64, &bytes_written) != 1) {
fprintf (stderr, "%s: could not parse device_speed output\n",
guestfs_int_program_name);
exit (EXIT_FAILURE);
}
print_rate ("block device writes:", bytes_written / t);
}
if (block_device_read) {
/* Test read speed. */
argv[0] = devices[0];
argv[1] = "r";
argv[2] = tbuf;
argv[3] = NULL;
r = guestfs_debug (g, "device_speed", (char **) argv);
if (r == NULL)
exit (EXIT_FAILURE);
if (sscanf (r, "%" SCNi64, &bytes_read) != 1) {
fprintf (stderr, "%s: could not parse device_speed output\n",
guestfs_int_program_name);
exit (EXIT_FAILURE);
}
print_rate ("block device reads:", bytes_read / t);
}
if (guestfs_shutdown (g) == -1)
exit (EXIT_FAILURE);
guestfs_close (g);
/* Remove temporary file. */
unlink (tmpfile);
}
开发者ID:AlphaStaxLLC,项目名称:libguestfs,代码行数:96,代码来源:qemu-speed-test.c
示例12: avi_write_header
static int avi_write_header(AVFormatContext *s)
{
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *video_enc;
AVStream *video_st = NULL;
int64_t list1, list2, strh, strf;
AVDictionaryEntry *t = NULL;
int padding;
if (s->nb_streams > AVI_MAX_STREAM_COUNT) {
av_log(s, AV_LOG_ERROR, "AVI does not support >%d streams\n",
AVI_MAX_STREAM_COUNT);
return AVERROR(EINVAL);
}
for (n = 0; n < s->nb_streams; n++) {
s->streams[n]->priv_data = av_mallocz(sizeof(AVIStream));
if (!s->streams[n]->priv_data)
return AVERROR(ENOMEM);
}
/* header list */
avi->riff_id = 0;
list1 = avi_start_new_riff(s, pb, "AVI ", "hdrl");
/* avi header */
ffio_wfourcc(pb, "avih");
avio_wl32(pb, 14 * 4);
bitrate = 0;
video_enc = NULL;
for (n = 0; n < s->nb_streams; n++) {
AVCodecContext *codec = s->streams[n]->codec;
bitrate += codec->bit_rate;
if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_enc = codec;
video_st = s->streams[n];
}
}
nb_frames = 0;
// TODO: should be avg_frame_rate
if (video_st)
avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_st->time_base.num /
video_st->time_base.den));
else
avio_wl32(pb, 0);
avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
avio_wl32(pb, 0); /* padding */
if (!pb->seekable)
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
else
avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
avi->frames_hdr_all = avio_tell(pb); /* remember this offset to fill later */
avio_wl32(pb, nb_frames); /* nb frames, filled later */
avio_wl32(pb, 0); /* initial frame */
avio_wl32(pb, s->nb_streams); /* nb streams */
avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
if (video_enc) {
avio_wl32(pb, video_enc->width);
avio_wl32(pb, video_enc->height);
} else {
avio_wl32(pb, 0);
avio_wl32(pb, 0);
}
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
avio_wl32(pb, 0); /* reserved */
/* stream list */
for (i = 0; i < n; i++) {
AVStream *st = s->streams[i];
AVCodecContext *enc = st->codec;
AVIStream *avist = st->priv_data;
list2 = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "strl");
/* stream generic header */
strh = ff_start_tag(pb, "strh");
switch (enc->codec_type) {
case AVMEDIA_TYPE_SUBTITLE:
// XSUB subtitles behave like video tracks, other subtitles
// are not (yet) supported.
if (enc->codec_id != AV_CODEC_ID_XSUB) {
av_log(s, AV_LOG_ERROR,
"Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
return AVERROR_PATCHWELCOME;
}
case AVMEDIA_TYPE_VIDEO:
ffio_wfourcc(pb, "vids");
break;
case AVMEDIA_TYPE_AUDIO:
ffio_wfourcc(pb, "auds");
break;
// case AVMEDIA_TYPE_TEXT:
// ffio_wfourcc(pb, "txts");
//.........这里部分代码省略.........
开发者ID:FatCat1411,项目名称:opencvr,代码行数:101,代码来源:avienc.c
示例13: _pv_resize_single
//.........这里部分代码省略.........
goto bad;
}
pv = pvl->pv;
if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
log_error("Can't get info for PV %s in volume group %s",
pv_name, vg->name);
goto bad;
}
mda_count = dm_list_size(&info->mdas);
if (!archive(vg))
goto bad;
}
/* FIXME Create function to test compatibility properly */
if (mda_count > 1) {
log_error("%s: too many metadata areas for pvresize", pv_name);
goto bad;
}
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
pv_name);
goto bad;
}
/* Get new size */
if (!dev_get_size(pv_dev(pv), &size)) {
log_error("%s: Couldn't get size.", pv_name);
goto bad;
}
if (new_size) {
if (new_size > size)
log_warn("WARNING: %s: Overriding real size. "
"You could lose data.", pv_name);
log_verbose("%s: Pretending size is %" PRIu64 " not %" PRIu64
" sectors.", pv_name, new_size, pv_size(pv));
size = new_size;
}
if (size < PV_MIN_SIZE) {
log_error("%s: Size must exceed minimum of %ld sectors.",
pv_name, PV_MIN_SIZE);
goto bad;
}
if (size < pv_pe_start(pv)) {
log_error("%s: Size must exceed physical extent start of "
"%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
goto bad;
}
pv->size = size;
if (vg) {
pv->size -= pv_pe_start(pv);
new_pe_count = pv_size(pv) / vg->extent_size;
if (!new_pe_count) {
log_error("%s: Size must leave space for at "
"least one physical extent of "
"%" PRIu32 " sectors.", pv_name,
pv_pe_size(pv));
goto bad;
}
if (!pv_resize(pv, vg, new_pe_count))
goto_bad;
}
log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
pv_name, pv_size(pv));
log_verbose("Updating physical volume \"%s\"", pv_name);
if (!is_orphan_vg(pv_vg_name(pv))) {
if (!vg_write(vg) || !vg_commit(vg)) {
log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name);
goto bad;
}
backup(vg);
} else if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
log_error("Failed to store physical volume \"%s\"",
pv_name);
goto bad;;
}
log_print("Physical volume \"%s\" changed", pv_name);
r = 1;
bad:
unlock_vg(cmd, vg_name);
if (!old_vg)
vg_release(vg);
return r;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:101,代码来源:pvresize.c
示例14: verify_same_types
verify_same_types (INT8_MAX, (int8_t) 0 + 0);
int16_t a2[3] = { INT16_C (17), INT16_MIN, INT16_MAX };
verify (TYPE_MINIMUM (int16_t) == INT16_MIN);
verify (TYPE_MAXIMUM (int16_t) == INT16_MAX);
verify_same_types (INT16_MIN, (int16_t) 0 + 0);
verify_same_types (INT16_MAX, (int16_t) 0 + 0);
int32_t a3[3] = { INT32_C (17), INT32_MIN, INT32_MAX };
verify (TYPE_MINIMUM (int32_t) == INT32_MIN);
verify (TYPE_MAXIMUM (int32_t) == INT32_MAX);
verify_same_types (INT32_MIN, (int32_t) 0 + 0);
verify_same_types (INT32_MAX, (int32_t) 0 + 0);
#ifdef INT64_MAX
int64_t a4[3] = { INT64_C (17), INT64_MIN, INT64_MAX };
verify (TYPE_MINIMUM (int64_t) == INT64_MIN);
verify (TYPE_MAXIMUM (int64_t) == INT64_MAX);
verify_same_types (INT64_MIN, (int64_t) 0 + 0);
verify_same_types (INT64_MAX, (int64_t) 0 + 0);
#endif
uint8_t b1[2] = { UINT8_C (17), UINT8_MAX };
verify (TYPE_MAXIMUM (uint8_t) == UINT8_MAX);
verify_same_types (UINT8_MAX, (uint8_t) 0 + 0);
uint16_t b2[2] = { UINT16_C (17), UINT16_MAX };
verify (TYPE_MAXIMUM (uint16_t) == UINT16_MAX);
verify_same_types (UINT16_MAX, (uint16_t) 0 + 0);
uint32_t b3[2] = { UINT32_C (17), UINT32_MAX };
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:31,代码来源:test-stdint.c
示例15: check_mult_div
//.........这里部分代码省略.........
a, b, "expected %s got %s = %s * %s for mult exact");
/* Force 128-bit math to come into play */
for (j = 1; j < 31; j++)
{
a = gnc_numeric_create(na << j, 1 << j);
b = gnc_numeric_create(nb << j, 1 << j);
check_binary_op (gnc_numeric_create(ne, 1),
gnc_numeric_mul(a, b, GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE),
a, b, "expected %s got %s = %s * %s for mult reduce");
}
/* Do some hokey random 128-bit division too */
b = gnc_numeric_create(deno, nb);
check_binary_op_equal (gnc_numeric_create(ne, 1),
gnc_numeric_div(a, b, GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT),
a, b, "expected %s got %s = %s / %s for div exact");
/* avoid overflow; */
na /= 2;
nb /= 2;
ne = na * nb;
for (j = 1; j < 16; j++)
{
a = gnc_numeric_create(na << j, 1 << j);
b = gnc_numeric_create(1 << j, nb << j);
check_binary_op (gnc_numeric_create(ne, 1),
gnc_numeric_div(a, b, GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE),
a, b, "expected %s got %s = %s / %s for div reduce");
}
}
a = gnc_numeric_create(INT64_C(1173888083434299), 93773);
b = gnc_numeric_create(INT64_C(2222554708930978), 89579);
/* Dividing the above pair overflows, in that after
* the division the denominator won't fit into a
* 64-bit quantity. This can be seen from
* the factorization into primes:
* 1173888083434299 = 3 * 2283317 * 171371749
* (yes, thats a seven and a nine digit prime)
* 2222554708930978 = 2 * 1111277354465489
* (yes, that's a sixteen-digit prime number)
* 93773 = 79*1187
* 89579 = 67*7*191
* If the rounding method is exact/no-round, then
* an overflow error should be si
|
请发表评论