@@ -76,14 +76,14 @@ void ICodec::open()
76
76
77
77
std::string ICodec::getCodecName () const
78
78
{
79
- assert ( _avCodec != NULL );
80
- return avcodec_descriptor_get ( _avCodec-> id )->name ;
79
+ assert ( _avCodecContext != NULL );
80
+ return avcodec_descriptor_get ( _avCodecContext-> codec_id )->name ;
81
81
}
82
82
83
83
AVCodecID ICodec::getCodecId () const
84
84
{
85
- assert ( _avCodec != NULL );
86
- return _avCodec-> id ;
85
+ assert ( _avCodecContext != NULL );
86
+ return _avCodecContext-> codec_id ;
87
87
}
88
88
89
89
int ICodec::getLatency () const
@@ -124,19 +124,13 @@ void ICodec::setCodec( const ECodecType type, const AVCodecID codecId )
124
124
}
125
125
126
126
if ( type == eCodecTypeEncoder )
127
- {
128
127
_avCodec = avcodec_find_encoder ( codecId );
129
- if ( _avCodecContext )
130
- _avCodecContext->codec = _avCodec;
131
- }
132
128
else if ( type == eCodecTypeDecoder )
133
- {
134
129
_avCodec = avcodec_find_decoder ( codecId );
135
- if ( _avCodecContext )
136
- _avCodecContext->codec = _avCodec;
137
- }
138
- }
139
130
131
+ if ( _avCodecContext )
132
+ _avCodecContext->codec = _avCodec;
133
+ }
140
134
141
135
void ICodec::allocateContext ()
142
136
{
@@ -145,14 +139,23 @@ void ICodec::allocateContext()
145
139
{
146
140
throw std::runtime_error ( " unable to allocate the codecContext and set its fields to default values" );
147
141
}
142
+ _avCodecContext->codec = _avCodec;
148
143
}
149
144
150
145
void ICodec::loadCodecOptions ()
151
146
{
152
147
if ( _type == eCodecTypeEncoder )
148
+ {
153
149
loadOptions ( _options, _avCodecContext, AV_OPT_FLAG_ENCODING_PARAM );
150
+ // load specific options of the codec
151
+ loadOptions ( _options, _avCodecContext->priv_data , AV_OPT_FLAG_ENCODING_PARAM );
152
+ }
154
153
else if ( _type == eCodecTypeDecoder )
154
+ {
155
155
loadOptions ( _options, _avCodecContext, AV_OPT_FLAG_DECODING_PARAM );
156
+ // load specific options of the codec
157
+ loadOptions ( _options, _avCodecContext->priv_data , AV_OPT_FLAG_DECODING_PARAM );
158
+ }
156
159
}
157
160
158
161
}
0 commit comments