avcodec_alloc_frame() allocates memory for AVFrame structure, but not
it's data buffer.
by data buffer I mean AVFrame::data[4].
if you do not explicitly allocate memory for it's buffer but program
works ok, it means that
1) you don't use data field of your AVFrame anywhere :)
2) buffer is allocated by one of ffmpeg functions (for example
avcodec_decode_video() does this )

p.s av_picture_fill() doesn't allocates memory. it only sets correct
linesize values and points data[] to the buffer that you specified

2011/2/16 Lorenzo Mattiussi <[email protected]>:
> Il 16/02/2011 16:48, Gilles Maire ha scritto:
>>
>> av_picturefill fill a Picture not a Frame. Picture and Frame start with
>> the
>> same informations. If you fill frame you will have missed
>> informations.....
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 2011/2/16 Lorenzo Mattiussi<[email protected]>
>>
>>> Il 16/02/2011 14:14, Gilles Maire ha scritto:
>>>
>>>  Hi Lorenzo
>>>>
>>>> Perhaps you forget to make a
>>>>
>>>> int size = avpicture_get_size(avctx->fmt, avctx->width, avctx->height);
>>>> tempFrame = av_malloc(size*sizeof(uint8_t));
>>>>
>>>> before your
>>>> avpicture_fill ((AVPicture *)tempFrame,(uint8_t
>>>> *)img.data,PIX_FMT_BGR24,img.width,img.height)
>>>>
>>>> After don't forget to free the tempFrame.
>>>>
>>>>
>>>> Cheers
>>>>
>>>>
>>>> Gilles Maire
>>>>
>>>> 2011/2/16 Lorenzo Mattiussi<[email protected]>
>>>>
>>>>  hi all,
>>>>>
>>>>> I've a problem, when the program execute avpicture_fill, I find this
>>>>> message error:
>>>>> Unhandled exception at 0x632415fe in EraEndo.exe:0xC0000005: Access
>>>>> violation writing location 0xcdcdcddd.
>>>>> Someone can help me?!?
>>>>> This is the code:
>>>>> int videoCode::comprimi(const ImageData&img,AVPacket&pack)//PAck deve
>>>>> già
>>>>> essere stato inizializzato
>>>>> {
>>>>>
>>>>>    uint8_t *tempFramebuf;
>>>>>    int sizebuf;
>>>>>    int x;
>>>>>    frameMutex->lock();
>>>>>    //riempo un immagine temporanea con i dati provenienti dalla webcam
>>>>>    x = avpicture_fill ((AVPicture *)tempFrame,(uint8_t
>>>>> *)img.data,PIX_FMT_BGR24,img.width,img.height)
>>>>> ...
>>>>>
>>>>> where imageData is this structure:
>>>>>
>>>>> struct ImageData
>>>>> {
>>>>>    // In DirectShow standard RGB formats
>>>>>    // have an inverted memory layout
>>>>>    enum Format {BGR24, BGR32};
>>>>>
>>>>>    Format format;
>>>>>    unsigned char* data;
>>>>>    long dataSize;
>>>>>    int width;
>>>>>    int height;
>>>>> };
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>>>
>>> Tnx for your replay
>>> In a early function that initialize all FFmpeg parameter, I initialize
>>> tempFrame with this methods:
>>>
>>> tempFrame = avcodec_alloc_frame();
>>>
>>> I can't make:
>>>
>>>
>>> int size = avpicture_get_size(avctx->fmt, avctx->width, avctx->height);
>>> tempFrame = av_malloc(size*sizeof(uint8_t));
>>>
>>> because the compiler say " Impossible conversion from 'void *' to
>>> 'AVFrame
>>> *'  " at av_malloc function
>>>
>>>
>>> _______________________________________________
>>> 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
>
> Thanks for all replay
> I've found my error. The error was in another function that initialize all
> ffmpeg structures.
> I've a question about this:
> In all my code I never make tempFrame = (AVFrame
> *)av_malloc(size*sizeof(uint8_t));
> but it seems runnig correctly..
> Isn't Inside the  avcodec_alloc_frame() something that allocate memory for
> the frame??!?!
> _______________________________________________
> 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