Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
22nd January 2013, 12:28 | #1 | Link |
Beginner
Join Date: Jan 2009
Location: Europe
Posts: 125
|
sws_scale issue
Hi all,
Here is a part of my code, Code:
convertCtx = sws_getContext(aWidth, aHeight, PIX_FMT_RGB24, aWidth, aHeight, PIX_FMT_YUV420P, SCALING_ALGORITHM, NULL, NULL, NULL); x264_picture_alloc(&pic_in, X264_CSP_I420, aWidth, aHeight); srcstride = aWidth*3; sws_scale(convertCtx, &bits, &srcstride, 0, aHeight, pic_in.img.plane, pic_in.img.i_stride); This code works perfect for for example 1024x768 resolution input frames but not for example 1366x768. It gives an error "Warning: data is not aligned!". I am guessing that it is just because 1366 is not divisible by 4. I thought that I can fix it by playing with the srcstride parameter but it won't help. Could you please guide me how to fix this properly? Last edited by koliva; 22nd January 2013 at 12:52. |
24th January 2013, 09:41 | #3 | Link | |
Beginner
Join Date: Jan 2009
Location: Europe
Posts: 125
|
Quote:
Another question, what does the stride parameter do then? |
|
24th January 2013, 18:01 | #4 | Link | |
Guest
Posts: n/a
|
Quote:
It's tells the function the length of each plane of the source/destination images (again something straight from the doc). And the reason you don't simply change the stride parameter is because if your buffers are smaller than what you're telling sws_scale what the stride is, then you have the potential of a buffer overrun occurring that is going to cause memory corruption and/or crash your program. Last edited by paradoxical; 24th January 2013 at 19:13. |
|
28th January 2013, 14:16 | #5 | Link |
Beginner
Join Date: Jan 2009
Location: Europe
Posts: 125
|
I guess you are talking about the following code segment. I should have figured this out before asking. Thanks for the lesson.
420 if ( (uintptr_t)dst[0]%16 || (uintptr_t)dst[1]%16 || (uintptr_t)dst[2]%16 421 || (uintptr_t)src[0]%16 || (uintptr_t)src[1]%16 || (uintptr_t)src[2]%16 422 || dstStride[0]%16 || dstStride[1]%16 || dstStride[2]%16 || dstStride[3]%16 423 || srcStride[0]%16 || srcStride[1]%16 || srcStride[2]%16 || srcStride[3]%16 424 ) { 425 static int warnedAlready=0; 426 int cpu_flags = av_get_cpu_flags(); 427 if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){ 428 av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speedloss\n"); 429 warnedAlready=1; 430 } 431 } Last edited by koliva; 28th January 2013 at 14:19. |
|
|