Skip to content

Commit 6d392ca

Browse files
committed
Checkin noad-0.8.0 2012-09-19
1 parent 32a8d04 commit 6d392ca

File tree

3 files changed

+173
-2
lines changed

3 files changed

+173
-2
lines changed

Diff for: Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ noad_SOURCES=audiotools.cpp cchecklogo.cpp ccontrol.cpp cgetlogo.cpp ctoolbox.cp
1010
main.cpp \
1111
audiotools.h cchecklogo.h ccontrol.h cgetlogo.h ctoolbox.h \
1212
noad.h tnoad.h noaddata.h videodir.h \
13-
ffmpeg_decoder.h libmpeg2_decoder.h mpeg2wrap_ffmpeg.h mpeg_decoder.h
13+
ffmpeg_decoder.h libmpeg2_decoder.h mpeg2wrap_ffmpeg.h mpeg_decoder.h yuvbuf.h
1414

1515

1616
noad_LDADD=libnoad.a

Diff for: Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ noad_SOURCES = audiotools.cpp cchecklogo.cpp ccontrol.cpp cgetlogo.cpp ctoolbox.
270270
main.cpp \
271271
audiotools.h cchecklogo.h ccontrol.h cgetlogo.h ctoolbox.h \
272272
noad.h tnoad.h noaddata.h videodir.h \
273-
ffmpeg_decoder.h libmpeg2_decoder.h mpeg2wrap_ffmpeg.h mpeg_decoder.h
273+
ffmpeg_decoder.h libmpeg2_decoder.h mpeg2wrap_ffmpeg.h mpeg_decoder.h yuvbuf.h
274274

275275
noad_LDADD = libnoad.a
276276
noinst_PROGRAMS = @PICSRC@ @TOOLSRC@

