File: _codec_image_8h-source.html

package info (click to toggle)
camstream 0.27%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,320 kB
  • ctags: 5,393
  • sloc: cpp: 17,031; sh: 8,154; asm: 455; ansic: 440; makefile: 343
file content (162 lines) | stat: -rw-r--r-- 12,284 bytes parent folder | download | duplicates (2)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<html>
<head>
<title>Camstream: CamStream API documentation</title>
<link rel="stylesheet" href="../../tech.css" type="text/css">
</head>
<body>

<!-- Generated by Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
<h1>CodecImage.h</h1><a href="_codec_image_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="preprocessor">#ifndef CODEC_IMAGE_HPP</span>
00002 <span class="preprocessor"></span><span class="preprocessor">#define CODEC_IMAGE_HPP</span>
00003 <span class="preprocessor"></span>
00004 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
00005 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
00006 <span class="preprocessor">#include &lt;string.h&gt;</span>
00007 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
00008 
00009 <span class="preprocessor">#if defined(WIN32)</span>
00010 <span class="preprocessor"></span><span class="keyword">typedef</span> __int16 int16_t;
00011 <span class="preprocessor">#endif</span>
00012 <span class="preprocessor"></span>
<a name="l00013"></a><a class="code" href="class_c_codec_image.html">00013</a> <span class="keyword">class </span><a class="code" href="class_c_codec_image.html">CCodecImage</a>
00014 {
00015 <span class="keyword">private</span>:
00016 
00017 <span class="keyword">protected</span>:
<a name="l00018"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html">00018</a>    <span class="keyword">struct </span><a class="code" href="struct_c_codec_image_1_1_image_data.html">ImageData</a>
00019    {
<a name="l00020"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#o0">00020</a>      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#o0">Count</a>;
<a name="l00021"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">00021</a>      <span class="keywordtype">int</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">Width</a>, <a class="code" href="struct_c_codec_image_1_1_image_data.html#o2">Height</a>;
<a name="l00022"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">00022</a>      <span class="keywordtype">int</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">Pixels</a>;
<a name="l00023"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">00023</a>      int16_t *<a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a>;
00024 
<a name="l00025"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#a0">00025</a>      <a class="code" href="struct_c_codec_image_1_1_image_data.html#a0">ImageData</a>()
00026      {
00027        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o0">Count</a> = 1;
00028        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">Width</a> = 0;
00029        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o2">Height</a> = 0;
00030        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">Pixels</a> = 0;
00031        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a> = 0;
00032      }
00033 
<a name="l00034"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#a1">00034</a>      <a class="code" href="struct_c_codec_image_1_1_image_data.html#a1">~ImageData</a>()
00035      {
00036        free(<a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a>);
00037        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a> = 0;
00038      }
00039 
<a name="l00040"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#a2">00040</a>      <span class="keywordtype">void</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#a2">Malloc</a>(<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h)
00041      {
00042        <span class="keywordtype">void</span> *s;
00043 
00044        <span class="comment">// Only reallocate when size is different</span>
00045        <span class="keywordflow">if</span> (w == <a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">Width</a> &amp;&amp; h == <a class="code" href="struct_c_codec_image_1_1_image_data.html#o2">Height</a> &amp;&amp; <a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a> != 0)
00046          <span class="keywordflow">return</span>;
00047        s = realloc(<a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a>, w * h * <span class="keyword">sizeof</span>(int16_t));
00048        <span class="keywordflow">if</span> (s == 0)
00049        {
00050          printf(<span class="stringliteral">"CCodecImage::ImageData::Malloc: no memory!\n"</span>);
00051          free(<a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a>);
00052          s = 0;
00053          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">Width</a> = 0;
00054          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o2">Height</a> = 0;
00055          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">Pixels</a> = 0;
00056        }
00057        <span class="keywordflow">else</span>
00058        {
00059          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o1">Width</a> = w;
00060          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o2">Height</a> = h;
00061          <a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">Pixels</a> = w * h;
00062          memset(s, 0, <a class="code" href="struct_c_codec_image_1_1_image_data.html#o3">Pixels</a> * <span class="keyword">sizeof</span>(int16_t));
00063        }
00064        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o4">pImage</a> = (int16_t *)s;
00065      }
00066 
<a name="l00067"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#a3">00067</a>      <span class="keywordtype">void</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#a3">ref</a>()
00068      {
00069        <a class="code" href="struct_c_codec_image_1_1_image_data.html#o0">Count</a>++;
00070      }
<a name="l00071"></a><a class="code" href="struct_c_codec_image_1_1_image_data.html#a4">00071</a>      <span class="keywordtype">bool</span> <a class="code" href="struct_c_codec_image_1_1_image_data.html#a4">deref</a>()
00072      {
00073        <span class="keywordflow">return</span> !--<a class="code" href="struct_c_codec_image_1_1_image_data.html#o0">Count</a>;
00074      }
00075    } *m_pData;
00076 
00077    <span class="keyword">static</span> <span class="keywordtype">bool</span> SanityCheck(<span class="keyword">const</span> <a class="code" href="class_c_codec_image.html">CCodecImage</a> &amp;one, <span class="keyword">const</span> <a class="code" href="class_c_codec_image.html">CCodecImage</a> &amp;two);
00078    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_codec_image.html#b0">detach</a>();
00079    <a class="code" href="class_c_codec_image.html">CCodecImage</a> <a class="code" href="class_c_codec_image.html#b1">copy</a>() const;
00080 
00081  public:
00082    <a class="code" href="class_c_codec_image.html">CCodecImage</a>();
00083    CCodecImage(const CCodecImage &amp;);
00084    CCodecImage(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height);
00085    virtual ~CCodecImage();
00086 
00087    <span class="keywordtype">int</span> Width() const;
00088    <span class="keywordtype">int</span> Height() const;
00089    virtual <span class="keywordtype">void</span> Resize(<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h);
00090 
00091    <span class="keywordtype">void</span> Load(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, const <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *src);
00092    <span class="keywordtype">void</span> Store(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *dst);
00093 
00094    CCodecImage &amp;operator =(const CCodecImage &amp;src);
00095    CCodecImage &amp;operator -=(const CCodecImage &amp;sub);
00096    CCodecImage operator -(const CCodecImage &amp;sub) const;
00097 };
00098 
<a name="l00099"></a><a class="code" href="class_y_u_v_triplet.html">00099</a> template &lt;class Image&gt; class <a class="code" href="class_y_u_v_triplet.html">YUVTriplet</a>
00100 {
00101 <span class="keyword">private</span>:
00102 
00103 <span class="keyword">public</span>:
<a name="l00104"></a><a class="code" href="class_y_u_v_triplet.html#o0">00104</a>    Image Y;
<a name="l00105"></a><a class="code" href="class_y_u_v_triplet.html#o1">00105</a>    Image U;
<a name="l00106"></a><a class="code" href="class_y_u_v_triplet.html#o2">00106</a>    Image V;
00107 
00108    <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a>()
00109    {
00110       <span class="comment">/* Do exactly nothing */</span>
00111    }
00112 
00113    <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a>(<span class="keyword">const</span> YUVTriplet &lt;Image&gt; &amp;copy)
00114    {
00115      Y = copy.Y;
00116      U = copy.U;
00117      V = copy.V;
00118    }
00119 
<a name="l00120"></a><a class="code" href="class_y_u_v_triplet.html#a2">00120</a>    <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a> &amp;operator =(<span class="keyword">const</span> <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a> &amp;assign)
00121    {
00122       Y = assign.<a class="code" href="class_y_u_v_triplet.html#o0">Y</a>;
00123       U = assign.<a class="code" href="class_y_u_v_triplet.html#o1">U</a>;
00124       V = assign.<a class="code" href="class_y_u_v_triplet.html#o2">V</a>;
00125       <span class="keywordflow">return</span> *<span class="keyword">this</span>;
00126    }
00127 
<a name="l00128"></a><a class="code" href="class_y_u_v_triplet.html#a3">00128</a>    <span class="keywordtype">void</span> Resize(<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h)
00129    {
00130      Y.Resize(w, h);
00131      w &gt;&gt;= 1;
00132      h &gt;&gt;= 1;
00133      U.Resize(w, h);
00134      V.Resize(w, h);
00135    }
00136 
<a name="l00137"></a><a class="code" href="class_y_u_v_triplet.html#a4">00137</a>    <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a> operator -(<span class="keyword">const</span> <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a> &amp;sub)<span class="keyword"> const</span>
00138 <span class="keyword">   </span>{
00139       <a class="code" href="class_y_u_v_triplet.html">YUVTriplet&lt;Image&gt;</a> result;
00140 
00141       result.<a class="code" href="class_y_u_v_triplet.html#o0">Y</a> = Y - sub.<a class="code" href="class_y_u_v_triplet.html#o0">Y</a>;
00142       result.<a class="code" href="class_y_u_v_triplet.html#o1">U</a> = U - sub.<a class="code" href="class_y_u_v_triplet.html#o1">U</a>;
00143       result.<a class="code" href="class_y_u_v_triplet.html#o2">V</a> = V - sub.<a class="code" href="class_y_u_v_triplet.html#o2">V</a>;
00144       <span class="keywordflow">return</span> result;
00145    }
00146 };
00147 
00148 <span class="preprocessor">#endif</span>
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Wed Dec 13 23:38:46 2006 for CamStream by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>