Skip to content

Commit

Permalink
Partial rewrite: Go like func naming; Objs
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgisio committed Sep 3, 2015
1 parent 0e97991 commit f8e07f7
Show file tree
Hide file tree
Showing 20 changed files with 1,680 additions and 1,786 deletions.
659 changes: 106 additions & 553 deletions avcodec/avcodec.go

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions avcodec/avpicture.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
AvPicture
*/
package avcodec

//#cgo pkg-config: libavcodec
//#include <libavcodec/avcodec.h>
import "C"
import (
"unsafe"
)

//Setup the picture fields based on the specified image parameters and the provided image data buffer.
func (p *AvPicture) AvpictureFill(pt *uint8, pf AvPixelFormat, w, h int) int {
return int(C.avpicture_fill((*C.struct_AVPicture)(p), (*C.uint8_t)(pt), (C.enum_AVPixelFormat)(pf), C.int(w), C.int(h)))
}

//Copy pixel data from an AvPicture into a buffer.
func (p *AvPicture) AvpictureLayout(pf AvPixelFormat, w, h int, d *string, ds int) int {
return int(C.avpicture_layout((*C.struct_AVPicture)(p), (C.enum_AVPixelFormat)(pf), C.int(w), C.int(h), (*C.uchar)(unsafe.Pointer(d)), C.int(ds)))
}

//Copy image src to dst.
func (p *AvPicture) AvPictureCopy(d *AvPicture, pf AvPixelFormat, w, h int) {
C.av_picture_copy((*C.struct_AVPicture)(d), (*C.struct_AVPicture)(p), (C.enum_AVPixelFormat)(pf), C.int(w), C.int(h))
}

//Crop image top and left side.
func (p *AvPicture) AvPictureCrop(d *AvPicture, pf AvPixelFormat, t, l int) int {
return int(C.av_picture_crop((*C.struct_AVPicture)(d), (*C.struct_AVPicture)(p), (C.enum_AVPixelFormat)(pf), C.int(t), C.int(l)))
}

//Pad image.
func (p *AvPicture) AvPicturePad(d *AvPicture, h, w int, pf AvPixelFormat, t, b, l, r int, c *int) int {
return int(C.av_picture_pad((*C.struct_AVPicture)(d), (*C.struct_AVPicture)(p), (C.int)(h), (C.int)(w), (C.enum_AVPixelFormat)(pf), (C.int)(t), (C.int)(b), (C.int)(l), (C.int)(r), (*C.int)(unsafe.Pointer(c))))
}

//Free a picture previously allocated by avpicture_alloc(). Allocate memory for the pixels of a picture and setup the AvPicture fields for it.
func (p *AvPicture) AvpictureAlloc(t AvPixelFormat, w, h int) int {
return int(C.avpicture_alloc((*C.struct_AVPicture)(p), (C.enum_AVPixelFormat)(t), C.int(w), C.int(h)))
}

func (p *AvPicture) AvpictureFree() {
C.avpicture_free((*C.struct_AVPicture)(p))
}

//Calculate the size in bytes that a picture of the given width and height would occupy if stored in the given picture format.
func AvpictureGetSize(pf AvPixelFormat, w, h int) int {
return int(C.avpicture_get_size((C.enum_AVPixelFormat)(pf), C.int(w), C.int(h)))
}
13 changes: 0 additions & 13 deletions avcodec/codecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,3 @@ const (
AV_CODEC_ID_ZLIB = int(C.AV_CODEC_ID_ZLIB)
AV_CODEC_ID_ZMBV = int(C.AV_CODEC_ID_ZMBV)
)

// const (
// AV_CODEC_ID_4GV = int(C.AV_CODEC_ID_4GV)
// AV_CODEC_ID_ADPCM_THP_LE = int(C.AV_CODEC_ID_ADPCM_THP_LE)
// AV_CODEC_ID_APNG = int(C.AV_CODEC_ID_APNG)
// AV_CODEC_ID_DDS = int(C.AV_CODEC_ID_DDS)
// AV_CODEC_ID_DSS_SP = int(C.AV_CODEC_ID_DSS_SP)
// AV_CODEC_ID_HAP = int(C.AV_CODEC_ID_HAP)
// AV_CODEC_ID_HQX = int(C.AV_CODEC_ID_HQX)
// AV_CODEC_ID_HQ_HQA = int(C.AV_CODEC_ID_HQ_HQA)
// AV_CODEC_ID_STL = int(C.AV_CODEC_ID_STL)
// AV_CODEC_ID_TDSC = int(C.AV_CODEC_ID_TDSC)
// )
Loading

0 comments on commit f8e07f7

Please sign in to comment.