Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

RFC: Play10bit #845

Merged
merged 10 commits into from

4 participants

Joakim Plate jmarshallnz davilla CrystalP
Joakim Plate
Collaborator

So, this branch adds support for avoiding the 10bit to 8bit color space conversion and letting the GPU get the full precision data.

I mainly want some comments on the WIP commit. I really don't like including that dvdplayer header in there. At the same time i'd rather not pull in renderer headers into dvdplayer.

Pulling in ffmpeg's pixfmt might be one option. But i'm not sure how we would handle any pixelformats not defined by that. Comments are welcome.

jmarshallnz
Owner

A separate header (or using rendermanager or something similar) seems the best way to go, yeah.

Joakim Plate
Collaborator

Christ that made the diff of this thing grow... I suppose the first 2 commits are really quite separate since they are mainly refactoring.

Joakim Plate
Collaborator

@CrystalP could you give this a whirl on windows with dxva? Just want to make sure i didn't break anything there.
@davilla A test on OSX would be nice

davilla
Collaborator

borked in osx, no video and where the video would be is pure red.

davilla
Collaborator

Any clues why I see red, I poke around and after climbing out of the m_format showing RENDER_FMT_NONE hole, I could not see anything obvious.

Joakim Plate
Collaborator
.../cores/VideoRenderers/VideoShaders/WinVideoFilter.cpp
((12 lines not shown))
unsigned int texWidth;
DefinesMap defines;
- if (fmt == YV12)
+ if (fmt == RENDER_FMT_YUV420P16)
+ {
+ defines["XBMC_YV12"] = "";
+ texWidth = sourceWidth;
+
+ if(!m_YUVPlanes[0].Create(texWidth , m_sourceHeight , 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[1].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[2].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": Failed to create YV12 planes.");
CrystalP Collaborator

would be nice to include the bit depth. same for 10bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
CrystalP CrystalP commented on the diff
xbmc/cores/VideoRenderers/WinRenderer.cpp
@@ -405,6 +377,17 @@ unsigned int CWinRenderer::PreInit()
if ((g_advancedSettings.m_DXVAForceProcessorRenderer || m_iRequestedMethod == RENDER_METHOD_DXVA) && !m_processor.PreInit())
CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA2 processor - skipping");
+ m_formats.push_back(RENDER_FMT_YUV420P);
+ if(g_Windowing.IsTextureFormatOk(D3DFMT_L16, 0))
CrystalP Collaborator

OK. It could be a good idea to also call a new SupportedFormats function in CWinShader, to reduce the risk of problems later.
It's not a big deal and could be added later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/cores/VideoRenderers/WinRenderer.cpp
@@ -1200,26 +1189,40 @@ void YUVBuffer::Clear()
switch(m_format)
{
- case YV12:
+ case RENDER_FMT_YUV420P16:
+ {
+ wmemset((wchar_t*)planes[PLANE_Y].rect.pBits, 32768, planes[PLANE_Y].rect.Pitch * m_height / 2);
CrystalP Collaborator

zero, not 32768 I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
CrystalP
Collaborator

I'll give dxva decoding and/or rendering a go tonight. Did you benchmark CPU/GPU usage?

Joakim Plate
Collaborator

Sådär, hade blivit en drös buggar i senaste rebasen.. @davilla nu får du gärna försöka igen.

@CrystalP har inte gjort några speciella benchmarks, men det borde hjälpa en del. Det skippar en memcpy med shift på varje byte.

Joakim Plate
Collaborator

lol.. i wonder why i wrote that in swedsh.. A translation might be in order:

There we go, had managed to introduce a bunch of bugs in the last rebase.. @davilla feel free to give it a try again.

@CrystalP havn't done any real benchmarks, but it should help some. It skips a memcpy with a shift on each byte.

CrystalP
Collaborator

OK, tried it and software decoding + pixel shaders or software render work
dxva decoding works.
software decoding + dxva renderer on 10 bit material doesn't work because a 10/16 bit copy to GPU memory is not implemented in CProcessor::Add() of dxva.cpp. But would it make sense to add, instead of letting ffmpeg convert to 8bit?

Joakim Plate
Collaborator
CrystalP
Collaborator

I'll try it but I'd be surprised if they could.

In the meantime, something is screwing with dxva rendering after dxva decoding - nVidia drivers compensate, but ATI's do not.

At the beginning of CWinRenderer::SelectRenderMethod, m_Processor.Open() is called. Problem is that as its last parameter, it expects a D3D input data format for the processor, ie the format of the data after decoding (for ex. MAKEFOURCC('Y','V','1','2')). With this PR, it receives RENDER_FMT_DXVA, which means nothing to D3D and fails badly with ATI when querying processor capabilities, creating textures, ...

Joakim Plate
Collaborator
Joakim Plate
Collaborator

@CrystalP could you give it a go again?

Joakim Plate
Collaborator

Okey, so I've rebased and squashed in changes to their rightful place. Should be ready to go I think. Still needs a test on GLES platforms thou.

davilla
Collaborator

gles and hw codec exclude fixes -> http://dl.dropbox.com/u/14341410/gles-10bit.patch

Joakim Plate
Collaborator

what format was that? doesn't seem to be a text file?

davilla
Collaborator

opps, my bad, dropped an alias instead of the real file. Try again with same URL.

Joakim Plate
Collaborator

Thanx @davilla, have incorporated the changes. Noticed some ordering errors that would cause bisecting errors. I think they should be bisectable now (have not tested thou)

I think this should be ready to pull now.

xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
@@ -115,6 +117,13 @@ void CalculateYUVMatrix(TransformMatrix &matrix
, - 16.0f / 255
, - 16.0f / 255);
}
+
+ if(format == RENDER_FMT_YUV420P10)
+ {
+ matrix *= TransformMatrix::CreateScaler(64.0
+ , 64.0
+ , 64.0);
+ }
CrystalP Collaborator

Shouldn't there be a 16 bit case as well?

Joakim Plate Collaborator
elupus added a note

And my response to this apperently got lost (this is getting annoying github). No.. For the 16bit case we are filling the full 16 bit. In the 10 bit case we are using the lower 10 bits of a 16bit value. That said. the 64 is somewhat wrong since we won't be getting the full 16bit range then. ie. 03FF will turn into FFD0 instead of FFFF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
davilla
Collaborator

elupus, have you tried mpeg2 iso's ? I'm crashing in CopyPicture in iOS.

CrystalP
Collaborator

OK now for dxva decoding. I checked the dxva processors, they only accept a few 8 bit formats. Maybe future GPUs or drivers will add more but that's it for now, and they can't work properly with data direct from ffmpeg.

Gave a DVD a spin, all renderers are fine with libmpeg2 decoding on Windows.

davilla
Collaborator

ok, mpeg2 iso's under iOS are fine with a recent pull. must have been some local issue.

OSX/iOS signoff for inject.

davilla
Collaborator

ping elupus, found two more, see http://pastebin.com/qUR6phWY

Joakim Plate
Collaborator

I intend to merge this in a day or two. I'll look at that copy & paste regarding profiles later and factor it out into DVDCodecUtils most likely.

Joakim Plate
Collaborator

That profile change is technically separate from this pull request and could have been applied before this goes in. But it can go in with this pull too.

Joakim Plate elupus merged commit 41887d5 into from
Holger Wiedemann HolgerW1 referenced this pull request from a commit in HolgerW1/xbmc
Patrick Vos itofzo Merge branch 'PR-845_PP_filter_extensions' into development
* PR-845_PP_filter_extensions: closes gh-845
  Add extension filter to associated files for Post Processing
a3bfb87
Holger Wiedemann HolgerW1 referenced this pull request from a commit in HolgerW1/xbmc
Patrick Vos itofzo Merge branch 'development'
Updated **Womble** provider to use 'tv-sd' and 'tv-hd' categories 
instead of the now defunct 'TV-x264'.

Add extension filter to associated files for Post Processing #845
  * One case example is if you only want subs, you could create the 
    filter '.idx, .sub, .srt'. We strip spaces and ignore case when 
    matching against the filter.
  * This is useful for those that do not have the ability to setup a 
    cleanup script in their downloader.

Re-arrange snatched+download SQL to be easier to read and compare (split
snatched and download out).
  * Show **downloaded+snatched** on homepage rather than the combine
number,
    show tooltip that explains it #842
  * Fix sorting shows with more than 100k episodes

Cleaned up season pack vs single episode searching logic
  * Added check to only consider a full season pack if the last episode
in the 
    season airdate is older than 7 days or if the last aired ep is older
than 'today'.
  * Fix **BTN** backlog search for single episode searches, remove
duplicate search parameters.

Fix **OMGWTFNZBS** proper/repack search

Post-Processing fixes
  * Fix release name not set on air-by-date shows during post-processing
  * Fix processing season 0

Change clean proper name to check against history
Should prevent a proper from being re-downloaded 
(such as the reposted '-RP' releases)

Change setting status to **UNAIRED** for future episodes (GC-2397)

Revised Roman Numerals conversion routine to be stricter
(ex: IIII is not 4, IL is not 1) and raise error instead of defaulting
to 0.

Regex tweaks. Pull #841
  * Add '480p' to our regex to reduce the chance of it being matched 
    as the season/ep or multi-ep reference.
  * Filter out releases like
'Louie.S02E11.PROOFFiX.720p.BluRay.x264-DEiMOS' 
    and 'Rome.S02.DiRFiXES.720p.BluRay.x264-SiNNERS' as they are useless
for our purposes.

Season 0 fix. Pull #843
  * Exclude specials from being changed to wanted automatically because
of the daily search.
  * When excluding specials use '> 0' rather than '!= 0' just to be more
efficient.
e5abe14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 571 additions and 308 deletions.
  1. +5 −0 xbmc/cores/VideoRenderers/BaseRenderer.h
  2. +101 −55 xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
  3. +7 −2 xbmc/cores/VideoRenderers/LinuxRendererGL.h
  4. +23 −9 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
  5. +5 −1 xbmc/cores/VideoRenderers/LinuxRendererGLES.h
  6. +0 −11 xbmc/cores/VideoRenderers/RenderFlags.h
  7. +40 −0 xbmc/cores/VideoRenderers/RenderFormats.h
  8. +13 −11 xbmc/cores/VideoRenderers/RenderManager.cpp
  9. +10 −1 xbmc/cores/VideoRenderers/RenderManager.h
  10. +42 −8 xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.cpp
  11. +5 −2 xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.h
  12. +33 −17 xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
  13. +9 −5 xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h
  14. +68 −63 xbmc/cores/VideoRenderers/WinRenderer.cpp
  15. +9 −14 xbmc/cores/VideoRenderers/WinRenderer.h
  16. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h
  17. +43 −7 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
  18. +5 −1 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
  19. +8 −1 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.h
  20. +8 −3 xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
  21. +3 −2 xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.h
  22. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodec.h
  23. +17 −17 xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
  24. +2 −2 xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.h
  25. +3 −12 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
  26. +13 −0 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecCrystalHD.cpp
  27. +15 −15 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
  28. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecLibMpeg2.cpp
  29. +2 −2 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecOpenMax.cpp
  30. +15 −1 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
  31. +15 −1 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
  32. +2 −2 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp
  33. +6 −6 xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.cpp
  34. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Video/DXVA.h
  35. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Video/OpenMaxVideo.cpp
  36. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
  37. +1 −1  xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
  38. +1 −1  xbmc/cores/dvdplayer/DVDOverlayRenderer.h
  39. +36 −29 xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
5 xbmc/cores/VideoRenderers/BaseRenderer.h
View
@@ -23,6 +23,7 @@
#include "guilib/Resolution.h"
#include "guilib/Geometry.h"
+#include "RenderFormats.h"
#define MAX_PLANES 3
#define MAX_FIELDS 3
@@ -38,6 +39,7 @@ typedef struct YV12Image
unsigned cshift_x; /* this is the chroma shift used */
unsigned cshift_y;
+ unsigned bpp; /* bytes per pixel */
} YV12Image;
enum ERENDERFEATURE
@@ -68,6 +70,9 @@ class CBaseRenderer
virtual unsigned int GetProcessorSize() { return 0; }
+ // Supported pixel formats, can be called before configure
+ std::vector<ERenderFormat> SupportedFormats() { return std::vector<ERenderFormat>(); }
+
protected:
void ChooseBestResolution(float fps);
bool FindResolutionFromOverride(float fps, float& weight, bool fallback);
156 xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
View
@@ -43,6 +43,7 @@
#include "utils/log.h"
#include "utils/GLUtils.h"
#include "RenderCapture.h"
+#include "RenderFormats.h"
#ifdef HAVE_LIBVDPAU
#include "cores/dvdplayer/DVDCodecs/Video/VDPAU.h"
@@ -139,6 +140,7 @@ CLinuxRendererGL::CLinuxRendererGL()
m_renderMethod = RENDER_GLSL;
m_renderQuality = RQ_SINGLEPASS;
m_iFlags = 0;
+ m_format = RENDER_FMT_NONE;
m_iYV12RenderBuffer = 0;
m_flipindex = 0;
@@ -253,7 +255,7 @@ bool CLinuxRendererGL::ValidateRenderTarget()
return false;
}
-bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format)
+bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format)
{
m_sourceWidth = width;
m_sourceHeight = height;
@@ -261,6 +263,7 @@ bool CLinuxRendererGL::Configure(unsigned int width, unsigned int height, unsign
// Save the flags.
m_iFlags = flags;
+ m_format = format;
// Calculate the input frame aspect ratio.
CalculateFrameAspectRatio(d_width, d_height);
@@ -333,6 +336,7 @@ int CLinuxRendererGL::GetImage(YV12Image *image, int source, bool readonly)
image->flags = im.flags;
image->cshift_x = im.cshift_x;
image->cshift_y = im.cshift_y;
+ image->bpp = im.bpp;
return source;
@@ -424,7 +428,7 @@ void CLinuxRendererGL::CalculateTextureSourceRects(int source, int num_planes)
void CLinuxRendererGL::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
, unsigned width, unsigned height
- , int stride, void* data, GLuint* pbo/*= NULL*/ )
+ , int stride, int bpp, void* data, GLuint* pbo/*= NULL*/)
{
if(plane.flipindex == flipindex)
return;
@@ -439,23 +443,29 @@ void CLinuxRendererGL::LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
if(currPbo)
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, currPbo);
- int bps = glFormatElementByteCount(type);
+ int bps = bpp * glFormatElementByteCount(type);
+
+ unsigned datatype;
+ if(bpp == 2)
+ datatype = GL_UNSIGNED_SHORT;
+ else
+ datatype = GL_UNSIGNED_BYTE;
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / bps);
glBindTexture(m_textureTarget, plane.id);
- glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, GL_UNSIGNED_BYTE, data);
+ glTexSubImage2D(m_textureTarget, 0, 0, 0, width, height, type, datatype, data);
/* check if we need to load any border pixels */
if(height < plane.texheight)
glTexSubImage2D( m_textureTarget, 0
, 0, height, width, 1
- , type, GL_UNSIGNED_BYTE
+ , type, datatype
, (unsigned char*)data + stride * (height-1));
if(width < plane.texwidth)
glTexSubImage2D( m_textureTarget, 0
, width, 0, 1, height
- , type, GL_UNSIGNED_BYTE
+ , type, datatype
, (unsigned char*)data + bps * (width-1));
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
@@ -494,47 +504,47 @@ void CLinuxRendererGL::UploadYV12Texture(int source)
// Load Even Y Field
LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
, im->width, im->height >> 1
- , im->stride[0]*2, im->plane[0] );
+ , im->stride[0]*2, im->bpp, im->plane[0] );
//load Odd Y Field
LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
, im->width, im->height >> 1
- , im->stride[0]*2, im->plane[0] + im->stride[0]) ;
+ , im->stride[0]*2, im->bpp, im->plane[0] + im->stride[0]) ;
// Load Even U & V Fields
LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1]*2, im->plane[1] );
+ , im->stride[1]*2, im->bpp, im->plane[1] );
LoadPlane( fields[FIELD_TOP][2], GL_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[2]*2, im->plane[2] );
+ , im->stride[2]*2, im->bpp, im->plane[2] );
// Load Odd U & V Fields
LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1]*2, im->plane[1] + im->stride[1] );
+ , im->stride[1]*2, im->bpp, im->plane[1] + im->stride[1] );
LoadPlane( fields[FIELD_BOT][2], GL_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[2]*2, im->plane[2] + im->stride[2] );
+ , im->stride[2]*2, im->bpp, im->plane[2] + im->stride[2] );
}
else
{
//Load Y plane
LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
, im->width, im->height
- , im->stride[0], im->plane[0] );
+ , im->stride[0], im->bpp, im->plane[0] );
//load U plane
LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE, buf.flipindex
, im->width >> im->cshift_x, im->height >> im->cshift_y
- , im->stride[1], im->plane[1] );
+ , im->stride[1], im->bpp, im->plane[1] );
//load V plane
LoadPlane( fields[FIELD_FULL][2], GL_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> im->cshift_y
- , im->stride[2], im->plane[2] );
+ , im->stride[2], im->bpp, im->plane[2] );
}
m_eventTexturesDone[source]->Set();
@@ -741,6 +751,20 @@ unsigned int CLinuxRendererGL::PreInit()
m_iYV12RenderBuffer = 0;
m_NumYV12Buffers = 2;
+ m_formats.push_back(RENDER_FMT_YUV420P);
+ GLint size;
+ glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_LUMINANCE16, NP2(1920), NP2(1080), 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, NULL);
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &size);
+ if(size >= 16)
+ {
+ m_formats.push_back(RENDER_FMT_YUV420P10);
+ m_formats.push_back(RENDER_FMT_YUV420P16);
+ }
+ CLog::Log(LOGDEBUG, "CLinuxRendererGL::PreInit - precision of luminance 16 is %d", size);
+ m_formats.push_back(RENDER_FMT_NV12);
+ m_formats.push_back(RENDER_FMT_YUYV422);
+ m_formats.push_back(RENDER_FMT_UYVY422);
+
// setup the background colour
m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
@@ -890,12 +914,12 @@ void CLinuxRendererGL::UpdateVideoFilter()
void CLinuxRendererGL::LoadShaders(int field)
{
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU)
+ if (m_format == RENDER_FMT_VDPAU)
{
CLog::Log(LOGNOTICE, "GL: Using VDPAU render method");
m_renderMethod = RENDER_VDPAU;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VAAPI)
+ else if (m_format == RENDER_FMT_VAAPI)
{
CLog::Log(LOGNOTICE, "GL: Using VAAPI render method");
m_renderMethod = RENDER_VAAPI;
@@ -927,7 +951,7 @@ void CLinuxRendererGL::LoadShaders(int field)
if (glCreateProgram && tryGlsl)
{
// create regular progressive scan shader
- m_pYUVShader = new YUV2RGBProgressiveShader(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags,
+ m_pYUVShader = new YUV2RGBProgressiveShader(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags, m_format,
m_nonLinStretch && m_renderQuality == RQ_SINGLEPASS);
CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader");
@@ -955,7 +979,7 @@ void CLinuxRendererGL::LoadShaders(int field)
m_renderMethod = RENDER_ARB ;
// create regular progressive scan shader
- m_pYUVShader = new YUV2RGBProgressiveShaderARB(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags);
+ m_pYUVShader = new YUV2RGBProgressiveShaderARB(m_textureTarget==GL_TEXTURE_RECTANGLE_ARB, m_iFlags, m_format);
CLog::Log(LOGNOTICE, "GL: Selecting Single Pass ARB YUV2RGB shader");
if (m_pYUVShader && m_pYUVShader->CompileAndLink())
@@ -1009,26 +1033,26 @@ void CLinuxRendererGL::LoadShaders(int field)
m_pboUsed = false;
// Now that we now the render method, setup texture function handlers
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_NV12)
+ if (m_format == RENDER_FMT_NV12)
{
m_textureUpload = &CLinuxRendererGL::UploadNV12Texture;
m_textureCreate = &CLinuxRendererGL::CreateNV12Texture;
m_textureDelete = &CLinuxRendererGL::DeleteNV12Texture;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YUY2 ||
- CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_UYVY)
+ else if (m_format == RENDER_FMT_YUYV422 ||
+ m_format == RENDER_FMT_UYVY422)
{
m_textureUpload = &CLinuxRendererGL::UploadYUV422PackedTexture;
m_textureCreate = &CLinuxRendererGL::CreateYUV422PackedTexture;
m_textureDelete = &CLinuxRendererGL::DeleteYUV422PackedTexture;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU)
+ else if (m_format == RENDER_FMT_VDPAU)
{
m_textureUpload = &CLinuxRendererGL::UploadVDPAUTexture;
m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture;
m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VAAPI)
+ else if (m_format == RENDER_FMT_VAAPI)
{
m_textureUpload = &CLinuxRendererGL::UploadVAAPITexture;
m_textureCreate = &CLinuxRendererGL::CreateVAAPITexture;
@@ -1739,11 +1763,18 @@ bool CLinuxRendererGL::CreateYV12Texture(int index)
im.cshift_x = 1;
im.cshift_y = 1;
- im.stride[0] = im.width;
- im.stride[1] = im.width >> im.cshift_x;
- im.stride[2] = im.width >> im.cshift_x;
- im.planesize[0] = im.stride[0] * im.height;
+ if(m_format == RENDER_FMT_YUV420P16
+ || m_format == RENDER_FMT_YUV420P10)
+ im.bpp = 2;
+ else
+ im.bpp = 1;
+
+ im.stride[0] = im.bpp * im.width;
+ im.stride[1] = im.bpp * ( im.width >> im.cshift_x );
+ im.stride[2] = im.bpp * ( im.width >> im.cshift_x );
+
+ im.planesize[0] = im.stride[0] * im.height;
im.planesize[1] = im.stride[1] * ( im.height >> im.cshift_y );
im.planesize[2] = im.stride[2] * ( im.height >> im.cshift_y );
@@ -1857,13 +1888,26 @@ bool CLinuxRendererGL::CreateYV12Texture(int index)
}
else
{
- GLint format;
+ GLenum format;
+ GLint internalformat;
if (p == 2) //V plane needs an alpha texture
+ {
format = GL_ALPHA;
+ if(im.bpp == 2)
+ internalformat = GL_ALPHA16;
+ else
+ internalformat = GL_ALPHA;
+ }
else
+ {
format = GL_LUMINANCE;
+ if(im.bpp == 2)
+ internalformat = GL_LUMINANCE16;
+ else
+ internalformat = GL_LUMINANCE;
+ }
- glTexImage2D(m_textureTarget, 0, format, plane.texwidth, plane.texheight, 0, format, GL_UNSIGNED_BYTE, NULL);
+ glTexImage2D(m_textureTarget, 0, internalformat, plane.texwidth, plane.texheight, 0, format, GL_UNSIGNED_BYTE, NULL);
}
glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -1902,29 +1946,29 @@ void CLinuxRendererGL::UploadNV12Texture(int source)
glEnable(m_textureTarget);
VerifyGLState();
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, im->bpp);
if (deinterlacing)
{
// Load Odd Y field
LoadPlane( fields[FIELD_TOP][0] , GL_LUMINANCE, buf.flipindex
, im->width, im->height >> 1
- , im->stride[0]*2, im->plane[0] );
+ , im->stride[0]*2, im->bpp, im->plane[0] );
// Load Even Y field
LoadPlane( fields[FIELD_BOT][0], GL_LUMINANCE, buf.flipindex
, im->width, im->height >> 1
- , im->stride[0]*2, im->plane[0] + im->stride[0]) ;
+ , im->stride[0]*2, im->bpp, im->plane[0] + im->stride[0]) ;
// Load Odd UV Fields
LoadPlane( fields[FIELD_TOP][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1]*2, im->plane[1] );
+ , im->stride[1]*2, im->bpp, im->plane[1] );
// Load Even UV Fields
LoadPlane( fields[FIELD_BOT][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> (im->cshift_y + 1)
- , im->stride[1]*2, im->plane[1] + im->stride[1] );
+ , im->stride[1]*2, im->bpp, im->plane[1] + im->stride[1] );
}
else
@@ -1932,12 +1976,12 @@ void CLinuxRendererGL::UploadNV12Texture(int source)
// Load Y plane
LoadPlane( fields[FIELD_FULL][0], GL_LUMINANCE, buf.flipindex
, im->width, im->height
- , im->stride[0], im->plane[0] );
+ , im->stride[0], im->bpp, im->plane[0] );
// Load UV plane
LoadPlane( fields[FIELD_FULL][1], GL_LUMINANCE_ALPHA, buf.flipindex
, im->width >> im->cshift_x, im->height >> im->cshift_y
- , im->stride[1], im->plane[1] );
+ , im->stride[1], im->bpp, im->plane[1] );
}
m_eventTexturesDone[source]->Set();
@@ -1963,6 +2007,7 @@ bool CLinuxRendererGL::CreateNV12Texture(int index)
im.width = m_sourceWidth;
im.cshift_x = 1;
im.cshift_y = 1;
+ im.bpp = 1;
im.stride[0] = im.width;
im.stride[1] = im.width;
@@ -2382,18 +2427,18 @@ void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
// Load YUYV fields
LoadPlane( fields[FIELD_TOP][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height >> 1
- , im->stride[0] * 2, im->plane[0] );
+ , im->stride[0] * 2, im->bpp, im->plane[0] );
LoadPlane( fields[FIELD_BOT][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height >> 1
- , im->stride[0] * 2, im->plane[0] + im->stride[0]) ;
+ , im->stride[0] * 2, im->bpp, im->plane[0] + im->stride[0]) ;
}
else
{
// Load YUYV plane
LoadPlane( fields[FIELD_FULL][0], GL_BGRA, buf.flipindex
, im->width / 2, im->height
- , im->stride[0], im->plane[0] );
+ , im->stride[0], im->bpp, im->plane[0] );
}
m_eventTexturesDone[source]->Set();
@@ -2467,6 +2512,7 @@ bool CLinuxRendererGL::CreateYUV422PackedTexture(int index)
im.width = m_sourceWidth;
im.cshift_x = 0;
im.cshift_y = 0;
+ im.bpp = 1;
im.stride[0] = im.width * 2;
im.stride[1] = 0;
@@ -2609,7 +2655,7 @@ void CLinuxRendererGL::ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsign
int srcStride[4] = {};
int srcFormat = -1;
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YV12)
+ if (m_format == RENDER_FMT_YUV420P)
{
srcFormat = PIX_FMT_YUV420P;
for (int i = 0; i < 3; i++)
@@ -2618,7 +2664,7 @@ void CLinuxRendererGL::ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsign
srcStride[i] = im->stride[i];
}
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_NV12)
+ else if (m_format == RENDER_FMT_NV12)
{
srcFormat = PIX_FMT_NV12;
for (int i = 0; i < 2; i++)
@@ -2627,13 +2673,13 @@ void CLinuxRendererGL::ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsign
srcStride[i] = im->stride[i];
}
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YUY2)
+ else if (m_format == RENDER_FMT_YUYV422)
{
srcFormat = PIX_FMT_YUYV422;
src[0] = im->plane[0];
srcStride[0] = im->stride[0];
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_UYVY)
+ else if (m_format == RENDER_FMT_UYVY422)
{
srcFormat = PIX_FMT_UYVY422;
src[0] = im->plane[0];
@@ -2641,7 +2687,7 @@ void CLinuxRendererGL::ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsign
}
else //should never happen
{
- CLog::Log(LOGERROR, "CLinuxRendererGL::ToRGBFrame: called with unsupported format %i", CONF_FLAGS_FORMAT_MASK(m_iFlags));
+ CLog::Log(LOGERROR, "CLinuxRendererGL::ToRGBFrame: called with unsupported format %i", m_format);
return;
}
@@ -2680,7 +2726,7 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un
int srcStrideBot[4] = {};
int srcFormat = -1;
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YV12)
+ if (m_format == RENDER_FMT_YUV420P)
{
srcFormat = PIX_FMT_YUV420P;
for (int i = 0; i < 3; i++)
@@ -2691,7 +2737,7 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un
srcStrideBot[i] = im->stride[i] * 2;
}
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_NV12)
+ else if (m_format == RENDER_FMT_NV12)
{
srcFormat = PIX_FMT_NV12;
for (int i = 0; i < 2; i++)
@@ -2702,7 +2748,7 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un
srcStrideBot[i] = im->stride[i] * 2;
}
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YUY2)
+ else if (m_format == RENDER_FMT_YUYV422)
{
srcFormat = PIX_FMT_YUYV422;
srcTop[0] = im->plane[0];
@@ -2710,7 +2756,7 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un
srcBot[0] = im->plane[0] + im->stride[0];
srcStrideBot[0] = im->stride[0] * 2;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_UYVY)
+ else if (m_format == RENDER_FMT_UYVY422)
{
srcFormat = PIX_FMT_UYVY422;
srcTop[0] = im->plane[0];
@@ -2720,7 +2766,7 @@ void CLinuxRendererGL::ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, un
}
else //should never happen
{
- CLog::Log(LOGERROR, "CLinuxRendererGL::ToRGBFields: called with unsupported format %i", CONF_FLAGS_FORMAT_MASK(m_iFlags));
+ CLog::Log(LOGERROR, "CLinuxRendererGL::ToRGBFields: called with unsupported format %i", m_format);
return;
}
@@ -2864,17 +2910,17 @@ void CLinuxRendererGL::UploadRGBTexture(int source)
{
LoadPlane( fields[FIELD_TOP][0] , GL_BGRA, buf.flipindex
, im->width, im->height >> 1
- , m_sourceWidth*4, m_rgbBuffer, &m_rgbPbo );
+ , m_sourceWidth*4, 1, m_rgbBuffer, &m_rgbPbo );
LoadPlane( fields[FIELD_BOT][0], GL_BGRA, buf.flipindex
, im->width, im->height >> 1
- , m_sourceWidth*4, m_rgbBuffer + m_sourceWidth*m_sourceHeight*2, &m_rgbPbo );
+ , m_sourceWidth*4, 1, m_rgbBuffer + m_sourceWidth*m_sourceHeight*2, &m_rgbPbo );
}
else
{
LoadPlane( fields[FIELD_FULL][0], GL_BGRA, buf.flipindex
, im->width, im->height
- , m_sourceWidth*4, m_rgbBuffer, &m_rgbPbo );
+ , m_sourceWidth*4, 1, m_rgbBuffer, &m_rgbPbo );
}
//after using the pbo to upload, allocate a new buffer so we don't have to wait
@@ -3055,8 +3101,8 @@ bool CLinuxRendererGL::Supports(ESCALINGMETHOD method)
{
//nearest neighbor doesn't work on YUY2 and UYVY
if (method == VS_SCALINGMETHOD_NEAREST &&
- CONF_FLAGS_FORMAT_MASK(m_iFlags) != CONF_FLAGS_FORMAT_YUY2 &&
- CONF_FLAGS_FORMAT_MASK(m_iFlags) != CONF_FLAGS_FORMAT_UYVY)
+ m_format != RENDER_FMT_YUYV422 &&
+ m_format != RENDER_FMT_UYVY422)
return true;
if(method == VS_SCALINGMETHOD_LINEAR
9 xbmc/cores/VideoRenderers/LinuxRendererGL.h
View
@@ -30,6 +30,7 @@
#include "RenderFlags.h"
#include "guilib/GraphicContext.h"
#include "BaseRenderer.h"
+#include "RenderFormats.h"
#include "threads/Event.h"
@@ -132,7 +133,7 @@ class CLinuxRendererGL : public CBaseRenderer
bool RenderCapture(CRenderCapture* capture);
// Player functions
- virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format);
+ virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format);
virtual bool IsConfigured() { return m_bConfigured; }
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
@@ -160,6 +161,8 @@ class CLinuxRendererGL : public CBaseRenderer
virtual EINTERLACEMETHOD AutoInterlaceMethod();
+ virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
+
protected:
virtual void Render(DWORD flags, int renderBuffer);
void ClearBackBuffer();
@@ -220,8 +223,10 @@ class CLinuxRendererGL : public CBaseRenderer
bool m_bConfigured;
bool m_bValidated;
+ std::vector<ERenderFormat> m_formats;
bool m_bImageReady;
unsigned m_iFlags;
+ ERenderFormat m_format;
GLenum m_textureTarget;
unsigned short m_renderMethod;
RenderQuality m_renderQuality;
@@ -280,7 +285,7 @@ class CLinuxRendererGL : public CBaseRenderer
void LoadPlane( YUVPLANE& plane, int type, unsigned flipindex
, unsigned width, unsigned height
- , int stride, void* data, GLuint* pbo = NULL );
+ , int stride, int bpp, void* data, GLuint* pbo = NULL );
Shaders::BaseYUV2RGBShader *m_pYUVShader;
32 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
View
@@ -44,6 +44,8 @@
#include "../dvdplayer/DVDCodecs/Video/OpenMaxVideo.h"
#include "threads/SingleLock.h"
#include "RenderCapture.h"
+#include "RenderFormats.h"
+
#if defined(__ARM_NEON__)
#include "yuv2rgb.neon.h"
#endif
@@ -85,6 +87,7 @@ CLinuxRendererGLES::CLinuxRendererGLES()
m_renderMethod = RENDER_GLSL;
m_renderQuality = RQ_SINGLEPASS;
m_iFlags = 0;
+ m_format = RENDER_FMT_NONE;
m_iYV12RenderBuffer = 0;
m_flipindex = 0;
@@ -153,13 +156,14 @@ bool CLinuxRendererGLES::ValidateRenderTarget()
return false;
}
-bool CLinuxRendererGLES::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format)
+bool CLinuxRendererGLES::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format)
{
m_sourceWidth = width;
m_sourceHeight = height;
// Save the flags.
m_iFlags = flags;
+ m_format = format;
// Calculate the input frame aspect ratio.
CalculateFrameAspectRatio(d_width, d_height);
@@ -236,6 +240,7 @@ int CLinuxRendererGLES::GetImage(YV12Image *image, int source, bool readonly)
image->flags = im.flags;
image->cshift_x = im.cshift_x;
image->cshift_y = im.cshift_y;
+ image->bpp = 1;
return source;
@@ -414,7 +419,7 @@ void CLinuxRendererGLES::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
int index = m_iYV12RenderBuffer;
YUVBUFFER& buf = m_buffers[index];
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) != CONF_FLAGS_FORMAT_OMXEGL)
+ if (m_format != RENDER_FMT_OMXEGL)
{
if (!buf.fields[FIELD_FULL][0].id) return;
}
@@ -500,6 +505,15 @@ unsigned int CLinuxRendererGLES::PreInit()
m_iYV12RenderBuffer = 0;
m_NumYV12Buffers = 2;
+ m_formats.push_back(RENDER_FMT_YUV420P);
+ m_formats.push_back(RENDER_FMT_BYPASS);
+#if defined(HAVE_LIBOPENMAX)
+ m_formats.push_back(RENDER_FMT_OMXEGL);
+#endif
+#ifdef HAVE_VIDEOTOOLBOXDECODER
+ m_formats.push_back(RENDER_FMT_CVBREF);
+#endif
+
// setup the background colour
m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
@@ -592,26 +606,26 @@ void CLinuxRendererGLES::LoadShaders(int field)
{
case RENDER_METHOD_AUTO:
case RENDER_METHOD_GLSL:
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_OMXEGL)
+ if (m_format == RENDER_FMT_OMXEGL)
{
CLog::Log(LOGNOTICE, "GL: Using OMXEGL RGBA render method");
m_renderMethod = RENDER_OMXEGL;
break;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_BYPASS)
+ else if (m_format == RENDER_FMT_BYPASS)
{
CLog::Log(LOGNOTICE, "GL: Using BYPASS render method");
m_renderMethod = RENDER_BYPASS;
break;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_CVBREF)
+ else if (m_format == RENDER_FMT_CVBREF)
{
CLog::Log(LOGNOTICE, "GL: Using CoreVideoRef RGBA render method");
m_renderMethod = RENDER_CVREF;
break;
}
#if defined(TARGET_DARWIN_IOS)
- else if (ios_version < 5.0 && CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_YV12)
+ else if (ios_version < 5.0 && m_format == RENDER_FMT_YUV420P)
{
CLog::Log(LOGNOTICE, "GL: Using software color conversion/RGBA render method");
m_renderMethod = RENDER_SW;
@@ -622,7 +636,7 @@ void CLinuxRendererGLES::LoadShaders(int field)
if (glCreateProgram)
{
// create regular progressive scan shader
- m_pYUVShader = new YUV2RGBProgressiveShader(false, m_iFlags);
+ m_pYUVShader = new YUV2RGBProgressiveShader(false, m_iFlags, m_format);
CLog::Log(LOGNOTICE, "GL: Selecting Single Pass YUV 2 RGB shader");
if (m_pYUVShader && m_pYUVShader->CompileAndLink())
@@ -660,13 +674,13 @@ void CLinuxRendererGLES::LoadShaders(int field)
CLog::Log(LOGNOTICE, "GL: NPOT texture support detected");
// Now that we now the render method, setup texture function handlers
- if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_CVBREF)
+ if (m_format == RENDER_FMT_CVBREF)
{
m_textureUpload = &CLinuxRendererGLES::UploadCVRefTexture;
m_textureCreate = &CLinuxRendererGLES::CreateCVRefTexture;
m_textureDelete = &CLinuxRendererGLES::DeleteCVRefTexture;
}
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_BYPASS)
+ else if (m_format == RENDER_FMT_BYPASS)
{
m_textureUpload = &CLinuxRendererGLES::UploadBYPASSTexture;
m_textureCreate = &CLinuxRendererGLES::CreateBYPASSTexture;
6 xbmc/cores/VideoRenderers/LinuxRendererGLES.h
View
@@ -134,7 +134,7 @@ class CLinuxRendererGLES : public CBaseRenderer
bool RenderCapture(CRenderCapture* capture);
// Player functions
- virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format);
+ virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format);
virtual bool IsConfigured() { return m_bConfigured; }
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
@@ -154,6 +154,8 @@ class CLinuxRendererGLES : public CBaseRenderer
virtual EINTERLACEMETHOD AutoInterlaceMethod();
+ virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
+
#ifdef HAVE_LIBOPENMAX
virtual void AddProcessor(COpenMax* openMax, DVDVideoPicture *picture);
#endif
@@ -204,8 +206,10 @@ class CLinuxRendererGLES : public CBaseRenderer
bool m_bConfigured;
bool m_bValidated;
+ std::vector<ERenderFormat> m_formats;
bool m_bImageReady;
unsigned m_iFlags;
+ ERenderFormat m_format;
GLenum m_textureTarget;
unsigned short m_renderMethod;
RenderQuality m_renderQuality;
11 xbmc/cores/VideoRenderers/RenderFlags.h
View
@@ -69,15 +69,4 @@
#define CONF_FLAGS_TRC_GAMMA22 0x0800
#define CONF_FLAGS_TRC_GAMMA28 0x0c00
-#define CONF_FLAGS_FORMAT_MASK(a) ((a) & 0x00fff000)
-#define CONF_FLAGS_FORMAT_YV12 0x001000
-#define CONF_FLAGS_FORMAT_NV12 0x002000
-#define CONF_FLAGS_FORMAT_UYVY 0x004000
-#define CONF_FLAGS_FORMAT_YUY2 0x008000
-#define CONF_FLAGS_FORMAT_DXVA 0x010000
-#define CONF_FLAGS_FORMAT_VDPAU 0x020000
-#define CONF_FLAGS_FORMAT_VAAPI 0x030000
-#define CONF_FLAGS_FORMAT_OMXEGL 0x040000
-#define CONF_FLAGS_FORMAT_CVBREF 0x080000
-#define CONF_FLAGS_FORMAT_BYPASS 0x100000
#endif
40 xbmc/cores/VideoRenderers/RenderFormats.h
View
@@ -0,0 +1,40 @@
+#ifndef _RENDER_FORMATS_H_
+#define _RENDER_FORMATS_H_
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+enum ERenderFormat {
+ RENDER_FMT_NONE = 0,
+ RENDER_FMT_YUV420P,
+ RENDER_FMT_YUV420P10,
+ RENDER_FMT_YUV420P16,
+ RENDER_FMT_VDPAU,
+ RENDER_FMT_NV12,
+ RENDER_FMT_UYVY422,
+ RENDER_FMT_YUYV422,
+ RENDER_FMT_DXVA,
+ RENDER_FMT_VAAPI,
+ RENDER_FMT_OMXEGL,
+ RENDER_FMT_CVBREF,
+ RENDER_FMT_BYPASS,
+};
+
+#endif
24 xbmc/cores/VideoRenderers/RenderManager.cpp
View
@@ -212,7 +212,7 @@ CStdString CXBMCRenderManager::GetVSyncState()
return state;
}
-bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format)
+bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format)
{
/* make sure any queued frame was fully presented */
double timeout = m_presenttime + 0.1;
@@ -232,7 +232,7 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
return false;
}
- bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags, format);
+ bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags, format, extended_format);
if(result)
{
if( flags & CONF_FLAGS_FULLSCREEN )
@@ -758,37 +758,39 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic)
if(index < 0)
return index;
- if(pic.format == DVDVideoPicture::FMT_YUV420P)
+ if(pic.format == RENDER_FMT_YUV420P
+ || pic.format == RENDER_FMT_YUV420P10
+ || pic.format == RENDER_FMT_YUV420P16)
{
CDVDCodecUtils::CopyPicture(&image, &pic);
}
- else if(pic.format == DVDVideoPicture::FMT_NV12)
+ else if(pic.format == RENDER_FMT_NV12)
{
CDVDCodecUtils::CopyNV12Picture(&image, &pic);
}
- else if(pic.format == DVDVideoPicture::FMT_YUY2
- || pic.format == DVDVideoPicture::FMT_UYVY)
+ else if(pic.format == RENDER_FMT_YUYV422
+ || pic.format == RENDER_FMT_UYVY422)
{
CDVDCodecUtils::CopyYUV422PackedPicture(&image, &pic);
}
- else if(pic.format == DVDVideoPicture::FMT_DXVA)
+ else if(pic.format == RENDER_FMT_DXVA)
{
CDVDCodecUtils::CopyDXVA2Picture(&image, &pic);
}
#ifdef HAVE_LIBVDPAU
- else if(pic.format == DVDVideoPicture::FMT_VDPAU)
+ else if(pic.format == RENDER_FMT_VDPAU)
m_pRenderer->AddProcessor(pic.vdpau);
#endif
#ifdef HAVE_LIBOPENMAX
- else if(pic.format == DVDVideoPicture::FMT_OMXEGL)
+ else if(pic.format == RENDER_FMT_OMXEGL)
m_pRenderer->AddProcessor(pic.openMax, &pic);
#endif
#ifdef HAVE_VIDEOTOOLBOXDECODER
- else if(pic.format == DVDVideoPicture::FMT_CVBREF)
+ else if(pic.format == RENDER_FMT_CVBREF)
m_pRenderer->AddProcessor(pic.vtb, &pic);
#endif
#ifdef HAVE_LIBVA
- else if(pic.format == DVDVideoPicture::FMT_VAAPI)
+ else if(pic.format == RENDER_FMT_VAAPI)
m_pRenderer->AddProcessor(*pic.vaapi);
#endif
m_pRenderer->ReleaseImage(index, false);
11 xbmc/cores/VideoRenderers/RenderManager.h
View
@@ -68,7 +68,7 @@ class CXBMCRenderManager
void SetViewMode(int iViewMode) { CSharedLock lock(m_sharedSection); if (m_pRenderer) m_pRenderer->SetViewMode(iViewMode); };
// Functions called from mplayer
- bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format);
+ bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format);
bool IsConfigured();
int AddVideoPicture(DVDVideoPicture& picture);
@@ -167,6 +167,15 @@ class CXBMCRenderManager
return 0;
}
+ // Supported pixel formats, can be called before configure
+ std::vector<ERenderFormat> SupportedFormats()
+ {
+ CSharedLock lock(m_sharedSection);
+ if (m_pRenderer)
+ return m_pRenderer->SupportedFormats();
+ return std::vector<ERenderFormat>();
+ }
+
#ifdef HAS_GL
CLinuxRendererGL *m_pRenderer;
#elif HAS_GLES == 2
50 xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.cpp
View
@@ -29,13 +29,14 @@
#include "ConvolutionKernels.h"
#include "YUV2RGBShader.h"
#include "win32/WIN32Util.h"
+#include "cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
CYUV2RGBMatrix::CYUV2RGBMatrix()
{
m_NeedRecalc = true;
}
-void CYUV2RGBMatrix::SetParameters(float contrast, float blacklevel, unsigned int flags)
+void CYUV2RGBMatrix::SetParameters(float contrast, float blacklevel, unsigned int flags, ERenderFormat format)
{
if (m_contrast != contrast)
{
@@ -52,6 +53,11 @@ void CYUV2RGBMatrix::SetParameters(float contrast, float blacklevel, unsigned in
m_NeedRecalc = true;
m_flags = flags;
}
+ if (m_format != format)
+ {
+ m_NeedRecalc = true;
+ m_format = format;
+ }
}
D3DXMATRIX* CYUV2RGBMatrix::Matrix()
@@ -59,7 +65,7 @@ D3DXMATRIX* CYUV2RGBMatrix::Matrix()
if (m_NeedRecalc)
{
TransformMatrix matrix;
- CalculateYUVMatrix(matrix, m_flags, m_blacklevel, m_contrast);
+ CalculateYUVMatrix(matrix, m_flags, m_format, m_blacklevel, m_contrast);
m_mat._11 = matrix.m[0][0];
m_mat._12 = matrix.m[1][0];
@@ -199,18 +205,45 @@ bool CWinShader::Execute(std::vector<LPDIRECT3DSURFACE9> *vecRT, unsigned int ve
//==================================================================================
-bool CYUV2RGBShader::Create(unsigned int sourceWidth, unsigned int sourceHeight, BufferFormat fmt)
+bool CYUV2RGBShader::Create(unsigned int sourceWidth, unsigned int sourceHeight, ERenderFormat fmt)
{
CWinShader::CreateVertexBuffer(D3DFVF_XYZRHW | D3DFVF_TEX3, 4, sizeof(CUSTOMVERTEX), 2);
m_sourceWidth = sourceWidth;
m_sourceHeight = sourceHeight;
+ m_format = fmt;
unsigned int texWidth;
DefinesMap defines;
- if (fmt == YV12)
+ if (fmt == RENDER_FMT_YUV420P16)
+ {
+ defines["XBMC_YV12"] = "";
+ texWidth = sourceWidth;
+
+ if(!m_YUVPlanes[0].Create(texWidth , m_sourceHeight , 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[1].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[2].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": Failed to create 16 bit YV12 planes.");
+ return false;
+ }
+ }
+ else if (fmt == RENDER_FMT_YUV420P10)
+ {
+ defines["XBMC_YV12"] = "";
+ texWidth = sourceWidth;
+
+ if(!m_YUVPlanes[0].Create(texWidth , m_sourceHeight , 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[1].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT)
+ || !m_YUVPlanes[2].Create(texWidth / 2, m_sourceHeight / 2, 1, 0, D3DFMT_L16, D3DPOOL_DEFAULT))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": Failed to create 10 bit YV12 planes.");
+ return false;
+ }
+ }
+ else if (fmt == RENDER_FMT_YUV420P)
{
defines["XBMC_YV12"] = "";
texWidth = sourceWidth;
@@ -223,7 +256,7 @@ bool CYUV2RGBShader::Create(unsigned int sourceWidth, unsigned int sourceHeight,
return false;
}
}
- else if (fmt == NV12)
+ else if (fmt == RENDER_FMT_NV12)
{
defines["XBMC_NV12"] = "";
texWidth = sourceWidth;
@@ -235,7 +268,7 @@ bool CYUV2RGBShader::Create(unsigned int sourceWidth, unsigned int sourceHeight,
return false;
}
}
- else if (fmt == YUY2)
+ else if (fmt == RENDER_FMT_YUYV422)
{
defines["XBMC_YUY2"] = "";
texWidth = sourceWidth >> 1;
@@ -246,7 +279,7 @@ bool CYUV2RGBShader::Create(unsigned int sourceWidth, unsigned int sourceHeight,
return false;
}
}
- else if (fmt == UYVY)
+ else if (fmt == RENDER_FMT_UYVY422)
{
defines["XBMC_UYVY"] = "";
texWidth = sourceWidth >> 1;
@@ -355,7 +388,8 @@ void CYUV2RGBShader::PrepareParameters(CRect sourceRect,
m_matrix.SetParameters(contrast * 0.02f,
brightness * 0.01f - 0.5f,
- flags);
+ flags,
+ m_format);
}
void CYUV2RGBShader::SetShaderParameters(YUVBuffer* YUVbuf)
7 xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.h
View
@@ -25,13 +25,14 @@
#include "../../guilib/Geometry.h"
#include "../WinRenderer.h"
+#include "../RenderFormats.h"
class CYUV2RGBMatrix
{
public:
CYUV2RGBMatrix();
- void SetParameters(float contrast, float blacklevel, unsigned int flags);
+ void SetParameters(float contrast, float blacklevel, unsigned int flags, ERenderFormat format);
D3DXMATRIX* Matrix();
private:
@@ -39,6 +40,7 @@ class CYUV2RGBMatrix
float m_contrast;
float m_blacklevel;
unsigned int m_flags;
+ ERenderFormat m_format;
D3DXMATRIX m_mat;
};
@@ -66,7 +68,7 @@ class CWinShader
class CYUV2RGBShader : public CWinShader
{
public:
- virtual bool Create(unsigned int sourceWidth, unsigned int sourceHeight, BufferFormat fmt);
+ virtual bool Create(unsigned int sourceWidth, unsigned int sourceHeight, ERenderFormat fmt);
virtual void Render(CRect sourceRect,
CRect destRect,
float contrast,
@@ -88,6 +90,7 @@ class CYUV2RGBShader : public CWinShader
CYUV2RGBMatrix m_matrix;
unsigned int m_sourceWidth, m_sourceHeight;
CRect m_sourceRect, m_destRect;
+ ERenderFormat m_format;
CD3DTexture m_YUVPlanes[3];
float m_texSteps[2];
50 xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
View
@@ -28,6 +28,7 @@
#if defined(HAS_GL) || defined(HAS_GLES)
#include "utils/GLUtils.h"
#endif
+#include "cores/VideoRenderers/RenderFormats.h"
#include <string>
#include <sstream>
@@ -90,6 +91,7 @@ static float** PickYUVConversionMatrix(unsigned flags)
void CalculateYUVMatrix(TransformMatrix &matrix
, unsigned int flags
+ , ERenderFormat format
, float black
, float contrast)
{
@@ -115,6 +117,13 @@ void CalculateYUVMatrix(TransformMatrix &matrix
, - 16.0f / 255
, - 16.0f / 255);
}
+
+ if(format == RENDER_FMT_YUV420P10)
+ {
+ matrix *= TransformMatrix::CreateScaler(65535.0 / 1023.0
+ , 65535.0 / 1023.0
+ , 65535.0 / 1023.0);
+ }
}
#if defined(HAS_GL) || HAS_GLES == 2
@@ -124,11 +133,12 @@ using namespace std;
static void CalculateYUVMatrixGL(GLfloat res[4][4]
, unsigned int flags
+ , ERenderFormat format
, float black
, float contrast)
{
TransformMatrix matrix;
- CalculateYUVMatrix(matrix, flags, black, contrast);
+ CalculateYUVMatrix(matrix, flags, format, black, contrast);
for(int row = 0; row < 3; row++)
for(int col = 0; col < 4; col++)
@@ -144,12 +154,13 @@ static void CalculateYUVMatrixGL(GLfloat res[4][4]
// BaseYUV2RGBGLSLShader - base class for GLSL YUV2RGB shaders
//////////////////////////////////////////////////////////////////////
-BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, unsigned flags, bool stretch)
+BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, unsigned flags, ERenderFormat format, bool stretch)
{
m_width = 1;
m_height = 1;
m_field = 0;
m_flags = flags;
+ m_format = format;
m_black = 0.0f;
m_contrast = 1.0f;
@@ -180,14 +191,18 @@ BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, unsigned flags, bool str
else
m_defines += "#define XBMC_STRETCH 0\n";
- if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YV12)
+ if (m_format == RENDER_FMT_YUV420P ||
+ m_format == RENDER_FMT_YUV420P10 ||
+ m_format == RENDER_FMT_YUV420P16)
m_defines += "#define XBMC_YV12\n";
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_NV12)
+ else if (m_format == RENDER_FMT_NV12)
m_defines += "#define XBMC_NV12\n";
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YUY2)
+ else if (m_format == RENDER_FMT_YUYV422)
m_defines += "#define XBMC_YUY2\n";
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY)
+ else if (m_format == RENDER_FMT_UYVY422)
m_defines += "#define XBMC_UYVY\n";
+ else
+ CLog::Log(LOGERROR, "GL: BaseYUV2RGBGLSLShader - unsupported format %d", m_format);
VertexShader()->LoadSource("yuv2rgb_vertex.glsl", m_defines);
#elif HAS_GLES == 2
@@ -235,7 +250,7 @@ bool BaseYUV2RGBGLSLShader::OnEnabled()
glUniform2f(m_hStep, 1.0 / m_width, 1.0 / m_height);
GLfloat matrix[4][4];
- CalculateYUVMatrixGL(matrix, m_flags, m_black, m_contrast);
+ CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast);
glUniformMatrix4fv(m_hMatrix, 1, GL_FALSE, (GLfloat*)matrix);
#if HAS_GLES == 2
@@ -251,12 +266,13 @@ bool BaseYUV2RGBGLSLShader::OnEnabled()
// BaseYUV2RGBGLSLShader - base class for GLSL YUV2RGB shaders
//////////////////////////////////////////////////////////////////////
#if HAS_GLES != 2 // No ARB Shader when using GLES2.0
-BaseYUV2RGBARBShader::BaseYUV2RGBARBShader(unsigned flags)
+BaseYUV2RGBARBShader::BaseYUV2RGBARBShader(unsigned flags, ERenderFormat format)
{
m_width = 1;
m_height = 1;
m_field = 0;
m_flags = flags;
+ m_format = format;
// shader attribute handles
m_hYTex = -1;
@@ -270,8 +286,8 @@ BaseYUV2RGBARBShader::BaseYUV2RGBARBShader(unsigned flags)
// Use for weave deinterlacing / progressive
//////////////////////////////////////////////////////////////////////
-YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, unsigned flags, bool stretch)
- : BaseYUV2RGBGLSLShader(rect, flags, stretch)
+YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, unsigned flags, ERenderFormat format, bool stretch)
+ : BaseYUV2RGBGLSLShader(rect, flags, format, stretch)
{
#ifdef HAS_GL
PixelShader()->LoadSource("yuv2rgb_basic.glsl", m_defines);
@@ -285,8 +301,8 @@ YUV2RGBProgressiveShader::YUV2RGBProgressiveShader(bool rect, unsigned flags, bo
// YUV2RGBBobShader - YUV2RGB with Bob deinterlacing
//////////////////////////////////////////////////////////////////////
-YUV2RGBBobShader::YUV2RGBBobShader(bool rect, unsigned flags)
- : BaseYUV2RGBGLSLShader(rect, flags, false)
+YUV2RGBBobShader::YUV2RGBBobShader(bool rect, unsigned flags, ERenderFormat format)
+ : BaseYUV2RGBGLSLShader(rect, flags, format, false)
{
m_hStepX = -1;
m_hStepY = -1;
@@ -323,22 +339,22 @@ bool YUV2RGBBobShader::OnEnabled()
// YUV2RGBProgressiveShaderARB - YUV2RGB with no deinterlacing
//////////////////////////////////////////////////////////////////////
#if HAS_GLES != 2 // No ARB Shader when using GLES2.0
-YUV2RGBProgressiveShaderARB::YUV2RGBProgressiveShaderARB(bool rect, unsigned flags)
- : BaseYUV2RGBARBShader(flags)
+YUV2RGBProgressiveShaderARB::YUV2RGBProgressiveShaderARB(bool rect, unsigned flags, ERenderFormat format)
+ : BaseYUV2RGBARBShader(flags, format)
{
m_black = 0.0f;
m_contrast = 1.0f;
string shaderfile;
- if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YUY2)
+ if (m_format == RENDER_FMT_YUYV422)
{
if(rect)
shaderfile = "yuv2rgb_basic_rect_YUY2.arb";
else
shaderfile = "yuv2rgb_basic_2d_YUY2.arb";
}
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY)
+ else if (m_format == RENDER_FMT_UYVY422)
{
if(rect)
shaderfile = "yuv2rgb_basic_rect_UYVY.arb";
@@ -365,7 +381,7 @@ void YUV2RGBProgressiveShaderARB::OnCompiledAndLinked()
bool YUV2RGBProgressiveShaderARB::OnEnabled()
{
GLfloat matrix[4][4];
- CalculateYUVMatrixGL(matrix, m_flags, m_black, m_contrast);
+ CalculateYUVMatrixGL(matrix, m_flags, m_format, m_black, m_contrast);
for(int i=0;i<4;i++)
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, i
14 xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.h
View
@@ -23,9 +23,11 @@
*/
#include "guilib/TransformMatrix.h"
+#include "cores/VideoRenderers/RenderFormats.h"
void CalculateYUVMatrix(TransformMatrix &matrix
, unsigned int flags
+ , ERenderFormat format
, float black
, float contrast);
@@ -69,7 +71,7 @@ namespace Shaders {
, public CGLSLShaderProgram
{
public:
- BaseYUV2RGBGLSLShader(bool rect, unsigned flags, bool stretch);
+ BaseYUV2RGBGLSLShader(bool rect, unsigned flags, ERenderFormat format, bool stretch);
~BaseYUV2RGBGLSLShader() {}
virtual void SetField(int field) { m_field = field; }
virtual void SetWidth(int w) { m_width = w; }
@@ -93,6 +95,7 @@ namespace Shaders {
bool OnEnabled();
unsigned m_flags;
+ ERenderFormat m_format;
int m_width;
int m_height;
int m_field;
@@ -131,7 +134,7 @@ namespace Shaders {
, public CARBShaderProgram
{
public:
- BaseYUV2RGBARBShader(unsigned flags);
+ BaseYUV2RGBARBShader(unsigned flags, ERenderFormat format);
~BaseYUV2RGBARBShader() {}
virtual void SetField(int field) { m_field = field; }
virtual void SetWidth(int w) { m_width = w; }
@@ -142,6 +145,7 @@ namespace Shaders {
protected:
unsigned m_flags;
+ ERenderFormat m_format;
int m_width;
int m_height;
int m_field;
@@ -158,7 +162,7 @@ namespace Shaders {
class YUV2RGBProgressiveShaderARB : public BaseYUV2RGBARBShader
{
public:
- YUV2RGBProgressiveShaderARB(bool rect=false, unsigned flags=0);
+ YUV2RGBProgressiveShaderARB(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE);
void OnCompiledAndLinked();
bool OnEnabled();
};
@@ -167,13 +171,13 @@ namespace Shaders {
class YUV2RGBProgressiveShader : public BaseYUV2RGBGLSLShader
{
public:
- YUV2RGBProgressiveShader(bool rect=false, unsigned flags=0, bool stretch = false);
+ YUV2RGBProgressiveShader(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE, bool stretch = false);
};
class YUV2RGBBobShader : public BaseYUV2RGBGLSLShader
{
public:
- YUV2RGBBobShader(bool rect=false, unsigned flags=0);
+ YUV2RGBBobShader(bool rect=false, unsigned flags=0, ERenderFormat format=RENDER_FMT_NONE);
void OnCompiledAndLinked();
bool OnEnabled();
131 xbmc/cores/VideoRenderers/WinRenderer.cpp
View
@@ -37,6 +37,7 @@
#include "guilib/LocalizeStrings.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "win32/WIN32Util.h"
+#include "cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
typedef struct {
RenderMethod method;
@@ -66,6 +67,7 @@ CWinRenderer::CWinRenderer()
m_colorShader = NULL;
m_scalerShader = NULL;
+ m_extended_format = 0;
m_iRequestedMethod = RENDER_METHOD_AUTO;
@@ -82,7 +84,6 @@ CWinRenderer::CWinRenderer()
m_sw_scale_ctx = NULL;
m_dllSwScale = NULL;
- m_dxvaDecoding = false;
}
CWinRenderer::~CWinRenderer()
@@ -90,21 +91,14 @@ CWinRenderer::~CWinRenderer()
UnInit();
}
-static BufferFormat BufferFormatFromFlags(unsigned int flags)
+static enum PixelFormat PixelFormatFromFormat(ERenderFormat format)
{
- if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YV12) return YV12;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_NV12) return NV12;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YUY2) return YUY2;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY) return UYVY;
- else return Invalid;
-}
-
-static enum PixelFormat PixelFormatFromFlags(unsigned int flags)
-{
- if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YV12) return PIX_FMT_YUV420P;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_NV12) return PIX_FMT_NV12;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY) return PIX_FMT_UYVY422;
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_YUY2) return PIX_FMT_YUYV422;
+ if (format == RENDER_FMT_YUV420P) return PIX_FMT_YUV420P;
+ else if (format == RENDER_FMT_YUV420P10) return PIX_FMT_YUV420P10;
+ else if (format == RENDER_FMT_YUV420P10) return PIX_FMT_YUV420P16;
+ else if (format == RENDER_FMT_NV12) return PIX_FMT_NV12;
+ else if (format == RENDER_FMT_UYVY422) return PIX_FMT_UYVY422;
+ else if (format == RENDER_FMT_YUYV422) return PIX_FMT_YUYV422;
else return PIX_FMT_NONE;
}
@@ -134,11 +128,11 @@ void CWinRenderer::SelectRenderMethod()
// Set rendering to dxva before trying it, in order to open the correct processor immediately, when deinterlacing method is auto.
// Force dxva renderer after dxva decoding: PS and SW renderers have performance issues after dxva decode.
- if (g_advancedSettings.m_DXVAForceProcessorRenderer && CONF_FLAGS_FORMAT_MASK(m_flags) == CONF_FLAGS_FORMAT_DXVA)
+ if (g_advancedSettings.m_DXVAForceProcessorRenderer && m_format == RENDER_FMT_DXVA)
{
CLog::Log(LOGNOTICE, "D3D: rendering method forced to DXVA2 processor");
m_renderMethod = RENDER_DXVA;
- if (!m_processor.Open(m_sourceWidth, m_sourceHeight, m_flags, m_format))
+ if (!m_processor.Open(m_sourceWidth, m_sourceHeight, m_flags, m_format, m_extended_format))
{
CLog::Log(LOGNOTICE, "D3D: unable to open DXVA2 processor");
m_processor.Close();
@@ -153,7 +147,7 @@ void CWinRenderer::SelectRenderMethod()
{
case RENDER_METHOD_DXVA:
m_renderMethod = RENDER_DXVA;
- if (m_processor.Open(m_sourceWidth, m_sourceHeight, m_flags, m_format))
+ if (m_processor.Open(m_sourceWidth, m_sourceHeight, m_flags, m_format, m_extended_format))
break;
else
{
@@ -192,27 +186,6 @@ void CWinRenderer::SelectRenderMethod()
}
}
- // Update flags for DXVA2 pictures
- if (CONF_FLAGS_FORMAT_MASK(m_flags) == CONF_FLAGS_FORMAT_DXVA)
- {
- m_flags &= ~CONF_FLAGS_FORMAT_DXVA;
- switch (m_format)
- {
- case MAKEFOURCC('Y','V','1','2'):
- m_flags |= CONF_FLAGS_FORMAT_YV12;
- break;
- case MAKEFOURCC('N','V','1','2'):
- m_flags |= CONF_FLAGS_FORMAT_NV12;
- break;
- case MAKEFOURCC('U','Y','V','Y'):
- m_flags |= CONF_FLAGS_FORMAT_UYVY;
- break;
- case MAKEFOURCC('Y','U','Y','2'):
- m_flags |= CONF_FLAGS_FORMAT_YUY2;
- break;
- }
- }
-
RenderMethodDetail *rmdet = FindRenderMethod(m_renderMethod);
CLog::Log(LOGDEBUG, __FUNCTION__": Selected render method %d: %s", m_renderMethod, rmdet != NULL ? rmdet->name : "unknown");
}
@@ -238,7 +211,7 @@ bool CWinRenderer::UpdateRenderMethod()
return true;
}
-bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format)
+bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format)
{
if(m_sourceWidth != width
|| m_sourceHeight != height)
@@ -252,14 +225,10 @@ bool CWinRenderer::Configure(unsigned int width, unsigned int height, unsigned i
m_bFilterInitialized = false;
}
- if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_DXVA)
- m_dxvaDecoding = true;
- else
- m_dxvaDecoding = false;
-
m_fps = fps;
m_flags = flags;
m_format = format;
+ m_extended_format = extended_format;
// calculate the input frame aspect ratio
CalculateFrameAspectRatio(d_width, d_height);
@@ -316,6 +285,11 @@ int CWinRenderer::GetImage(YV12Image *image, int source, bool readonly)
image->height = m_sourceHeight;
image->width = m_sourceWidth;
image->flags = 0;
+ if(m_format == RENDER_FMT_YUV420P10
+ || m_format == RENDER_FMT_YUV420P16)
+ image->bpp = 2;
+ else
+ image->bpp = 1;
for(int i=0;i<3;i++)
{
@@ -405,6 +379,17 @@ unsigned int CWinRenderer::PreInit()
if ((g_advancedSettings.m_DXVAForceProcessorRenderer || m_iRequestedMethod == RENDER_METHOD_DXVA) && !m_processor.PreInit())
CLog::Log(LOGNOTICE, "CWinRenderer::Preinit - could not init DXVA2 processor - skipping");
+ m_formats.push_back(RENDER_FMT_YUV420P);
+ if(g_Windowing.IsTextureFormatOk(D3DFMT_L16, 0))
CrystalP Collaborator

OK. It could be a good idea to also call a new SupportedFormats function in CWinShader, to reduce the risk of problems later.
It's not a big deal and could be added later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ {
+ m_formats.push_back(RENDER_FMT_YUV420P10);
+ m_formats.push_back(RENDER_FMT_YUV420P16);
+ }
+ m_formats.push_back(RENDER_FMT_NV12);
+ m_formats.push_back(RENDER_FMT_YUYV422);
+ m_formats.push_back(RENDER_FMT_UYVY422);
+
+
return 0;
}
@@ -574,12 +559,10 @@ void CWinRenderer::UpdatePSVideoFilter()
SAFE_DELETE(m_colorShader);
- BufferFormat format = BufferFormatFromFlags(m_flags);
-
if (m_bUseHQScaler)
{
m_colorShader = new CYUV2RGBShader();
- if (!m_colorShader->Create(m_sourceWidth, m_sourceHeight, format))
+ if (!m_colorShader->Create(m_sourceWidth, m_sourceHeight, m_format))
{
// Try again after disabling the HQ scaler and freeing its resources
m_IntermediateTarget.Release();
@@ -592,7 +575,7 @@ void CWinRenderer::UpdatePSVideoFilter()
if (!m_bUseHQScaler) //fallback from HQ scalers and multipass creation above
{
m_colorShader = new CYUV2RGBShader();
- if (!m_colorShader->Create(m_sourceWidth, m_sourceHeight, format))
+ if (!m_colorShader->Create(m_sourceWidth, m_sourceHeight, m_format))
SAFE_DELETE(m_colorShader);
// we're in big trouble - should fallback on D3D accelerated or sw method
}
@@ -670,7 +653,7 @@ void CWinRenderer::Render(DWORD flags)
void CWinRenderer::RenderSW()
{
- enum PixelFormat format = PixelFormatFromFlags(m_flags);
+ enum PixelFormat format = PixelFormatFromFormat(m_format);
// 1. convert yuv to rgb
m_sw_scale_ctx = m_dllSwScale->sws_getCachedContext(m_sw_scale_ctx,
@@ -991,9 +974,7 @@ bool CWinRenderer::CreateYV12Texture(int index)
{
YUVBuffer *buf = new YUVBuffer();
- BufferFormat format = BufferFormatFromFlags(m_flags);
-
- if (!buf->Create(format, m_sourceWidth, m_sourceHeight))
+ if (!buf->Create(m_format, m_sourceWidth, m_sourceHeight))
{
CLog::Log(LOGERROR, __FUNCTION__" - Unable to create YV12 video texture %i", index);
return false;
@@ -1035,7 +1016,7 @@ bool CWinRenderer::Supports(EINTERLACEMETHOD method)
return true;
}
- if(!m_dxvaDecoding
+ if(m_format != RENDER_FMT_DXVA
&& ( method == VS_INTERLACEMETHOD_DEINTERLACE
|| method == VS_INTERLACEMETHOD_DEINTERLACE_HALF
|| method == VS_INTERLACEMETHOD_SW_BLEND))
@@ -1109,7 +1090,7 @@ YUVBuffer::~YUVBuffer()
Release();
}
-bool YUVBuffer::Create(BufferFormat format, unsigned int width, unsigned int height)
+bool YUVBuffer::Create(ERenderFormat format, unsigned int width, unsigned int height)
{
m_format = format;
m_width = width;
@@ -1122,7 +1103,17 @@ bool YUVBuffer::Create(BufferFormat format, unsigned int width, unsigned int hei
// - this is what D3D9 does behind the scenes anyway
switch(m_format)
{
- case YV12:
+ case RENDER_FMT_YUV420P10:
+ case RENDER_FMT_YUV420P16:
+ {
+ if ( !planes[PLANE_Y].texture.Create(m_width , m_height , 1, 0, D3DFMT_L16, D3DPOOL_SYSTEMMEM)
+ || !planes[PLANE_U].texture.Create(m_width / 2, m_height / 2, 1, 0, D3DFMT_L16, D3DPOOL_SYSTEMMEM)
+ || !planes[PLANE_V].texture.Create(m_width / 2, m_height / 2, 1, 0, D3DFMT_L16, D3DPOOL_SYSTEMMEM))
+ return false;
+ m_activeplanes = 3;
+ break;
+ }
+ case RENDER_FMT_YUV420P:
{
if ( !planes[PLANE_Y].texture.Create(m_width , m_height , 1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM)
|| !planes[PLANE_U].texture.Create(m_width / 2, m_height / 2, 1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM)
@@ -1131,7 +1122,7 @@ bool YUVBuffer::Create(BufferFormat format, unsigned int width, unsigned int hei
m_activeplanes = 3;
break;
}
- case NV12:
+ case RENDER_FMT_NV12:
{
if ( !planes[PLANE_Y].texture.Create(m_width , m_height , 1, 0, D3DFMT_L8, D3DPOOL_SYSTEMMEM)
|| !planes[PLANE_UV].texture.Create(m_width / 2, m_height / 2, 1, 0, D3DFMT_A8L8, D3DPOOL_SYSTEMMEM))
@@ -1139,14 +1130,14 @@ bool YUVBuffer::Create(BufferFormat format, unsigned int width, unsigned int hei
m_activeplanes = 2;
break;
}
- case YUY2:
+ case RENDER_FMT_YUYV422:
{
if ( !planes[PLANE_Y].texture.Create(m_width >> 1 , m_height , 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM))
return false;
m_activeplanes = 1;
break;
}
- case UYVY:
+ case RENDER_FMT_UYVY422:
{
if ( !planes[PLANE_Y].texture.Create(m_width >> 1 , m_height , 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM))
return false;
@@ -1200,26 +1191,40 @@ void YUVBuffer::Clear()
switch(m_format)
{
- case YV12:
+ case RENDER_FMT_YUV420P16:
+ {
+ wmemset((wchar_t*)planes[PLANE_Y].rect.pBits, 0, planes[PLANE_Y].rect.Pitch * m_height / 2);
+ wmemset((wchar_t*)planes[PLANE_U].rect.pBits, 32768, planes[PLANE_U].rect.Pitch * (m_height/2) / 2);
+ wmemset((wchar_t*)planes[PLANE_V].rect.pBits, 32768, planes[PLANE_V].rect.Pitch * (m_height/2) / 2);
+ break;
+ }
+ case RENDER_FMT_YUV420P10:
+ {
+ wmemset((wchar_t*)planes[PLANE_Y].rect.pBits, 0, planes[PLANE_Y].rect.Pitch * m_height / 2);
+ wmemset((wchar_t*)planes[PLANE_U].rect.pBits, 512, planes[PLANE_U].rect.Pitch * (m_height/2) / 2);
+ wmemset((wchar_t*)planes[PLANE_V].rect.pBits, 512, planes[PLANE_V].rect.Pitch * (m_height/2) / 2);
+ break;
+ }
+ case RENDER_FMT_YUV420P:
{
memset(planes[PLANE_Y].rect.pBits, 0, planes[PLANE_Y].rect.Pitch * m_height);
memset(planes[PLANE_U].rect.pBits, 128, planes[PLANE_U].rect.Pitch * (m_height/2));
memset(planes[PLANE_V].rect.pBits, 128, planes[PLANE_V].rect.Pitch * (m_height/2));
break;
}
- case NV12:
+ case RENDER_FMT_NV12:
{
memset(planes[PLANE_Y].rect.pBits, 0, planes[PLANE_Y].rect.Pitch * m_height);
memset(planes[PLANE_UV].rect.pBits, 128, planes[PLANE_U].rect.Pitch * (m_height/2));
break;
}
// YUY2, UYVY: wmemset to set a 16bit pattern, byte-swapped because x86 is LE
- case YUY2:
+ case RENDER_FMT_YUYV422:
{
wmemset((wchar_t*)planes[PLANE_Y].rect.pBits, 0x8000, planes[PLANE_Y].rect.Pitch / 2 * m_height);
break;
}
- case UYVY:
+ case RENDER_FMT_UYVY422:
{
wmemset((wchar_t*)planes[PLANE_Y].rect.pBits, 0x0080, planes[PLANE_Y].rect.Pitch / 2 * m_height);
break;
23 xbmc/cores/VideoRenderers/WinRenderer.h
View
@@ -31,6 +31,7 @@
#include "settings/VideoSettings.h"
#include "cores/dvdplayer/DVDCodecs/Video/DXVA.h"
#include "cores/VideoRenderers/RenderFlags.h"
+#include "cores/VideoRenderers/RenderFormats.h"
//#define MP_DIRECTRENDERING
@@ -102,15 +103,6 @@ enum RenderMethod
#define FIELD_TOP 1
#define FIELD_BOT 2
-enum BufferFormat
-{
- Invalid,
- YV12,
- NV12,
- YUY2,
- UYVY
-};
-
struct SVideoBuffer
{
virtual ~SVideoBuffer() {}
@@ -130,7 +122,7 @@ struct SVideoPlane
struct YUVBuffer : SVideoBuffer
{
~YUVBuffer();
- bool Create(BufferFormat format, unsigned int width, unsigned int height);
+ bool Create(ERenderFormat format, unsigned int width, unsigned int height);
virtual void Release();
virtual void StartDecode();
virtual void StartRender();
@@ -142,7 +134,7 @@ struct YUVBuffer : SVideoBuffer
private:
unsigned int m_width;
unsigned int m_height;
- BufferFormat m_format;
+ ERenderFormat m_format;
unsigned int m_activeplanes;
};
@@ -171,7 +163,7 @@ class CWinRenderer : public CBaseRenderer
bool RenderCapture(CRenderCapture* capture);
// Player functions
- virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, unsigned int format);
+ virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format);
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
virtual bool AddVideoPicture(DVDVideoPicture* picture);
@@ -181,6 +173,8 @@ class CWinRenderer : public CBaseRenderer
virtual void Reset(); /* resets renderer after seek for example */
virtual bool IsConfigured() { return m_bConfigured; }
+ virtual std::vector<ERenderFormat> SupportedFormats() { return m_formats; }
+
virtual bool Supports(ERENDERFEATURE feature);
virtual bool Supports(EDEINTERLACEMODE mode);
virtual bool Supports(EINTERLACEMETHOD method);
@@ -223,6 +217,7 @@ class CWinRenderer : public CBaseRenderer
SVideoBuffer *m_VideoBuffers[NUM_BUFFERS];
RenderMethod m_renderMethod;
DXVA::CProcessor m_processor;
+ std::vector<ERenderFormat> m_formats;
// software scale libraries (fallback if required pixel shaders version is not available)
DllAvUtil *m_dllAvUtil;
@@ -253,8 +248,8 @@ class CWinRenderer : public CBaseRenderer
// clear colour for "black" bars
DWORD m_clearColour;
unsigned int m_flags;
- unsigned int m_format;
- bool m_dxvaDecoding;
+ ERenderFormat m_format;
+ unsigned int m_extended_format;
// Width and height of the render target
// the separable HQ scalers need this info, but could the m_destRect be used instead?
2  xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodec.h
View
@@ -34,7 +34,7 @@ struct AVStream;
class CDVDStreamInfo;
class CDVDCodecOption;
-typedef std::vector<CDVDCodecOption> CDVDCodecOptions;
+class CDVDCodecOptions;
class CDVDAudioCodec
{
50 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.cpp
View
@@ -110,8 +110,8 @@ bool CDVDCodecUtils::CopyPicture(YV12Image* pImage, DVDVideoPicture *pSrc)
{
BYTE *s = pSrc->data[0];
BYTE *d = pImage->plane[0];
- int w = pSrc->iWidth;
- int h = pSrc->iHeight;
+ int w = pImage->width * pImage->bpp;
+ int h = pImage->height;
if ((w == pSrc->iLineSize[0]) && ((unsigned int) pSrc->iLineSize[0] == pImage->stride[0]))
{
fast_memcpy(d, s, w*h);
@@ -127,8 +127,8 @@ bool CDVDCodecUtils::CopyPicture(YV12Image* pImage, DVDVideoPicture *pSrc)
}
s = pSrc->data[1];
d = pImage->plane[1];
- w = pSrc->iWidth >> 1;
- h = pSrc->iHeight >> 1;
+ w =(pImage->width >> pImage->cshift_x) * pImage->bpp;
+ h =(pImage->height >> pImage->cshift_y);
if ((w==pSrc->iLineSize[1]) && ((unsigned int) pSrc->iLineSize[1]==pImage->stride[1]))
{
fast_memcpy(d, s, w*h);
@@ -183,7 +183,7 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToNV12Picture(DVDVideoPicture *pSrc)
pPicture->iLineSize[1] = pPicture->iWidth;
pPicture->iLineSize[2] = 0;
pPicture->iLineSize[3] = 0;
- pPicture->format = DVDVideoPicture::FMT_NV12;
+ pPicture->format = RENDER_FMT_NV12;
// copy luma
uint8_t *s = pSrc->data[0];
@@ -218,7 +218,7 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToNV12Picture(DVDVideoPicture *pSrc)
return pPicture;
}
-DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *pSrc, DVDVideoPicture::EFormat format)
+DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *pSrc, ERenderFormat format)
{
// Clone a YV12 picture to new YUY2 or UYVY picture.
DVDVideoPicture* pPicture = new DVDVideoPicture;
@@ -257,7 +257,7 @@ DVDVideoPicture* CDVDCodecUtils::ConvertToYUV422PackedPicture(DVDVideoPicture *p
int dstStride[] = { pPicture->iLineSize[0], 0, 0, 0 };
int dstformat;
- if (format == DVDVideoPicture::FMT_UYVY)
+ if (format == RENDER_FMT_UYVY422)
dstformat = PIX_FMT_UYVY422;
else
dstformat = PIX_FMT_YUYV422;
@@ -446,3 +446,39 @@ double CDVDCodecUtils::NormalizeFrameduration(double frameduration)
return frameduration;
}
+struct EFormatMap {
+ PixelFormat pix_fmt;
+ ERenderFormat format;
+};
+
+static const EFormatMap g_format_map[] = {
+ { PIX_FMT_YUV420P, RENDER_FMT_YUV420P }
+, { PIX_FMT_YUVJ420P, RENDER_FMT_YUV420P }
+, { PIX_FMT_YUV420P10, RENDER_FMT_YUV420P10 }
+, { PIX_FMT_YUV420P16, RENDER_FMT_YUV420P16 }
+, { PIX_FMT_UYVY422, RENDER_FMT_UYVY422 }
+, { PIX_FMT_YUYV422, RENDER_FMT_YUYV422 }
+, { PIX_FMT_VAAPI_VLD, RENDER_FMT_VAAPI }
+, { PIX_FMT_DXVA2_VLD, RENDER_FMT_DXVA }
+, { PIX_FMT_NONE , RENDER_FMT_NONE }
+};
+
+ERenderFormat CDVDCodecUtils::EFormatFromPixfmt(int fmt)
+{
+ for(const EFormatMap *p = g_format_map; p->pix_fmt != PIX_FMT_NONE; ++p)
+ {
+ if(p->pix_fmt == fmt)
+ return p->format;
+ }
+ return RENDER_FMT_NONE;
+}
+
+int CDVDCodecUtils::PixfmtFromEFormat(ERenderFormat fmt)
+{
+ for(const EFormatMap *p = g_format_map; p->pix_fmt != PIX_FMT_NONE; ++p)
+ {
+ if(p->format == fmt)
+ return p->pix_fmt;
+ }
+ return PIX_FMT_NONE;
+}
6 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecUtils.h
View
@@ -22,6 +22,7 @@
*/
#include "Video/DVDVideoCodec.h"
+#include "cores/VideoRenderers/RenderFormats.h"
struct YV12Image;
@@ -34,7 +35,7 @@ class CDVDCodecUtils
static bool CopyPicture(YV12Image* pDst, DVDVideoPicture *pSrc);
static DVDVideoPicture* ConvertToNV12Picture(DVDVideoPicture *pSrc);
- static DVDVideoPicture* ConvertToYUV422PackedPicture(DVDVideoPicture *pSrc, DVDVideoPicture::EFormat format);
+ static DVDVideoPicture* ConvertToYUV422PackedPicture(DVDVideoPicture *pSrc, ERenderFormat format);
static bool CopyNV12Picture(YV12Image* pImage, DVDVideoPicture *pSrc);
static bool CopyYUV422PackedPicture(YV12Image* pImage, DVDVideoPicture *pSrc);
static bool CopyDXVA2Picture(YV12Image* pImage, DVDVideoPicture *pSrc);
@@ -42,5 +43,8 @@ class CDVDCodecUtils
static bool IsVP3CompatibleWidth(int width);
static double NormalizeFrameduration(double frameduration);
+
+ static ERenderFormat EFormatFromPixfmt(int fmt);
+ static int PixfmtFromEFormat(ERenderFormat format);
};
9 xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.h
View
@@ -28,6 +28,7 @@