Improve the interface for the different pixel formats
Unify the get pixel function Complete the interface Change some defines from PlaYUVerDefs.h Add a class to represent a pixel Improve LibAvContextHandle
This commit is contained in:
1 parent
82631f22f9
commit
3dfc1de042
11 files changed
+211
-177
No files matched your search
@@ -91,15 +91,7 @@ Void fillRGBbufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt rati
|
||||
/**
|
||||
* YUV420p 12 bits per pixel
|
||||
*/
|
||||
Pixel getPixelValueYUV420p( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_YUV;
|
||||
pixel_value.Luma = Img[LUMA][yPos][xPos];
|
||||
pixel_value.ChromaU = Img[CHROMA_U][yPos >> 1][xPos >> 1];
|
||||
pixel_value.ChromaV = Img[CHROMA_V][yPos >> 1][xPos >> 1];
|
||||
return pixel_value;
|
||||
}
|
||||
|
||||
Void frameFromBufferYUV420p( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
frameFromBufferYUVProgressive( in, out, width, height, 4 );
|
||||
@@ -119,7 +111,6 @@ PlaYUVerFramePelFormat yuv420p =
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
getPixelValueYUV420p,
|
||||
frameFromBufferYUV420p,
|
||||
bufferFromFrameYUV420p,
|
||||
fillRGBbufferYUV420p,
|
||||
@@ -128,15 +119,7 @@ PlaYUVerFramePelFormat yuv420p =
|
||||
/**
|
||||
* YUV444p 24 bits per pixel
|
||||
*/
|
||||
Pixel getPixelValueYUV444p( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_YUV;
|
||||
pixel_value.Luma = Img[LUMA][yPos][xPos];
|
||||
pixel_value.ChromaU = Img[CHROMA_U][yPos][xPos];
|
||||
pixel_value.ChromaV = Img[CHROMA_V][yPos][xPos];
|
||||
return pixel_value;
|
||||
}
|
||||
|
||||
Void frameFromBufferYUV444p( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
frameFromBufferYUVProgressive( in, out, width, height, 1 );
|
||||
@@ -156,7 +139,6 @@ PlaYUVerFramePelFormat yuv444p =
|
||||
3,
|
||||
1,
|
||||
1,
|
||||
getPixelValueYUV444p,
|
||||
frameFromBufferYUV444p,
|
||||
bufferFromFrameYUV444p,
|
||||
fillRGBbufferYUV444p,
|
||||
@@ -165,15 +147,7 @@ PlaYUVerFramePelFormat yuv444p =
|
||||
/**
|
||||
* YUV422p 16 bits per pixel
|
||||
*/
|
||||
Pixel getPixelValueYUV422( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_YUV;
|
||||
pixel_value.Luma = Img[LUMA][yPos][xPos];
|
||||
pixel_value.ChromaU = Img[CHROMA_U][yPos][xPos >> 1];
|
||||
pixel_value.ChromaV = Img[CHROMA_V][yPos][xPos >> 1];
|
||||
return pixel_value;
|
||||
}
|
||||
|
||||
Void frameFromBufferYUV422p( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
frameFromBufferYUVProgressive( in, out, width, height, 2 );
|
||||
@@ -193,7 +167,6 @@ PlaYUVerFramePelFormat yuv422p =
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
getPixelValueYUV422,
|
||||
frameFromBufferYUV422p,
|
||||
bufferFromFrameYUV422p,
|
||||
fillRGBbufferYUV422,
|
||||
@@ -236,7 +209,6 @@ PlaYUVerFramePelFormat yuyv422 =
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
getPixelValueYUV422,
|
||||
frameFromBufferYUYV422,
|
||||
bufferFromFrameYUYV422,
|
||||
fillRGBbufferYUV422,
|
||||
@@ -246,15 +218,6 @@ PlaYUVerFramePelFormat yuyv422 =
|
||||
* Gray Format
|
||||
*/
|
||||
|
||||
Pixel getPixelValueGray( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_YUV;
|
||||
pixel_value.Luma = Img[LUMA][yPos][xPos];
|
||||
pixel_value.ChromaU = 0;
|
||||
pixel_value.ChromaV = 0;
|
||||
return pixel_value;
|
||||
}
|
||||
Void frameFromBufferGray( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
memcpy( &out[LUMA][0][0], in, width * height * sizeof(Pel) );
|
||||
@@ -282,7 +245,6 @@ PlaYUVerFramePelFormat gray =
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
getPixelValueGray,
|
||||
frameFromBufferGray,
|
||||
bufferFromFrameGray,
|
||||
fillRGBbufferGray,
|
||||
@@ -293,41 +255,25 @@ PlaYUVerFramePelFormat gray =
|
||||
* Interlaced
|
||||
*/
|
||||
|
||||
/** RGB 8 bits per pixel / 3 channels */
|
||||
Pixel getPixelValueRGB24( Pel ***Img, Int xPos, Int yPos )
|
||||
Void frameFromBufferRGB( Pel *in, Pel*** out, UInt64 size, Pel* pFirst, Pel* pSecond, Pel* pthird )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_RGB;
|
||||
pixel_value.ColorR = Img[COLOR_R][yPos][xPos];
|
||||
pixel_value.ColorG = Img[COLOR_G][yPos][xPos];
|
||||
pixel_value.ColorB = Img[COLOR_B][yPos][xPos];
|
||||
return pixel_value;
|
||||
}
|
||||
Void frameFromBufferRGB24( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
Pel* pR = out[COLOR_R][0];
|
||||
Pel* pG = out[COLOR_G][0];
|
||||
Pel* pB = out[COLOR_B][0];
|
||||
for( UInt i = 0; i < width * height; i++ )
|
||||
for( UInt i = 0; i < size; i++ )
|
||||
{
|
||||
*pR++ = *in++;
|
||||
*pG++ = *in++;
|
||||
*pB++ = *in++;
|
||||
*pFirst++ = *in++;
|
||||
*pSecond++ = *in++;
|
||||
*pthird++ = *in++;
|
||||
}
|
||||
}
|
||||
Void bufferFromFrameRGB24( Pel ***in, Pel* out, UInt width, UInt height )
|
||||
Void bufferFromFrameRGB( Pel ***in, Pel* out, UInt64 size, Pel* pFirst, Pel* pSecond, Pel* pthird )
|
||||
{
|
||||
Pel* pR = in[COLOR_R][0];
|
||||
Pel* pG = in[COLOR_G][0];
|
||||
Pel* pB = in[COLOR_B][0];
|
||||
for( UInt i = 0; i < width * height; i++ )
|
||||
for( UInt i = 0; i < size; i++ )
|
||||
{
|
||||
*out++ = *pR++;
|
||||
*out++ = *pG++;
|
||||
*out++ = *pB++;
|
||||
*out++ = *pFirst++;
|
||||
*out++ = *pSecond++;
|
||||
*out++ = *pthird++;
|
||||
}
|
||||
}
|
||||
Void fillRGBbufferRGB24( Pel*** in, UChar* out, UInt width, UInt height )
|
||||
Void fillRGBbufferRGB( Pel*** in, UChar* out, UInt width, UInt height )
|
||||
{
|
||||
Pel* pR = in[COLOR_R][0];
|
||||
Pel* pG = in[COLOR_G][0];
|
||||
@@ -342,19 +288,51 @@ Void fillRGBbufferRGB24( Pel*** in, UChar* out, UInt width, UInt height )
|
||||
*buff++ = pelRgb( iR, iG, iB );
|
||||
}
|
||||
}
|
||||
|
||||
/** RGB 8 bits per pixel / 3 channels */
|
||||
Void frameFromBufferRGB24( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
frameFromBufferRGB( in, out, width * height, out[COLOR_R][0], out[COLOR_G][0], out[COLOR_B][0] );
|
||||
}
|
||||
Void bufferFromFrameRGB24( Pel ***in, Pel* out, UInt width, UInt height )
|
||||
{
|
||||
bufferFromFrameRGB( in, out, width * height, in[COLOR_R][0], in[COLOR_G][0], in[COLOR_B][0] );
|
||||
}
|
||||
|
||||
PlaYUVerFramePelFormat rgb24 =
|
||||
{
|
||||
"RGB8",
|
||||
"RGB24",
|
||||
PlaYUVerFrame::COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
1,
|
||||
getPixelValueRGB24,
|
||||
frameFromBufferRGB24,
|
||||
bufferFromFrameRGB24,
|
||||
fillRGBbufferRGB24,
|
||||
fillRGBbufferRGB,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), };
|
||||
|
||||
/** BGR 8 bits per pixel / 3 channels */
|
||||
Void frameFromBufferBGR24( Pel *in, Pel*** out, UInt width, UInt height )
|
||||
{
|
||||
frameFromBufferRGB( in, out, width * height, out[COLOR_B][0], out[COLOR_G][0], out[COLOR_R][0] );
|
||||
}
|
||||
Void bufferFromFrameBGR24( Pel ***in, Pel* out, UInt width, UInt height )
|
||||
{
|
||||
bufferFromFrameRGB( in, out, width * height, in[COLOR_B][0], in[COLOR_G][0], in[COLOR_R][0] );
|
||||
}
|
||||
|
||||
PlaYUVerFramePelFormat BGR24 =
|
||||
{
|
||||
"BRG24",
|
||||
PlaYUVerFrame::COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
1,
|
||||
frameFromBufferBGR24,
|
||||
bufferFromFrameBGR24,
|
||||
fillRGBbufferRGB,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), };
|
||||
|
||||
PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS] =
|
||||
{
|
||||
yuv420p,
|
||||
@@ -362,7 +340,8 @@ PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS] =
|
||||
yuv422p,
|
||||
yuyv422,
|
||||
gray,
|
||||
rgb24, };
|
||||
rgb24,
|
||||
BGR24, };
|
||||
|
||||
|
||||
} // NAMESPACE
|
||||
Reference in new issue
Block a user