I just have a question with regards to extracting a sequence of LSBs from an audio file. I've embedded 580 bits in sequences of 58 in the audio file, each sequence is 1000 samples apart. The first 10 bits of the sequence are the trigger bits.
What I'm trying to do is go through all the audio samples and if there's a 10 bit sequence that matches the trigger bit sequence, extract the first bit of that sequence plus the next 57.
However, I am getting millions of bits extracted which is not correct since the max number of samples of this particular audio is 1.5 million.
I understand that there may be samples which matches the trigger sequence which weren't embedded but even then I didn't think it was possible to have 8 million bits extracted.
Below is my code and I would appreciate if anyone could shed any light to where I am going wrong?
int counter = 0;
bool startOfWatermark = 0;
int idxOfWatermarkStart = 0;
//goes through all the frames in the audio
for (int frames = 0; frames < maxFrames; frames++)
{
//checks if the LSB of a frame is = to 1st trigger bit
if ((outputFrames[frames] & 1) == 1){
counter = 0;
//check the next 10 bits to see if they match the trigger bits
for (int i = 0; i < 10; i++){
int idxToCheck = i + frames;
if ((outputFrames[idxToCheck] & 1) == triggerBits[i]){
counter++;
//if all 10 bits matches the trigger bits, set startOfWatermark to true and keep record of that frame position
if (counter == 10){
startOfWatermark = 1;
idxOfWatermarkStart = frames;
}
}
}
}
//write out the 58bits starting from the first trigger bit.
if (startOfWatermark){
for (int j = idxOfWatermarkStart; j < idxOfWatermarkStart + 58; j++){
fprintf(fp, "%d", outputFrames[j] & 1);
}
}
}