From f37f4286700ab316526e609bb9890dc3d521b4c5 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Wed, 23 Jun 2010 12:16:17 +0300 Subject: [PATCH] Added preliminary support for LATM. --- HISTORY | 3 +- Makefile | 4 +- femonaudio.h | 3 +- femonlatm.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++ femonlatm.h | 27 ++++++++++++ femonreceiver.c | 9 ++-- femonreceiver.h | 2 + femontools.c | 1 + po/de_DE.po | 9 ++-- po/es_ES.po | 9 ++-- po/et_EE.po | 9 ++-- po/fi_FI.po | 9 ++-- po/fr_FR.po | 9 ++-- po/it_IT.po | 10 +++-- po/lt_LT.po | 9 ++-- po/ru_RU.po | 9 ++-- po/zh_CN.po | 9 ++-- po/zh_TW.po | 9 ++-- 18 files changed, 213 insertions(+), 39 deletions(-) create mode 100644 femonlatm.c create mode 100644 femonlatm.h diff --git a/HISTORY b/HISTORY index 7a45890..9877eb7 100644 --- a/HISTORY +++ b/HISTORY @@ -396,8 +396,9 @@ VDR Plugin 'femon' Revision History - Added a setup option to downscale the OSD size. - Updated Estonian translation (Thanks to Arthur Konovalov). -2010-xx-xx: Version 1.7.8 +2010-06-23: Version 1.7.8 - Fixed device switching. +- Added preliminary support for LATM. - Updated Italian translation (Thanks to Diego Pierotto). - Fixed a crash in femon service (Thanks to Wolfgang Astleitner). diff --git a/Makefile b/Makefile index 91f75b9..6c503c3 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ all-redirect: all ### The object files (add further files here): -OBJS = femon.o femonosd.o femonreceiver.o femoncfg.o femontools.o femonmpeg.o femonac3.o femonaac.o femonh264.o femonsymbol.o +OBJS = femon.o femonosd.o femonreceiver.o femoncfg.o femontools.o femonmpeg.o femonac3.o femonaac.o femonlatm.o femonh264.o femonsymbol.o ### The main target: @@ -95,7 +95,7 @@ I18Npot = $(PODIR)/$(PLUGIN).pot msgfmt -c -o $@ $< $(I18Npot): $(wildcard *.c) - xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='Rolf Ahrenberg' -o $@ $^ + xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --msgid-bugs-address='' -o $@ $^ %.po: $(I18Npot) msgmerge -U --no-wrap --no-location --backup=none -q $@ $< diff --git a/femonaudio.h b/femonaudio.h index 8e62297..1257df1 100644 --- a/femonaudio.h +++ b/femonaudio.h @@ -17,7 +17,8 @@ enum eAudioCodec { AUDIO_CODEC_MPEG2_I, AUDIO_CODEC_MPEG2_II, AUDIO_CODEC_MPEG2_III, - AUDIO_CODEC_HEAAC + AUDIO_CODEC_HEAAC, + AUDIO_CODEC_LATM }; enum eAudioChannelMode { diff --git a/femonlatm.c b/femonlatm.c new file mode 100644 index 0000000..3c89069 --- /dev/null +++ b/femonlatm.c @@ -0,0 +1,112 @@ +/* + * Frontend Status Monitor plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#include "femontools.h" +#include "femonlatm.h" + +unsigned int cFemonLATM::s_Bitrates[3][16] = +{ + {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1}, // MPEG-2 Layer I + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1}, // MPEG-2 Layer II/III + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1} // MPEG-2 Layer II/III +}; + +unsigned int cFemonLATM::s_Samplerates[4] = +{ + 22050, 24000, 16000, -1 +}; + +cFemonLATM::cFemonLATM(cFemonAudioIf *audiohandler) +: m_AudioHandler(audiohandler) +{ +} + +cFemonLATM::~cFemonLATM() +{ +} + +bool cFemonLATM::processAudio(const uint8_t *buf, int len) +{ + cBitStream bs(buf, len * 8); + + if (!m_AudioHandler) + return false; + + // skip PES header + if (!PesLongEnough(len)) + return false; + bs.skipBits(8 * PesPayloadOffset(buf)); + + // MPEG audio detection + if (bs.getBits(12) != 0x56E) // syncword + return false; + + if (bs.getBit() == 1) // id: MPEG-1=1, extension to lower sampling frequences=0 + return false; + int layer = 3 - bs.getBits(2); // layer: I=11, II=10, III=01 + bs.skipBit(); // protection bit + int bit_rate_index = bs.getBits(4); // bitrate index + int sampling_frequency = bs.getBits(2); // sampling frequency + bs.skipBit(); // padding bit + bs.skipBit(); // private pid + int mode = bs.getBits(2); // mode + + m_AudioHandler->SetAudioCodec(AUDIO_CODEC_LATM); + + switch (mode) { + case 0: + m_AudioHandler->SetAudioChannel(AUDIO_CHANNEL_MODE_STEREO); + break; + + case 1: + m_AudioHandler->SetAudioChannel(AUDIO_CHANNEL_MODE_JOINT_STEREO); + break; + + case 2: + m_AudioHandler->SetAudioChannel(AUDIO_CHANNEL_MODE_DUAL); + break; + + case 3: + m_AudioHandler->SetAudioChannel(AUDIO_CHANNEL_MODE_SINGLE); + break; + + default: + m_AudioHandler->SetAudioChannel(AUDIO_CHANNEL_MODE_INVALID); + break; + } + + if (layer == 3) { + m_AudioHandler->SetAudioBitrate(AUDIO_BITRATE_FREE); + } + else { + switch (bit_rate_index) { + case 0: + m_AudioHandler->SetAudioBitrate(AUDIO_BITRATE_FREE); + break; + + case 0xF: + m_AudioHandler->SetAudioBitrate(AUDIO_BITRATE_RESERVED); + break; + + default: + m_AudioHandler->SetAudioBitrate(1000 * s_Bitrates[layer][bit_rate_index]); + break; + } + } + + switch (sampling_frequency) { + case 3: + m_AudioHandler->SetAudioSamplingFrequency(AUDIO_SAMPLING_FREQUENCY_RESERVED); + break; + + default: + m_AudioHandler->SetAudioSamplingFrequency(s_Samplerates[sampling_frequency]); + break; + } + + return true; +} diff --git a/femonlatm.h b/femonlatm.h new file mode 100644 index 0000000..864d63e --- /dev/null +++ b/femonlatm.h @@ -0,0 +1,27 @@ +/* + * Frontend Status Monitor plugin for the Video Disk Recorder + * + * See the README file for copyright information and how to reach the author. + * + */ + +#ifndef __FEMONLATM_H +#define __FEMONLATM_H + +#include "femonaudio.h" + +class cFemonLATM { +private: + cFemonAudioIf *m_AudioHandler; + + static unsigned int s_Bitrates[3][16]; + static unsigned int s_Samplerates[4]; + +public: + cFemonLATM(cFemonAudioIf *audiohandler); + virtual ~cFemonLATM(); + + bool processAudio(const uint8_t *buf, int len); + }; + +#endif //__FEMONLATM_H diff --git a/femonreceiver.c b/femonreceiver.c index d53c0bc..233be06 100644 --- a/femonreceiver.c +++ b/femonreceiver.c @@ -18,6 +18,7 @@ cFemonReceiver::cFemonReceiver(int Vtype, int Vpid, int Apid, int Dpid) m_DetectH264(this), m_DetectMPEG(this, this), m_DetectAAC(this), + m_DetectLATM(this), m_DetectAC3(this), m_VideoBuffer(KILOBYTE(512), TS_SIZE, false, "Femon video"), m_VideoType(Vtype), @@ -144,7 +145,7 @@ void cFemonReceiver::Action(void) while (Data = m_VideoBuffer.Get(Length)) { if (!m_Active || (Length < TS_SIZE)) break; - Length = TS_SIZE; + Length = TS_SIZE; if (*Data != TS_SYNC_BYTE) { for (int i = 1; i < Length; ++i) { if (Data[i] == TS_SYNC_BYTE) { @@ -181,7 +182,7 @@ void cFemonReceiver::Action(void) while (Data = m_AudioBuffer.Get(Length)) { if (!m_Active || (Length < TS_SIZE)) break; - Length = TS_SIZE; + Length = TS_SIZE; if (*Data != TS_SYNC_BYTE) { for (int i = 1; i < Length; ++i) { if (Data[i] == TS_SYNC_BYTE) { @@ -194,7 +195,7 @@ void cFemonReceiver::Action(void) } processed = true; if (const uint8_t *p = m_AudioAssembler.GetPes(len)) { - if (m_DetectAAC.processAudio(p, len) || m_DetectMPEG.processAudio(p, len)) + if (m_DetectAAC.processAudio(p, len) || m_DetectLATM.processAudio(p, len) || m_DetectMPEG.processAudio(p, len)) m_AudioValid = true; m_AudioAssembler.Reset(); } @@ -206,7 +207,7 @@ void cFemonReceiver::Action(void) while (Data = m_AC3Buffer.Get(Length)) { if (!m_Active || (Length < TS_SIZE)) break; - Length = TS_SIZE; + Length = TS_SIZE; if (*Data != TS_SYNC_BYTE) { for (int i = 1; i < Length; ++i) { if (Data[i] == TS_SYNC_BYTE) { diff --git a/femonreceiver.h b/femonreceiver.h index 2749ac3..878a5d9 100644 --- a/femonreceiver.h +++ b/femonreceiver.h @@ -14,6 +14,7 @@ #include "femonh264.h" #include "femonmpeg.h" #include "femonaac.h" +#include "femonlatm.h" #include "femonac3.h" #include "femonaudio.h" #include "femonvideo.h" @@ -28,6 +29,7 @@ private: cFemonH264 m_DetectH264; cFemonMPEG m_DetectMPEG; cFemonAAC m_DetectAAC; + cFemonLATM m_DetectLATM; cFemonAC3 m_DetectAC3; cRingBufferLinear m_VideoBuffer; diff --git a/femontools.c b/femontools.c index 05f1f6e..a059d88 100644 --- a/femontools.c +++ b/femontools.c @@ -294,6 +294,7 @@ cString getAudioCodec(int value) case AUDIO_CODEC_MPEG2_II: return cString::sprintf("%s", tr("MPEG-2 Layer II")); case AUDIO_CODEC_MPEG2_III: return cString::sprintf("%s", tr("MPEG-2 Layer III")); case AUDIO_CODEC_HEAAC: return cString::sprintf("%s", tr("HE-AAC")); + case AUDIO_CODEC_LATM: return cString::sprintf("%s", tr("LATM")); default: break; } return cString::sprintf("---"); diff --git a/po/de_DE.po b/po/de_DE.po index 3c42042..481063d 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Christian Wieninger\n" "Language-Team: \n" @@ -266,6 +266,9 @@ msgstr "" msgid "HE-AAC" msgstr "" +msgid "LATM" +msgstr "" + msgid "stereo" msgstr "" diff --git a/po/es_ES.po b/po/es_ES.po index 3633386..4942e78 100644 --- a/po/es_ES.po +++ b/po/es_ES.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Luis Palacios\n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "" msgid "HE-AAC" msgstr "" +msgid "LATM" +msgstr "" + msgid "stereo" msgstr "" diff --git a/po/et_EE.po b/po/et_EE.po index e358c37..6cd081e 100644 --- a/po/et_EE.po +++ b/po/et_EE.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Arthur Konovalov\n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "MPEG-2 Layer III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "stereo" diff --git a/po/fi_FI.po b/po/fi_FI.po index 0ed8ff7..b8bba93 100644 --- a/po/fi_FI.po +++ b/po/fi_FI.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Rolf Ahrenberg\n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "MPEG-2 kerros III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "stereo" diff --git a/po/fr_FR.po b/po/fr_FR.po index 807c030..e47d12c 100644 --- a/po/fr_FR.po +++ b/po/fr_FR.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2008-01-26 09:59+0100\n" "Last-Translator: NIVAL Michal \n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "" msgid "HE-AAC" msgstr "" +msgid "LATM" +msgstr "" + msgid "stereo" msgstr "" diff --git a/po/it_IT.po b/po/it_IT.po index f817692..e08d6a1 100644 --- a/po/it_IT.po +++ b/po/it_IT.po @@ -6,9 +6,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2010-03-29 00:24+0100\n" "Last-Translator: Diego Pierotto \n" "Language-Team: \n" @@ -268,6 +268,9 @@ msgstr "MPEG-2 Layer III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "stereo" @@ -381,4 +384,3 @@ msgstr "Mbit/s" msgid "kbit/s" msgstr "kbit/s" - diff --git a/po/lt_LT.po b/po/lt_LT.po index 2628c6c..2a31898 100644 --- a/po/lt_LT.po +++ b/po/lt_LT.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Valdemaras Pipiras\n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "MPEG-2 Layer III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "stereo" diff --git a/po/ru_RU.po b/po/ru_RU.po index 4b04f24..ea0740e 100644 --- a/po/ru_RU.po +++ b/po/ru_RU.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2007-08-12 23:22+0300\n" "Last-Translator: Vyacheslav Dikonov\n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "" msgid "HE-AAC" msgstr "" +msgid "LATM" +msgstr "" + msgid "stereo" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 1a1437d..83cd43b 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2009-09-21 21:36+0800\n" "Last-Translator: NanFeng \n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "MPEG-2 Layer III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "立体声" diff --git a/po/zh_TW.po b/po/zh_TW.po index ae1a3ee..e4baa4d 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -5,9 +5,9 @@ # msgid "" msgstr "" -"Project-Id-Version: femon 1.7.7\n" -"Report-Msgid-Bugs-To: Rolf Ahrenberg\n" -"POT-Creation-Date: 2010-02-25 20:31+0200\n" +"Project-Id-Version: femon 1.7.8\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-06-23 12:14+0300\n" "PO-Revision-Date: 2009-09-21 21:36+0800\n" "Last-Translator: NanFeng \n" "Language-Team: \n" @@ -264,6 +264,9 @@ msgstr "MPEG-2 Layer III" msgid "HE-AAC" msgstr "HE-AAC" +msgid "LATM" +msgstr "LATM" + msgid "stereo" msgstr "立體聲"