1
1
#include " AvInputAudio.hpp"
2
2
3
+ #include < AvTranscoder/codec/ICodec.hpp>
4
+ #include < AvTranscoder/codedStream/AvInputStream.hpp>
5
+ #include < AvTranscoder/frame/AudioFrame.hpp>
6
+
3
7
extern " C" {
4
8
#include < libavcodec/avcodec.h>
5
9
#include < libavformat/avformat.h>
@@ -8,9 +12,6 @@ extern "C" {
8
12
#include < libavutil/channel_layout.h>
9
13
}
10
14
11
- #include < AvTranscoder/codedStream/AvInputStream.hpp>
12
- #include < AvTranscoder/frame/AudioFrame.hpp>
13
-
14
15
#include < iostream>
15
16
#include < stdexcept>
16
17
@@ -20,7 +21,6 @@ namespace avtranscoder
20
21
AvInputAudio::AvInputAudio ( AvInputStream& inputStream )
21
22
: IInputEssence()
22
23
, _inputStream ( &inputStream )
23
- , _codec( &inputStream.getAudioCodec() )
24
24
, _frame ( NULL )
25
25
{
26
26
}
@@ -45,8 +45,8 @@ AvInputAudio::~AvInputAudio()
45
45
46
46
void AvInputAudio::setup ()
47
47
{
48
- AVCodecContext* avCodecContext = _codec-> getAVCodecContext ();
49
- AVCodec* avCodec = _codec-> getAVCodec ();
48
+ AVCodecContext* avCodecContext = _inputStream-> getAudioCodec (). getAVCodecContext ();
49
+ AVCodec* avCodec = _inputStream-> getAudioCodec (). getAVCodec ();
50
50
51
51
avCodecContext->channels = _inputStream->getAudioCodec ().getAudioFrameDesc ().getChannels ();
52
52
@@ -84,7 +84,7 @@ bool AvInputAudio::decodeNextFrame( Frame& frameBuffer )
84
84
if ( ! decodeNextFrame () )
85
85
return false ;
86
86
87
- AVCodecContext* avCodecContext = _codec-> getAVCodecContext ();
87
+ AVCodecContext* avCodecContext = _inputStream-> getAudioCodec (). getAVCodecContext ();
88
88
89
89
size_t decodedSize = av_samples_get_buffer_size ( NULL , avCodecContext->channels , _frame->nb_samples , avCodecContext->sample_fmt , 1 );
90
90
@@ -114,9 +114,9 @@ bool AvInputAudio::decodeNextFrame( Frame& frameBuffer, const size_t subStreamIn
114
114
115
115
const int output_nbChannels = 1 ;
116
116
const int output_align = 1 ;
117
- size_t decodedSize = av_samples_get_buffer_size (NULL , output_nbChannels, _frame->nb_samples , _codec-> getAVCodecContext ()->sample_fmt , output_align);
117
+ size_t decodedSize = av_samples_get_buffer_size (NULL , output_nbChannels, _frame->nb_samples , _inputStream-> getAudioCodec (). getAVCodecContext ()->sample_fmt , output_align);
118
118
119
- size_t nbSubStreams = _codec-> getAVCodecContext ()->channels ;
119
+ size_t nbSubStreams = _inputStream-> getAudioCodec (). getAVCodecContext ()->channels ;
120
120
size_t bytePerSample = av_get_bytes_per_sample ( (AVSampleFormat)_frame->format );
121
121
122
122
if ( subStreamIndex > nbSubStreams - 1 )
@@ -165,7 +165,7 @@ bool AvInputAudio::decodeNextFrame()
165
165
packet.data = nextPacketRead ? data.getPtr (): NULL ;
166
166
packet.size = data.getSize ();
167
167
168
- int ret = avcodec_decode_audio4 ( _codec-> getAVCodecContext (), _frame, &got_frame, &packet );
168
+ int ret = avcodec_decode_audio4 ( _inputStream-> getAudioCodec (). getAVCodecContext (), _frame, &got_frame, &packet );
169
169
av_free_packet ( &packet );
170
170
171
171
if ( ! nextPacketRead && ret == 0 && got_frame == 0 ) // error or end of file
0 commit comments