Skip to content

Commit 0011865

Browse files
author
Clement Champetier
committed
Pixel: add support of pixel formats 4:4:0, 4:1:1 and 4:1:0
1 parent 37e28e3 commit 0011865

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

src/AvTranscoder/frame/Pixel.cpp

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,31 @@ void Pixel::init( const AVPixelFormat avPixelFormat )
8787

8888
setSubsampling( eSubsamplingNone );
8989

90-
if( ( pix_desc->log2_chroma_w == true ) &&
91-
( pix_desc->log2_chroma_h == false ) )
90+
if( ( pix_desc->log2_chroma_w == 0 ) &&
91+
( pix_desc->log2_chroma_h == 1 ) )
92+
{
93+
setSubsampling( eSubsampling440 );
94+
}
95+
else if( ( pix_desc->log2_chroma_w == 1 ) &&
96+
( pix_desc->log2_chroma_h == 0 ) )
9297
{
9398
setSubsampling( eSubsampling422 );
9499
}
95-
if( ( pix_desc->log2_chroma_w == true ) &&
96-
( pix_desc->log2_chroma_h == true ) )
100+
else if( ( pix_desc->log2_chroma_w == 1 ) &&
101+
( pix_desc->log2_chroma_h == 1 ) )
97102
{
98103
setSubsampling( eSubsampling420 );
99104
}
105+
else if( ( pix_desc->log2_chroma_w == 3 ) &&
106+
( pix_desc->log2_chroma_h == 0 ) )
107+
{
108+
setSubsampling( eSubsampling411 );
109+
}
110+
else if( ( pix_desc->log2_chroma_w == 2 ) &&
111+
( pix_desc->log2_chroma_h == 2 ) )
112+
{
113+
setSubsampling( eSubsampling410 );
114+
}
100115
}
101116

102117
bool Pixel::asCorrectColorComponents( const AVPixFmtDescriptor* pix_desc, const EComponentType componentType ) const
@@ -114,18 +129,33 @@ bool Pixel::asCorrectSubsampling( const AVPixFmtDescriptor* pix_desc, const ESub
114129
{
115130
case eSubsamplingNone :
116131
{
117-
return ( pix_desc->log2_chroma_w == false ) &&
118-
( pix_desc->log2_chroma_h == false );
132+
return ( pix_desc->log2_chroma_w == 0 ) &&
133+
( pix_desc->log2_chroma_h == 0 );
134+
}
135+
case eSubsampling440 :
136+
{
137+
return ( pix_desc->log2_chroma_w == 0 ) &&
138+
( pix_desc->log2_chroma_h == 1 );
119139
}
120140
case eSubsampling422 :
121141
{
122-
return ( pix_desc->log2_chroma_w == true ) &&
123-
( pix_desc->log2_chroma_h == false );
142+
return ( pix_desc->log2_chroma_w == 1 ) &&
143+
( pix_desc->log2_chroma_h == 0 );
124144
}
125145
case eSubsampling420 :
126146
{
127-
return ( pix_desc->log2_chroma_w == true ) &&
128-
( pix_desc->log2_chroma_h == true );
147+
return ( pix_desc->log2_chroma_w == 1 ) &&
148+
( pix_desc->log2_chroma_h == 1 );
149+
}
150+
case eSubsampling411:
151+
{
152+
return ( pix_desc->log2_chroma_w == 3 ) &&
153+
( pix_desc->log2_chroma_h == 0 );
154+
}
155+
case eSubsampling410 :
156+
{
157+
return ( pix_desc->log2_chroma_w == 2 ) &&
158+
( pix_desc->log2_chroma_h == 2 );
129159
}
130160
}
131161
return false;

src/AvTranscoder/frame/Pixel.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ enum EComponentType
2323
enum ESubsamplingType
2424
{
2525
eSubsamplingNone = 0, // 4:4:4
26+
eSubsampling440, // 4:4:0
2627
eSubsampling422, // 4:2:2
27-
eSubsampling420 // 4:2:0
28+
eSubsampling420, // 4:2:0
29+
eSubsampling411, // 4:1:1
30+
eSubsampling410 // 4:1:0
2831
};
2932

3033
class AvExport Pixel

0 commit comments

Comments
 (0)