[Libav-user] 980210 - What is wrong while providing arguments for sws_scale?!

hamidi hamidi at gmail.com
Tue Apr 30 14:34:53 EEST 2019


Hi
In the following code, I can't figure out what's wrong:

uint8_t *dstData[4];
int dstLinesize[4];
AVPixelFormat convertToPixFmt = AV_PIX_FMT_RGBA;
int ret;

// ...

printf("tmp_frame format: %d (%s) %dx%d\n", tmp_frame->format,
av_get_pix_fmt_name((AVPixelFormat)tmp_frame->format), tmp_frame->width,
tmp_frame->height);
// The above line prints: tmp_frame format: 23 (nv12) 480x480

int size = av_image_get_buffer_size(convertToPixFmt, tmp_frame->width,
tmp_frame->height, 1);
uint8_t *buffer = (uint8_t *) av_malloc(size);

ret = av_image_copy_to_buffer(buffer, size,
(const uint8_t * const *)&tmp_frame->data[i],
(const int *)&tmp_frame->linesize[i], (AVPixelFormat)tmp_frame->format,
tmp_frame->width, tmp_frame->height, 1);
ASSERT(ret >= 0);

ret = av_image_fill_arrays(dstData, dstLinesize, buffer, convertToPixFmt,
dest_width, dest_height, 1);
ASSERT(ret >= 0);

ret = sws_scale(
convertContext,
dstData,
dstLinesize,
0,
dest_width,
convertedFrame->data,
convertedFrame->linesize);
printf("sws_scale returns %d\n", ret);  // prints: sws_scale returns 0
ASSERT(ret == tmp_frame->height);

// ...

It's part of a code which uses dxva2 to obtain tmp_frame. I inspired the
code from hw_decode.c and am sure that there's no mistake in the code. The
date is properly given in NV12 format. The error occurs just when I call
sws_scale and it's:

bad src image pointers

So I don't know how to provide pointers not to get this error and sws_scale
may work properly.
Any idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190430/c347b5ba/attachment.html>


More information about the Libav-user mailing list