func avcodec_decode_audio(ctx *_CodecContext, buffer []byte, size *int, packet *avPacket) int { return int(C.avcodec_decode_audio3( ctx.ctx, (*C.int16_t)(unsafe.Pointer(&buffer[0])), (*C.int)(unsafe.Pointer(size)), (*C.AVPacket)(unsafe.Pointer(packet)))) }
func (c *Decoder) decodeAudio(p Packet) *Frame { packet := new(C.AVPacket) C.av_init_packet(packet) defer C.av_free_packet(packet) packet.pts = C.int64_t(p.Pts) packet.dts = C.int64_t(p.Dts) packet.size = C.int(p.Size) packet.data = (*C.uint8_t)(unsafe.Pointer(&p.Data[0])) packet.stream_index = C.int(p.Stream) packet.flags = C.int(p.Flags) packet.duration = C.int(p.Duration) packet.pos = C.int64_t(p.Pos) //size:=packet.size; samples_size := C.int(C.AVCODEC_MAX_AUDIO_FRAME_SIZE) //bps := C.av_get_bits_per_sample_fmt(c.Ctx.sample_fmt) >> 3; outbuf := (*C.uint8_t)(C.av_malloc(C.uint(samples_size))) defer C.av_free(unsafe.Pointer(outbuf)) C.avcodec_decode_audio3(c.Ctx, (*C.int16_t)(unsafe.Pointer(outbuf)), &samples_size, packet) //println(data_len) return nil }