On Thu, 24 Jul 2014 09:23:46 +0300 [email protected] wrote: > Sorry for formating, it was first message. > > Hi > > I want to realise AVFrames handling with queue. > My code is > > int decode(AVCodecContext *codec_ctx, AVPacket *packet) > { > AVFrame *frame = av_frame_alloc(); > if (!frame) > return -1; > > int got_frame; > int ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, packet); > if (ret >= 0 && got_frame) { > /* Allocate buffer references */ > for (int i = 0; i < 3; i++) { > uint8_t *data = frame->data[i]; > int size = frame->linesize[i] * frame->height; > frame->buf[i] = av_buffer_create(data, size, av_buffer_default_free, > NULL, 0); > } > > enqueue(frame); > return 0; > } > > av_frame_free(&frame); > return -1; > } > > void someFunc() > { > AVFrame *frame = dequeue(); > > ... > > if (frame) > av_frame_free(&frame); > } > > Is it right?
No, the newly created buffers references data of another buffer, but since the other buffer is not referenced and doesn't know anything about the new buffer, you will get use-after-free problems. Use av_frame_ref() if you want to create new frame references. _______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
