Change the conversion between PlaYUVerFrame and ffmpeg pel formats
This commit is contained in:
1 parent
ef8a8b6038
commit
a33b61d082
4 files changed
+96
-120
No files matched your search
@@ -26,10 +26,20 @@
|
||||
#include <cstdio>
|
||||
#include "LibMemory.h"
|
||||
#include "PlaYUVerFrame.h"
|
||||
#ifdef USE_FFMPEG
|
||||
#include "LibAvContextHandle.h"
|
||||
#endif
|
||||
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
#define ADD_FFMPEG_PEL_FMT( fmt ) fmt
|
||||
#else
|
||||
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
|
||||
#endif
|
||||
|
||||
|
||||
Void frameFromBuffer_yuv420p( Pel *in, Pel*** out )
|
||||
{
|
||||
|
||||
@@ -42,7 +52,7 @@ Void fillRGBbuffer_yuv420p( Pel*** in, UChar* out )
|
||||
{
|
||||
|
||||
}
|
||||
Pixel getPixelValueYUV420p ( Pel ***Img, Int xPos, Int yPos )
|
||||
Pixel getPixelValueYUV420p( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
Pixel pixel_value;
|
||||
pixel_value.color_space = PlaYUVerFrame::COLOR_YUV;
|
||||
@@ -52,46 +62,6 @@ Pixel getPixelValueYUV420p ( Pel ***Img, Int xPos, Int yPos )
|
||||
return pixel_value;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Pixel getPixelValueRGB8 ( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
PlaYUVerFramePelFormat yuv420p =
|
||||
{
|
||||
"YUV420p",
|
||||
@@ -103,8 +73,49 @@ PlaYUVerFramePelFormat yuv420p =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ),
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Pixel getPixelValueRGB8( Pel ***Img, Int xPos, Int yPos )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
PlaYUVerFramePelFormat yuv444p =
|
||||
{
|
||||
"YUV444p",
|
||||
@@ -116,6 +127,7 @@ PlaYUVerFramePelFormat yuv444p =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ),
|
||||
};
|
||||
|
||||
PlaYUVerFramePelFormat yuv422p =
|
||||
@@ -129,6 +141,7 @@ PlaYUVerFramePelFormat yuv422p =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ),
|
||||
};
|
||||
|
||||
PlaYUVerFramePelFormat yuv422 =
|
||||
@@ -142,6 +155,7 @@ PlaYUVerFramePelFormat yuv422 =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ),
|
||||
};
|
||||
|
||||
PlaYUVerFramePelFormat gray =
|
||||
@@ -155,6 +169,7 @@ PlaYUVerFramePelFormat gray =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ),
|
||||
};
|
||||
|
||||
PlaYUVerFramePelFormat rgb8 =
|
||||
@@ -168,6 +183,7 @@ PlaYUVerFramePelFormat rgb8 =
|
||||
frameFromBuffer_yuv420p,
|
||||
bufferFromFrame_yuv420p,
|
||||
fillRGBbuffer_yuv420p,
|
||||
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ),
|
||||
};
|
||||
|
||||
extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS] =
|
||||
@@ -177,7 +193,6 @@ extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORM
|
||||
yuv422p,
|
||||
yuv422,
|
||||
gray,
|
||||
rgb8,
|
||||
};
|
||||
rgb8, };
|
||||
|
||||
} // NAMESPACE
|
||||
Reference in new issue
Block a user