mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-15 09:09:36 +02:00
Fix compile bugs, and avoid defining "LC" (from neaacdec.h) since that clashes with a Rivendell internal symbol.
This commit is contained in:
parent
f63b14cca9
commit
988e9a73fe
@ -691,22 +691,31 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
#ifdef HAVE_MP4_LIBS
|
||||
SNDFILE *sf_dst=NULL;
|
||||
SF_INFO sf_dst_info;
|
||||
int ret = RDAudioConvert::ErrorOk;
|
||||
MP4FileHandle f;
|
||||
MP4TrackId audioTrack;
|
||||
MP4SampleId firstSample, lastSample;
|
||||
uint32_t aacBufSize, aacConfigSize;
|
||||
uint8_t *aacBuf, *aacConfigBuffer;
|
||||
NeAACDecHandle hDecoder;
|
||||
NeAACDecConfigurationPtr config;
|
||||
unsigned long foundSampleRate;
|
||||
unsigned char foundChannels;
|
||||
RDAudioConvert::ErrorCode ret = RDAudioConvert::ErrorOk;
|
||||
|
||||
if(!LoadMP4Libs()) {
|
||||
if(!dlmp4.load()) {
|
||||
return RDAudioConvert::ErrorFormatNotSupported;
|
||||
}
|
||||
|
||||
//
|
||||
// Open source
|
||||
//
|
||||
MP4FileHandle f = dlmp4.MP4Read(getName());
|
||||
f = dlmp4.MP4Read(wave->getName());
|
||||
if(f == MP4_INVALID_FILE_HANDLE)
|
||||
return RDAudioConvert::ErrorNoSource;
|
||||
|
||||
MP4TrackId audioTrack = dlmp4.getMP4AACTrack(f);
|
||||
MP4SampleId firstSample = 0;
|
||||
MP4SampleId lastSample = dlmp4.MP4GetTrackNumberOfSamples(f, audioTrack) - 1;
|
||||
audioTrack = dlmp4.getMP4AACTrack(f);
|
||||
firstSample = 0;
|
||||
lastSample = dlmp4.MP4GetTrackNumberOfSamples(f, audioTrack) - 1;
|
||||
if(conv_start_point > 0) {
|
||||
|
||||
double startsecs = ((double)conv_start_point) / 1000;
|
||||
@ -731,17 +740,14 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
|
||||
}
|
||||
|
||||
uint32_t aacBufSize = dlmp4.MP4GetTrackMaxSampleSize(f, audioTrack);
|
||||
uint8_t* aacBuf = malloc(aacBufSize);
|
||||
aacBufSize = dlmp4.MP4GetTrackMaxSampleSize(f, audioTrack);
|
||||
aacBuf = (uint8_t*)malloc(aacBufSize);
|
||||
if(!aacBufSize || !aacBuf) {
|
||||
// Probably the source's fault for specifying a massive buffer.
|
||||
ret = RDAudioConvert::ErrorInvalidSource;
|
||||
goto out_mp4;
|
||||
}
|
||||
|
||||
uint8_t* aacConfigBuffer;
|
||||
uint32_t* aacConfigSize;
|
||||
|
||||
dlmp4.MP4GetTrackESConfiguration(f, audioTrack, &aacConfigBuffer, &aacConfigSize);
|
||||
if(!aacConfigBuffer) {
|
||||
ret = RDAudioConvert::ErrorInvalidSource;
|
||||
@ -765,9 +771,9 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
//
|
||||
// Initialize Decoder
|
||||
//
|
||||
NeAACDecHandle hDecoder = dlmp4.NeAACDecOpen();
|
||||
hDecoder = dlmp4.NeAACDecOpen();
|
||||
|
||||
NeAACDecConfigurationPtr config = dlmp4.NeAACDecGetCurrentConfiguration(hDecoder);
|
||||
config = dlmp4.NeAACDecGetCurrentConfiguration(hDecoder);
|
||||
config->outputFormat = FAAD_FMT_FLOAT;
|
||||
config->downMatrix = 1; // Downmix >2 channels to stereo.
|
||||
if(!dlmp4.NeAACDecSetConfiguration(hDecoder, config)) {
|
||||
@ -775,15 +781,13 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
goto out_decoder;
|
||||
}
|
||||
|
||||
unsigned long foundSampleRate;
|
||||
unsigned char foundChannels;
|
||||
if(dlmp4.NeAACDecInit2(hDecoder, aacConfigBuffer, aacConfigSize, &foundSampleRate, &foundChannels) < 0) {
|
||||
ret = RDAudioConvert::ErrorInvalidSource;
|
||||
goto out_decoder;
|
||||
}
|
||||
|
||||
if(foundSampleRate != wave->getSamplesPerSec() || foundChannels != wave->getChannels()) {
|
||||
fprintf(stderr, "M4A header information inconsistent with actual file? Header: %lu/%u; file: %lu/%u\n",
|
||||
fprintf(stderr, "M4A header information inconsistent with actual file? Header: %u/%u; file: %lu/%u\n",
|
||||
wave->getSamplesPerSec(), (unsigned)wave->getChannels(), foundSampleRate, (unsigned)foundChannels);
|
||||
ret = RDAudioConvert::ErrorInvalidSource;
|
||||
goto out_decoder;
|
||||
@ -809,9 +813,9 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
break;
|
||||
}
|
||||
|
||||
UpdatePeak(sample_buffer, frameInfo.samples);
|
||||
UpdatePeak((const float*)sample_buffer, frameInfo.samples);
|
||||
|
||||
if(sf_write_float(dst_sf, sample_buffer, frameInfo.samples) != frameInfo.samples) {
|
||||
if(sf_write_float(sf_dst, (const float*)sample_buffer, frameInfo.samples) != (sf_count_t)frameInfo.samples) {
|
||||
ret = RDAudioConvert::ErrorInternal;
|
||||
break;
|
||||
}
|
||||
@ -824,7 +828,7 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
||||
|
||||
out_decoder:
|
||||
dlmp4.NeAACDecClose(hDecoder);
|
||||
out_sf:
|
||||
// out_sf:
|
||||
sf_close(sf_dst);
|
||||
out_mp4_configbuf:
|
||||
free(aacConfigBuffer);
|
||||
|
@ -33,6 +33,9 @@
|
||||
#ifdef HAVE_MAD
|
||||
#include <mad.h>
|
||||
#endif // HAVE_MAD
|
||||
|
||||
#include <rdmp4.h>
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdwavedata.h>
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <rdmp4.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
MP4TrackId DLMP4::getMP4AACTrack(MP4FileHandle f)
|
||||
{
|
||||
@ -98,6 +99,7 @@ bool DLMP4::load()
|
||||
check_dlsym(this->NeAACDecClose, neaac_handle, "NeAACDecClose");
|
||||
|
||||
loadSuccess = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,15 @@
|
||||
|
||||
#include <mp4v2/mp4v2.h>
|
||||
#include <neaacdec.h>
|
||||
// neaacdec.h defines "LC", as in "low-complexity AAC", which clashes with a Rivendell Command.
|
||||
#undef LC
|
||||
|
||||
struct DLMP4 {
|
||||
|
||||
DLMP4() : loadSuccess(false) {}
|
||||
|
||||
void *conv_neaac_handle;
|
||||
void *conv_mp4_handle;
|
||||
void *neaac_handle;
|
||||
void *mp4_handle;
|
||||
bool loadSuccess;
|
||||
|
||||
// MP4v2 Functions
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <id3/tag.h>
|
||||
#include <id3/misc_support.h>
|
||||
@ -3861,7 +3862,7 @@ bool RDWaveFile::GetFlacStreamInfo()
|
||||
|
||||
void RDWaveFile::ReadFlacMetadata()
|
||||
{
|
||||
#ifdef HAVE_FLAC_METADATA
|
||||
#ifdef HAVE_FLAC
|
||||
QString artist;
|
||||
QString composer;
|
||||
FLAC__StreamMetadata* tags;
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <vorbis/vorbisenc.h>
|
||||
#endif // HAVE_VORBIS
|
||||
|
||||
#include <rdmp4.h>
|
||||
|
||||
#include <rdwavedata.h>
|
||||
#include <rdringbuffer.h>
|
||||
#include <rdsettings.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user