Lines 53-59
Link Here
|
53 |
} |
53 |
} |
54 |
|
54 |
|
55 |
private: |
55 |
private: |
56 |
static const int BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE * 2; |
56 |
static const int BUFFER_SIZE = 192000 * 2; |
57 |
uint8_t *m_buffer1; |
57 |
uint8_t *m_buffer1; |
58 |
uint8_t *m_buffer2; |
58 |
uint8_t *m_buffer2; |
59 |
std::string m_file_name; |
59 |
std::string m_file_name; |
Lines 80-86
Link Here
|
80 |
avcodec_close(m_codec_ctx); |
80 |
avcodec_close(m_codec_ctx); |
81 |
} |
81 |
} |
82 |
if (m_format_ctx) { |
82 |
if (m_format_ctx) { |
83 |
av_close_input_file(m_format_ctx); |
83 |
avformat_close_input(&m_format_ctx); |
84 |
} |
84 |
} |
85 |
//av_audio_convert_free(m_convert_ctx); |
85 |
//av_audio_convert_free(m_convert_ctx); |
86 |
av_free(m_buffer2); |
86 |
av_free(m_buffer2); |
Lines 89-100
Link Here
|
89 |
|
89 |
|
90 |
inline bool Decoder::Open() |
90 |
inline bool Decoder::Open() |
91 |
{ |
91 |
{ |
92 |
if (av_open_input_file(&m_format_ctx, m_file_name.c_str(), NULL, 0, NULL) != 0) { |
92 |
if (avformat_open_input(&m_format_ctx, m_file_name.c_str(), NULL, NULL) != 0) { |
93 |
m_error = "Couldn't open the file." + m_file_name; |
93 |
m_error = "Couldn't open the file." + m_file_name; |
94 |
return false; |
94 |
return false; |
95 |
} |
95 |
} |
96 |
|
96 |
|
97 |
if (av_find_stream_info(m_format_ctx) < 0) { |
97 |
if (avformat_find_stream_info(m_format_ctx, NULL) < 0) { |
98 |
m_error = "Couldn't find stream information in the file."; |
98 |
m_error = "Couldn't find stream information in the file."; |
99 |
return false; |
99 |
return false; |
100 |
} |
100 |
} |
Lines 129-139
Link Here
|
129 |
return false; |
129 |
return false; |
130 |
} |
130 |
} |
131 |
|
131 |
|
132 |
if (m_codec_ctx->sample_fmt != SAMPLE_FMT_S16) { |
132 |
if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16) { |
133 |
m_error = "Unsupported sample format.\n"; |
133 |
m_error = "Unsupported sample format.\n"; |
134 |
return false; |
134 |
return false; |
135 |
} |
135 |
} |
136 |
/*m_convert_ctx = av_audio_convert_alloc(SAMPLE_FMT_S16, 1, |
136 |
/*m_convert_ctx = av_audio_convert_alloc(AV_SAMPLE_FMT_S16, 1, |
137 |
m_codec_ctx->sample_fmt, 1, |
137 |
m_codec_ctx->sample_fmt, 1, |
138 |
NULL, 0); |
138 |
NULL, 0); |
139 |
if (!m_convert_ctx) { |
139 |
if (!m_convert_ctx) { |