Implement n bits per pixel in Frame to buffer and from buffer

This commit is contained in:
jfmcarreira committed 2015-04-02 18:53:26 +01:00
1 parent a38f9c3283
commit c8079e87cb
8 files changed
+181 -111

No files matched your search

+145 -88
View File
@@ -52,8 +52,7 @@ namespace plaYUVer
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
#endif
Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt ratioChromaHor, UInt ratioChromaVer )
Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt depth, UInt ratioChromaHor, UInt ratioChromaVer )
{
Pel* pLineY = in[LUMA][0];
Pel* pLineU = in[CHROMA_U][0];
@@ -78,7 +77,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r
{
iU = *pU++;
iV = *pV++;
for( Int j = 0; j < 1 << ratioChromaHor; j++ )
for( Int j = 0; j < ( 1 << ratioChromaHor ) * depth; j++ )
{
iY = *pY++;
YUV2RGB( iY, iU, iV, iR, iG, iB );
@@ -93,7 +92,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r
}
}
Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth )
{
#ifdef USE_SSE
if( ( width % 16 ) == 0 )
@@ -184,14 +183,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
b00 = _mm_srai_epi16( _mm_add_epi16( y00r0, bu00 ), 6 );
b01 = _mm_srai_epi16( _mm_add_epi16( y01r0, bu01 ), 6 );
r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated
g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated
b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated
r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated
g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated
b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated
r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r..
gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb..
rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb..
rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb..
r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r..
gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb..
rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb..
rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb..
r01 = _mm_unpackhi_epi8( r00, zero );
gbgb = _mm_unpackhi_epi8( b00, g00 );
@@ -211,14 +210,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
b00 = _mm_srai_epi16( _mm_add_epi16( y00r1, bu00 ), 6 );
b01 = _mm_srai_epi16( _mm_add_epi16( y01r1, bu01 ), 6 );
r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated
g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated
b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated
r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated
g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated
b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated
r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r..
gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb..
rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb..
rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb..
r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r..
gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb..
rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb..
rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb..
r01 = _mm_unpackhi_epi8( r00, zero );
gbgb = _mm_unpackhi_epi8( b00, g00 );
@@ -236,50 +235,20 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
else
#endif
{
fillARGB32bufferYUV( in, out, width, height, 1, 1 );
fillARGB32bufferYUV( in, out, width, height, depth, 1, 1 );
}
}
Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height )
Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth )
{
fillARGB32bufferYUV( in, out, width, height, 0, 0 );
fillARGB32bufferYUV( in, out, width, height, depth, 0, 0 );
}
Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height )
Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height, UInt depth )
{
fillARGB32bufferYUV( in, out, width, height, 1, 0 );
fillARGB32bufferYUV( in, out, width, height, depth, 1, 0 );
}
Void fillARGB32bufferGray( Pel*** in, UChar* out, UInt width, UInt height )
{
Pel *inPel = in[0][0];
Pel iY;
UInt* buff = ( UInt* )out;
for( UInt i = 0; i < height * width; i++ )
{
iY = *inPel;
*buff++ = PEL_RGB( iY, iY, iY );
inPel++;
}
}
Void fillARGB32bufferRGB( Pel*** in, UChar* out, UInt width, UInt height )
{
Pel* pR = in[COLOR_R][0];
Pel* pG = in[COLOR_G][0];
Pel* pB = in[COLOR_B][0];
Int iR, iG, iB;
UInt* buff = ( UInt* )out;
for( UInt i = 0; i < height * width; i++ )
{
iR = *pR++;
iG = *pG++;
iB = *pB++;
*buff++ = PEL_RGB( iR, iG, iB );
}
}
PlaYUVerPixFmtDescriptor yuv420p =
{
"YUV420p",
@@ -290,12 +259,26 @@ PlaYUVerPixFmtDescriptor yuv420p =
1,
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,
0,
7 }, /* Y */
{
1,
0,
1,
0,
7 }, /* U */
{
2,
0,
1,
0,
7 }, /* V */
},
fillARGB32bufferYUV420p,
};
fillARGB32bufferYUV420p, };
PlaYUVerPixFmtDescriptor yuv422p =
{
@@ -307,12 +290,26 @@ PlaYUVerPixFmtDescriptor yuv422p =
0,
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,
0,
7 }, /* Y */
{
1,
0,
1,
0,
7 }, /* U */
{
2,
0,
1,
0,
7 }, /* V */
},
fillARGB32bufferYUV422,
};
fillARGB32bufferYUV422, };
PlaYUVerPixFmtDescriptor yuv444p =
{
@@ -324,12 +321,26 @@ PlaYUVerPixFmtDescriptor yuv444p =
0,
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,
0,
7 }, /* Y */
{
1,
0,
1,
0,
7 }, /* U */
{
2,
0,
1,
0,
7 }, /* V */
},
fillARGB32bufferYUV444p,
};
fillARGB32bufferYUV444p, };
PlaYUVerPixFmtDescriptor yuyv422 =
{
@@ -341,12 +352,26 @@ PlaYUVerPixFmtDescriptor yuyv422 =
0,
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,
0,
7 }, /* Y */
{
0,
3,
2,
0,
7 }, /* U */
{
0,
3,
4,
0,
7 }, /* V */
},
fillARGB32bufferYUV422,
};
fillARGB32bufferYUV422, };
PlaYUVerPixFmtDescriptor gray =
{
@@ -357,9 +382,14 @@ PlaYUVerPixFmtDescriptor gray =
0,
0,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ),
{ { 0, 0, 1, 0, 7 } }, /* Y */
fillARGB32bufferGray,
};
{
{
0,
0,
1,
0,
7 } }, /* Y */
NULL, };
PlaYUVerPixFmtDescriptor RGB24 =
{
@@ -371,12 +401,26 @@ PlaYUVerPixFmtDescriptor RGB24 =
0,
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,
0,
7 }, /* R */
{
0,
2,
2,
0,
7 }, /* G */
{
0,
2,
3,
0,
7 }, /* B */
},
fillARGB32bufferRGB,
};
NULL, };
PlaYUVerPixFmtDescriptor BGR24 =
{
@@ -388,12 +432,26 @@ PlaYUVerPixFmtDescriptor BGR24 =
0,
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,
0,
7 }, /* R */
{
0,
2,
2,
0,
7 }, /* G */
{
0,
2,
1,
0,
7 }, /* B */
},
fillARGB32bufferRGB,
};
NULL, };
PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] =
{
@@ -403,7 +461,6 @@ PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS
yuyv422,
gray,
RGB24,
BGR24,
};
BGR24, };
} // NAMESPACE