diff -Nru audacity-2.0.5/debian/changelog audacity-2.0.5/debian/changelog --- audacity-2.0.5/debian/changelog 2014-05-31 22:18:51.000000000 +0200 +++ audacity-2.0.5/debian/changelog 2014-06-06 00:11:46.000000000 +0200 @@ -1,3 +1,9 @@ +audacity (2.0.5-1ubuntu3.2) trusty-proposed; urgency=medium + + * Really enable FFmpeg and fix crash on FFmpeg import (LP: #1076928) + + -- Benjamin Drung Thu, 05 Jun 2014 23:16:16 +0200 + audacity (2.0.5-1ubuntu3.1) trusty-proposed; urgency=medium * Add support for recent FFmpeg/libav versions. Thanks to Michael Niedermayer diff -Nru audacity-2.0.5/debian/control audacity-2.0.5/debian/control --- audacity-2.0.5/debian/control 2013-11-10 21:30:23.000000000 +0100 +++ audacity-2.0.5/debian/control 2014-06-05 23:14:49.000000000 +0200 @@ -13,9 +13,9 @@ dh-autoreconf, gettext, libasound2-dev [linux-any], -# libavcodec-dev (>= 4:0.6), -# libavformat-dev (>= 4:0.6), -# libavutil-dev (>= 4:0.6), + libavcodec-dev (>= 6:0.8), + libavformat-dev (>= 6:0.8), + libavutil-dev (>= 6:0.8), libexpat1-dev, libflac++-dev, libgtk2.0-dev, diff -Nru audacity-2.0.5/debian/patches/ffmpeg.patch audacity-2.0.5/debian/patches/ffmpeg.patch --- audacity-2.0.5/debian/patches/ffmpeg.patch 2014-05-31 22:17:41.000000000 +0200 +++ audacity-2.0.5/debian/patches/ffmpeg.patch 2014-06-06 00:06:17.000000000 +0200 @@ -9,6 +9,15 @@ --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp +@@ -17,7 +17,7 @@ + // Store function pointers here when including FFmpeg.h + #define DEFINE_FFMPEG_POINTERS + +-#include "Audacity.h" // for config*.h ++#include "Audacity.h" // for config*.h + #include "FFmpeg.h" + #include "AudacityApp.h" + #include "FileNames.h" @@ -25,16 +25,6 @@ #include @@ -547,8 +556,6 @@ - FFMPEG_INITALT(avformat, avio_close, url_fclose); - FFMPEG_INITALT(avformat, av_metadata_set2, av_metadata_set); + FFMPEG_INITDYN(avformat, avformat_open_input); -+ FFMPEG_INITDYN(avformat, av_dict_get); -+ FFMPEG_INITDYN(avformat, av_dict_set); + FFMPEG_INITDYN(avformat, avio_size); + FFMPEG_INITDYN(avformat, avio_alloc_context); FFMPEG_INITALT(avformat, av_guess_format, guess_format); @@ -587,9 +594,11 @@ - FFMPEG_INITALT(avcodec, av_get_bits_per_sample_format, av_get_bits_per_sample_fmt); + FFMPEG_INITDYN(avcodec, av_codec_is_encoder); + FFMPEG_INITDYN(avcodec, avcodec_fill_audio_frame); -+ FFMPEG_INITDYN(avcodec, av_get_bytes_per_sample); FFMPEG_INITDYN(avutil, av_free); ++ FFMPEG_INITDYN(avutil, av_dict_get); ++ FFMPEG_INITDYN(avutil, av_dict_set); ++ FFMPEG_INITDYN(avutil, av_get_bytes_per_sample); FFMPEG_INITDYN(avutil, av_log_set_callback); FFMPEG_INITDYN(avutil, av_log_default_callback); -#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(49, 15, 0) @@ -656,22 +665,48 @@ --- a/src/FFmpeg.h +++ b/src/FFmpeg.h -@@ -41,28 +41,81 @@ +@@ -16,6 +16,10 @@ + #if !defined(__AUDACITY_FFMPEG__) + #define __AUDACITY_FFMPEG__ + ++// TODO: Determine whether the libav* headers come from the FFmpeg or libav ++// project and set IS_FFMPEG_PROJECT depending on it. ++#define IS_FFMPEG_PROJECT 1 ++ + /* FFmpeg is written in C99. It uses many types from stdint.h. Because we are + * compiling this using a C++ compiler we have to put it in extern "C". + * __STDC_CONSTANT_MACROS is defined to make behave like it +@@ -31,7 +35,7 @@ + + #if defined(USE_FFMPEG) + extern "C" { +- // Include errno.h before the ffmpeg includes since they depend on ++ // Include errno.h before the ffmpeg includes since they depend on + // knowing the value of EINVAL...see bottom of avcodec.h. Not doing + // so will produce positive error returns when they should be < 0. + #include +@@ -41,28 +45,85 @@ #include #include - #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52, 102, 0) - #define AVIOContext ByteIOContext -+ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 45, 101) -+ #define av_frame_alloc avcodec_alloc_frame -+ #define av_frame_free avcodec_free_frame - #endif - +- #endif +- - #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 94, 1) - #define AVSampleFormat SampleFormat -+ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 59, 100) -+ #define avcodec_free_frame av_free - #endif +- #endif ++ #if defined(DISABLE_DYNAMIC_LOADING_FFMPEG) ++ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 45, 101) ++ #define av_frame_alloc avcodec_alloc_frame ++ #define av_frame_free avcodec_free_frame ++ #endif ++ ++ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 59, 100) ++ inline void avcodec_free_frame(AVFrame **frame) { ++ av_free(*frame); ++ } ++ #endif - #if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 120, 0) - #define CodecType AVMediaType @@ -682,81 +717,88 @@ - #define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE - #define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT - #define CODEC_TYPE_NB AVMEDIA_TYPE_NB -+ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 51, 100) -+ #define AVCodecID CodecID -+ #define AV_CODEC_ID_AAC CODEC_ID_AAC -+ #define AV_CODEC_ID_AC CODEC_ID_AC -+ #define AV_CODEC_ID_AC3 CODEC_ID_AC3 -+ #define AV_CODEC_ID_ADPCM CODEC_ID_ADPCM -+ #define AV_CODEC_ID_ADPCM_CT CODEC_ID_ADPCM_CT -+ #define AV_CODEC_ID_ADPCM_G726 CODEC_ID_ADPCM_G726 -+ #define AV_CODEC_ID_ADPCM_IMA_QT CODEC_ID_ADPCM_IMA_QT -+ #define AV_CODEC_ID_ADPCM_IMA_WAV CODEC_ID_ADPCM_IMA_WAV -+ #define AV_CODEC_ID_ADPCM_MS CODEC_ID_ADPCM_MS -+ #define AV_CODEC_ID_ADPCM_SWF CODEC_ID_ADPCM_SWF -+ #define AV_CODEC_ID_ADPCM_YAMAHA CODEC_ID_ADPCM_YAMAHA -+ #define AV_CODEC_ID_ALAC CODEC_ID_ALAC -+ #define AV_CODEC_ID_AMR CODEC_ID_AMR -+ #define AV_CODEC_ID_AMR_NB CODEC_ID_AMR_NB -+ #define AV_CODEC_ID_AMR_WB CODEC_ID_AMR_WB -+ #define AV_CODEC_ID_ATRAC CODEC_ID_ATRAC -+ #define AV_CODEC_ID_ATRAC3 CODEC_ID_ATRAC3 -+ #define AV_CODEC_ID_DTS CODEC_ID_DTS -+ #define AV_CODEC_ID_DVAUDIO CODEC_ID_DVAUDIO -+ #define AV_CODEC_ID_FLAC CODEC_ID_FLAC -+ #define AV_CODEC_ID_GSM CODEC_ID_GSM -+ #define AV_CODEC_ID_GSM_MS CODEC_ID_GSM_MS -+ #define AV_CODEC_ID_IMC CODEC_ID_IMC -+ #define AV_CODEC_ID_MACE CODEC_ID_MACE -+ #define AV_CODEC_ID_MACE3 CODEC_ID_MACE3 -+ #define AV_CODEC_ID_MACE6 CODEC_ID_MACE6 -+ #define AV_CODEC_ID_MP CODEC_ID_MP -+ #define AV_CODEC_ID_MP2 CODEC_ID_MP2 -+ #define AV_CODEC_ID_MP3 CODEC_ID_MP3 -+ #define AV_CODEC_ID_NELLYMOSER CODEC_ID_NELLYMOSER -+ #define AV_CODEC_ID_NONE CODEC_ID_NONE -+ #define AV_CODEC_ID_PCM CODEC_ID_PCM -+ #define AV_CODEC_ID_PCM_ALAW CODEC_ID_PCM_ALAW -+ #define AV_CODEC_ID_PCM_MULAW CODEC_ID_PCM_MULAW -+ #define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE -+ #define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE -+ #define AV_CODEC_ID_PCM_S24BE CODEC_ID_PCM_S24BE -+ #define AV_CODEC_ID_PCM_S24LE CODEC_ID_PCM_S24LE -+ #define AV_CODEC_ID_PCM_S32BE CODEC_ID_PCM_S32BE -+ #define AV_CODEC_ID_PCM_S32LE CODEC_ID_PCM_S32LE -+ #define AV_CODEC_ID_PCM_S8 CODEC_ID_PCM_S8 -+ #define AV_CODEC_ID_PCM_U8 CODEC_ID_PCM_U8 -+ #define AV_CODEC_ID_QCELP CODEC_ID_QCELP -+ #define AV_CODEC_ID_QDM CODEC_ID_QDM -+ #define AV_CODEC_ID_QDM2 CODEC_ID_QDM2 -+ #define AV_CODEC_ID_ROQ CODEC_ID_ROQ -+ #define AV_CODEC_ID_ROQ_DPCM CODEC_ID_ROQ_DPCM -+ #define AV_CODEC_ID_SONIC CODEC_ID_SONIC -+ #define AV_CODEC_ID_SONIC_LS CODEC_ID_SONIC_LS -+ #define AV_CODEC_ID_TRUESPEECH CODEC_ID_TRUESPEECH -+ #define AV_CODEC_ID_VORBIS CODEC_ID_VORBIS -+ #define AV_CODEC_ID_VOXWARE CODEC_ID_VOXWARE -+ #define AV_CODEC_ID_WMAPRO CODEC_ID_WMAPRO -+ #define AV_CODEC_ID_WMAV CODEC_ID_WMAV -+ #define AV_CODEC_ID_WMAV1 CODEC_ID_WMAV1 -+ #define AV_CODEC_ID_WMAV2 CODEC_ID_WMAV2 -+ #define AV_CODEC_ID_WMAVOICE CODEC_ID_WMAVOICE ++ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 51, 100) ++ #define AVCodecID CodecID ++ #define AV_CODEC_ID_AAC CODEC_ID_AAC ++ #define AV_CODEC_ID_AC CODEC_ID_AC ++ #define AV_CODEC_ID_AC3 CODEC_ID_AC3 ++ #define AV_CODEC_ID_ADPCM CODEC_ID_ADPCM ++ #define AV_CODEC_ID_ADPCM_CT CODEC_ID_ADPCM_CT ++ #define AV_CODEC_ID_ADPCM_G726 CODEC_ID_ADPCM_G726 ++ #define AV_CODEC_ID_ADPCM_IMA_QT CODEC_ID_ADPCM_IMA_QT ++ #define AV_CODEC_ID_ADPCM_IMA_WAV CODEC_ID_ADPCM_IMA_WAV ++ #define AV_CODEC_ID_ADPCM_MS CODEC_ID_ADPCM_MS ++ #define AV_CODEC_ID_ADPCM_SWF CODEC_ID_ADPCM_SWF ++ #define AV_CODEC_ID_ADPCM_YAMAHA CODEC_ID_ADPCM_YAMAHA ++ #define AV_CODEC_ID_ALAC CODEC_ID_ALAC ++ #define AV_CODEC_ID_AMR CODEC_ID_AMR ++ #define AV_CODEC_ID_AMR_NB CODEC_ID_AMR_NB ++ #define AV_CODEC_ID_AMR_WB CODEC_ID_AMR_WB ++ #define AV_CODEC_ID_ATRAC CODEC_ID_ATRAC ++ #define AV_CODEC_ID_ATRAC3 CODEC_ID_ATRAC3 ++ #define AV_CODEC_ID_DTS CODEC_ID_DTS ++ #define AV_CODEC_ID_DVAUDIO CODEC_ID_DVAUDIO ++ #define AV_CODEC_ID_FLAC CODEC_ID_FLAC ++ #define AV_CODEC_ID_GSM CODEC_ID_GSM ++ #define AV_CODEC_ID_GSM_MS CODEC_ID_GSM_MS ++ #define AV_CODEC_ID_IMC CODEC_ID_IMC ++ #define AV_CODEC_ID_MACE CODEC_ID_MACE ++ #define AV_CODEC_ID_MACE3 CODEC_ID_MACE3 ++ #define AV_CODEC_ID_MACE6 CODEC_ID_MACE6 ++ #define AV_CODEC_ID_MP CODEC_ID_MP ++ #define AV_CODEC_ID_MP2 CODEC_ID_MP2 ++ #define AV_CODEC_ID_MP3 CODEC_ID_MP3 ++ #define AV_CODEC_ID_NELLYMOSER CODEC_ID_NELLYMOSER ++ #define AV_CODEC_ID_NONE CODEC_ID_NONE ++ #define AV_CODEC_ID_PCM CODEC_ID_PCM ++ #define AV_CODEC_ID_PCM_ALAW CODEC_ID_PCM_ALAW ++ #define AV_CODEC_ID_PCM_MULAW CODEC_ID_PCM_MULAW ++ #define AV_CODEC_ID_PCM_S16BE CODEC_ID_PCM_S16BE ++ #define AV_CODEC_ID_PCM_S16LE CODEC_ID_PCM_S16LE ++ #define AV_CODEC_ID_PCM_S24BE CODEC_ID_PCM_S24BE ++ #define AV_CODEC_ID_PCM_S24LE CODEC_ID_PCM_S24LE ++ #define AV_CODEC_ID_PCM_S32BE CODEC_ID_PCM_S32BE ++ #define AV_CODEC_ID_PCM_S32LE CODEC_ID_PCM_S32LE ++ #define AV_CODEC_ID_PCM_S8 CODEC_ID_PCM_S8 ++ #define AV_CODEC_ID_PCM_U8 CODEC_ID_PCM_U8 ++ #define AV_CODEC_ID_QCELP CODEC_ID_QCELP ++ #define AV_CODEC_ID_QDM CODEC_ID_QDM ++ #define AV_CODEC_ID_QDM2 CODEC_ID_QDM2 ++ #define AV_CODEC_ID_ROQ CODEC_ID_ROQ ++ #define AV_CODEC_ID_ROQ_DPCM CODEC_ID_ROQ_DPCM ++ #define AV_CODEC_ID_SONIC CODEC_ID_SONIC ++ #define AV_CODEC_ID_SONIC_LS CODEC_ID_SONIC_LS ++ #define AV_CODEC_ID_TRUESPEECH CODEC_ID_TRUESPEECH ++ #define AV_CODEC_ID_VORBIS CODEC_ID_VORBIS ++ #define AV_CODEC_ID_VOXWARE CODEC_ID_VOXWARE ++ #define AV_CODEC_ID_WMAPRO CODEC_ID_WMAPRO ++ #define AV_CODEC_ID_WMAV CODEC_ID_WMAV ++ #define AV_CODEC_ID_WMAV1 CODEC_ID_WMAV1 ++ #define AV_CODEC_ID_WMAV2 CODEC_ID_WMAV2 ++ #define AV_CODEC_ID_WMAVOICE CODEC_ID_WMAVOICE ++ #endif ++ ++ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 8, 100) ++ inline bool av_codec_is_encoder(AVCodec *codec) { ++ return codec != NULL && (codec->encode != NULL || codec->encode2 != NULL); ++ } ++ #endif #endif - +- - #ifndef PKT_FLAG_KEY - #define PKT_FLAG_KEY AV_PKT_FLAG_KEY - #endif -+ #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 8, 100) -+ inline bool av_codec_is_encoder(AVCodec *codec) { -+ return codec != NULL && (codec->encode != NULL || codec->encode2 != NULL); -+ } -+ #endif } #endif -@@ -74,10 +127,10 @@ - #include // for wxLogNull - #include // for wxMessageBox +@@ -71,13 +132,13 @@ + * we need for the next bit */ + #include + #include +-#include // for wxLogNull +-#include // for wxMessageBox ++#include // for wxLogNull ++#include // for wxMessageBox #include -#include "../widgets/LinkingHtmlWindow.h" +#include "widgets/LinkingHtmlWindow.h" @@ -767,7 +809,16 @@ #include #include // needed for sampleCount -@@ -331,6 +384,7 @@ +@@ -310,7 +371,7 @@ + wxString mAVCodecVersion; + wxString mAVFormatVersion; + wxString mAVUtilVersion; +- ++ + ///! wx interfaces for dynamic libraries + wxDynamicLibrary *avformat; + wxDynamicLibrary *avcodec; +@@ -331,6 +392,7 @@ int ufile_fopen(AVIOContext **s, const wxString & name, int flags); int ufile_fopen_input(AVFormatContext **ic_ptr, wxString & name); @@ -775,7 +826,16 @@ typedef struct _streamContext { -@@ -353,7 +407,7 @@ +@@ -341,7 +403,7 @@ + AVPacket m_pkt; // the last AVPacket we read for this stream + int m_pktValid; // is m_pkt valid? + uint8_t *m_pktDataPtr; // pointer into m_pkt.data +- int m_pktRemainingSiz; ++ int m_pktRemainingSiz; + + int64_t m_pts; // the current presentation time of the input stream + int64_t m_ptsOffset; // packets associated with stream are relative to this +@@ -353,7 +415,7 @@ int m_initialchannels; // number of channels allocated when we begin the importing. Assumes that number of channels doesn't change on the fly. int m_samplesize; // input sample size in bytes @@ -784,7 +844,7 @@ int m_osamplesize; // output sample size in bytes sampleFormat m_osamplefmt; // output sample format -@@ -368,18 +422,7 @@ +@@ -368,18 +430,7 @@ int import_ffmpeg_decode_frame(streamContext *sc, bool flushing); @@ -804,7 +864,34 @@ extern "C" { // A little explanation of what's going on here. // -@@ -510,15 +553,10 @@ +@@ -401,7 +452,7 @@ + // make sure that the definitions are the same. If not, it will complain. For this to occur, + // the functions MUST be defined in an extern "C" block otherwise the compiler just thinks the + // functions are being overloaded. +- // ++ // + // The compiler should optimize away the inline function since it just passes control to the real + // function and we should wind up with about the same function call we had before, only now it is + // safer due to the validation. +@@ -476,7 +527,7 @@ + } \ + } + +- // ++ // + // libavutil + // + FFMPEG_FUNCTION_WITH_RETURN( +@@ -486,7 +537,7 @@ + () + ); + FFMPEG_FUNCTION_NO_RETURN( +- av_log_set_callback, ++ av_log_set_callback, + (void (*cb)(void*, int, const char*, va_list)), + (cb) + ); +@@ -510,15 +561,10 @@ (void), () ); @@ -821,7 +908,7 @@ (id) ); FFMPEG_FUNCTION_WITH_RETURN( -@@ -530,46 +568,32 @@ +@@ -530,46 +576,41 @@ FFMPEG_FUNCTION_WITH_RETURN( AVCodec*, avcodec_find_decoder, @@ -851,6 +938,7 @@ + (avctx, codec, options); ); -#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 25, 0) ++#if defined(IS_FFMPEG_PROJECT) FFMPEG_FUNCTION_WITH_RETURN( int, - avcodec_decode_audio3, @@ -860,16 +948,19 @@ + (AVCodecContext *avctx, AVFrame *frame, int *got_output, const AVPacket *avpkt), + (avctx, frame, got_output, avpkt) ); --#else + #else FFMPEG_FUNCTION_WITH_RETURN( int, - avcodec_decode_audio2, - (AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, const uint8_t *buf, int buf_size), - (avctx, samples, frame_size_ptr, buf, buf_size) -- ); --#endif -- FFMPEG_FUNCTION_WITH_RETURN( -- int, ++ avcodec_decode_audio4, ++ (AVCodecContext *avctx, AVFrame *frame, int *got_output, AVPacket *avpkt), ++ (avctx, frame, got_output, avpkt) + ); + #endif + FFMPEG_FUNCTION_WITH_RETURN( + int, - avcodec_encode_audio, - (AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples), - (avctx, buf, buf_size, samples) @@ -879,7 +970,7 @@ ); FFMPEG_FUNCTION_WITH_RETURN( int, -@@ -584,15 +608,15 @@ +@@ -584,15 +625,15 @@ ); FFMPEG_FUNCTION_WITH_RETURN( int, @@ -900,7 +991,7 @@ ); // -@@ -604,32 +628,11 @@ +@@ -604,32 +645,11 @@ (void), () ); @@ -936,7 +1027,7 @@ ); FFMPEG_FUNCTION_NO_RETURN( av_register_all, -@@ -638,15 +641,9 @@ +@@ -638,15 +658,9 @@ ); FFMPEG_FUNCTION_WITH_RETURN( int, @@ -955,7 +1046,7 @@ ); FFMPEG_FUNCTION_WITH_RETURN( int, -@@ -661,21 +658,15 @@ +@@ -661,21 +675,15 @@ (s, stream_index, timestamp, flags) ); FFMPEG_FUNCTION_NO_RETURN( @@ -982,7 +1073,7 @@ ); FFMPEG_FUNCTION_WITH_RETURN( AVOutputFormat*, -@@ -686,68 +677,14 @@ +@@ -686,69 +694,24 @@ FFMPEG_FUNCTION_WITH_RETURN( AVCodec*, av_codec_next, @@ -990,6 +1081,7 @@ + (const AVCodec *c), (c) ); ++#if defined(IS_FFMPEG_PROJECT) FFMPEG_FUNCTION_WITH_RETURN( - int, - av_set_parameters, @@ -1043,19 +1135,26 @@ - url_fsize, - (AVIOContext *s), - (s) -- ); -- FFMPEG_FUNCTION_WITH_RETURN( ++ AVStream*, ++ avformat_new_stream, ++ (AVFormatContext *s, const AVCodec *c), ++ (s, c) + ); ++#else + FFMPEG_FUNCTION_WITH_RETURN( AVStream*, - av_new_stream, - (AVFormatContext *s, int id), - (s, id) + avformat_new_stream, -+ (AVFormatContext *s, const AVCodec *c), ++ (AVFormatContext *s, AVCodec *c), + (s, c) ); ++#endif FFMPEG_FUNCTION_WITH_RETURN( AVFormatContext*, -@@ -763,12 +700,6 @@ + avformat_alloc_context, +@@ -763,12 +726,6 @@ ); FFMPEG_FUNCTION_WITH_RETURN( int, @@ -1068,7 +1167,7 @@ av_write_trailer, (AVFormatContext *s), (s) -@@ -801,21 +732,12 @@ +@@ -801,21 +758,12 @@ (AVFifoBuffer *f), (f) ); @@ -1090,7 +1189,7 @@ FFMPEG_FUNCTION_NO_RETURN( av_freep, (void *ptr), -@@ -827,16 +749,11 @@ +@@ -827,16 +775,11 @@ (int64_t a, AVRational bq, AVRational cq), (a, bq, cq) ); @@ -1107,7 +1206,7 @@ FFMPEG_FUNCTION_WITH_RETURN( AVFifoBuffer*, av_fifo_alloc, -@@ -849,20 +766,6 @@ +@@ -849,20 +792,6 @@ (AVFifoBuffer *f, void *buf, int buf_size, void (*func)(void*, void*, int)), (f, buf, buf_size, func) ); @@ -1128,7 +1227,7 @@ FFMPEG_FUNCTION_WITH_RETURN( int, av_fifo_realloc2, -@@ -870,46 +773,57 @@ +@@ -870,46 +799,57 @@ (f, size) ); FFMPEG_FUNCTION_WITH_RETURN( @@ -1252,38 +1351,55 @@ void SetMetadata(Tags *tags, const char *name, const wxChar *tag); /// Encodes audio -@@ -147,17 +151,12 @@ +@@ -145,19 +149,14 @@ + + private: - AVFormatContext * mEncFormatCtx; // libavformat's context for our output file - AVOutputFormat * mEncFormatDesc; // describes our output file to libavformat +- AVFormatContext * mEncFormatCtx; // libavformat's context for our output file +- AVOutputFormat * mEncFormatDesc; // describes our output file to libavformat - -+ int default_frame_size; - AVStream * mEncAudioStream; // the output audio stream (may remain NULL) - AVCodecContext * mEncAudioCodecCtx; // the encoder for the output audio stream +- AVStream * mEncAudioStream; // the output audio stream (may remain NULL) +- AVCodecContext * mEncAudioCodecCtx; // the encoder for the output audio stream - uint8_t * mEncAudioEncodedBuf; // buffer to hold frames encoded by the encoder - int mEncAudioEncodedBufSiz; - AVFifoBuffer * mEncAudioFifo; // FIFO to write incoming audio samples into - uint8_t * mEncAudioFifoOutBuf; // buffer to read _out_ of the FIFO into +- AVFifoBuffer * mEncAudioFifo; // FIFO to write incoming audio samples into +- uint8_t * mEncAudioFifoOutBuf; // buffer to read _out_ of the FIFO into - -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(50, 0, 0) - AVFifoBuffer mEncAudioFifoBuffer; // FIFO to write incoming audio samples into -#endif ++ AVFormatContext * mEncFormatCtx; // libavformat's context for our output file ++ AVOutputFormat * mEncFormatDesc; // describes our output file to libavformat ++ int default_frame_size; ++ AVStream * mEncAudioStream; // the output audio stream (may remain NULL) ++ AVCodecContext * mEncAudioCodecCtx; // the encoder for the output audio stream ++ AVFifoBuffer * mEncAudioFifo; // FIFO to write incoming audio samples into ++ uint8_t * mEncAudioFifoOutBuf; // buffer to read _out_ of the FIFO into + int mEncAudioFifoOutBufSiz; wxString mName; -@@ -175,14 +174,9 @@ - mEncFormatDesc = NULL; // describes our output file to libavformat - mEncAudioStream = NULL; // the output audio stream (may remain NULL) - mEncAudioCodecCtx = NULL; // the encoder for the output audio stream +@@ -171,18 +170,13 @@ + ExportFFmpeg::ExportFFmpeg() + : ExportPlugin() + { +- mEncFormatCtx = NULL; // libavformat's context for our output file +- mEncFormatDesc = NULL; // describes our output file to libavformat +- mEncAudioStream = NULL; // the output audio stream (may remain NULL) +- mEncAudioCodecCtx = NULL; // the encoder for the output audio stream - mEncAudioEncodedBuf = NULL; // buffer to hold frames encoded by the encoder ++ mEncFormatCtx = NULL; // libavformat's context for our output file ++ mEncFormatDesc = NULL; // describes our output file to libavformat ++ mEncAudioStream = NULL; // the output audio stream (may remain NULL) ++ mEncAudioCodecCtx = NULL; // the encoder for the output audio stream #define MAX_AUDIO_PACKET_SIZE (128 * 1024) - mEncAudioEncodedBufSiz = 4*MAX_AUDIO_PACKET_SIZE; - mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into +- mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into - -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(50, 0, 0) - mEncAudioFifo = &mEncAudioFifoBuffer; -#endif ++ mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into + mEncAudioFifoOutBufSiz = 0; mSampleRate = 0; @@ -1362,7 +1478,8 @@ + bool ExportFFmpeg::InitCodecs(AudacityProject *project) { - AVCodec * codec = NULL; +- AVCodec * codec = NULL; ++ AVCodec *codec = NULL; + AVDictionary *options = NULL; // Configure the audio stream's codec context. @@ -1612,16 +1729,21 @@ bool ExportFFmpeg::Finalize() { int i, nEncodedBytes; -@@ -524,82 +606,75 @@ - AVPacket pkt; - int nFifoBytes = av_fifo_size(mEncAudioFifo); // any bytes left in audio FIFO? - -+ av_init_packet(&pkt); +@@ -521,85 +603,78 @@ + // Flush the audio FIFO and encoder. + for (;;) + { +- AVPacket pkt; +- int nFifoBytes = av_fifo_size(mEncAudioFifo); // any bytes left in audio FIFO? ++ AVPacket pkt; ++ int nFifoBytes = av_fifo_size(mEncAudioFifo); // any bytes left in audio FIFO? + ++ av_init_packet(&pkt); + nEncodedBytes = 0; - int nAudioFrameSizeOut = mEncAudioCodecCtx->frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); - if (mEncAudioCodecCtx->frame_size == 1) nAudioFrameSizeOut = mEncAudioEncodedBufSiz; -+ int nAudioFrameSizeOut = default_frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); ++ int nAudioFrameSizeOut = default_frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); + + if (nAudioFrameSizeOut > mEncAudioFifoOutBufSiz || nFifoBytes > mEncAudioFifoOutBufSiz) { + wxLogError(wxT("FFmpeg : ERROR - Too much remaining data.")); @@ -1721,7 +1843,7 @@ } // Write any file trailers. -@@ -617,22 +692,17 @@ +@@ -617,34 +692,28 @@ // Close the output file if we created it. if (!(mEncFormatDesc->flags & AVFMT_NOFILE)) @@ -1747,16 +1869,23 @@ return true; } -@@ -642,8 +712,7 @@ - AVPacket pkt; - int nBytesToWrite = 0; - uint8_t * pRawSamples = NULL; + + bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, int frameSize) + { +- AVPacket pkt; +- int nBytesToWrite = 0; +- uint8_t * pRawSamples = NULL; - int nAudioFrameSizeOut = mEncAudioCodecCtx->frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); - if (mEncAudioCodecCtx->frame_size == 1) nAudioFrameSizeOut = mEncAudioEncodedBufSiz; -+ int nAudioFrameSizeOut = default_frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); - int ret; +- int ret; ++ AVPacket pkt; ++ int nBytesToWrite = 0; ++ uint8_t *pRawSamples = NULL; ++ int nAudioFrameSizeOut = default_frame_size * mEncAudioCodecCtx->channels * sizeof(int16_t); ++ int ret; nBytesToWrite = frameSize; + pRawSamples = (uint8_t*)pFrame; @@ -655,42 +724,46 @@ wxASSERT(ret == nBytesToWrite); @@ -1783,8 +1912,8 @@ - if (mEncAudioCodecCtx->frame_size == 1) { wxASSERT(pkt.size == mEncAudioEncodedBufSiz); } - if (pkt.size < 0) + int ret= encode_audio(mEncAudioCodecCtx, -+ &pkt, // out -+ (int16_t*)mEncAudioFifoOutBuf, // in ++ &pkt, // out ++ (int16_t*)mEncAudioFifoOutBuf, // in + default_frame_size); + if (ret < 0) { @@ -1993,7 +2122,7 @@ case FEMaxPartOrderID: case FEMuxRateID: case FEPacketSizeID: -@@ -793,302 +793,312 @@ +@@ -793,302 +793,292 @@ /// Format-codec compatibility list /// Must end with NULL entry @@ -2335,10 +2464,6 @@ + { wxT("asf"), AV_CODEC_ID_IMC }, + { wxT("asf"), AV_CODEC_ID_AC3 }, + { wxT("asf"), AV_CODEC_ID_DTS }, -+#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVCODEC_VERSION_MAJOR == 53) -+ { wxT("asf"), AV_CODEC_ID_SONIC }, -+ { wxT("asf"), AV_CODEC_ID_SONIC_LS }, -+#endif + { wxT("asf"), AV_CODEC_ID_FLAC }, + { wxT("asf"), AV_CODEC_ID_ADPCM_SWF }, + { wxT("asf"), AV_CODEC_ID_VORBIS }, @@ -2373,10 +2498,6 @@ + { wxT("avi"), AV_CODEC_ID_IMC }, + { wxT("avi"), AV_CODEC_ID_AC3 }, + { wxT("avi"), AV_CODEC_ID_DTS }, -+#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVCODEC_VERSION_MAJOR == 53) -+ { wxT("avi"), AV_CODEC_ID_SONIC }, -+ { wxT("avi"), AV_CODEC_ID_SONIC_LS }, -+#endif + { wxT("avi"), AV_CODEC_ID_FLAC }, + { wxT("avi"), AV_CODEC_ID_ADPCM_SWF }, + { wxT("avi"), AV_CODEC_ID_VORBIS }, @@ -2424,10 +2545,6 @@ + { wxT("matroska"), AV_CODEC_ID_IMC }, + { wxT("matroska"), AV_CODEC_ID_AC3 }, + { wxT("matroska"), AV_CODEC_ID_DTS }, -+#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVCODEC_VERSION_MAJOR == 53) -+ { wxT("matroska"), AV_CODEC_ID_SONIC }, -+ { wxT("matroska"), AV_CODEC_ID_SONIC_LS }, -+#endif + { wxT("matroska"), AV_CODEC_ID_FLAC }, + { wxT("matroska"), AV_CODEC_ID_ADPCM_SWF }, + { wxT("matroska"), AV_CODEC_ID_VORBIS }, @@ -2534,10 +2651,6 @@ + { wxT("nut"), AV_CODEC_ID_IMC }, + { wxT("nut"), AV_CODEC_ID_AC3 }, + { wxT("nut"), AV_CODEC_ID_DTS }, -+#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVCODEC_VERSION_MAJOR == 53) -+ { wxT("nut"), AV_CODEC_ID_SONIC }, -+ { wxT("nut"), AV_CODEC_ID_SONIC_LS }, -+#endif + { wxT("nut"), AV_CODEC_ID_FLAC }, + { wxT("nut"), AV_CODEC_ID_ADPCM_SWF }, + { wxT("nut"), AV_CODEC_ID_VORBIS }, @@ -2586,10 +2699,6 @@ + { wxT("wav"), AV_CODEC_ID_IMC }, + { wxT("wav"), AV_CODEC_ID_AC3 }, + { wxT("wav"), AV_CODEC_ID_DTS }, -+#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || (LIBAVCODEC_VERSION_MAJOR == 53) -+ { wxT("wav"), AV_CODEC_ID_SONIC }, -+ { wxT("wav"), AV_CODEC_ID_SONIC_LS }, -+#endif + { wxT("wav"), AV_CODEC_ID_FLAC }, + { wxT("wav"), AV_CODEC_ID_ADPCM_SWF }, + { wxT("wav"), AV_CODEC_ID_VORBIS }, @@ -2599,7 +2708,7 @@ }; /// AAC profiles -@@ -1110,11 +1120,11 @@ +@@ -1110,11 +1100,11 @@ /// List of export types ExposedFormat ExportFFmpegOptions::fmts[] = { @@ -2616,7 +2725,7 @@ }; /// Sample rates supported by AAC encoder (must end with zero-element) -@@ -1125,84 +1135,84 @@ +@@ -1125,84 +1115,84 @@ /// Syntax: first, enable a control for each applicable format-codec combination /// then disable it for anything else /// "any" - any format @@ -2778,7 +2887,7 @@ }; /// Prediction order method - names. Labels are indices of this array. -@@ -1251,7 +1261,7 @@ +@@ -1251,7 +1241,7 @@ DoOnFormatList(); //Select the codec that was selected last time this dialog was closed @@ -2787,7 +2896,7 @@ if (codec != NULL) mCodecList->Select(mCodecList->FindString(wxString::FromUTF8(codec->name))); DoOnCodecList(); } -@@ -1268,7 +1278,7 @@ +@@ -1268,7 +1258,7 @@ { // Any audio-capable format has default audio codec. // If it doesn't, then it doesn't supports any audio codecs @@ -2796,7 +2905,7 @@ { mFormatNames.Add(wxString::FromUTF8(ofmt->name)); mFormatLongNames.Add(wxString::Format(wxT("%s - %s"),mFormatNames.Last().c_str(),wxString::FromUTF8(ofmt->long_name).c_str())); -@@ -1288,7 +1298,7 @@ +@@ -1288,7 +1278,7 @@ while ((codec = av_codec_next(codec))) { // We're only interested in audio and only in encoders @@ -2805,7 +2914,7 @@ { mCodecNames.Add(wxString::FromUTF8(codec->name)); mCodecLongNames.Add(wxString::Format(wxT("%s - %s"),mCodecNames.Last().c_str(),wxString::FromUTF8(codec->long_name).c_str())); -@@ -1299,157 +1309,156 @@ +@@ -1299,157 +1289,156 @@ mShownCodecLongNames = mCodecLongNames; } @@ -3108,7 +3217,7 @@ } S.EndMultiColumn(); S.EndVerticalLay(); -@@ -1506,7 +1515,7 @@ +@@ -1506,7 +1495,7 @@ /// /// @@ -3117,7 +3226,7 @@ { // By default assume that id is not in the list int index = -1; -@@ -1524,16 +1533,16 @@ +@@ -1524,16 +1513,16 @@ { // Format is found in the list found = 1; @@ -3137,7 +3246,7 @@ { // If it was selected - remember it's new index if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount(); -@@ -1548,7 +1557,7 @@ +@@ -1548,7 +1537,7 @@ AVCodec *codec = NULL; while ((codec = av_codec_next(codec))) { @@ -3146,7 +3255,7 @@ { if (mShownCodecNames.Index(wxString::FromUTF8(codec->name)) < 0) { -@@ -1568,7 +1577,7 @@ +@@ -1568,7 +1557,7 @@ if (format != NULL) { AVCodec *codec = avcodec_find_encoder(format->audio_codec); @@ -3155,7 +3264,7 @@ { if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount(); mShownCodecNames.Add(wxString::FromUTF8(codec->name)); -@@ -1584,7 +1593,7 @@ +@@ -1584,7 +1573,7 @@ /// /// @@ -3164,7 +3273,7 @@ { int index = -1; mShownFormatNames.Clear(); -@@ -1596,7 +1605,7 @@ +@@ -1596,7 +1585,7 @@ // Find all formats compatible to this codec in compatibility list for (int i = 0; CompatibilityList[i].fmt != NULL; i++) { @@ -3173,7 +3282,7 @@ { if ((selfmt != NULL) && (selfmt->Cmp(CompatibilityList[i].fmt) == 0)) index = mShownFormatNames.GetCount(); FromList.Add(CompatibilityList[i].fmt); -@@ -1778,7 +1787,7 @@ +@@ -1778,7 +1767,7 @@ { bool codec = false; bool format = false; @@ -3182,7 +3291,7 @@ else if (cdc != NULL && apptable[i].codec == cdc->id) codec = true; if (!wxString::FromUTF8(apptable[i].format).Cmp(wxT("any"))) format = true; else if (selfmt != NULL && selfmt->Cmp(wxString::FromUTF8(apptable[i].format)) == 0) format = true; -@@ -1824,7 +1833,7 @@ +@@ -1824,7 +1813,7 @@ selcdcid = cdc->id; } } @@ -3191,7 +3300,7 @@ if (newselcdc >= 0) mCodecList->Select(newselcdc); AVCodec *cdc = NULL; -@@ -1898,7 +1907,7 @@ +@@ -1898,7 +1887,7 @@ { int selcdc = mCodecList->GetSelection(); int selfmt = mFormatList->GetSelection(); @@ -3202,6 +3311,15 @@ ShuttleGui S(this, eIsSavingToPrefs); --- a/src/export/ExportFFmpegDialogs.h +++ b/src/export/ExportFFmpegDialogs.h +@@ -22,7 +22,7 @@ + + + /// Identifiers for pre-set export types. +-enum FFmpegExposedFormat ++enum FFmpegExposedFormat + { + FMT_M4A, + FMT_AC3, @@ -43,7 +43,7 @@ int canmetadata; //!< !=0 if format supports metadata, -1 any avformat version, otherwise version support added bool canutf8; //!< true if format supports metadata in UTF-8, false otherwise @@ -3229,6 +3347,24 @@ const char *format; //!< Format short name }; +@@ -237,7 +237,7 @@ + wxButton *mDeletePreset; + wxButton *mImportPresets; + wxButton *mExportPresets; +- ++ + int mBitRateFromChoice; + int mSampleRateFromChoice; + +@@ -247,7 +247,7 @@ + + /// Finds the format currently selected and returns it's name and description + void FindSelectedFormat(wxString **name, wxString **longname); +- ++ + /// Finds the codec currently selected and returns it's name and description + void FindSelectedCodec(wxString **name, wxString **longname); + @@ -258,7 +258,7 @@ ///\param id Codec ID ///\param selfmt format selected at the moment @@ -3247,6 +3383,15 @@ /// Retreives list of presets from configuration file void FetchPresetList(); +@@ -275,7 +275,7 @@ + // Enables/disables controls based on format/codec combination, + // leaving only relevant controls enabled. + // Hiding the controls may have been a better idea, +- // but it's hard to hide their text labels too ++ // but it's hard to hide their text labels too + void EnableDisableControls(AVCodec *cdc, wxString *selfmt); + DECLARE_EVENT_TABLE() + }; --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -37,7 +37,7 @@ diff -Nru audacity-2.0.5/debian/rules audacity-2.0.5/debian/rules --- audacity-2.0.5/debian/rules 2013-11-10 21:30:23.000000000 +0100 +++ audacity-2.0.5/debian/rules 2014-06-05 23:15:25.000000000 +0200 @@ -5,7 +5,7 @@ configure_flags := \ --disable-dynamic-loading \ --with-expat=system \ - --without-ffmpeg \ + --with-ffmpeg=system \ --with-lame=system \ --with-libflac=system \ --with-libid3tag=system \