Diff for: yuvbuf.h

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#ifndef _NOADYUVBUF_H
2+
#define _NOADYUVBUF_H
3+
#include <string.h> // memcpy
4+
5+
class noadYUVBuf
6+
{
7+
noadYUVBuf(noadYUVBuf&){}
8+
public:
9+
uint8_t * buf[3];
10+
int linewidth[3];
11+
int width,height;
12+
bool bAlloced;
13+
noadYUVBuf()
14+
{
15+
bAlloced=false;
16+
buf[0] = 0;
17+
buf[1] = 0;
18+
buf[2] = 0;
19+
linewidth[0] = 0;
20+
linewidth[1] = 0;
21+
linewidth[2] = 0;
22+
width = 0;
23+
height = 0;
24+
}
25+
~noadYUVBuf()
26+
{
27+
if(bAlloced)
28+
release();
29+
}
30+
void assign(const noadYUVBuf rhs)
31+
{
32+
if( width != rhs.width || height != rhs.height || linewidth[0] != rhs.linewidth[0]
33+
|| linewidth[1] != rhs.linewidth[1] || linewidth[2] != rhs.linewidth[2])
34+
{
35+
width = rhs.width;
36+
height = rhs.height;
37+
linewidth[0] = rhs.linewidth[0];
38+
linewidth[1] = rhs.linewidth[1];
39+
linewidth[2] = rhs.linewidth[2];
40+
if(bAlloced)
41+
release();
42+
}
43+
if( rhs.bAlloced )
44+
{
45+
if(!bAlloced)
46+
alloc(width , height, linewidth[0], linewidth[1]);
47+
copyData(rhs.buf, linewidth[0], linewidth[1]);
48+
}
49+
else
50+
{
51+
buf[0] = rhs.buf[0];
52+
buf[1] = rhs.buf[1];
53+
buf[2] = rhs.buf[2];
54+
}
55+
//return *this;
56+
}
57+
noadYUVBuf& operator=(noadYUVBuf *rhs)
58+
{
59+
if( width != rhs->width || height != rhs->height || linewidth[0] != rhs->linewidth[0]
60+
|| linewidth[1] != rhs->linewidth[1] || linewidth[2] != rhs->linewidth[2])
61+
{
62+
width = rhs->width;
63+
height = rhs->height;
64+
linewidth[0] = rhs->linewidth[0];
65+
linewidth[1] = rhs->linewidth[1];
66+
linewidth[2] = rhs->linewidth[2];
67+
if(bAlloced)
68+
release();
69+
}
70+
if( rhs->bAlloced )
71+
{
72+
if(!bAlloced)
73+
alloc(width , height, linewidth[0], linewidth[1]);
74+
copyData(rhs->buf, linewidth[0], linewidth[1]);
75+
}
76+
else
77+
{
78+
if(bAlloced)
79+
release();
80+
buf[0] = rhs->buf[0];
81+
buf[1] = rhs->buf[1];
82+
buf[2] = rhs->buf[2];
83+
}
84+
return *this;
85+
}
86+
87+
bool isNull() { return (width==0 || height== 0); }
88+
noadYUVBuf(uint8_t *const data[3], const unsigned int w, const unsigned int h)
89+
{
90+
bAlloced=false;
91+
width = w;
92+
height = h;
93+
buf[0] = data[0];
94+
buf[1] = data[1];
95+
buf[2] = data[2];
96+
linewidth[0] = w;
97+
linewidth[1] = w/2;
98+
linewidth[2] = w/2;
99+
}
100+
noadYUVBuf(uint8_t **data, int *linesizes, int w, int h)
101+
{
102+
bAlloced=false;
103+
width = w;
104+
height = h;
105+
buf[0] = data[0];
106+
buf[1] = data[1];
107+
buf[2] = data[2];
108+
linewidth[0] = linesizes[0];
109+
linewidth[1] = linesizes[1];
110+
linewidth[2] = linesizes[2];
111+
}
112+
void alloc(int w, int h)
113+
{
114+
width = w;
115+
height = h;
116+
buf[0] = new uint8_t[width*height];
117+
buf[1] = new uint8_t[(width*height)/4];
118+
buf[2] = new uint8_t[(width*height)/4];
119+
linewidth[0] = w;
120+
linewidth[1] = w/2;
121+
linewidth[2] = w/2;
122+
bAlloced=true;
123+
}
124+
void alloc(int w, int h, int linesize1, int linesize2)
125+
{
126+
width = w;
127+
height = h;
128+
buf[0] = new uint8_t[linesize1*height];
129+
buf[1] = new uint8_t[linesize2*(height/2)];
130+
buf[2] = new uint8_t[linesize2*(height/2)];
131+
linewidth[0] = linesize1;
132+
linewidth[1] = linesize2;
133+
linewidth[2] = linesize2;
134+
bAlloced=true;
135+
}
136+
void release()
137+
{
138+
if(bAlloced)
139+
{
140+
delete [] buf[0];
141+
delete [] buf[1];
142+
delete [] buf[2];
143+
buf[0] = 0;
144+
buf[1] = 0;
145+
buf[2] = 0;
146+
}
147+
bAlloced=false;
148+
}
149+
void copyData(uint8_t * const _buf[3])
150+
{
151+
if( bAlloced )
152+
{
153+
memcpy(buf[0],_buf[0],width*height);
154+
memcpy(buf[1],_buf[1],(width*height)/4);
155+
memcpy(buf[2],_buf[2],(width*height)/4);
156+
}
157+
}
158+
void copyData(uint8_t * const _buf[3], int linesize1, int linesize2)
159+
{
160+
if( bAlloced )
161+
{
162+
memcpy(buf[0],_buf[0],linesize1*height);
163+
memcpy(buf[1],_buf[1],linesize2*(height/2));
164+
memcpy(buf[2],_buf[2],linesize2*(height/2));
165+
}
166+
}
167+
};
168+
typedef noadYUVBuf noadYUVBuf;
169+
170+
#endif //_NOADYUVBUF_H
171+

0 commit comments

Comments
 (0)