Major improvements and generalization of the frame from/to buffer based on ffmpeg enfort
This commit is contained in:
1 parent
2b749e3da0
commit
379d13a8ed
6 files changed
+275
-256
No files matched your search
@@ -34,7 +34,8 @@ namespace plaYUVer
|
||||
#define CHROMA_RESAMPLING( X ) ( ( ( X + 1 ) >> 1 ) << 1 )
|
||||
|
||||
#define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE )
|
||||
#define CHROMASHIFT( SIZE, SHIFT ) ( SHIFT > 0 ? ( ( SIZE + 1 ) >> SHIFT ) : SIZE )
|
||||
|
||||
#define CHROMASHIFT( SIZE, SHIFT ) UInt( -( ( - ( Int( SIZE ) ) ) >> SHIFT ) )
|
||||
|
||||
#define CLAMP(X) X = X < 0 ? 0 : X > 255 ? 255 : X;
|
||||
|
||||
@@ -74,23 +75,94 @@ inline Int pelAlpha( UInt rgb ) // get alpha part of RGBA
|
||||
#define PEL_RGB( r, g, b ) \
|
||||
( 0xffu << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff )
|
||||
|
||||
struct structPlaYUVerFramePelFormat
|
||||
typedef struct PlaYUVerComponentDescriptor
|
||||
{
|
||||
const Char* name;
|
||||
Int colorSpace;
|
||||
UInt numberChannels;
|
||||
Int ratioChromaWidth;
|
||||
Int ratioChromaHeight;
|
||||
Void (*frameFromBuffer)( Pel *in, Pel*** out, UInt width, UInt height );
|
||||
Void (*bufferFromFrame)( Pel ***in, Pel* out, UInt width, UInt height );
|
||||
Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height );
|
||||
Int ffmpegPelFormat;
|
||||
};
|
||||
/**
|
||||
* Which of the 4 planes contains the component.
|
||||
*/
|
||||
UInt16 plane;
|
||||
|
||||
typedef struct structPlaYUVerFramePelFormat PlaYUVerFramePelFormat;
|
||||
/**
|
||||
* Number of elements between 2 horizontally consecutive pixels minus 1.
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
UInt16 step_minus1;
|
||||
|
||||
/**
|
||||
* Number of elements before the component of the first pixel plus 1.
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Descriptor that unambiguously describes how the bits of a pixel are
|
||||
* stored in the up to 4 data planes of an image. It also stores the
|
||||
* subsampling factors and number of components.
|
||||
*
|
||||
* @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV
|
||||
* and all the YUV variants) AVPixFmtDescriptor just stores how values
|
||||
* are stored not what these values represent.
|
||||
*/
|
||||
typedef struct PlaYUVerPixFmtDescriptor
|
||||
{
|
||||
const char *name;
|
||||
|
||||
Int colorSpace;
|
||||
|
||||
UInt8 numberChannels; ///< The number of components each pixel has, (1-4)
|
||||
|
||||
UInt8 numberPlanes; ///< The number of planes that should be read from the file
|
||||
|
||||
/**
|
||||
* Amount to shift the luma width right to find the chroma width.
|
||||
* For YV12 this is 1 for example.
|
||||
* chroma_width = -((-luma_width) >> log2ChromaWidth)
|
||||
* The note above is needed to ensure rounding up.
|
||||
* This value only refers to the chroma components.
|
||||
*/
|
||||
UInt8 log2ChromaWidth; ///< chroma_width = -((-luma_width )>>log2ChromaWidth)
|
||||
|
||||
/**
|
||||
* Amount to shift the luma height right to find the chroma height.
|
||||
* For YV12 this is 1 for example.
|
||||
* chroma_height= -((-luma_height) >> log2ChromaHeight)
|
||||
* The note above is needed to ensure rounding up.
|
||||
* This value only refers to the chroma components.
|
||||
*/
|
||||
UInt8 log2ChromaHeight;
|
||||
|
||||
Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height );
|
||||
|
||||
Int ffmpegPelFormat;
|
||||
|
||||
/**
|
||||
* Parameters that describe how pixels are packed.
|
||||
* If the format has 2 or 4 components, then alpha is last.
|
||||
* If the format has 1 or 2 components, then luma is 0.
|
||||
* If the format has 3 or 4 components,
|
||||
* if the RGB flag is set then 0 is red, 1 is green and 2 is blue;
|
||||
* otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
|
||||
*/
|
||||
PlaYUVerComponentDescriptor comp[4];
|
||||
|
||||
} PlaYUVerPixFmtDescriptor;
|
||||
|
||||
#define MAX_NUMBER_PLANES 3
|
||||
|
||||
#define PLAYUVER_NUMBER_FORMATS 7
|
||||
extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS];
|
||||
extern PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS];
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
|
||||
Reference in new issue
Block a user