@@ -18,20 +18,12 @@ Pixel::Pixel( const std::string& avPixelFormat )
18
18
}
19
19
20
20
Pixel::Pixel ( const AVPixelFormat avPixelFormat )
21
- : _pixelSize ( 24 )
22
- , _components ( 3 )
23
- , _componentType ( eComponentYuv )
24
- , _subsamplingType ( eSubsamplingNone )
25
- , _endianess ( false )
26
- , _withAlpha ( false )
27
- , _planar ( true )
28
21
{
29
22
init ( avPixelFormat );
30
23
}
31
24
32
25
AVPixelFormat Pixel::findPixel () const
33
26
{
34
- // av_register_all();
35
27
#if LIBAVUTIL_VERSION_MAJOR > 51
36
28
const AVPixFmtDescriptor *pix_desc = NULL ;
37
29
while ( ( pix_desc = av_pix_fmt_desc_next ( pix_desc ) ) )
@@ -87,16 +79,31 @@ void Pixel::init( const AVPixelFormat avPixelFormat )
87
79
88
80
setSubsampling ( eSubsamplingNone );
89
81
90
- if ( ( pix_desc->log2_chroma_w == true ) &&
91
- ( pix_desc->log2_chroma_h == false ) )
82
+ if ( ( pix_desc->log2_chroma_w == 0 ) &&
83
+ ( pix_desc->log2_chroma_h == 1 ) )
84
+ {
85
+ setSubsampling ( eSubsampling440 );
86
+ }
87
+ else if ( ( pix_desc->log2_chroma_w == 1 ) &&
88
+ ( pix_desc->log2_chroma_h == 0 ) )
92
89
{
93
90
setSubsampling ( eSubsampling422 );
94
91
}
95
- if ( ( pix_desc->log2_chroma_w == true ) &&
96
- ( pix_desc->log2_chroma_h == true ) )
92
+ else if ( ( pix_desc->log2_chroma_w == 1 ) &&
93
+ ( pix_desc->log2_chroma_h == 1 ) )
97
94
{
98
95
setSubsampling ( eSubsampling420 );
99
96
}
97
+ else if ( ( pix_desc->log2_chroma_w == 3 ) &&
98
+ ( pix_desc->log2_chroma_h == 0 ) )
99
+ {
100
+ setSubsampling ( eSubsampling411 );
101
+ }
102
+ else if ( ( pix_desc->log2_chroma_w == 2 ) &&
103
+ ( pix_desc->log2_chroma_h == 2 ) )
104
+ {
105
+ setSubsampling ( eSubsampling410 );
106
+ }
100
107
}
101
108
102
109
bool Pixel::asCorrectColorComponents ( const AVPixFmtDescriptor* pix_desc, const EComponentType componentType ) const
@@ -114,18 +121,33 @@ bool Pixel::asCorrectSubsampling( const AVPixFmtDescriptor* pix_desc, const ESub
114
121
{
115
122
case eSubsamplingNone :
116
123
{
117
- return ( pix_desc->log2_chroma_w == false ) &&
118
- ( pix_desc->log2_chroma_h == false );
124
+ return ( pix_desc->log2_chroma_w == 0 ) &&
125
+ ( pix_desc->log2_chroma_h == 0 );
126
+ }
127
+ case eSubsampling440 :
128
+ {
129
+ return ( pix_desc->log2_chroma_w == 0 ) &&
130
+ ( pix_desc->log2_chroma_h == 1 );
119
131
}
120
132
case eSubsampling422 :
121
133
{
122
- return ( pix_desc->log2_chroma_w == true ) &&
123
- ( pix_desc->log2_chroma_h == false );
134
+ return ( pix_desc->log2_chroma_w == 1 ) &&
135
+ ( pix_desc->log2_chroma_h == 0 );
124
136
}
125
137
case eSubsampling420 :
126
138
{
127
- return ( pix_desc->log2_chroma_w == true ) &&
128
- ( pix_desc->log2_chroma_h == true );
139
+ return ( pix_desc->log2_chroma_w == 1 ) &&
140
+ ( pix_desc->log2_chroma_h == 1 );
141
+ }
142
+ case eSubsampling411:
143
+ {
144
+ return ( pix_desc->log2_chroma_w == 3 ) &&
145
+ ( pix_desc->log2_chroma_h == 0 );
146
+ }
147
+ case eSubsampling410 :
148
+ {
149
+ return ( pix_desc->log2_chroma_w == 2 ) &&
150
+ ( pix_desc->log2_chroma_h == 2 );
129
151
}
130
152
}
131
153
return false ;
0 commit comments