1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +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"
@ -333,22 +335,29 @@ int ufile_fopen_input(AVFormatContext **ic_ptr, wxString & name);
typedef struct _streamContext
{
bool m_use; // TRUE = this stream will be loaded into Audacity
AVStream *m_stream; // an AVStream *
AVCodecContext *m_codecCtx; // pointer to m_stream->codec
AVStream *m_stream; // an AVStream *
AVCodecContext *m_codecCtx; // pointer to m_stream->codec
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;
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;
int64_t m_pts; // the current presentation time of the input stream
int64_t m_ptsOffset; // packets associated with stream are relative to this
int64_t m_pts; // the current presentation time of the input stream
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
unsigned int m_decodedAudioSamplesSiz; // current size of m_decodedAudioSamples
int m_decodedAudioSamplesValidSiz; // # valid bytes in m_decodedAudioSamples
int m_frameValid; // is m_decodedVideoFrame/m_decodedAudioSamples valid?
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
&sc->m_decodedAudioSamplesValidSiz, // in/out
pDecode, nDecodeSiz); // in
#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
&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,8 +624,8 @@ 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;
cache->len = (sc->m_decodedAudioSamplesValidSiz/sizeof(int16_t) )/cache->numChannels;
// 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);
memcpy(cache->samplePtr,sc->m_decodedAudioSamples,sc->m_decodedAudioSamplesValidSiz);