@@ -73,7 +73,32 @@ def singleChannelEmbed(au, awmOpt):
73
73
return output
74
74
75
75
#def awmExtract(self):
76
-
76
+
77
+ @staticmethod
78
+ def extractMCLT (y , index , awmOpt ):
79
+ dataSeq = AudioWatermarkingMCLT .string2binary (awmOpt .data )
80
+ bitPerFrame = int ((awmOpt .dataFreqBand [1 ]- awmOpt .dataFreqBand [0 ]+ 1 ) / awmOpt .spreadLen )
81
+ syncFrameSize = int (np .size (awmOpt .syncSeq ) / ((awmOpt .syncFreqBand [1 ]- awmOpt .syncFreqBand [0 ])/ 2 + 1 )* 2 )
82
+ dataFrameSize = int (np .ceil (np .size (dataSeq )/ bitPerFrame ))
83
+ blockSize = syncFrameSize + dataFrameSize
84
+ tmp = util .enframe (y [index :index + (blockSize - 1 )* (awmOpt .frameSize - awmOpt .overlap )+ awmOpt .frameSize ], awmOpt .frameSize , awmOpt .overlap )
85
+ block = AudioWatermarkingMCLT .fmclt2 (tmp )
86
+ cipher = np .matrix (np .zeros ((1 , bitPerFrame * dataFrameSize ), dtype = np .int ))
87
+ count = 0
88
+ rowIndex = np .arange (awmOpt .dataFreqBand [0 ], awmOpt .dataFreqBand [1 ]+ 1 , awmOpt .spreadLen )
89
+ for i in range (syncFrameSize , block .shape [1 ]):
90
+ for j in range (bitPerFrame ):
91
+ positive = len (np .nonzero (np .sign (block [rowIndex [j ]:rowIndex [j ]+ awmOpt .spreadLen , i ].real ) == 1 )[0 ])
92
+ negative = len (np .nonzero (np .sign (block [rowIndex [j ]:rowIndex [j ]+ awmOpt .spreadLen , i ].real ) == - 1 )[0 ])
93
+ if positive >= negative :
94
+ cipher [0 , count ] = 1
95
+ else :
96
+ cipher [0 , count ] = - 1
97
+ count = count + 1
98
+ if (dataSeq .shape [1 ] % bitPerFrame ) != 0 :
99
+ cipher = cipher [0 , 0 :dataSeq .shape [1 ]]
100
+ return cipher
101
+
77
102
@staticmethod
78
103
def findSyncFast (y , base , length , awmOpt ):
79
104
M = int (awmOpt .frameSize / 2 )
@@ -91,9 +116,6 @@ def findSyncFast(y, base, length, awmOpt):
91
116
cor [i - base , 0 ] = np .sum (np .divide (np .multiply (embed [np .ix_ (k , j )], sync ), np .absolute (embed [np .ix_ (k , j )])))
92
117
return cor
93
118
94
-
95
-
96
-
97
119
@staticmethod
98
120
def compExpo (M , r ):
99
121
return np .exp (- 1j * 2 * np .pi * r / M )
@@ -215,11 +237,12 @@ def main():
215
237
awmOpt = awmOptSet ('mclt' )
216
238
output = AudioWatermarkingMCLT .singleChannelEmbed (au , awmOpt )
217
239
startTime = time .time ()
218
- cor = AudioWatermarkingMCLT .findSyncFast (output , 0 , 44100 , awmOpt )
240
+ cor = AudioWatermarkingMCLT .findSyncFast (output , 0 , 100 , awmOpt )
219
241
print ('Elapsed time: %s\n ' , (time .time () - startTime ))
220
- scipy .io .savemat ('cor.mat' , {'cor' : cor })
221
- print (cor .shape )
222
- print (cor .dtype )
242
+ pos = np .nonzero (cor .real > 100 )
243
+ ci = AudioWatermarkingMCLT .extractMCLT (output , pos [0 ][0 ], awmOpt )
244
+ plain = AudioWatermarkingMCLT .cipher2plain (ci )
245
+ print (plain )
223
246
224
247
if __name__ == '__main__' :
225
248
main ()
0 commit comments