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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
vbiparse.h
Parse Philips codes and other data from VBI lines.
***************************************************************************/
#pragma once
#ifndef __VBIPARSE_H__
#define __VBIPARSE_H__
#include "osdcomm.h"
/***************************************************************************
CONSTANTS
***************************************************************************/
/* size of packed VBI data */
#define VBI_PACKED_BYTES 16
/* these codes are full 24-bit codes with no parameter data */
#define VBI_CODE_LEADIN 0x88ffff
#define VBI_CODE_LEADOUT 0x80eeee
#define VBI_CODE_STOP 0x82cfff
#define VBI_CODE_CLV 0x87ffff
/* these codes require a mask because some bits are parameters */
#define VBI_MASK_CAV_PICTURE 0xf00000
#define VBI_CODE_CAV_PICTURE 0xf00000
#define VBI_MASK_CHAPTER 0xf00fff
#define VBI_CODE_CHAPTER 0x800ddd
#define VBI_MASK_CLV_TIME 0xf0ff00
#define VBI_CODE_CLV_TIME 0xf0dd00
#define VBI_MASK_STATUS_CX_ON 0xfff000
#define VBI_CODE_STATUS_CX_ON 0x8dc000
#define VBI_MASK_STATUS_CX_OFF 0xfff000
#define VBI_CODE_STATUS_CX_OFF 0x8bc000
#define VBI_MASK_USER 0xf0f000
#define VBI_CODE_USER 0x80d000
#define VBI_MASK_CLV_PICTURE 0xf0f000
#define VBI_CODE_CLV_PICTURE 0x80e000
/***************************************************************************
MACROS
***************************************************************************/
#define VBI_CAV_PICTURE(x) (((((x) >> 16) & 0x07) * 10000) + ((((x) >> 12) & 0x0f) * 1000) + ((((x) >> 8) & 0x0f) * 100) + ((((x) >> 4) & 0x0f) * 10) + ((((x) >> 0) & 0x0f) * 1))
#define VBI_CHAPTER(x) (((((x) >> 16) & 0x07) * 10) + ((((x) >> 12) & 0x0f) * 1))
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
struct vbi_metadata
{
uint8_t white; /* white flag: on or off */
uint32_t line16; /* line 16 code */
uint32_t line17; /* line 17 code */
uint32_t line18; /* line 18 code */
uint32_t line1718; /* most plausible value from lines 17/18 */
};
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
/* parse a Manchester code from a line of video data */
int vbi_parse_manchester_code(const uint16_t *source, int sourcewidth, int sourceshift, int expectedbits, uint32_t *result);
/* compute the "white flag" from a line of video data */
bool vbi_parse_white_flag(const uint16_t *source, int sourcewidth, int sourceshift);
/* parse everything from a video frame */
void vbi_parse_all(const uint16_t *source, int sourcerowpixels, int sourcewidth, int sourceshift, vbi_metadata *vbi);
/* pack the VBI data down into a smaller form for storage */
void vbi_metadata_pack(uint8_t *dest, uint32_t framenum, const vbi_metadata *vbi);
/* unpack the VBI data from a smaller form into the full structure */
void vbi_metadata_unpack(vbi_metadata *vbi, uint32_t *framenum, const uint8_t *source);
#endif /* __VBIPARSE_H__ */
|