示例#1
0
文件: frame.go 项目: davidoram/gmf
func (this *Frame) ImgAlloc() error {
	if ret := int(C.av_image_alloc(
		(**C.uint8_t)(unsafe.Pointer(&this.avFrame.data)),
		(*_Ctype_int)(unsafe.Pointer(&this.avFrame.linesize)),
		C.int(this.Width()), C.int(this.Height()), int32(this.Format()), 32)); ret < 0 {
		return errors.New(fmt.Sprintf("Unable to allocate raw image buffer: %v", AvError(ret)))
	}

	return nil
}
示例#2
0
文件: imgutils.go 项目: jasonmoo/gmf
// @todo find better way to do allocation
func NewImage(w, h int, pixFmt int32, align int) (*Image, error) {
	this := &Image{
		avPointers: C.alloc_uint4(), // allocate uint8_t *pointers[4]
		avLineSize: C.alloc_int4(),  // allocate int[4]
	}

	ret := C.av_image_alloc(this.avPointers, this.avLineSize, C.int(w), C.int(h), pixFmt, C.int(align))
	if ret < 0 {
		return nil, errors.New(fmt.Sprintf("Unable to allocate image:%s", AvError(int(ret))))
	}

	this.bufsize = int(ret)
	this.pixFmt = pixFmt
	this.width = w
	this.height = h

	return this, nil
}