From 1aeaeb05aadf196636ea5b6a0613c38111821436 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 15 Apr 2016 10:57:47 +0200 Subject: Make getSizeCu a dabSubchannel member function --- src/DabMultiplexer.cpp | 4 ++-- src/MuxElements.cpp | 35 ++++++++++++++++------------------- src/MuxElements.h | 4 ++-- src/fig/FIG0.cpp | 4 ++-- src/utils.cpp | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index d9ba496..3b28bd0 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -158,7 +158,7 @@ void DabMultiplexer::prepare() vector::iterator subchannel = ensemble->subchannels.end() - 1; - if ((*subchannel)->startAddress + getSizeCu((*subchannel)) > 864) { + if ((*subchannel)->startAddress + (*subchannel)->getSizeCu() > 864) { etiLog.log(error, "Total size in CU exceeds 864\n"); printSubchannels(ensemble->subchannels); throw MuxInitException(); @@ -314,7 +314,7 @@ void DabMultiplexer::prepare_data_inputs() (*subchannel)->startAddress = 0; } else { (*subchannel)->startAddress = (*(subchannel - 1))->startAddress + - getSizeCu(*(subchannel - 1)); + (*subchannel - 1)->getSizeCu(); } if ((*subchannel)->input->open((*subchannel)->inputUri) == -1) { perror((*subchannel)->inputUri.c_str()); diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp index a4102b8..9892acd 100644 --- a/src/MuxElements.cpp +++ b/src/MuxElements.cpp @@ -515,29 +515,26 @@ const string dabEnsemble::get_parameter(const string& parameter) const return ss.str(); } -unsigned short getSizeCu(dabSubchannel* subchannel) +unsigned short dabSubchannel::getSizeCu() const { - if (subchannel->protection.form == UEP) { - return Sub_Channel_SizeTable[subchannel-> - protection.uep.tableIndex]; - } - else if (subchannel->protection.form == EEP) { - dabProtectionEEP* protection = - &subchannel->protection.eep; - switch (protection->profile) { + if (protection.form == UEP) { + return Sub_Channel_SizeTable[protection.uep.tableIndex]; + } + else if (protection.form == EEP) { + switch (protection.eep.profile) { case EEP_A: - switch (subchannel->protection.level) { + switch (protection.level) { case 0: - return (subchannel->bitrate * 12) >> 3; + return (bitrate * 12) >> 3; break; case 1: - return subchannel->bitrate; + return bitrate; break; case 2: - return (subchannel->bitrate * 6) >> 3; + return (bitrate * 6) >> 3; break; case 3: - return (subchannel->bitrate >> 1); + return (bitrate >> 1); break; default: // Should not happens etiLog.log(error, "Bad protection level on " @@ -546,18 +543,18 @@ unsigned short getSizeCu(dabSubchannel* subchannel) } break; case EEP_B: - switch (subchannel->protection.level) { + switch (protection.level) { case 0: - return (subchannel->bitrate * 27) >> 5; + return (bitrate * 27) >> 5; break; case 1: - return (subchannel->bitrate * 21) >> 5; + return (bitrate * 21) >> 5; break; case 2: - return (subchannel->bitrate * 18) >> 5; + return (bitrate * 18) >> 5; break; case 3: - return (subchannel->bitrate * 15) >> 5; + return (bitrate * 15) >> 5; break; default: // Should not happens etiLog.log(error, diff --git a/src/MuxElements.h b/src/MuxElements.h index f8e60b1..d4a8ad3 100644 --- a/src/MuxElements.h +++ b/src/MuxElements.h @@ -256,6 +256,8 @@ public: { } + unsigned short getSizeCu(void) const; + std::string uid; std::string inputUri; @@ -410,8 +412,6 @@ std::vector >::iterator getService( DabComponent* component, std::vector >& services); -unsigned short getSizeCu(dabSubchannel* subchannel); - unsigned short getSizeDWord(dabSubchannel* subchannel); unsigned short getSizeByte(dabSubchannel* subchannel); diff --git a/src/fig/FIG0.cpp b/src/fig/FIG0.cpp index ca5a4a6..41cf9f2 100644 --- a/src/fig/FIG0.cpp +++ b/src/fig/FIG0.cpp @@ -208,9 +208,9 @@ FillStatus FIG0_1::fill(uint8_t *buf, size_t max_size) protection->level; fig0_1subchLong1->Sub_ChannelSize_high = - getSizeCu(*subchannelFIG0_1) / 256; + (*subchannelFIG0_1)->getSizeCu() / 256; fig0_1subchLong1->Sub_ChannelSize_low = - getSizeCu(*subchannelFIG0_1) % 256; + (*subchannelFIG0_1)->getSizeCu() % 256; buf += 4; remaining -= 4; diff --git a/src/utils.cpp b/src/utils.cpp index e87a698..6940a11 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -528,7 +528,7 @@ void printSubchannels(vector& subchannels) etiLog.log(info, " SAD: %u", (*subchannel)->startAddress); etiLog.log(info, " size (CU): %i", - getSizeCu(*subchannel)); + (*subchannel)->getSizeCu()); ++index; } } -- cgit v1.2.3