0

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);
        }
    }
}
  • What happens when you step through the code in your debugger? Hint: Take a closer look at `startOfWatermark`. – doynax May 01 '17 at 11:21
  • @doynax - thank you for pointing this out. It took me a while to find out what you meant but after a closer look, it looks like the the frame doesn't increment correctly after the 58 bits were extracted. However, I have tried using `frames = idxOfWatermarkStart + 58;` outside the for loop for writing out the 58 bits but it's made the issue worse, the extracted bits have become too big for Notepadd++ to open. – user3604802 May 01 '17 at 21:20
  • I think I've got it by resetting the boolean back to false after the for loop. I'm down to 45k extracted bits so I think it's just a matter of the trigger bits being too common of a sequence – user3604802 May 01 '17 at 21:40

0 Answers0