Skip to content
This repository
Browse code

Merge pull request #3615 from FernetMenta/vdpau

vdpau: move cropping of top and bottom lines to renderer
  • Loading branch information...
commit 76b5b1c489f175f5b4643a9c0e5655124312ed20 2 parents dcacc8d + b48efa1
Rainer Hochecker FernetMenta authored
33 xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
@@ -1536,7 +1536,6 @@ void CLinuxRendererGL::RenderVDPAU(int index, int field)
1536 1536
1537 1537 // make sure we know the correct texture size
1538 1538 GetPlaneTextureSize(plane);
1539   - CalculateTextureSourceRects(index, 1);
1540 1539
1541 1540 // Try some clamping or wrapping
1542 1541 glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -1583,10 +1582,10 @@ void CLinuxRendererGL::RenderVDPAU(int index, int field)
1583 1582 }
1584 1583 else
1585 1584 {
1586   - glTexCoord2f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y); glVertex4f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y, 0.0f, 0.0f);
1587   - glTexCoord2f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y); glVertex4f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y, 1.0f, 0.0f);
1588   - glTexCoord2f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y); glVertex4f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y, 1.0f, 1.0f);
1589   - glTexCoord2f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y); glVertex4f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y, 0.0f, 1.0f);
  1585 + glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex4f(m_rotatedDestCoords[0].x, m_rotatedDestCoords[0].y, 0.0f, 0.0f);
  1586 + glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex4f(m_rotatedDestCoords[1].x, m_rotatedDestCoords[1].y, 1.0f, 0.0f);
  1587 + glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex4f(m_rotatedDestCoords[2].x, m_rotatedDestCoords[2].y, 1.0f, 1.0f);
  1588 + glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex4f(m_rotatedDestCoords[3].x, m_rotatedDestCoords[3].y, 0.0f, 1.0f);
1590 1589 }
1591 1590 glEnd();
1592 1591 VerifyGLState();
@@ -2407,23 +2406,27 @@ bool CLinuxRendererGL::UploadVDPAUTexture(int index)
2407 2406
2408 2407 plane.id = vdpau->texture[0];
2409 2408
  2409 + // in stereoscopic mode sourceRect may only
  2410 + // be a part of the source video surface
2410 2411 plane.rect = m_sourceRect;
2411   - plane.width = im.width;
2412   - plane.height = im.height;
2413 2412
2414   - plane.height /= plane.pixpertex_y;
2415   - plane.rect.y1 /= plane.pixpertex_y;
2416   - plane.rect.y2 /= plane.pixpertex_y;
2417   - plane.width /= plane.pixpertex_x;
2418   - plane.rect.x1 /= plane.pixpertex_x;
2419   - plane.rect.x2 /= plane.pixpertex_x;
  2413 + // clip rect
  2414 + if (vdpau->crop.x1 > plane.rect.x1)
  2415 + plane.rect.x1 = vdpau->crop.x1;
  2416 + if (vdpau->crop.x2 < plane.rect.x2)
  2417 + plane.rect.x2 = vdpau->crop.x2;
  2418 + if (vdpau->crop.y1 > plane.rect.y1)
  2419 + plane.rect.y1 = vdpau->crop.y1;
  2420 + if (vdpau->crop.y2 < plane.rect.y2)
  2421 + plane.rect.y2 = vdpau->crop.y2;
  2422 +
  2423 + plane.texheight = vdpau->texHeight;
  2424 + plane.texwidth = vdpau->texWidth;
2420 2425
2421 2426 if (m_textureTarget == GL_TEXTURE_2D)
2422 2427 {
2423   - plane.height /= plane.texheight;
2424 2428 plane.rect.y1 /= plane.texheight;
2425 2429 plane.rect.y2 /= plane.texheight;
2426   - plane.width /= plane.texwidth;
2427 2430 plane.rect.x1 /= plane.texwidth;
2428 2431 plane.rect.x2 /= plane.texwidth;
2429 2432 }
49 xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -1682,11 +1682,6 @@ void CMixer::CreateVdpauMixer()
1682 1682 &m_videoMixer);
1683 1683 CheckStatus(vdp_st, __LINE__);
1684 1684
1685   - // create 3 pitches of black lines needed for clipping top
1686   - // and bottom lines when de-interlacing
1687   - m_BlackBar = new uint32_t[3*m_config.outWidth];
1688   - memset(m_BlackBar, 0, 3*m_config.outWidth*sizeof(uint32_t));
1689   -
1690 1685 }
1691 1686
1692 1687 void CMixer::InitCSCMatrix(int Width)
@@ -2223,6 +2218,8 @@ void CMixer::Init()
2223 2218 m_Sharpness = 0.0;
2224 2219 m_DeintMode = 0;
2225 2220 m_Deint = 0;
  2221 + m_Upscale = 0;
  2222 + m_SeenInterlaceFlag = false;
