1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
Index: openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
===================================================================
--- openscenegraph-3.6.5+dfsg1.orig/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
+++ openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp
@@ -45,12 +45,19 @@ static int decode_audio(AVCodecContext *
if (!frame)
return AVERROR(ENOMEM);
- ret = avcodec_decode_audio4(avctx, frame, &got_frame, &avpkt);
+ ret = avcodec_send_packet(avctx, &avpkt);
+ if (ret >= 0) {
+ ret = avcodec_receive_frame(avctx, frame);
+ if (ret == 0) {
+ got_frame = 1;
+ }
+ }
+
#ifdef USE_AVRESAMPLE // libav's AVFrame structure does not contain a 'channels' field
if (ret >= 0 && got_frame) {
#else
- if (ret >= 0 && got_frame && av_frame_get_channels(frame)>0) {
+ if (ret >= 0 && got_frame && frame->ch_layout.nb_channels>0) {
#endif
int ch, plane_size;
int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
@@ -151,11 +158,13 @@ void FFmpegDecoderAudio::open(AVStream *
return;
m_stream = stream;
- m_context = stream->codec;
-
- m_in_sample_rate = m_context->sample_rate;
- m_in_nb_channels = m_context->channels;
- m_in_sample_format = m_context->sample_fmt;
+ AVCodecParameters* avp = stream->codecpar;
+ const AVCodec * p_codec = avcodec_find_decoder(avp->codec_id);
+ m_context = avcodec_alloc_context3(p_codec);
+
+ m_in_sample_rate = avp->sample_rate;
+ m_in_nb_channels = avp->channels;
+ m_in_sample_format = ((AVSampleFormat)(avp->format));
AVDictionaryEntry *opt_out_sample_rate = av_dict_get( *parameters->getOptions(), "out_sample_rate", NULL, 0 );
if ( opt_out_sample_rate )
@@ -210,11 +219,10 @@ printf("### CONVERTING from sample forma
}
// Check stream sanity
- if (m_context->codec_id == AV_CODEC_ID_NONE)
+ if (avp->codec_id == AV_CODEC_ID_NONE)
throw std::runtime_error("invalid audio codec");;
// Find the decoder for the audio stream
- AVCodec * const p_codec = avcodec_find_decoder(m_context->codec_id);
if (p_codec == 0)
throw std::runtime_error("avcodec_find_decoder() failed");
Index: openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
===================================================================
--- openscenegraph-3.6.5+dfsg1.orig/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
+++ openscenegraph-3.6.5+dfsg1/src/osgPlugins/ffmpeg/FFmpegPacket.hpp
@@ -42,7 +42,7 @@ namespace osgFFmpeg
void clear()
{
if (packet.data != 0)
- av_free_packet(&packet);
+ av_packet_unref(&packet);
release();
}
|