[Libav-user] Using ffmpeg with SDL2 - Bad src image pointers / New decoding flow - questions
Gonzalo Garramuño
ggarra13 at gmail.com
Sun Feb 5 18:46:00 EET 2017
El 05/02/17 a las 12:07, Jan escribió:
>
> The error I get:
> [swscaler @ 0x555e2af7ff60] bad src image pointers
>
For the swscale call, I have C++ code, but you would do something like:
AVFrame output; // Final output frame
// The pointer to the allocated image
boost::uint8_t* ptr = (boost::uint8_t*)image->data().get();
// Actual width height of window, _av_dst_pix_fmt contains actual
// format for the window/image.
unsigned int w = width();
unsigned int h = height();
// Prepare output data and linesize based on ptr, format and w/h.
av_image_fill_arrays( output.data, output.linesize, ptr, _av_dst_pix_fmt,
w, h, 1);
AVPixelFormat fmt = _video_ctx->pix_fmt;
int sws_flags = 0;
if ( w < _video_ctx->width || h < _video_ctx->height )
sws_flags = SWS_BICUBIC;
// We store convert_ctx between invocations. It is part of a class or
static variable.
_convert_ctx = sws_getCachedContext(_convert_ctx,
_video_ctx->width,
_video_ctx->height,
fmt, w, h,
_av_dst_pix_fmt, sws_flags,
NULL, NULL, NULL);
if ( _convert_ctx == NULL )
{
IMG_ERROR( _("Could not get image conversion context.") );
return;
}
sws_scale(_convert_ctx, _av_frame->data, _av_frame->linesize,
0, _video_ctx->height, output.data, output.linesize);
--
Gonzalo Garramuño
More information about the Libav-user
mailing list