diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index bdff173..d3dc3a8 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -94,7 +94,7 @@ struct PlaYUVerFramePrivate Bool m_bInit; //! Struct with the pixel format description. - PlaYUVerPixFmtDescriptor* m_pcPelFormat; + const PlaYUVerPixFmtDescriptor* m_pcPelFormat; String m_cPelFmtName; UInt m_uiWidth; //!< Width of the frame @@ -145,7 +145,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, Bool bCopy ) : PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight ) : d( new PlaYUVerFramePrivate ) { - PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] ); + const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] ); if( pcPelFormat->log2ChromaWidth ) { if( posX % ( 1 << pcPelFormat->log2ChromaWidth ) ) @@ -391,7 +391,7 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel ) { - PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); + const PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1; UInt64 numberBytes = uiWidth * uiHeight; if( pcPelFormat->numberChannels > 1 ) diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 0e6b784..bdfd3ea 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -59,7 +59,7 @@ public: YUYV422, GRAY, RGB24, - BRG24, + BGR24, NUMBER_FORMATS }; diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp index d870a56..219eeda 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PlaYUVerFramePixelFormats.cpp @@ -24,7 +24,6 @@ #include "config.h" #include "PlaYUVerFramePixelFormats.h" -// #include #ifdef USE_SSE #include @@ -33,6 +32,7 @@ #endif #include "LibMemory.h" +#include "PlaYUVerFrame.h" #ifdef USE_FFMPEG #include "StreamHandlerLibav.h" #endif @@ -199,218 +199,101 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UI } #endif -PlaYUVerPixFmtDescriptor yuv420p = +const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NUMBER_FORMATS] = +{ { - "YUV420p", - PlaYUVerPixel::COLOR_YUV, - 3, - 3, - 1, - 1, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ), + name: "YUV420p", + colorSpace: PlaYUVerPixel::COLOR_YUV, + numberChannels: 3, + numberPlanes: 3, + log2ChromaWidth: 1, + log2ChromaHeight: 1, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1 }, /* Y */ + { 1, 0, 1 }, /* U */ + { 2, 0, 1 }, /* V */ }, - }; - -PlaYUVerPixFmtDescriptor yuv422p = + }, { - "YUV422p", - PlaYUVerPixel::COLOR_YUV, - 3, - 3, - 1, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), + name: "YUV422p", + colorSpace: PlaYUVerPixel::COLOR_YUV, + numberChannels: 3, + numberPlanes: 3, + log2ChromaWidth: 1, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1 }, /* Y */ + { 1, 0, 1 }, /* U */ + { 2, 0, 1 }, /* V */ }, - }; - -PlaYUVerPixFmtDescriptor yuv444p = + }, { - "YUV444p", - PlaYUVerPixel::COLOR_YUV, - 3, - 3, - 0, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ), + name: "YUV444p", + colorSpace: PlaYUVerPixel::COLOR_YUV, + numberChannels: 3, + numberPlanes: 3, + log2ChromaWidth: 0, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1 }, /* Y */ + { 1, 0, 1 }, /* U */ + { 2, 0, 1 }, /* V */ }, - }; - -PlaYUVerPixFmtDescriptor yuyv422 = + }, { - "YUYV422", - PlaYUVerPixel::COLOR_YUV, - 3, - 1, - 1, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), + name: "YUYV422", + colorSpace: PlaYUVerPixel::COLOR_YUV, + numberChannels: 3, + numberPlanes: 1, + log2ChromaWidth: 1, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), { - { - 0, - 1, - 1, - 0, - 7 }, /* Y */ - { - 0, - 3, - 2, - 0, - 7 }, /* U */ - { - 0, - 3, - 4, - 0, - 7 }, /* V */ + { 0, 1, 1 }, /* Y */ + { 0, 3, 2 }, /* U */ + { 0, 3, 4 }, /* V */ }, - }; - -PlaYUVerPixFmtDescriptor gray = + }, { - "GRAY", - PlaYUVerPixel::COLOR_GRAY, - 1, - 1, - 0, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ), - { - { - 0, - 0, - 1, - 0, - 7 } }, /* Y */ - }; - -PlaYUVerPixFmtDescriptor RGB24 = + name: "GRAY", + colorSpace: PlaYUVerPixel::COLOR_GRAY, + numberChannels: 1, + numberPlanes: 1, + log2ChromaWidth: 0, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ), + { { 0, 0, 1 } }, /* Y */ + }, { - "RGB24", - PlaYUVerPixel::COLOR_RGB, - 3, - 1, - 0, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), + name: "RGB24", + colorSpace: PlaYUVerPixel::COLOR_RGB, + numberChannels: 3, + numberPlanes: 1, + log2ChromaWidth: 0, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), { - { - 0, - 2, - 1, - 0, - 7 }, /* R */ - { - 0, - 2, - 2, - 0, - 7 }, /* G */ - { - 0, - 2, - 3, - 0, - 7 }, /* B */ + { 0, 2, 1 }, /* R */ + { 0, 2, 2 }, /* G */ + { 0, 2, 3 }, /* B */ }, - }; - -PlaYUVerPixFmtDescriptor BGR24 = + }, { - "BGR24", - PlaYUVerPixel::COLOR_RGB, - 3, - 1, - 0, - 0, - ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), + name: "BGR24", + colorSpace: PlaYUVerPixel::COLOR_RGB, + numberChannels: 3, + numberPlanes: 1, + log2ChromaWidth: 0, + log2ChromaHeight: 0, + ffmpegPelFormat: ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), { - { - 0, - 2, - 3, - 0, - 7 }, /* R */ - { - 0, - 2, - 2, - 0, - 7 }, /* G */ - { - 0, - 2, - 1, - 0, - 7 }, /* B */ + { 0, 2, 3}, /* R */ + { 0, 2, 2}, /* G */ + { 0, 2, 1}, /* B */ }, - }; - -PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] = - { - yuv420p, - yuv444p, - yuv422p, - yuyv422, - gray, - RGB24, - BGR24, - }; + } +}; diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h index 2036b44..dbb2bec 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PlaYUVerFramePixelFormats.h @@ -75,16 +75,6 @@ typedef struct PlaYUVerComponentDescriptor */ UInt16 offset_plus1; - /** - * Number of least significant bits that must be shifted away - * to get the value. - */ - UInt16 shift; - - /** - * Number of bits in the component minus 1. - */ - UInt16 depth_minus1; } PlaYUVerComponentDescriptor; /** @@ -140,7 +130,7 @@ typedef struct PlaYUVerPixFmtDescriptor #define MAX_NUMBER_PLANES 3 -#define PLAYUVER_NUMBER_FORMATS 7 -extern PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS]; +#define PLAYUVER_NUMBER_FORMATS 3 +extern const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[]; #endif // __PLAYUVERFRAMEPIXELFORMATS_H__