File: DummyFile.cc

package info (click to toggle)
steghide 0.5.1-15
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,440 kB
  • sloc: cpp: 13,302; ansic: 6,184; sh: 3,960; makefile: 384; yacc: 316; perl: 228; sed: 16
file content (96 lines) | stat: -rw-r--r-- 3,265 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * steghide 0.5.1 - a steganography program
 * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#include "BitString.h"
#include "Selector.h"

#include "DummyFile.h"
#include "DummySampleValue.h"

DummyFile::DummyFile (UWORD16 s, std::vector<std::vector<bool> >* svam)
	: SampleValueAdjacencyMatrix(svam)
{
	Samples.resize (s) ;
	for (UWORD16 i = 0 ; i < s ; i++) {
		Samples[i] = i ;
	}
	setSamplesPerVertex (SamplesPerVertex) ;
	setEmbValueModulus (EmbValueModulus) ;
	setRadius (0) ; // undefined, neighbourhood relatin decided by svam
}

std::list<CvrStgFile::Property> DummyFile::getProperties () const
{
	std::list<CvrStgFile::Property> retval ;
	retval.push_back (CvrStgFile::Property (_("format"), "dummy")) ;
	return retval ;
}

unsigned long DummyFile::getNumSamples () const
{
	return Samples.size() ;
}

SampleValue* DummyFile::getSampleValue (const SamplePos pos) const
{
	return (SampleValue*) (new DummySampleValue (Samples[pos])) ;
}

void DummyFile::replaceSample (const SamplePos pos, const SampleValue* s)
{
	myassert (pos < Samples.size()) ;
	DummySampleValue *sample = (DummySampleValue*) s ;
	Samples[pos] = sample->getValue() ;
}

void DummyFile::createGraph (std::vector<std::list<UWORD16> >& adjlist, BitString** bs, CvrStgFile** f, Selector** s)
{
	unsigned int numvertices = adjlist.size() ;

	// eliminate duplicated edges from adjlist (only allow v_i -> ...,v_j,... with j > i)
	for (UWORD16 srcv = 0 ; srcv < numvertices ; srcv++) {
		for (std::list<UWORD16>::iterator destv = adjlist[srcv].begin() ; destv != adjlist[srcv].end() ; destv++) {
			if (srcv > (*destv)) {
				adjlist[srcv].erase (destv) ;
			}
		}
	}

	// allocate memory for SampleValue Adjacency-Matrix
	std::vector<std::vector<bool> >* svam = new std::vector<std::vector<bool> > (2 * numvertices) ;
	for (UWORD16 srcv = 0 ; srcv < numvertices ; srcv++) {
		(*svam)[2*srcv] = std::vector<bool> (2 * numvertices) ;
		(*svam)[2*srcv + 1] = std::vector<bool> (2 * numvertices) ;
	}

	// fill SampleValue Adjacency-Matrix
	for (UWORD16 srcv = 0 ; srcv < numvertices ; srcv++) {
		UWORD16 srcsv = 2 * srcv ;
		for (std::list<UWORD16>::const_iterator destv = adjlist[srcv].begin() ; destv != adjlist[srcv].end() ; destv++) {
			UWORD16 destsv = 2 * (*destv) + 1 ;
			(*svam)[srcsv][destsv] = true ;
			(*svam)[destsv][srcsv] = true ;
		}
	}

	(*f) = (CvrStgFile*) new DummyFile (2 * numvertices, svam) ;
	(*bs) = new BitString ((unsigned long) numvertices) ; // zeros only
	(*s) = new Selector (2 * numvertices) ; // identity permutation
}