1 /* ***** BEGIN LICENSE BLOCK *****
7 * Copyright (c) 2008 BBC Research
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * ***** END LICENSE BLOCK ***** */
33 #include "rawIOleader-frm.h"
35 /* file format documentation from:
36 * http://www.leaderusa.com/web/dl_count.php?ftID=1&fDR=products%2Fmanual%2F01_Waveform_Monitor%2F12_LV5800%2F&fNM=LV5800+LV58SER01-01A+SDI+Input+Instruction+Manual.pdf
39 void RawReaderLeaderFRM::readHeader()
41 /* file format is little endian */
42 /* the first two bytes (addresses 0-1) are reserved */
45 /* the next four bytes (addresses 2 to 5) indicate the size of the captured data.
46 * In a dual link, half of the size of the captured data, which is equivalent to
47 * the size of one link will be indicated */
50 size
|= getc(infile
) << 8;
51 size
|= getc(infile
) << 16;
52 size
|= getc(infile
) << 24;
53 /* next two bytes indicate video format */
56 vfmt
|= getc(infile
) << 8;
57 /* the 56 bytes contained in addresses 8 through 0x3f are reserved */
58 for (int i
= 0; i
< 56; i
++) getc(infile
);
61 case 0x0000: /* 30 fps, interlaced/psf */
62 case 0x0001: /* 29.97 fps, interlaced/psf */
63 case 0x0002: /* 25 fps, interlaced/psf */
64 case 0x0004: /* 24 fps, psf */
65 case 0x0005: /* 23.98 fps, psf */
66 case 0x000a: /* 30p */
67 case 0x000b: /* 29.97p */
68 case 0x000c: /* 25p */
69 case 0x000e: /* 24p */
70 case 0x000f: /* 23.98p */
74 /* xxx, actually need to give the full raster width */
77 case 0x0106: /* 60p */
78 case 0x0107: /* 59.94p */
79 case 0x0108: /* 50p */
80 case 0x010a: /* 30p */
81 case 0x010b: /* 29.97p */
82 case 0x010c: /* 25p */
83 case 0x010e: /* 24p */
84 case 0x010f: /* 23.98p */
88 /* xxx, actually need to give the full raster width */
91 case 0x0201: _sd
=1; _depth
= 10; _width
= 858; _height
= 525; /* 29.97i */ break;
92 case 0x0202: _sd
=1; _depth
= 10; _width
= 864; _height
= 625; /* 25i */ break;
94 assert(!"unhandled mode");
96 /* todo: support the other chroma modes */
97 _chroma
= RawFrame::Cr422
;
100 RawFrame
& RawReaderLeaderFRM::read(RawFrame
&f
)
102 assert(f
.chroma
== _chroma
);
104 /* 10bits of digital data are expressed wih one word (16bits) */
105 /* order of words for SD: Cb0, xxx, Y0, xxx, Cr0, xxx, Y1, xxx... */
107 for (int y
= 0; y
< _height
; y
++) {
108 for (int x
= 0; x
< _width
; x
+=2) {
109 f
.cb
[y
][x
/2] = getc(infile
);
110 f
.cb
[y
][x
/2] |= (getc(infile
) & 0x3) << 8;
111 getc(infile
); getc(infile
);
112 f
.luma
[y
][x
] = getc(infile
);
113 f
.luma
[y
][x
] |= (getc(infile
) & 0x3) << 8;
114 getc(infile
); getc(infile
);
115 f
.cr
[y
][x
/2] = getc(infile
);
116 f
.cr
[y
][x
/2] |= (getc(infile
) & 0x3) << 8;
117 getc(infile
); getc(infile
);
118 f
.luma
[y
][x
+1] = getc(infile
);
119 f
.luma
[y
][x
+1] |= (getc(infile
) & 0x3) << 8;
120 getc(infile
); getc(infile
);
124 for (int y
= 0; y
< _height
; y
++) {
125 for (int x
= 0; x
< _width
; x
+=2) {
126 f
.luma
[y
][x
] = getc(infile
);
127 f
.luma
[y
][x
] |= (getc(infile
) & 0x3) << 8;
128 f
.cb
[y
][x
/2] = getc(infile
);
129 f
.cb
[y
][x
/2] |= (getc(infile
) & 0x3) << 8;
130 f
.luma
[y
][x
+1] = getc(infile
);
131 f
.luma
[y
][x
+1] |= (getc(infile
) & 0x3) << 8;
132 f
.cr
[y
][x
/2] = getc(infile
);
133 f
.cr
[y
][x
/2] |= (getc(infile
) & 0x3) << 8;
141 RawFrame
& RawReaderLeaderFRM::read()