本文整理匯總了Golang中C.int64_t函數的典型用法代碼示例。如果您正苦於以下問題:Golang int64_t函數的具體用法?Golang int64_t怎麽用?Golang int64_t使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了int64_t函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encodeVideo
func (c *Encoder) encodeVideo(f *Frame) *Packet {
f.avframe.pts = C.int64_t(f.Pts.Time)
for i := 0; i < f.frame_count; i++ {
f.avframe.pts = C.int64_t(c.last_dts)
esize := avcodec_encode_video(&c.Ctx, c.buffer, &c.buffer_size, f)
c.last_dts++
if esize > 0 {
var result Packet //=new(Packet)
av_init_packet(&result)
result.Size = esize
result.Data = make([]byte, esize+8)
for i := 0; i < esize; i++ {
result.Data[i] = c.buffer[i]
}
result.Stream = c.stream_index
result.Duration = Timestamp{int64(c.Ctx.ctx.ticks_per_frame), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
result.Flags = 0
if c.Ctx.ctx.coded_frame != nil {
if c.Ctx.ctx.coded_frame.key_frame == 1 {
result.Flags |= 0x0001
}
result.Pts = Timestamp{int64(c.Ctx.ctx.coded_frame.pts), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
result.Dts = Timestamp{int64(c.last_dts), Rational{int(c.Ctx.ctx.time_base.num), int(c.Ctx.ctx.time_base.den)}}
if c.Track != nil {
c.Track.WritePacket(&result)
}
}
}
}
return nil
}
示例2: SeekFile
func (this *FmtCtx) SeekFile(ist *Stream, minTs, maxTs int64, flag int) error {
if ret := int(C.avformat_seek_file(this.avCtx, C.int(ist.Index()), C.int64_t(0), C.int64_t(minTs), C.int64_t(maxTs), C.int(flag))); ret < 0 {
return errors.New(fmt.Sprintf("Error creating output context: %s", AvError(ret)))
}
return nil
}
示例3: Open
// Open creates options and opens the database. If the database
// doesn't yet exist at the specified directory, one is initialized
// from scratch. The RocksDB Open and Close methods are reference
// counted such that subsequent Open calls to an already opened
// RocksDB instance only bump the reference count. The RocksDB is only
// closed when a sufficient number of Close calls are performed to
// bring the reference count down to 0.
func (r *RocksDB) Open() error {
if r.rdb != nil {
return nil
}
if len(r.dir) != 0 {
log.Infof("opening rocksdb instance at %q", r.dir)
}
status := C.DBOpen(&r.rdb, goToCSlice([]byte(r.dir)),
C.DBOptions{
cache_size: C.int64_t(r.cacheSize),
memtable_budget: C.int64_t(r.memtableBudget),
allow_os_buffer: C.bool(true),
logging_enabled: C.bool(log.V(3)),
})
err := statusToError(status)
if err != nil {
return util.Errorf("could not open rocksdb instance: %s", err)
}
// Start a gorountine that will finish when the underlying handle
// is deallocated. This is used to check a leak in tests.
go func() {
<-r.deallocated
}()
r.stopper.AddCloser(r)
return nil
}
示例4: routine
func (m *Muxer) routine() {
vFrame := C.alloc_video_frame(m.videoStream.stream.codec)
if vFrame == (*C.AVFrame)(null) {
m.done <- true
return
}
aFrame := C.alloc_audio_frame(m.audioStream.stream.codec)
if aFrame == (*C.AVFrame)(null) {
m.done <- true
return
}
for m.loop {
if C.av_compare_ts(C.int64_t(m.videoStream.ts), m.videoStream.stream.codec.time_base,
C.int64_t(m.audioStream.ts), m.audioStream.stream.codec.time_base) <= 0 {
m.writeVideoFrame(vFrame)
} else {
m.writeAudioFrame(aFrame)
}
time.Sleep(time.Millisecond * 30)
}
if vFrame != (*C.AVFrame)(null) {
C.av_frame_free(&vFrame)
}
if aFrame != (*C.AVFrame)(null) {
C.av_frame_free(&aFrame)
}
m.done <- true
}
示例5: myseek
//export myseek
func myseek(archive *C.struct_archive, client_data unsafe.Pointer, request C.int64_t, whence C.int) C.int64_t {
reader := (*Reader)(client_data)
offset, err := reader.reader.Seek(int64(request), int(whence))
if err != nil {
return C.int64_t(0)
}
return C.int64_t(offset)
}
示例6: valueToXpc
// valueToXpc converts a go Value to an xpc object
//
// note that not all the types are supported, but only the subset required for Blued
func valueToXpc(val r.Value) C.xpc_object_t {
if !val.IsValid() {
return nil
}
var xv C.xpc_object_t
switch val.Kind() {
case r.Int, r.Int8, r.Int16, r.Int32, r.Int64:
xv = C.xpc_int64_create(C.int64_t(val.Int()))
case r.Uint, r.Uint8, r.Uint16, r.Uint32:
xv = C.xpc_int64_create(C.int64_t(val.Uint()))
case r.String:
xv = C.xpc_string_create(C.CString(val.String()))
case r.Map:
xv = C.xpc_dictionary_create(nil, nil, 0)
for _, k := range val.MapKeys() {
v := valueToXpc(val.MapIndex(k))
C.xpc_dictionary_set_value(xv, C.CString(k.String()), v)
if v != nil {
C.xpc_release(v)
}
}
case r.Array, r.Slice:
if val.Type() == TYPE_OF_UUID {
// array of bytes
var uuid [16]byte
r.Copy(r.ValueOf(uuid[:]), val)
xv = C.xpc_uuid_create(C.ptr_to_uuid(unsafe.Pointer(&uuid[0])))
} else if val.Type() == TYPE_OF_BYTES {
// slice of bytes
xv = C.xpc_data_create(unsafe.Pointer(val.Pointer()), C.size_t(val.Len()))
} else {
xv = C.xpc_array_create(nil, 0)
l := val.Len()
for i := 0; i < l; i++ {
v := valueToXpc(val.Index(i))
C.xpc_array_append_value(xv, v)
if v != nil {
C.xpc_release(v)
}
}
}
case r.Interface, r.Ptr:
xv = valueToXpc(val.Elem())
default:
log.Fatalf("unsupported %#v", val.String())
}
return xv
}
示例7: convertSet
func (client *Client) convertSet(set interface{}) (*C.char, C.size_t, C.enum_hyperdatatype, error) {
C_ds_set := C.hyperdex_ds_allocate_set(client.arena)
var C_ds_status C.enum_hyperdex_ds_returncode
switch vals := set.(type) {
case Set:
for _, val := range vals {
t := reflect.TypeOf(val)
v := reflect.ValueOf(val)
switch t.Kind() {
case reflect.String:
C_string := C.CString(v.String())
C_size_t := C.size_t(v.Len())
C.hyperdex_ds_set_insert_string(C_ds_set,
C_string, C_size_t, &C_ds_status)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32,
reflect.Int64:
C.hyperdex_ds_set_insert_int(C_ds_set,
C.int64_t(v.Int()), &C_ds_status)
case reflect.Float32, reflect.Float64:
C.hyperdex_ds_set_insert_float(C_ds_set,
C.double(v.Float()), &C_ds_status)
default:
return nil, 0, 0, fmt.Errorf("Unsupported type within set %s", t.String())
}
if C_ds_status != C.HYPERDEX_DS_SUCCESS {
return nil, 0, 0, fmt.Errorf("DS error: %d", C_ds_status)
}
}
case SetStr:
for _, val := range vals {
C_string := C.CString(val)
C_size_t := C.size_t(bytesOf(val))
C.hyperdex_ds_set_insert_string(C_ds_set,
C_string, C_size_t, &C_ds_status)
}
case SetI64:
for _, val := range vals {
C.hyperdex_ds_set_insert_int(C_ds_set,
C.int64_t(val), &C_ds_status)
}
case SetF64:
for _, val := range vals {
C.hyperdex_ds_set_insert_float(C_ds_set,
C.double(val), &C_ds_status)
}
}
var C_string *C.char
var C_size_t C.size_t
var C_datatype C.enum_hyperdatatype
C.hyperdex_ds_set_finalize(C_ds_set, &C_ds_status,
&C_string, &C_size_t, &C_datatype)
return C_string, C_size_t, C_datatype, nil
}
示例8: put
// called by rpc
func (p *cacheEntry) put(item *specs.RrdItem) {
p.Lock()
defer p.Unlock()
p.e.lastTs = C.int64_t(item.TimeStemp)
idx := p.e.dataId & CACHE_SIZE_MASK
p.e.time[idx] = C.int64_t(item.TimeStemp)
p.e.value[idx] = C.double(item.Value)
p.e.dataId += 1
}
示例9: Window
func (fh *FileHandleIMP) Window(window FileWindow, offset, length int64) error {
self := (*C.lucy_FileHandle)(clownfish.Unwrap(fh, "fh"))
windowC := (*C.lucy_FileWindow)(clownfish.Unwrap(window, "window"))
success := C.LUCY_FH_Window(self, windowC, C.int64_t(offset), C.int64_t(length))
if !success {
cfErr := C.cfish_Err_get_error()
return clownfish.WRAPAny(unsafe.Pointer(C.cfish_incref(unsafe.Pointer(cfErr)))).(error)
}
return nil
}
示例10: bind
func (stmt *Stmt) bind(args []driver.Value) error {
c := stmt.c
parameterCount := int(stmt.parameterCount)
if parameterCount == 0 || len(args) == 0 {
return nil
}
parameters := make([]C.struct_nuodb_value, parameterCount)
for i, v := range args {
if i >= parameterCount {
break // go1.0.3 allowed extra args; ignore
}
var vt C.enum_nuodb_value_type
var i32 C.int32_t
var i64 C.int64_t
switch v := v.(type) {
case int64:
vt = C.NUODB_TYPE_INT64
i64 = C.int64_t(v)
case float64:
vt = C.NUODB_TYPE_FLOAT64
i64 = *(*C.int64_t)(unsafe.Pointer(&v))
case bool:
vt = C.NUODB_TYPE_BOOL
if v {
i64 = 1
} else {
i64 = 0
}
case string:
vt = C.NUODB_TYPE_STRING
b := []byte(v)
args[i] = b // ensure the b is not GC'ed before the _bind
i32 = C.int32_t(len(v))
i64 = C.int64_t(uintptr(unsafe.Pointer(&b[0])))
case []byte:
vt = C.NUODB_TYPE_BYTES
i32 = C.int32_t(len(v))
i64 = C.int64_t(uintptr(unsafe.Pointer(&v[0])))
case time.Time:
vt = C.NUODB_TYPE_TIME
i32 = C.int32_t(v.Nanosecond())
i64 = C.int64_t(v.Unix()) // seconds
default:
vt = C.NUODB_TYPE_NULL
}
parameters[i].i64 = i64
parameters[i].i32 = i32
parameters[i].vt = vt
}
if C.nuodb_statement_bind(c.db, stmt.st,
(*C.struct_nuodb_value)(unsafe.Pointer(¶meters[0]))) != 0 {
return c.lastError()
}
return nil
}
示例11: Reopen
func (in *InStreamIMP) Reopen(fileName string, offset int64, length int64) (InStream, error) {
var retval InStream
err := clownfish.TrapErr(func() {
self := (*C.lucy_InStream)(clownfish.Unwrap(in, "in"))
fileNameCF := (*C.cfish_String)(clownfish.GoToClownfish(fileName, unsafe.Pointer(C.CFISH_STRING), true))
defer C.cfish_decref(unsafe.Pointer(fileNameCF))
retvalCF := C.LUCY_InStream_Reopen(self, fileNameCF,
C.int64_t(offset), C.int64_t(length))
retval = WRAPInStream(unsafe.Pointer(retvalCF))
})
return retval, err
}
示例12: node_to_go
func node_to_go(node *C.mpv_node) (interface{}, error) {
switch node.format {
case FormatFlag:
if C.node_get_int64(node) != 0 {
return true, nil
} else {
return false, nil
}
case FormatInt64:
value := C.node_get_int64(node)
return int64(value), nil
case FormatDouble:
value := C.node_get_double(node)
return float64(value), nil
case FormatString:
value := C.node_get_string(node)
return C.GoString(value), nil
case FormatNodeArray:
var value []interface{}
for i := C.int64_t(0); i < C.node_get_map_len(node); i++ {
cval := C.node_get_map_val(node, i)
val, _ := node_to_go(cval)
value = append(value, val)
}
return value, nil
case FormatNodeMap:
value := map[string]interface{}{}
for i := C.int64_t(0); i < C.node_get_map_len(node); i++ {
ckey := C.node_get_map_key(node, i)
cval := C.node_get_map_val(node, i)
key := C.GoString(ckey)
val, _ := node_to_go(cval)
value[key] = val
}
return value, nil
}
return nil, fmt.Errorf("Unsupported type")
}
示例13: Serialize
// Serializes a message to OSC wire format.
// If a unsupported type is encountered, serialization
// will be stopped.
func Serialize(m *Message) ([]byte, error) {
msg := C.lo_message_new()
for i, param := range m.Params {
switch x := param.(type) {
case int32:
C.lo_message_add_int32(msg, C.int32_t(x))
case int64:
C.lo_message_add_int64(msg, C.int64_t(x))
case float32:
C.lo_message_add_float(msg, C.float(x))
case float64:
C.lo_message_add_double(msg, C.double(x))
case string:
cstr := C.CString(x)
defer C.free(unsafe.Pointer(cstr))
C.lo_message_add_string(msg, cstr)
default:
return nil, fmt.Errorf("Parameter %d has invalid type", i)
}
}
cpath := C.CString(m.Path)
defer C.free(unsafe.Pointer(cpath))
var size int
tmpbuffer := C.lo_message_serialise(msg, cpath, unsafe.Pointer(nil), (*C.size_t)(unsafe.Pointer((&size))))
defer C.free(unsafe.Pointer(tmpbuffer))
longbuffer := C.GoBytes(tmpbuffer, C.int(size))
shortbuffer := make([]byte, size)
copy(shortbuffer, longbuffer)
return shortbuffer, nil
}
示例14: Open
// Open creates options and opens the database. If the database
// doesn't yet exist at the specified directory, one is initialized
// from scratch. The RocksDB Open and Close methods are reference
// counted such that subsequent Open calls to an already opened
// RocksDB instance only bump the reference count. The RocksDB is only
// closed when a sufficient number of Close calls are performed to
// bring the reference count down to 0.
func (r *RocksDB) Open() error {
if r.rdb != nil {
atomic.AddInt32(&r.refcount, 1)
return nil
}
if len(r.dir) == 0 {
log.Infof("opening in-memory rocksdb instance")
} else {
log.Infof("opening rocksdb instance at %q", r.dir)
}
status := C.DBOpen(&r.rdb, goToCSlice([]byte(r.dir)),
C.DBOptions{
cache_size: C.int64_t(r.cacheSize),
allow_os_buffer: C.bool(true),
logging_enabled: C.bool(log.V(3)),
})
err := statusToError(status)
if err != nil {
return util.Errorf("could not open rocksdb instance: %s", err)
}
atomic.AddInt32(&r.refcount, 1)
return nil
}
示例15: av_rescale_q
func av_rescale_q(time int64, src, trg Rational) int64 {
var a C.AVRational = C.AVRational{C.int(src.Num), C.int(src.Den)}
var b C.AVRational = C.AVRational{C.int(trg.Num), C.int(trg.Den)}
cresult := C.av_rescale_q(C.int64_t(time), a, b)
return int64(cresult)
}