I'm having trouble calling sws_scale because I'm passing a reference to a Go pointer on line 143:
---
var input_data [3]*C.uint8_t
var input_linesize [3]C.int
switch im := m.(type) {
case *image.RGBA:
bpp := 4
input_data = [3]*C.uint8_t{ptr(im.Pix)}
input_linesize = [3]C.int{C.int(im.Bounds().Dx() * bpp)}
case *image.NRGBA:
bpp := 4
input_data = [3]*C.uint8_t{ptr(im.Pix)}
input_linesize = [3]C.int{C.int(im.Bounds().Dx() * bpp)}
default:
panic("Unknown input image type")
}
// Perform scaling from input type to output type
C.sws_scale(e._swscontext, &input_data[0], &input_linesize[0],
0, e._context.height,
&e._frame.data[0], &e._frame.linesize[0])
---
In the switch statement, I have tried several options to change input_data to avoid having the Go pointer to Go pointer. The closest I have come, I think, is this:
---
var input_data [3]*uint8
var input_linesize [3]C.int
switch im := m.(type) {
case *image.RGBA:
bpp := 4
for i, _ := range im.Pix[:3] {
input_data[i] = &im.Pix[i]
}
input_linesize = [3]C.int{C.int(im.Bounds().Dx() * bpp)}
case *image.NRGBA:
bpp := 4
for i, _ := range im.Pix[:3] {
input_data[i] = &im.Pix[i]
}
input_linesize = [3]C.int{C.int(im.Bounds().Dx() * bpp)}
default:
panic("Unknown input image type")
}
// Perform scaling from input type to output type
C.sws_scale(e._swscontext, (**C.uint8_t)(&input_data[0]), &input_linesize[0],
0, e._context.height,
&e._frame.data[0], &e._frame.linesize[0])
---
...but then go build gives the following error:
ffmpeg/ffmpeg.go:147: cannot convert &input_data[0] (type **uint8) to type **C.uint8_t
Am I approaching this the right way?