Commit a499a6a0 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Make long block sync search work again.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 161617c1
......@@ -217,8 +217,11 @@ private:
// "long" blocks consist of two "normal" blocks, which means
// the sync bits pattern is repeated after the end of the first block
const int first_block_end = mark_sync_frame_count() + mark_data_frame_count();
UpDownGen up_down_gen (Random::Stream::sync_up_down);
const int block_count = block_length == BlockLength::LONG ? 2 : 1;
size_t n_bands = Params::max_band - Params::min_band + 1;
for (int block = 0; block < block_count; block++)
{
UpDownGen up_down_gen (Random::Stream::sync_up_down);
for (int bit = 0; bit < Params::sync_bits; bit++)
{
vector<FrameBit> frame_bits;
......@@ -228,14 +231,24 @@ private:
up_down_gen.get (f + bit * Params::sync_frames_per_bit, frame_up, frame_down);
FrameBit frame_bit;
frame_bit.frame = sync_frame_pos (f + bit * Params::sync_frames_per_bit);
frame_bit.frame = sync_frame_pos (f + bit * Params::sync_frames_per_bit) + block * first_block_end;
for (int ch = 0; ch < wav_data.n_channels(); ch++)
{
if (block == 0)
{
for (auto u : frame_up)
frame_bit.up.push_back (u - Params::min_band + n_bands * ch);
for (auto d : frame_down)
frame_bit.down.push_back (d - Params::min_band + n_bands * ch);
}
else
{
for (auto u : frame_up)
frame_bit.down.push_back (u - Params::min_band + n_bands * ch);
for (auto d : frame_down)
frame_bit.up.push_back (d - Params::min_band + n_bands * ch);
}
}
std::sort (frame_bit.up.begin(), frame_bit.up.end());
std::sort (frame_bit.down.begin(), frame_bit.down.end());
frame_bits.push_back (frame_bit);
......@@ -244,6 +257,7 @@ private:
sync_bits.push_back (frame_bits);
}
}
}
double
sync_decode (const WavData& wav_data, const size_t start_frame, const vector<float>& fft_out_db, ConvBlockType *block_type, int *len)
{
......@@ -251,7 +265,7 @@ private:
size_t n_bands = Params::max_band - Params::min_band + 1;
int lbits = 0;
for (int bit = 0; bit < Params::sync_bits; bit++)
for (size_t bit = 0; bit < sync_bits.size(); bit++)
{
const vector<FrameBit>& frame_bits = sync_bits[bit];
float umag = 0, dmag = 0;
......@@ -284,7 +298,7 @@ private:
const double q = expect_data_bit ? raw_bit : -raw_bit;
sync_quality += q;
}
sync_quality /= Params::sync_bits;
sync_quality /= sync_bits.size();
sync_quality = normalize_sync_quality (sync_quality);
*len = lbits;
......@@ -639,7 +653,7 @@ decode_and_report (const WavData& wav_data, const string& orig_pattern)
}
// L-blocks
SyncFinder sync_finder_l;
vector<SyncFinder::Score> sync_scores_l; // FIXME = sync_finder.search (wav_data, SyncFinder::BlockLength::LONG);
vector<SyncFinder::Score> sync_scores_l = sync_finder.search (wav_data, SyncFinder::BlockLength::LONG);
for (auto sync_score : sync_scores_l)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment