Dear Gilles,

> I will try even if I don't understand why it will work :)

The ffmpeg structures AVPacket, AVPicture and AVFrame often uses shared memory 
areas. So it is often problematic to store these kind of structures in own 
written lists. Sometimes it is better (this is my experience) to copy AVPackets 
(with av_dup_packet) and AVFrames (with av_picture_copy). 

regards,
Sven

> 
> Thanks again
> 
> Gilles M
> 
> 2011/2/1 Sven Alisch <[email protected]>
> 
>> Good evening Gilles,
>> 
>>> I make  a
>>> 
>>> struct BuffVideo *buf= malloc( sizeof (BuffVideo)) ;
>>> buf->pFrame=avcodec_alloc_frame();
>>> buf->id=i++;
>> 
>> This is ok but not complete. You have to do a little bit more. So like
>> here:
>> 
>> int size = avpicture_get_size(c->pix_fmt, c->width, c->height); // c is a
>> AVCodecContext
>> uint8_t* picture_buf = av_malloc(size);
>> avpicture_fill((AVPicture *)buf->pFrame, picture_buf, c->pix_fmt, c->width,
>> c->height);
>> 
>> 
>>> avcodec_decode_video2(pCodecCtx, buf->pFrame, &frameFinished, &packet);
>> 
>> And this is OK to, BUT! don't use buf->pFrame! Use a new (temporary)
>> AVFrame. For instance make
>> 
>> AVFrame* temp = avcodec_alloc_frame();
>> avcodec_decode_video2(pCodecCtx, temp, &frameFinished, &packet);
>> 
>> and when frameFinished is true make a real copy! So like this:
>> 
>> av_picture_copy((AVPicture*)buf->pFrame, (AVPicture*)temp, c->pix_fmt,
>> c->width, c->height);
>> 
>>> 
>>> but when all is done and when I want to swscale all my frame in list, all
>>> the frame are empty unless the last one with the last value of frame
>>> decoded.
>> 
>> Try it out. It should work.
>> 
>>> 
>>> I suppose the AVFrame keep only pointer to uint[4] ...
>>> 
>>> Idea ?
>> 
>> I hope it work.
>> 
>> regards,
>> Sven
>> 
>>> 
>>> Gilles M
>>> _______________________________________________
>>> libav-user mailing list
>>> [email protected]
>>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> 
>> _______________________________________________
>> libav-user mailing list
>> [email protected]
>> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>> 
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to