[Libav-user] Queuing of AVFrame
volich at ukr.net
volich at ukr.net
Thu Jul 24 08:23:46 CEST 2014
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?
Regards,
Yuriy
--- Исходное сообщение ---
От кого: volich at ukr.net
Дата: 24 нюля 2014, 09:01:34
>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(
More information about the Libav-user
mailing list