Index: libvo/vo_direct3d.c =================================================================== --- libvo/vo_direct3d.c (revision 27958) +++ libvo/vo_direct3d.c (working copy) @@ -331,7 +331,7 @@ */ if (mpi->flags & MP_IMGFLAG_DRAW_CALLBACK) - return VO_TRUE; + goto skip_upload; if (mpi->flags & MP_IMGFLAG_PLANAR) { /* Copy a planar frame. */ @@ -339,13 +339,6 @@ return VO_TRUE; } - /* If the previous if failed, we should draw a packed frame */ - if (FAILED (IDirect3DDevice9_BeginScene(gpD3DDevice))) - { - mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); - return VO_ERROR; - } - if (FAILED (IDirect3DSurface9_LockRect(gpD3DSurface, &stLockedRect, NULL, 0))) { @@ -362,6 +355,15 @@ return VO_ERROR; } +skip_upload: + + /* If the previous if failed, we should draw a packed frame */ + if (FAILED (IDirect3DDevice9_BeginScene(gpD3DDevice))) + { + mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); + return VO_ERROR; + } + if (FAILED (IDirect3DDevice9_StretchRect (gpD3DDevice, gpD3DSurface, gIsPanscan == 1 ? @@ -658,18 +660,22 @@ { D3DLOCKED_RECT stLockedRect; /**< Offscreen surface we lock in order to copy MPlayer's frame inside it.*/ + RECT srcRect; char *Src; /**< Pointer to the source image */ - char *Dst; /**< Pointer to the destination image */ + char *Dst_y; /**< Pointer to the destination image */ + char *Dst_u; /**< Pointer to the destination image */ + char *Dst_v; /**< Pointer to the destination image */ int UVstride; /**< Stride of the U/V planes */ - if (FAILED (IDirect3DDevice9_BeginScene(gpD3DDevice))) - { - mp_msg(MSGT_VO,MSGL_ERR,"BeginScene failed\n"); - return VO_ERROR; - } + srcRect.left = (LONG)x; + srcRect.right = (LONG)(x + w); + srcRect.top = (LONG)y; + srcRect.bottom = (LONG)(y + h); + //mp_msg(MSGT_VO,MSGL_ERR,"draw_slice lock = %ld %ld %ld %ld\n", srcRect.left, srcRect.right, srcRect.top, srcRect.bottom); + if (FAILED (IDirect3DSurface9_LockRect(gpD3DSurface, - &stLockedRect, NULL, 0))) + &stLockedRect, &srcRect, 0))) { mp_msg(MSGT_VO,MSGL_V,"Surface lock failure\n"); return VO_FALSE; @@ -677,35 +683,41 @@ UVstride = stLockedRect.Pitch / 2; + Dst_y = (char *)((unsigned int)stLockedRect.pBits - (y * stLockedRect.Pitch)); + Dst_u = Dst_y + (stLockedRect.Pitch * gSrcHeight); + Dst_v = Dst_u + ((stLockedRect.Pitch * gSrcHeight) / 4); + /* Copy Y */ - Dst = stLockedRect.pBits; - Dst = Dst + stLockedRect.Pitch * y + x; + //Dst_y = stLockedRect.pBits; + Dst_y = Dst_y + stLockedRect.Pitch * y + x; Src=src[0]; - memcpy_pic(Dst, Src, w, h, stLockedRect.Pitch, stride[0]); + memcpy_pic(Dst_y, Src, w, h, stLockedRect.Pitch, stride[0]); w/=2;h/=2;x/=2;y/=2; /* Copy U */ - Dst = stLockedRect.pBits; - Dst = Dst + stLockedRect.Pitch * gSrcHeight - + UVstride * y + x; + //Dst = stLockedRect.pBits; + //Dst = Dst + stLockedRect.Pitch * gSrcHeight + // + UVstride * y + x; + Dst_u = Dst_u + UVstride * y + x; if (gMovieSrcFmt == MAKEFOURCC('Y','V','1','2')) Src=src[2]; else Src=src[1]; - memcpy_pic(Dst, Src, w, h, UVstride, stride[1]); + memcpy_pic(Dst_u, Src, w, h, UVstride, stride[1]); /* Copy V */ - Dst = stLockedRect.pBits; - Dst = Dst + stLockedRect.Pitch * gSrcHeight - + UVstride * (gSrcHeight / 2) + UVstride * y + x; + //Dst = stLockedRect.pBits; + //Dst = Dst + stLockedRect.Pitch * gSrcHeight + // + UVstride * (gSrcHeight / 2) + UVstride * y + x; + Dst_v = Dst_v + UVstride * y + x; if (gMovieSrcFmt == MAKEFOURCC('Y','V','1','2')) Src=src[1]; else Src=src[2]; - memcpy_pic(Dst, Src, w, h, UVstride, stride[2]); + memcpy_pic(Dst_v, Src, w, h, UVstride, stride[2]); if (FAILED (IDirect3DSurface9_UnlockRect(gpD3DSurface))) { @@ -713,26 +725,6 @@ return VO_ERROR; } - if (FAILED (IDirect3DDevice9_StretchRect (gpD3DDevice, - gpD3DSurface, - gIsPanscan == 1 ? - &gPanScanSrcRect : NULL, - gpD3DBackBuf, - vo_fs == 1 ? - &gFullScrMovieRect : NULL, - D3DTEXF_LINEAR))) - { - mp_msg(MSGT_VO,MSGL_V, - "Unable to copy the frame to the back buffer\n"); - return VO_ERROR; - } - - if (FAILED (IDirect3DDevice9_EndScene(gpD3DDevice))) - { - mp_msg(MSGT_VO,MSGL_ERR,"EndScene failed\n"); - return VO_ERROR; - } - return 0; /* Success */ }