func avcodec_open(cctx CodecContext, codec Codec) int {
	avcodec_mutex.Lock()
	res := C.avcodec_open(cctx.ctx, codec.codec)
	avcodec_mutex.Unlock()
	return int(res)

}
func (c *Coder) Open() {
	c.prepare()
	c.Codec = C.avcodec_find_decoder(c.Ctx.codec_id)
	if c.Codec == nil {
		log.Printf("could not find Codec for id %d", c.Ctx.codec_id)
		return
	}
	avcodec_mutex.Lock()
	res := C.avcodec_open(c.Ctx, c.Codec)
	avcodec_mutex.Unlock()

	if res < 0 {
		println("error openning codec")
		return
	}
	println("codec openned")
	c.Valid = true
}