[libav-api] AVFrame memory management

g kuczera gkuczera at gmail.com
Wed Aug 20 11:32:01 CEST 2014


Hi Anton,
My LibAV is new enough. But if I simply change the getPreparedFrame method
to be like this:

AVFrame* getPreparedFrame(AVPixelFormat pPixelFormat, int pWidth /*= 320*/,
int pHeight /*= 240*/)
{
AVFrame* tFrame = av_frame_alloc();
tFrame->format = pPixelFormat;
tFrame->width = pWidth;
tFrame->height = pHeight;
tFrame->nb_samples = 0; tFrame->channel_layout = 0;

if (!tFrame)
{
return NULL;
}
//Have to be set:
//-format(pixel format for video, sample format for audio)
//-width and height for video
//-nb_samples and channel_layout for audio
av_frame_get_buffer(tFrame, 0);

return tFrame;
}

then passing this frame to sws_scale as the destination, results in the
error message:

"[swscaler @ 00b42260] bad dst image pointers"

What do you think about that? Should anything has to be done before passing
frame created in this way to sws_scale? Or maybe I should pass specific
value as the "align" parameter?


More information about the libav-api mailing list