Skip to content

Instantly share code, notes, and snippets.

@fzakaria
Created January 21, 2016 18:39
Show Gist options
  • Save fzakaria/5b0cab52536f35951c14 to your computer and use it in GitHub Desktop.
Save fzakaria/5b0cab52536f35951c14 to your computer and use it in GitHub Desktop.
How to iterate over a double array in Cgo
package avformat
//#cgo pkg-config: libavformat
//#include <libavformat/avformat.h>
import "C"
import (
"unsafe"
)
//https://www.ffmpeg.org/doxygen/2.7/structAVFormatContext.html
func (ctxt *Context) Streams(i uint) *Stream {
offset := (unsafe.Sizeof(unsafe.Pointer(*ctxt.streams)) * uintptr(i))
return *(** Stream)(unsafe.Pointer(uintptr(unsafe.Pointer(ctxt.streams)) + offset ))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment