mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-12 23:19:16 +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
|
#ifdef HAVE_MP4_LIBS
|
||||||
SNDFILE *sf_dst=NULL;
|
SNDFILE *sf_dst=NULL;
|
||||||
SF_INFO sf_dst_info;
|
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;
|
return RDAudioConvert::ErrorFormatNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open source
|
// Open source
|
||||||
//
|
//
|
||||||
MP4FileHandle f = dlmp4.MP4Read(getName());
|
f = dlmp4.MP4Read(wave->getName());
|
||||||
if(f == MP4_INVALID_FILE_HANDLE)
|
if(f == MP4_INVALID_FILE_HANDLE)
|
||||||
return RDAudioConvert::ErrorNoSource;
|
return RDAudioConvert::ErrorNoSource;
|
||||||
|
|
||||||
MP4TrackId audioTrack = dlmp4.getMP4AACTrack(f);
|
audioTrack = dlmp4.getMP4AACTrack(f);
|
||||||
MP4SampleId firstSample = 0;
|
firstSample = 0;
|
||||||
MP4SampleId lastSample = dlmp4.MP4GetTrackNumberOfSamples(f, audioTrack) - 1;
|
lastSample = dlmp4.MP4GetTrackNumberOfSamples(f, audioTrack) - 1;
|
||||||
if(conv_start_point > 0) {
|
if(conv_start_point > 0) {
|
||||||
|
|
||||||
double startsecs = ((double)conv_start_point) / 1000;
|
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);
|
aacBufSize = dlmp4.MP4GetTrackMaxSampleSize(f, audioTrack);
|
||||||
uint8_t* aacBuf = malloc(aacBufSize);
|
aacBuf = (uint8_t*)malloc(aacBufSize);
|
||||||
if(!aacBufSize || !aacBuf) {
|
if(!aacBufSize || !aacBuf) {
|
||||||
// Probably the source's fault for specifying a massive buffer.
|
// Probably the source's fault for specifying a massive buffer.
|
||||||
ret = RDAudioConvert::ErrorInvalidSource;
|
ret = RDAudioConvert::ErrorInvalidSource;
|
||||||
goto out_mp4;
|
goto out_mp4;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* aacConfigBuffer;
|
|
||||||
uint32_t* aacConfigSize;
|
|
||||||
|
|
||||||
dlmp4.MP4GetTrackESConfiguration(f, audioTrack, &aacConfigBuffer, &aacConfigSize);
|
dlmp4.MP4GetTrackESConfiguration(f, audioTrack, &aacConfigBuffer, &aacConfigSize);
|
||||||
if(!aacConfigBuffer) {
|
if(!aacConfigBuffer) {
|
||||||
ret = RDAudioConvert::ErrorInvalidSource;
|
ret = RDAudioConvert::ErrorInvalidSource;
|
||||||
@ -765,9 +771,9 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
|||||||
//
|
//
|
||||||
// Initialize Decoder
|
// Initialize Decoder
|
||||||
//
|
//
|
||||||
NeAACDecHandle hDecoder = dlmp4.NeAACDecOpen();
|
hDecoder = dlmp4.NeAACDecOpen();
|
||||||
|
|
||||||
NeAACDecConfigurationPtr config = dlmp4.NeAACDecGetCurrentConfiguration(hDecoder);
|
config = dlmp4.NeAACDecGetCurrentConfiguration(hDecoder);
|
||||||
config->outputFormat = FAAD_FMT_FLOAT;
|
config->outputFormat = FAAD_FMT_FLOAT;
|
||||||
config->downMatrix = 1; // Downmix >2 channels to stereo.
|
config->downMatrix = 1; // Downmix >2 channels to stereo.
|
||||||
if(!dlmp4.NeAACDecSetConfiguration(hDecoder, config)) {
|
if(!dlmp4.NeAACDecSetConfiguration(hDecoder, config)) {
|
||||||
@ -775,15 +781,13 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
|||||||
goto out_decoder;
|
goto out_decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long foundSampleRate;
|
|
||||||
unsigned char foundChannels;
|
|
||||||
if(dlmp4.NeAACDecInit2(hDecoder, aacConfigBuffer, aacConfigSize, &foundSampleRate, &foundChannels) < 0) {
|
if(dlmp4.NeAACDecInit2(hDecoder, aacConfigBuffer, aacConfigSize, &foundSampleRate, &foundChannels) < 0) {
|
||||||
ret = RDAudioConvert::ErrorInvalidSource;
|
ret = RDAudioConvert::ErrorInvalidSource;
|
||||||
goto out_decoder;
|
goto out_decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(foundSampleRate != wave->getSamplesPerSec() || foundChannels != wave->getChannels()) {
|
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);
|
wave->getSamplesPerSec(), (unsigned)wave->getChannels(), foundSampleRate, (unsigned)foundChannels);
|
||||||
ret = RDAudioConvert::ErrorInvalidSource;
|
ret = RDAudioConvert::ErrorInvalidSource;
|
||||||
goto out_decoder;
|
goto out_decoder;
|
||||||
@ -809,9 +813,9 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
|||||||
break;
|
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;
|
ret = RDAudioConvert::ErrorInternal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -824,7 +828,7 @@ RDAudioConvert::ErrorCode RDAudioConvert::Stage1M4A(const QString &dstfile,
|
|||||||
|
|
||||||
out_decoder:
|
out_decoder:
|
||||||
dlmp4.NeAACDecClose(hDecoder);
|
dlmp4.NeAACDecClose(hDecoder);
|
||||||
out_sf:
|
// out_sf:
|
||||||
sf_close(sf_dst);
|
sf_close(sf_dst);
|
||||||
out_mp4_configbuf:
|
out_mp4_configbuf:
|
||||||
free(aacConfigBuffer);
|
free(aacConfigBuffer);
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
#ifdef HAVE_MAD
|
#ifdef HAVE_MAD
|
||||||
#include <mad.h>
|
#include <mad.h>
|
||||||
#endif // HAVE_MAD
|
#endif // HAVE_MAD
|
||||||
|
|
||||||
|
#include <rdmp4.h>
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
|
||||||
#include <rdwavedata.h>
|
#include <rdwavedata.h>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <rdmp4.h>
|
#include <rdmp4.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
MP4TrackId DLMP4::getMP4AACTrack(MP4FileHandle f)
|
MP4TrackId DLMP4::getMP4AACTrack(MP4FileHandle f)
|
||||||
{
|
{
|
||||||
@ -98,6 +99,7 @@ bool DLMP4::load()
|
|||||||
check_dlsym(this->NeAACDecClose, neaac_handle, "NeAACDecClose");
|
check_dlsym(this->NeAACDecClose, neaac_handle, "NeAACDecClose");
|
||||||
|
|
||||||
loadSuccess = true;
|
loadSuccess = true;
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,15 @@
|
|||||||
|
|
||||||
#include <mp4v2/mp4v2.h>
|
#include <mp4v2/mp4v2.h>
|
||||||
#include <neaacdec.h>
|
#include <neaacdec.h>
|
||||||
|
// neaacdec.h defines "LC", as in "low-complexity AAC", which clashes with a Rivendell Command.
|
||||||
|
#undef LC
|
||||||
|
|
||||||
struct DLMP4 {
|
struct DLMP4 {
|
||||||
|
|
||||||
DLMP4() : loadSuccess(false) {}
|
DLMP4() : loadSuccess(false) {}
|
||||||
|
|
||||||
void *conv_neaac_handle;
|
void *neaac_handle;
|
||||||
void *conv_mp4_handle;
|
void *mp4_handle;
|
||||||
bool loadSuccess;
|
bool loadSuccess;
|
||||||
|
|
||||||
// MP4v2 Functions
|
// MP4v2 Functions
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <id3/tag.h>
|
#include <id3/tag.h>
|
||||||
#include <id3/misc_support.h>
|
#include <id3/misc_support.h>
|
||||||
@ -3861,7 +3862,7 @@ bool RDWaveFile::GetFlacStreamInfo()
|
|||||||
|
|
||||||
void RDWaveFile::ReadFlacMetadata()
|
void RDWaveFile::ReadFlacMetadata()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_FLAC_METADATA
|
#ifdef HAVE_FLAC
|
||||||
QString artist;
|
QString artist;
|
||||||
QString composer;
|
QString composer;
|
||||||
FLAC__StreamMetadata* tags;
|
FLAC__StreamMetadata* tags;
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include <vorbis/vorbisenc.h>
|
#include <vorbis/vorbisenc.h>
|
||||||
#endif // HAVE_VORBIS
|
#endif // HAVE_VORBIS
|
||||||
|
|
||||||
|
#include <rdmp4.h>
|
||||||
|
|
||||||
#include <rdwavedata.h>
|
#include <rdwavedata.h>
|
||||||
#include <rdringbuffer.h>
|
#include <rdringbuffer.h>
|
||||||
#include <rdsettings.h>
|
#include <rdsettings.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user