我只是有一个关于从音频文件中提取 LSB 序列的问题。我在音频文件中嵌入了 58 个序列中的 580 位,每个序列相隔 1000 个样本。序列的前 10 位是触发位。
我要做的是遍历所有音频样本,如果有一个 10 位序列与触发位序列匹配,则提取该序列的第一位加上下一个 57。
但是,由于此特定音频的最大样本数为 150 万,因此我提取了数百万位不正确的位。
我知道可能存在与未嵌入的触发序列匹配的样本,但即便如此,我认为不可能提取 800 万位。
以下是我的代码,如果有人能说明我哪里出错了,我将不胜感激?
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);
}
}
}