blob: 35130024609006b00c6ead2fa98b9d03bfa87f48 (
plain) (
blame)
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
|
#include "main.h"
#include "VideoDataConverter.h"
#include <cassert>
class YV12Converter : public VideoDataConverter
{
public:
YV12Converter(int w, int h)
: width(w), height(h)
{
yv12.y.rowBytes = width;
yv12.v.rowBytes = width / 2;
yv12.u.rowBytes = width / 2;
vOffset = width*height;
uOffset = width*height/4;
}
void *Convert(void *videoData)
{
yv12.y.baseAddr = (unsigned char*)videoData;
yv12.v.baseAddr = yv12.y.baseAddr + vOffset;
yv12.u.baseAddr = yv12.v.baseAddr + uOffset;
return (void *)&yv12;
}
int width, height;
int vOffset, uOffset;
YV12_PLANES yv12;
};
VideoDataConverter *MakeConverter(VideoOutputStream *stream)
{
switch (stream->FourCC())
{
case '21VY':
return new YV12Converter(stream->DestinationWidth(), stream->DestinationHeight());
default:
return new VideoDataConverter;
}
}
|