From 7588507ba166c2a572b60fb7245722fee65a6405 Mon Sep 17 00:00:00 2001 From: Colin Guthrie <cguthrie@mandriva.org> Date: Thu, 3 Mar 2011 16:21:26 +0000 Subject: [PATCH 100/102] lame: Allow building without lame libraries. --- mythtv/configure | 8 +++---- mythtv/libs/libmythtv/NuppelVideoRecorder.cpp | 32 ++++++++++++++++++++++--- mythtv/libs/libmythtv/NuppelVideoRecorder.h | 5 ++++ mythtv/libs/libmythtv/libmythtv.pro | 7 +++++- mythtv/libs/libmythtv/recordingprofile.cpp | 16 ++++++++++++- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git mythtv/configure mythtv/configure index 5e9c8a8..4e252b2 100755 --- mythtv/configure +++ mythtv/configure @@ -2003,7 +2003,7 @@ enable hdpvr enable iptv enable ivtv enable asi -enable lamemp3 +disable libmp3lame enable libass enable libcec enable libcrypto @@ -4062,10 +4062,6 @@ enabled asi && check_cc <<EOF || disable asi int main(void) { return 1; } EOF -# Check that all MythTV build "requirements" are met: -enabled lamemp3 && check_lib2 lame/lame.h lame_init -lmp3lame -lm || - die "ERROR! You must have the Lame MP3 encoding library installed to compile MythTV." - # Qt dependency checks if test $target_os = mingw32 ; then qt_inc="-I`cd $(${qmake} -query QT_INSTALL_HEADERS); pwd`" @@ -4751,6 +4747,8 @@ enabled audio_oss && append CCONFIG "using_oss" enabled audio_pulse && append CCONFIG "using_pulse" enabled audio_pulseoutput && append CCONFIG "using_pulseoutput" +enabled libmp3lame && append CCONFIG "using_lame" + if enabled darwin_da; then append CCONFIG "darwin_da" echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> $TMPMAK diff --git mythtv/libs/libmythtv/NuppelVideoRecorder.cpp mythtv/libs/libmythtv/NuppelVideoRecorder.cpp index 8d26b8b..690f3ed 100644 --- mythtv/libs/libmythtv/NuppelVideoRecorder.cpp +++ mythtv/libs/libmythtv/NuppelVideoRecorder.cpp @@ -94,7 +94,11 @@ NuppelVideoRecorder::NuppelVideoRecorder(TVRec *rec, ChannelBase *channel) : pid = pid2 = 0; inputchannel = 1; compression = 1; +#ifdef LAME compressaudio = 1; +#else + compressaudio = 0; +#endif usebttv = 1; width = 352; height = 240; @@ -106,11 +110,13 @@ NuppelVideoRecorder::NuppelVideoRecorder(TVRec *rec, ChannelBase *channel) : framerate_multiplier = 1.0; height_multiplier = 1.0; +#ifdef LAME mp3quality = 3; gf = NULL; + mp3buf = NULL; +#endif rtjc = NULL; strm = NULL; - mp3buf = NULL; transcoding = false; @@ -204,10 +210,12 @@ NuppelVideoRecorder::~NuppelVideoRecorder(void) } if (rtjc) delete rtjc; +#ifdef LAME if (mp3buf) delete [] mp3buf; if (gf) lame_close(gf); +#endif if (strm) delete [] strm; if (audio_device) @@ -328,8 +336,10 @@ void NuppelVideoRecorder::SetOption(const QString &opt, int value) hmjpg_vdecimation = value; else if (opt == "audiocompression") compressaudio = value; +#ifdef LAME else if (opt == "mp3quality") mp3quality = value; +#endif else if (opt == "samplerate") audio_samplerate = value; else if (opt == "audioframesize") @@ -429,13 +439,16 @@ void NuppelVideoRecorder::SetOptionsFromProfile(RecordingProfile *profile, if ((tmp = profile->byName("audiocodec"))) setting = tmp->getValue(); +#ifdef LAME if (setting == "MP3") { SetOption("audiocompression", 1); SetIntOption(profile, "mp3quality"); SetIntOption(profile, "samplerate"); } - else if (setting == "Uncompressed") + else +#endif + if (setting == "Uncompressed") { SetOption("audiocompression", 0); SetIntOption(profile, "samplerate"); @@ -754,7 +767,6 @@ void NuppelVideoRecorder::Initialize(void) int NuppelVideoRecorder::AudioInit(bool skipdevice) { int blocksize; - int tmp; if (!skipdevice) { @@ -792,6 +804,8 @@ int NuppelVideoRecorder::AudioInit(bool skipdevice) if (compressaudio) { +#ifdef LAME + int tmp; gf = lame_init(); lame_set_bWriteVbrTag(gf, 0); lame_set_quality(gf, mp3quality); @@ -812,9 +826,17 @@ int NuppelVideoRecorder::AudioInit(bool skipdevice) "AudioInit(): lame support requires 16bit audio"); compressaudio = false; } +#else + LOG(VB_GENERAL, LOG_ERR, LOC + + "AudioInit(): support for LAME MP3 compression not enabled, disabling"); + compressaudio = false; +#endif } + +#ifdef LAME mp3buf_size = (int)(1.25 * 16384 + 7200); mp3buf = new char[mp3buf_size]; +#endif return 0; } @@ -2158,6 +2180,7 @@ void NuppelVideoRecorder::WriteHeader(void) moredata.rtjpeg_chroma_filter = M2; } +#ifdef LAME if (compressaudio) { moredata.audio_fourcc = FOURCC_LAME; @@ -2165,6 +2188,7 @@ void NuppelVideoRecorder::WriteHeader(void) moredata.audio_quality = mp3quality; } else +#endif { moredata.audio_fourcc = FOURCC_RAWA; } @@ -3142,6 +3166,7 @@ void NuppelVideoRecorder::WriteAudio(unsigned char *buf, int fnum, int timecode) } } +#ifdef LAME if (compressaudio) { char mp3gapless[7200]; @@ -3202,6 +3227,7 @@ void NuppelVideoRecorder::WriteAudio(unsigned char *buf, int fnum, int timecode) audiobytes += audio_buffer_size; } else +#endif { frameheader.comptype = '0'; // uncompressed audio frameheader.packetlength = audio_buffer_size; diff --git mythtv/libs/libmythtv/NuppelVideoRecorder.h mythtv/libs/libmythtv/NuppelVideoRecorder.h index 67b7d67..55d0a20 100644 --- mythtv/libs/libmythtv/NuppelVideoRecorder.h +++ mythtv/libs/libmythtv/NuppelVideoRecorder.h @@ -6,6 +6,8 @@ #include <sys/time.h> #include <time.h> + +#ifdef LAME #ifdef MMX #undef MMX #define MMXBLAH @@ -14,6 +16,7 @@ #ifdef MMXBLAH #define MMX #endif +#endif #undef HAVE_AV_CONFIG_H extern "C" { @@ -181,10 +184,12 @@ class MTV_PUBLIC NuppelVideoRecorder : public V4LRecorder, public CC608Input bool transcoding; +#ifdef LAME int mp3quality; char *mp3buf; int mp3buf_size; lame_global_flags *gf; +#endif RTjpeg *rtjc; diff --git mythtv/libs/libmythtv/libmythtv.pro mythtv/libs/libmythtv/libmythtv.pro index f50d2cb..66a91aa 100644 --- mythtv/libs/libmythtv/libmythtv.pro +++ mythtv/libs/libmythtv/libmythtv.pro @@ -64,7 +64,6 @@ LIBS += -lmythservicecontracts-$$LIBVERSION using_mheg: LIBS += -L../libmythfreemheg -lmythfreemheg-$$LIBVERSION using_live: LIBS += -L../libmythlivemedia -lmythlivemedia-$$LIBVERSION using_hdhomerun: LIBS += -L../libmythhdhomerun -lmythhdhomerun-$$LIBVERSION -using_backend: LIBS += -lmp3lame LIBS += $$EXTRA_LIBS $$QMAKE_LIBS_DYNLOAD POST_TARGETDEPS += ../libmyth/libmyth-$${MYTH_SHLIB_EXT} @@ -672,6 +671,12 @@ using_backend { DEFINES += USING_ASI } + # LAME MP3 Compression enabled + using_lame { + DEFINES += LAME + LIBS += -lmp3lame + } + DEFINES += USING_BACKEND } diff --git mythtv/libs/libmythtv/recordingprofile.cpp mythtv/libs/libmythtv/recordingprofile.cpp index d88cb36..362ecae 100644 --- mythtv/libs/libmythtv/recordingprofile.cpp +++ mythtv/libs/libmythtv/recordingprofile.cpp @@ -79,6 +79,7 @@ class AudioCodecName: public ComboBoxSetting, public RecordingProfileStorage } }; +#ifdef LAME class MP3Quality : public SliderSetting, public CodecParamStorage { public: @@ -93,6 +94,7 @@ class MP3Quality : public SliderSetting, public CodecParamStorage "numbers) requires more CPU.")); }; }; +#endif class BTTVVolume : public SliderSetting, public CodecParamStorage { @@ -402,12 +404,16 @@ class AudioCompressionSettings : public TriggeredConfigurationGroup addChild(codecName); setTrigger(codecName); - ConfigurationGroup* params = new VerticalConfigurationGroup(false); + ConfigurationGroup* params; + +#ifdef LAME + params = new VerticalConfigurationGroup(false); params->setLabel("MP3"); params->addChild(new SampleRate(parent)); params->addChild(new MP3Quality(parent)); params->addChild(new BTTVVolume(parent)); addTarget("MP3", params); +#endif params = new VerticalConfigurationGroup(false, false, true, true); params->setLabel("MPEG-2 Hardware Encoder"); @@ -448,13 +454,17 @@ class AudioCompressionSettings : public TriggeredConfigurationGroup else { // V4L, TRANSCODE (and any undefined types) +#ifdef LAME codecName->addSelection("MP3"); +#endif codecName->addSelection("Uncompressed"); } } else { +#ifdef LAME codecName->addSelection("MP3"); +#endif codecName->addSelection("Uncompressed"); codecName->addSelection("MPEG-2 Hardware Encoder"); } @@ -1489,7 +1499,11 @@ void RecordingProfileEditor::open(int id) "(:NAME, :VIDEOCODEC, :AUDIOCODEC, :PROFILEGROUP);"); query.bindValue(":NAME", profName); query.bindValue(":VIDEOCODEC", "MPEG-4"); +#ifdef LAME query.bindValue(":AUDIOCODEC", "MP3"); +#else + query.bindValue(":AUDIOCODEC", "Uncompressed"); +#endif query.bindValue(":PROFILEGROUP", group); if (!query.exec()) { -- 1.7.10