@@ -51,51 +51,54 @@ VideoProperties::VideoProperties( const FormatContext& formatContext, const size
51
51
52
52
std::string VideoProperties::getCodecName () const
53
53
{
54
- if ( _codecContext && _codec )
55
- {
56
- if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
57
- _codecContext->flags |= CODEC_FLAG_TRUNCATED;
54
+ if ( ! _codecContext || ! _codec )
55
+ throw std::runtime_error ( " unknown codec" );
58
56
59
- if ( _codec->name )
60
- return std::string ( _codec->name );
61
- }
62
- return " unknown codec" ;
57
+ if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
58
+ _codecContext->flags |= CODEC_FLAG_TRUNCATED;
59
+
60
+ if ( ! _codec->name )
61
+ throw std::runtime_error ( " unknown codec name" );
62
+
63
+ return std::string ( _codec->name );
63
64
}
64
65
65
66
std::string VideoProperties::getCodecLongName () const
66
67
{
67
- if ( _codecContext && _codec )
68
- {
69
- if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
70
- _codecContext->flags |= CODEC_FLAG_TRUNCATED;
68
+ if ( ! _codecContext || ! _codec )
69
+ throw std::runtime_error ( " unknown codec" );
71
70
72
- if ( _codec->long_name )
73
- return std::string ( _codec->long_name );
74
- }
75
- return " unknown codec" ;
71
+ if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
72
+ _codecContext->flags |= CODEC_FLAG_TRUNCATED;
73
+
74
+ if ( ! _codec->long_name )
75
+ throw std::runtime_error ( " unknown codec long name" );
76
+
77
+ return std::string ( _codec->long_name );
76
78
}
77
79
78
80
std::string VideoProperties::getProfileName () const
79
81
{
80
- if ( _codecContext && _codec )
82
+ if ( ! _codecContext || ! _codec )
83
+ throw std::runtime_error ( " unknown codec" );
84
+
85
+ if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
86
+ _codecContext->flags |= CODEC_FLAG_TRUNCATED;
87
+
88
+ if ( _codecContext->profile != -99 )
81
89
{
82
- if ( _codec->capabilities & CODEC_CAP_TRUNCATED )
83
- _codecContext->flags |= CODEC_FLAG_TRUNCATED;
90
+ const char * profile = NULL ;
91
+ if ( ( profile = av_get_profile_name ( _codec, _codecContext->profile ) ) == NULL )
92
+ throw std::runtime_error ( " unknown codec profile" );
84
93
85
- if ( _codecContext->profile != -99 )
86
- {
87
- const char * profile = NULL ;
88
- if ( ( profile = av_get_profile_name ( _codec, _codecContext->profile ) ) != NULL )
89
- return std::string ( profile );
90
- }
94
+ return std::string ( profile );
91
95
}
92
- return " unknown profile" ;
93
96
}
94
97
95
98
std::string VideoProperties::getColorTransfert () const
96
99
{
97
100
if ( ! _codecContext )
98
- return " unknown codec context" ;
101
+ throw std::runtime_error ( " unknown codec context" ) ;
99
102
100
103
switch ( _codecContext->color_trc )
101
104
{
@@ -159,7 +162,7 @@ std::string VideoProperties::getColorTransfert() const
159
162
std::string VideoProperties::getColorspace () const
160
163
{
161
164
if ( ! _codecContext )
162
- return " unknown codec context" ;
165
+ throw std::runtime_error ( " unknown codec context" ) ;
163
166
164
167
switch ( _codecContext->colorspace )
165
168
{
@@ -204,7 +207,7 @@ std::string VideoProperties::getColorspace() const
204
207
std::string VideoProperties::getColorRange () const
205
208
{
206
209
if ( ! _codecContext )
207
- return " unknown codec context" ;
210
+ throw std::runtime_error ( " unknown codec context" ) ;
208
211
209
212
switch ( _codecContext->color_range )
210
213
{
@@ -224,7 +227,7 @@ std::string VideoProperties::getColorRange() const
224
227
std::string VideoProperties::getColorPrimaries () const
225
228
{
226
229
if ( ! _codecContext )
227
- return " unknown codec context" ;
230
+ throw std::runtime_error ( " unknown codec context" ) ;
228
231
229
232
switch ( _codecContext->color_primaries )
230
233
{
@@ -258,7 +261,7 @@ std::string VideoProperties::getColorPrimaries() const
258
261
std::string VideoProperties::getChromaSampleLocation () const
259
262
{
260
263
if ( ! _codecContext )
261
- return " unknown codec context" ;
264
+ throw std::runtime_error ( " unknown codec context" ) ;
262
265
263
266
switch ( _codecContext->chroma_sample_location )
264
267
{
@@ -286,7 +289,7 @@ std::string VideoProperties::getChromaSampleLocation() const
286
289
std::string VideoProperties::getFieldOrder () const
287
290
{
288
291
if ( ! _codecContext )
289
- return " unknown codec context" ;
292
+ throw std::runtime_error ( " unknown codec context" ) ;
290
293
291
294
switch ( _codecContext->field_order )
292
295
{
0 commit comments