Skip to content

Commit 945ed4c

Browse files
author
Clement Champetier
committed
ICodec: remove private function initCodecContext
Also remove checkError function (no definition!).
1 parent 725be7e commit 945ed4c

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

src/AvTranscoder/codec/ICodec.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ int ICodec::getLatency() const
5858

5959
void ICodec::setCodec( const ECodecType type, const std::string& codecName )
6060
{
61-
avcodec_register_all();
62-
if( type == eCodecTypeEncoder )
63-
_codec = avcodec_find_encoder_by_name( codecName.c_str() );
64-
else if( type == eCodecTypeDecoder )
65-
_codec = avcodec_find_decoder_by_name( codecName.c_str() );
66-
initCodecContext();
61+
const AVCodecDescriptor* avCodecDescriptor = avcodec_descriptor_get_by_name( codecName.c_str() );
62+
if( ! avCodecDescriptor )
63+
{
64+
std::string msg( "unable to find codec " );
65+
msg += codecName;
66+
throw std::runtime_error( msg );
67+
}
68+
69+
setCodec( type, avCodecDescriptor->id );
6770
}
6871

6972
void ICodec::setCodec( const ECodecType type, const AVCodecID codecId )
@@ -73,16 +76,14 @@ void ICodec::setCodec( const ECodecType type, const AVCodecID codecId )
7376
std::cout << "Warning: Unsupported codec with id 0" << std::endl;
7477
return;
7578
}
79+
7680
avcodec_register_all();
81+
7782
if( type == eCodecTypeEncoder )
7883
_codec = avcodec_find_encoder( codecId );
7984
else if( type == eCodecTypeDecoder )
8085
_codec = avcodec_find_decoder( codecId );
81-
initCodecContext();
82-
}
8386

84-
void ICodec::initCodecContext( )
85-
{
8687
if( _codec == NULL )
8788
{
8889
throw std::runtime_error( "unknown codec" );

src/AvTranscoder/codec/ICodec.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ class AvExport ICodec
3838
AVCodecContext& getAVCodecContext() const { return *_codecContext; }
3939
#endif
4040

41-
private:
42-
void initCodecContext( );
43-
44-
void checkError( int error );
45-
4641
protected:
4742
AVCodec* _codec; ///< Codec abstract description
4843
AVCodecContext* _codecContext; ///< Full codec instance description

0 commit comments

Comments
 (0)