Beispiel #1
0
    def test_embedding_cero(self):
        quantizer = MagicMock(return_value=30)
        emb = BinaryDM(quantizer, d0=5)

        # positive d(m)
        emb.dither = Mock(return_value=4)

        self.assertEqual(emb.embed(25, 0), 26)
        quantizer.assert_called_with(29)
        self.assertListEqual(emb.dither.call_args_list, [call(0), call(0)])

        # negative d(m)
        emb.dither = Mock(return_value=-4)

        self.assertEqual(emb.embed(25, 0), 34)
        quantizer.assert_called_with(21)
        self.assertListEqual(emb.dither.call_args_list, [call(0), call(0)])
Beispiel #2
0
    def test_embedding_one(self):
        quantizer = MagicMock(return_value=-30)
        emb = BinaryDM(quantizer, d0=5)

        # positive d(m)
        emb.dither = Mock(return_value=4)

        self.assertEqual(emb.embed(-25, 1), -34)
        quantizer.assert_called_with(-21)
        self.assertListEqual(emb.dither.call_args_list, [call(1), call(1)])

        # negative d(m)
        emb.dither = Mock(return_value=-4)

        self.assertEqual(emb.embed(-25, 1), -26)
        quantizer.assert_called_with(-29)
        self.assertListEqual(emb.dither.call_args_list, [call(1), call(1)])
Beispiel #3
0
    def test_zero_d0(self):
        '''Test dither function for a positive d0'''

        quantize = Mock(step=12)
        emb = BinaryDM(quantize, d0=0)

        self.assertEqual(emb.dither(0), 0)
        self.assertEqual(emb.dither(1), -6)