1 .. SPDX-License-Identifier: GPL-2.0 2 3 The cx2341x driver 4 ================== 5 6 Non-compressed file format 7 -------------------------- 8 9 The cx23416 can produce (and the cx23415 can a 10 format of a YUV frame is 16x16 linear tiled NV 11 12 The format is YUV 4:2:0 which uses 1 Y byte pe 13 four pixels. 14 15 The data is encoded as two macroblock planes, 16 values, the second containing UV macroblocks. 17 18 The Y plane is divided into blocks of 16x16 pi 19 and from top to bottom. Each block is transmit 20 21 So the first 16 bytes are the first line of th 22 second 16 bytes are the second line of the top 23 transmitting this block the first line of the 24 first block is transmitted, etc. 25 26 The UV plane is divided into blocks of 16x8 UV 27 to right, top to bottom. Each block is transmi 28 29 So the first 16 bytes are the first line of th 30 contain 8 UV value pairs (16 bytes in total). 31 second line of 8 UV pairs of the top-left bloc 32 this block the first line of the block on the 33 transmitted, etc. 34 35 The code below is given as an example on how t 36 to separate Y, U and V planes. This code assum 37 38 The width of a frame is always 720 pixels, reg 39 width. 40 41 If the height is not a multiple of 32 lines, t 42 missing macroblocks at the end and is unusable 43 multiple of 32. 44 45 Raw format c example 46 ~~~~~~~~~~~~~~~~~~~~ 47 48 .. code-block:: c 49 50 #include <stdio.h> 51 #include <stdlib.h> 52 #include <string.h> 53 54 static unsigned char frame[576*720*3/2 55 static unsigned char framey[576*720]; 56 static unsigned char frameu[576*720 / 57 static unsigned char framev[576*720 / 58 59 static void de_macro_y(unsigned char* 60 { 61 unsigned int y, x, i; 62 63 // descramble Y plane 64 // dstride = 720 = w 65 // The Y plane is divided into blocks 66 // Each block in transmitted in turn, 67 for (y = 0; y < h; y += 16) { 68 for (x = 0; x < w; x += 16) { 69 for (i = 0; i < 16; i++) { 70 memcpy(dst + x + (y + 71 src += 16; 72 } 73 } 74 } 75 } 76 77 static void de_macro_uv(unsigned char 78 { 79 unsigned int y, x, i; 80 81 // descramble U/V plane 82 // dstride = 720 / 2 = w 83 // The U/V values are interlaced (UVUV 84 // Again, the UV plane is divided into 85 // Each block in transmitted in turn, 86 for (y = 0; y < h; y += 16) { 87 for (x = 0; x < w; x += 8) { 88 for (i = 0; i < 16; i++) { 89 int idx = x + (y + i) 90 91 dstu[idx+0] = src[0]; 92 dstu[idx+1] = src[2]; 93 dstu[idx+2] = src[4]; 94 dstu[idx+3] = src[6]; 95 dstu[idx+4] = src[8]; 96 dstu[idx+5] = src[10]; 97 dstu[idx+6] = src[12]; 98 dstu[idx+7] = src[14]; 99 src += 16; 100 } 101 } 102 } 103 } 104 105 /************************************* 106 int main(int argc, char **argv) 107 { 108 FILE *fin; 109 int i; 110 111 if (argc == 1) fin = stdin; 112 else fin = fopen(argv[1], "r"); 113 114 if (fin == NULL) { 115 fprintf(stderr, "cannot open i 116 exit(-1); 117 } 118 while (fread(frame, sizeof(frame), 1, 119 de_macro_y(framey, frame, 720, 120 de_macro_uv(frameu, framev, fr 121 fwrite(framey, sizeof(framey), 122 fwrite(framev, sizeof(framev), 123 fwrite(frameu, sizeof(frameu), 124 } 125 fclose(fin); 126 return 0; 127 } 128 129 130 Format of embedded V4L2_MPEG_STREAM_VBI_FMT_IV 131 ---------------------------------------------- 132 133 Author: Hans Verkuil <hverkuil@xs4all.nl> 134 135 136 This section describes the V4L2_MPEG_STREAM_VB 137 embedded in an MPEG-2 program stream. This for 138 hardware limitations of the ivtv driver (the d 139 chips), in particular a maximum size for the V 140 off when the MPEG stream is played back throug 141 142 The advantage of this format is it is very com 143 all lines can be stored while still fitting wi 144 145 The stream ID of the VBI data is 0xBD. The max 146 4 + 43 * 36, which is 4 bytes for a header and 147 header and a 42 bytes payload each. Anything b 148 the cx23415/6 firmware. Besides the data for t 149 for a bitmask determining which lines are capt 150 signifying that this data package contains V4L 151 If all lines are used, then there is no longer 152 two different magic numbers were introduced: 153 154 'itv0': After this magic number two unsigned l 155 unsigned long denote which lines of the first 156 the first unsigned long and bits 0-3 of the se 157 second field. 158 159 'ITV0': This magic number assumes all VBI line 160 implies that the bitmasks are 0xffffffff and 0 161 162 After these magic cookies (and the 8 byte bitm 163 captured VBI lines start: 164 165 For each line the least significant 4 bits of 166 Possible values are shown in the table below. 167 bytes. 168 169 Here is the list of possible data types: 170 171 .. code-block:: c 172 173 #define IVTV_SLICED_TYPE_TELETEXT 174 #define IVTV_SLICED_TYPE_CC 175 #define IVTV_SLICED_TYPE_WSS 176 #define IVTV_SLICED_TYPE_VPS 177
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.