Group :: Sound
RPM: chromaprint
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: chromaprint-1.1-alt-libav10.patch
Download
Download
--- chromaprint-1.1/src/ext/ffmpeg_decoder.h~ 2014-05-27 15:55:34.064000000 +0400
+++ chromaprint-1.1/src/ext/ffmpeg_decoder.h 2014-05-27 17:53:08.044000000 +0400
@@ -28,6 +28,10 @@ extern "C" {
}
#include "audio_consumer.h"
+#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
+#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
+#endif
+
class Decoder
{
public:
@@ -80,7 +84,7 @@ inline Decoder::~Decoder()
avcodec_close(m_codec_ctx);
}
if (m_format_ctx) {
- av_close_input_file(m_format_ctx);
+ avformat_close_input(&m_format_ctx);
}
//av_audio_convert_free(m_convert_ctx);
av_free(m_buffer2);
@@ -154,9 +158,11 @@ inline bool Decoder::Open()
inline void Decoder::Decode(Chromaprint::AudioConsumer *consumer, int max_length)
{
AVPacket packet, packet_temp;
+ AVFrame *decoded_frame;
int remaining = max_length * SampleRate() * Channels();
int stop = 0;
+ int got_frame = 0;
av_init_packet(&packet);
av_init_packet(&packet_temp);
@@ -174,10 +180,18 @@ inline void Decoder::Decode(Chromaprint:
int consumed = avcodec_decode_audio2(
m_codec_ctx, (int16_t *)m_buffer1, &buffer_size,
packet_temp.data, packet_temp.size);
-#else
+#elseif LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(54, 20, 0)
int consumed = avcodec_decode_audio3(
m_codec_ctx, (int16_t *)m_buffer1, &buffer_size,
&packet_temp);
+#else
+ if (!(decoded_frame = av_frame_alloc()))
+ break;
+ int consumed = avcodec_decode_audio4(
+ m_codec_ctx, decoded_frame, &got_frame,
+ &packet_temp);
+ memcpy(m_buffer1, decoded_frame->data[0], av_get_bytes_per_sample(m_codec_ctx->sample_fmt) * m_codec_ctx->channels * decoded_frame->nb_samples);
+ av_freep(&decoded_frame);
#endif
if (consumed < 0) {