2226 2223 m_ColorMatrix = 0;
2227 2224 m_PostProc = false;
2228 2225 m_vdpError = false;
@@ -2241,8 +2238,6 @@ void CMixer::Uninit()
2241 2238 m_outputSurfaces.pop();
2242 2239 }
2243 2240 m_config.context->GetProcs().vdp_video_mixer_destroy(m_videoMixer);
2244   -
2245   - delete [] m_BlackBar;
2246 2241 }
2247 2242
2248 2243 void CMixer::Flush()
@@ -2294,6 +2289,7 @@ void CMixer::InitCycle()
2294 2289 EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode;
2295 2290 EINTERLACEMETHOD method = GetDeinterlacingMethod();
2296 2291 bool interlaced = m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_INTERLACED;
  2292 + m_SeenInterlaceFlag |= interlaced;
2297 2293
2298 2294 // TODO
2299 2295 if (//!(flags & DVP_FLAG_NO_POSTPROC) &&
@@ -2377,6 +2373,12 @@ void CMixer::InitCycle()
2377 2373 m_processPicture.outputSurface = m_outputSurfaces.front();
2378 2374 m_mixerInput[1].DVDPic.iWidth = m_config.outWidth;
2379 2375 m_mixerInput[1].DVDPic.iHeight = m_config.outHeight;
  2376 + if (m_SeenInterlaceFlag)
  2377 + {
  2378 + double ratio = (double)m_mixerInput[1].DVDPic.iDisplayHeight / m_mixerInput[1].DVDPic.iHeight;
  2379 + m_mixerInput[1].DVDPic.iHeight -= 6;
  2380 + m_mixerInput[1].DVDPic.iDisplayHeight = lrint(ratio*m_mixerInput[1].DVDPic.iHeight);
  2381 + }
2380 2382 }
2381 2383 else
2382 2384 {
@@ -2511,32 +2513,6 @@ void CMixer::ProcessPicture()
2511 2513 0,
2512 2514 NULL);
2513 2515 CheckStatus(vdp_st, __LINE__);
2514   -
2515   - if (m_mixerfield != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
2516   - {
2517   - // in order to clip top and bottom lines when de-interlacing
2518   - // we black those lines as a work around for not working
2519   - // background colour using the mixer
2520   - // pixel perfect is preferred over overscanning or zooming
2521   -
2522   - VdpRect clipRect = destRect;
2523   - clipRect.y1 = clipRect.y0 + 2;
2524   - uint32_t *data[] = {m_BlackBar};
2525   - uint32_t pitches[] = {destRect.x1};
2526   - vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
2527   - (void**)data,
2528   - pitches,
2529   - &clipRect);
2530   - CheckStatus(vdp_st, __LINE__);
2531   -
2532   - clipRect = destRect;
2533   - clipRect.y0 = clipRect.y1 - 2;
2534   - vdp_st = m_config.context->GetProcs().vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
2535   - (void**)data,
2536   - pitches,
2537   - &clipRect);
2538   - CheckStatus(vdp_st, __LINE__);
2539   - }
2540 2516 }
2541 2517
2542 2518
@@ -3067,7 +3043,12 @@ CVdpauRenderPicture* COutput::ProcessMixerPicture()
3067 3043 GLMapSurfaces();
3068 3044 retPic->sourceIdx = procPic.outputSurface;
3069 3045 retPic->texture[0] = m_bufferPool.glOutputSurfaceMap[procPic.outputSurface].texture[0];
3070   - retPic->crop = CRect(0,0,0,0);
  3046 + retPic->texWidth = m_config.outWidth;
  3047 + retPic->texHeight = m_config.outHeight;
  3048 + retPic->crop.x1 = 0;
  3049 + retPic->crop.y1 = (m_config.outHeight - retPic->DVDPic.iHeight) / 2;
  3050 + retPic->crop.x2 = m_config.outWidth;
  3051 + retPic->crop.y2 = m_config.outHeight - retPic->crop.y1;
3071 3052 }
3072 3053 else
3073 3054 {
2  xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
@@ -330,8 +330,8 @@ class CMixer : private CThread
330 330 int m_DeintMode;
331 331 int m_Deint;
332 332 int m_Upscale;
  333 + bool m_SeenInterlaceFlag;
333 334 unsigned int m_ColorMatrix : 4;
334   - uint32_t *m_BlackBar;
335 335 VdpVideoMixerPictureStructure m_mixerfield;
336 336 int m_mixerstep;
337 337 int m_mixersteps;

0 comments on commit 76b5b1c

Please sign in to comment.
Something went wrong with that request. Please try again.