1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-05 22:59:29 +02:00

restore build for EXPERIMENTAL_OD_FFMPEG

EXPERIMENTAL_OD_FFMPEG is still commented out
This commit is contained in:
mchinen 2012-06-01 06:11:01 +00:00
parent 3da8cabc4d
commit 8cb2a38fbe
2 changed files with 47 additions and 20 deletions

View File

@ -80,6 +80,8 @@ extern "C" {
#include "../Prefs.h"
#include <wx/checkbox.h>
#include <wx/textctrl.h>
// needed for sampleCount
#include "Sequence.h"
#include "Experimental.h"
@ -345,10 +347,17 @@ typedef struct _streamContext
int64_t m_ptsOffset; // packets associated with stream are relative to this
int m_frameValid; // is m_decodedVideoFrame/m_decodedAudioSamples valid?
int16_t *m_decodedAudioSamples; // decoded audio samples stored here
uint8_t *m_decodedAudioSamples; // decoded audio samples stored here
unsigned int m_decodedAudioSamplesSiz; // current size of m_decodedAudioSamples
int m_decodedAudioSamplesValidSiz; // # valid bytes in m_decodedAudioSamples
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
SampleFormat m_samplefmt; // input sample format
int m_osamplesize; // output sample size in bytes
sampleFormat m_osamplefmt; // output sample format
} streamContext;
#endif

View File

@ -11,7 +11,6 @@
// For compilers that support precompilation, includes "wx/wx.h".
#ifdef EXPERIMENTAL_OD_FFMPEG
#include "../Audacity.h" // needed before FFmpeg.h
#include "../FFmpeg.h" // which brings in avcodec.h, avformat.h
#ifndef WX_PRECOMP
@ -561,7 +560,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing)
//\warning { for some reason using the following macro call right in the function call
// causes Audacity to crash in some unknown place. With "newsize" it works fine }
int newsize = FFMAX(sc->m_pkt.size*sizeof(*sc->m_decodedAudioSamples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
sc->m_decodedAudioSamples = (int16_t*)av_fast_realloc(sc->m_decodedAudioSamples,
sc->m_decodedAudioSamples = (uint8_t*)av_fast_realloc(sc->m_decodedAudioSamples,
&sc->m_decodedAudioSamplesSiz,
newsize
);
@ -576,10 +575,29 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing)
// avcodec_decode_audio2() expects the size of the output buffer as the 3rd parameter but
// also returns the number of bytes it decoded in the same parameter.
sc->m_decodedAudioSamplesValidSiz = sc->m_decodedAudioSamplesSiz;
nBytesDecoded = avcodec_decode_audio2(sc->m_codecCtx,
sc->m_decodedAudioSamples, // out
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 25, 0)
// avcodec_decode_audio3() expects the size of the output buffer as the 3rd parameter but
// also returns the number of bytes it decoded in the same parameter.
AVPacket avpkt;
av_init_packet(&avpkt);
avpkt.data = pDecode;
avpkt.size = nDecodeSiz;
nBytesDecoded =
avcodec_decode_audio3(sc->m_codecCtx,
(int16_t *)sc->m_decodedAudioSamples, // out
&sc->m_decodedAudioSamplesValidSiz, // in/out
pDecode, nDecodeSiz); // in
&avpkt); // in
#else
// avcodec_decode_audio2() expects the size of the output buffer as the 3rd parameter but
// also returns the number of bytes it decoded in the same parameter.
nBytesDecoded =
avcodec_decode_audio2(sc->m_codecCtx,
(int16_t *) sc->m_decodedAudioSamples, // out
&sc->m_decodedAudioSamplesValidSiz, // in/out
pDecode, // in
nDecodeSiz); // in
#endif
if (nBytesDecoded < 0)
{
@ -606,7 +624,7 @@ int ODFFmpegDecoder::DecodeFrame(streamContext *sc, bool flushing)
FFMpegDecodeCache* cache = new FFMpegDecodeCache;
//len is number of samples per channel
cache->numChannels = sc->m_stream->codec->channels;
// Here we convert to 16 bit stero frame length
cache->len = (sc->m_decodedAudioSamplesValidSiz/sizeof(int16_t) ) / cache->numChannels;
cache->start=mCurrentPos;
cache->samplePtr = (int16_t*) malloc(sc->m_decodedAudioSamplesValidSiz);