AVIOContext *avio_ctx;
AVStream *stream;
AVCodecContext *codec;
- AVPacket packet;
+ AVPacket *packet;
AVFrame *frame;
struct SwrContext *swr;
u8 *avio_ctx_buffer;
return -1;
}
- av_init_packet(&packet);
+ packet=av_packet_alloc();
+ if (!packet) {
+ LOG("Error allocating the packet\n");
+ return -1;
+ }
frame = av_frame_alloc();
if (!frame) {
LOG("Error allocating the frame\n");
/* iterate through frames */
*data = NULL;
*size = 0;
- while (av_read_frame(fmt_ctx, &packet) >= 0) {
- avcodec_send_packet(codec, &packet);
+ while (av_read_frame(fmt_ctx, packet) >= 0) {
+ avcodec_send_packet(codec, packet);
err = avcodec_receive_frame(codec, frame);
if (err == AVERROR(EAGAIN))
/* Flush any remaining conversion buffers... */
convert_frame(swr, codec, frame, data, size, true);
+ av_packet_free(&packet);
av_frame_free(&frame);
swr_free(&swr);
//avio_context_free(); // todo?
- avcodec_close(codec);
+ avcodec_free_context(&codec);
avformat_close_input(&fmt_ctx);
avformat_free_context(fmt_ctx);