€•üMŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”ŒhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K#hhÉhžhubhÛ)”}”(hŒTThe width of a frame is always 720 pixels, regardless of the actual specified width.”h]”hŒTThe width of a frame is always 720 pixels, regardless of the actual specified width.”…””}”(hjLhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K&hhÉhžhubhÛ)”}”(hŒŸIf the height is not a multiple of 32 lines, then the captured video is missing macroblocks at the end and is unusable. So the height must be a multiple of 32.”h]”hŒŸIf the height is not a multiple of 32 lines, then the captured video is missing macroblocks at the end and is unusable. So the height must be a multiple of 32.”…””}”(hjZhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K)hhÉhžhubhµ)”}”(hhh]”(hº)”}”(hŒRaw format c example”h]”hŒRaw format c example”…””}”(hjkhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjhhžhhŸh³h K.ubhŒ literal_block”“”)”}”(hXU #include #include #include static unsigned char frame[576*720*3/2]; static unsigned char framey[576*720]; static unsigned char frameu[576*720 / 4]; static unsigned char framev[576*720 / 4]; static void de_macro_y(unsigned char* dst, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble Y plane // dstride = 720 = w // The Y plane is divided into blocks of 16x16 pixels // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 16) { for (i = 0; i < 16; i++) { memcpy(dst + x + (y + i) * dstride, src, 16); src += 16; } } } } static void de_macro_uv(unsigned char *dstu, unsigned char *dstv, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble U/V plane // dstride = 720 / 2 = w // The U/V values are interlaced (UVUV...). // Again, the UV plane is divided into blocks of 16x16 UV values. // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 8) { for (i = 0; i < 16; i++) { int idx = x + (y + i) * dstride; dstu[idx+0] = src[0]; dstv[idx+0] = src[1]; dstu[idx+1] = src[2]; dstv[idx+1] = src[3]; dstu[idx+2] = src[4]; dstv[idx+2] = src[5]; dstu[idx+3] = src[6]; dstv[idx+3] = src[7]; dstu[idx+4] = src[8]; dstv[idx+4] = src[9]; dstu[idx+5] = src[10]; dstv[idx+5] = src[11]; dstu[idx+6] = src[12]; dstv[idx+6] = src[13]; dstu[idx+7] = src[14]; dstv[idx+7] = src[15]; src += 16; } } } } /*************************************************************************/ int main(int argc, char **argv) { FILE *fin; int i; if (argc == 1) fin = stdin; else fin = fopen(argv[1], "r"); if (fin == NULL) { fprintf(stderr, "cannot open input\n"); exit(-1); } while (fread(frame, sizeof(frame), 1, fin) == 1) { de_macro_y(framey, frame, 720, 720, 576); de_macro_uv(frameu, framev, frame + 720 * 576, 720 / 2, 720 / 2, 576 / 2); fwrite(framey, sizeof(framey), 1, stdout); fwrite(framev, sizeof(framev), 1, stdout); fwrite(frameu, sizeof(frameu), 1, stdout); } fclose(fin); return 0; }”h]”hXU #include #include #include static unsigned char frame[576*720*3/2]; static unsigned char framey[576*720]; static unsigned char frameu[576*720 / 4]; static unsigned char framev[576*720 / 4]; static void de_macro_y(unsigned char* dst, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble Y plane // dstride = 720 = w // The Y plane is divided into blocks of 16x16 pixels // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 16) { for (i = 0; i < 16; i++) { memcpy(dst + x + (y + i) * dstride, src, 16); src += 16; } } } } static void de_macro_uv(unsigned char *dstu, unsigned char *dstv, unsigned char *src, int dstride, int w, int h) { unsigned int y, x, i; // descramble U/V plane // dstride = 720 / 2 = w // The U/V values are interlaced (UVUV...). // Again, the UV plane is divided into blocks of 16x16 UV values. // Each block in transmitted in turn, line-by-line. for (y = 0; y < h; y += 16) { for (x = 0; x < w; x += 8) { for (i = 0; i < 16; i++) { int idx = x + (y + i) * dstride; dstu[idx+0] = src[0]; dstv[idx+0] = src[1]; dstu[idx+1] = src[2]; dstv[idx+1] = src[3]; dstu[idx+2] = src[4]; dstv[idx+2] = src[5]; dstu[idx+3] = src[6]; dstv[idx+3] = src[7]; dstu[idx+4] = src[8]; dstv[idx+4] = src[9]; dstu[idx+5] = src[10]; dstv[idx+5] = src[11]; dstu[idx+6] = src[12]; dstv[idx+6] = src[13]; dstu[idx+7] = src[14]; dstv[idx+7] = src[15]; src += 16; } } } } /*************************************************************************/ int main(int argc, char **argv) { FILE *fin; int i; if (argc == 1) fin = stdin; else fin = fopen(argv[1], "r"); if (fin == NULL) { fprintf(stderr, "cannot open input\n"); exit(-1); } while (fread(frame, sizeof(frame), 1, fin) == 1) { de_macro_y(framey, frame, 720, 720, 576); de_macro_uv(frameu, framev, frame + 720 * 576, 720 / 2, 720 / 2, 576 / 2); fwrite(framey, sizeof(framey), 1, stdout); fwrite(framev, sizeof(framev), 1, stdout); fwrite(frameu, sizeof(frameu), 1, stdout); } fclose(fin); return 0; }”…””}”hj{sbah}”(h]”h ]”h"]”h$]”h&]”h±h²Œforce”‰Œlanguage”Œc”Œhighlight_args”}”uh1jyhŸh³h K0hjhhžhubeh}”(h]”Œraw-format-c-example”ah ]”h"]”Œraw format c example”ah$]”h&]”uh1h´hhÉhžhhŸh³h K.ubeh}”(h]”Œnon-compressed-file-format”ah ]”h"]”Œnon-compressed file format”ah$]”h&]”uh1h´hh¶hžhhŸh³h Kubhµ)”}”(hhh]”(hº)”}”(hŒ9Format of embedded V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data”h]”hŒ9Format of embedded V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data”…””}”(hj¡hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjžhžhhŸh³h KƒubhÛ)”}”(hŒ)Author: Hans Verkuil ”h]”(hŒAuthor: Hans Verkuil <”…””}”(hj¯hžhhŸNh NubhŒ reference”“”)”}”(hŒhverkuil@xs4all.nl”h]”hŒhverkuil@xs4all.nl”…””}”(hj¹hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œmailto:hverkuil@xs4all.nl”uh1j·hj¯ubhŒ>”…””}”(hj¯hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K…hjžhžhubhÛ)”}”(hXwThis section describes the V4L2_MPEG_STREAM_VBI_FMT_IVTV format of the VBI data embedded in an MPEG-2 program stream. This format is in part dictated by some hardware limitations of the ivtv driver (the driver for the Conexant cx23415/6 chips), in particular a maximum size for the VBI data. Anything longer is cut off when the MPEG stream is played back through the cx23415.”h]”hXwThis section describes the V4L2_MPEG_STREAM_VBI_FMT_IVTV format of the VBI data embedded in an MPEG-2 program stream. This format is in part dictated by some hardware limitations of the ivtv driver (the driver for the Conexant cx23415/6 chips), in particular a maximum size for the VBI data. Anything longer is cut off when the MPEG stream is played back through the cx23415.”…””}”(hjÓhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KˆhjžhžhubhÛ)”}”(hŒ™The advantage of this format is it is very compact and that all VBI data for all lines can be stored while still fitting within the maximum allowed size.”h]”hŒ™The advantage of this format is it is very compact and that all VBI data for all lines can be stored while still fitting within the maximum allowed size.”…””}”(hjáhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KŽhjžhžhubhÛ)”}”(hX`The stream ID of the VBI data is 0xBD. The maximum size of the embedded data is 4 + 43 * 36, which is 4 bytes for a header and 2 * 18 VBI lines with a 1 byte header and a 42 bytes payload each. Anything beyond this limit is cut off by the cx23415/6 firmware. Besides the data for the VBI lines we also need 36 bits for a bitmask determining which lines are captured and 4 bytes for a magic cookie, signifying that this data package contains V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data. If all lines are used, then there is no longer room for the bitmask. To solve this two different magic numbers were introduced:”h]”hX`The stream ID of the VBI data is 0xBD. The maximum size of the embedded data is 4 + 43 * 36, which is 4 bytes for a header and 2 * 18 VBI lines with a 1 byte header and a 42 bytes payload each. Anything beyond this limit is cut off by the cx23415/6 firmware. Besides the data for the VBI lines we also need 36 bits for a bitmask determining which lines are captured and 4 bytes for a magic cookie, signifying that this data package contains V4L2_MPEG_STREAM_VBI_FMT_IVTV VBI data. If all lines are used, then there is no longer room for the bitmask. To solve this two different magic numbers were introduced:”…””}”(hjïhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K‘hjžhžhubhÛ)”}”(hX'itv0': After this magic number two unsigned longs follow. Bits 0-17 of the first unsigned long denote which lines of the first field are captured. Bits 18-31 of the first unsigned long and bits 0-3 of the second unsigned long are used for the second field.”h]”hX‘itv0’: After this magic number two unsigned longs follow. Bits 0-17 of the first unsigned long denote which lines of the first field are captured. Bits 18-31 of the first unsigned long and bits 0-3 of the second unsigned long are used for the second field.”…””}”(hjýhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KšhjžhžhubhÛ)”}”(hŒ‚'ITV0': This magic number assumes all VBI lines are captured, i.e. it implicitly implies that the bitmasks are 0xffffffff and 0xf.”h]”hŒ†â€˜ITV0’: This magic number assumes all VBI lines are captured, i.e. it implicitly implies that the bitmasks are 0xffffffff and 0xf.”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h KŸhjžhžhubhÛ)”}”(hŒiAfter these magic cookies (and the 8 byte bitmask in case of cookie 'itv0') the captured VBI lines start:”h]”hŒmAfter these magic cookies (and the 8 byte bitmask in case of cookie ‘itv0’) the captured VBI lines start:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K¢hjžhžhubhÛ)”}”(hŒ«For each line the least significant 4 bits of the first byte contain the data type. Possible values are shown in the table below. The payload is in the following 42 bytes.”h]”hŒ«For each line the least significant 4 bits of the first byte contain the data type. Possible values are shown in the table below. The payload is in the following 42 bytes.”…””}”(hj'hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K¥hjžhžhubhÛ)”}”(hŒ(Here is the list of possible data types:”h]”hŒ(Here is the list of possible data types:”…””}”(hj5hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÚhŸh³h K©hjžhžhubjz)”}”(hXW#define IVTV_SLICED_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL) #define IVTV_SLICED_TYPE_CC 0x4 // Closed Captions (line 21 NTSC) #define IVTV_SLICED_TYPE_WSS 0x5 // Wide Screen Signal (line 23 PAL) #define IVTV_SLICED_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16)”h]”hXW#define IVTV_SLICED_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL) #define IVTV_SLICED_TYPE_CC 0x4 // Closed Captions (line 21 NTSC) #define IVTV_SLICED_TYPE_WSS 0x5 // Wide Screen Signal (line 23 PAL) #define IVTV_SLICED_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16)”…””}”hjCsbah}”(h]”h ]”h"]”h$]”h&]”h±h²j‰‰jŠj‹jŒ}”uh1jyhŸh³h K«hjžhžhubeh}”(h]”Œ9format-of-embedded-v4l2-mpeg-stream-vbi-fmt-ivtv-vbi-data”ah ]”h"]”Œ9format of embedded v4l2_mpeg_stream_vbi_fmt_ivtv vbi data”ah$]”h&]”uh1h´hh¶hžhhŸh³h Kƒubeh}”(h]”Œthe-cx2341x-driver”ah ]”h"]”Œthe cx2341x driver”ah$]”h&]”uh1h´hhhžhhŸh³h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¹NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j…Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j_j\j›j˜j“jjWjTuŒ nametypes”}”(j_‰j›‰j“‰jW‰uh}”(j\h¶j˜hÉjjhjTjžuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.