Skip to content

Commit 9b44688

Browse files
author
Clement Champetier
committed
ICodec: fix set of AVCodec in AVCodecContext
1 parent 204f975 commit 9b44688

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/AvTranscoder/codec/ICodec.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,12 @@ void ICodec::setCodec( const ECodecType type, const AVCodecID codecId )
126126
}
127127

128128
if( type == eCodecTypeEncoder )
129-
{
130129
_avCodec = avcodec_find_encoder( codecId );
131-
if( _avCodecContext )
132-
_avCodecContext->codec = _avCodec;
133-
}
134130
else if( type == eCodecTypeDecoder )
135-
{
136131
_avCodec = avcodec_find_decoder( codecId );
137-
if( _avCodecContext )
138-
_avCodecContext->codec = _avCodec;
139-
}
132+
133+
if( _avCodecContext )
134+
_avCodecContext->codec = _avCodec;
140135
}
141136

142137
void ICodec::allocateContext()
@@ -146,6 +141,7 @@ void ICodec::allocateContext()
146141
{
147142
throw std::runtime_error( "unable to allocate the codecContext and set its fields to default values" );
148143
}
144+
_avCodecContext->codec = _avCodec;
149145
}
150146

151147
void ICodec::loadCodecOptions()

0 commit comments

Comments
 (0)