We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 689

Summary: X11 SDL_CreateYUVOverlay() fails on large image resolutions
Product: SDL Reporter: pross
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: netbeans
Version: HG 2.0   
Hardware: All   
OS: All   

Description pross 2009-01-31 15:54:36 UTC
How to reproduce:
1. Build SDL testoverlay program
2. ./testoverlay -width 4096 -height 1980 sample.bmp (works as expected)
2. Resize SDL/test/sample.bmp to 2048 x 2048 or larger
3. ./testoverlay -width 4096 -height 1980 sample_large.bmp (fails)

Behaviour:
1.2 svn-4415 (20080131): The testoverlay program segfaults, sometimes, other times exiting immediately.

1.3 svn-4415 (20080131): The testoverlay program exits immediately. Bitmap is not displayed.
Comment 1 pross 2009-01-31 15:59:10 UTC
The 1.2 SVN segfault is caused by XvShmCreateImage() not allocating memory for XvImage->pitches array, thefore hwdata->image->pitches is NULL.


From XvShmCreateImage:
===
        hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format,
                                                   0, width, height, yuvshm);
#ifdef PITCH_WORKAROUND
        if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) {
                                                     ^^^^^^^^^^
                /* Ajust overlay width according to pitch */
                XFree(hwdata->image);
                width = hwdata->image->pitches[0] / bpp;
                                       ^^^^^^^^^^
===
Comment 2 UGeorge 2010-07-30 11:53:53 UTC
I am using FFPLAY from ffmpeg to play a 1920x1080 avchd video. The laptop has only a 1024x768 video screen with 8mb video.
After a long discourse( ffmpef bug report 2079 ) , the cause of the malloc buffer overrun is from the (allegged) bad information returned from a call to SDL_CreateYUVOverlay.

  vp->bmp = SDL_CreateYUVOverlay(vp->width, vp->height,
                                   SDL_YV12_OVERLAY,
                                   screen);

According to ffplay folks, the SDL_CreateYUVOverlay results are wrong

(gdb) p vp->width
$4 = 1920
(gdb) p vp->height
$5 = 1080
(gdb) p *screen
$6 = {flags = 16, format = 0x8c352a8, w = 1920, h = 1080, pitch = 7680, pixels = 0xae016000, offset = 0, hwdata = 0x0, 
  clip_rect = {x = 0, y = 0, w = 1920, h = 1080}, unused1 = 0, locked = 0, map = 0x8c3e6e8, format_version = 2, 
  refcount = 1}
(gdb) p *vp->bmp
$7 = {format = 842094169, w = 1920, h = 1080, planes = 3, pitches = 0x8c55700, pixels = 0x8c55bf8, hwfuncs = 0x86b4a40, 
  hwdata = 0x8c3e6a8, hw_overlay = 1, UnusedBits = 0}
(gdb) p vp->bmp->pitches[0]
$8 = 1024
(gdb) p vp->bmp->pitches[1]
$9 = 512
(gdb) p vp->bmp->pitches[2]
$10 = 512
(gdb) 

It is not clear to me what wrong. But ffplay uses the 1920h to copy the buffer, and overruns the 1024 allocated.
Is this the same issue, or is it another bug?
Comment 3 Sam Lantinga 2011-02-16 04:32:40 UTC
I just tested this with the latest SDL 1.3 snapshot.  The test program exits immediately because the window height is smaller than the image height and it's trying to slide the image to the bottom of the window.

It works fine if you specify a width and height of 4096.

Thanks!