summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/chd.h3
-rw-r--r--src/lib/util/vbiparse.c45
-rw-r--r--src/lib/util/vbiparse.h46
3 files changed, 93 insertions, 1 deletions
diff --git a/src/lib/util/chd.h b/src/lib/util/chd.h
index 7914a9161f9..d8c74dca5d9 100644
--- a/src/lib/util/chd.h
+++ b/src/lib/util/chd.h
@@ -130,6 +130,9 @@
#define AV_METADATA_TAG 0x41564156 /* 'AVAV' */
#define AV_METADATA_FORMAT "FPS:%d.%06d WIDTH:%d HEIGHT:%d INTERLACED:%d CHANNELS:%d SAMPLERATE:%d"
+/* A/V laserdisc frame metadata */
+#define AV_LD_METADATA_TAG 0x41564C44 /* 'AVLD' */
+
/* CHD open values */
#define CHD_OPEN_READ 1
#define CHD_OPEN_READWRITE 2
diff --git a/src/lib/util/vbiparse.c b/src/lib/util/vbiparse.c
index 65f1061cf91..83a3331ca23 100644
--- a/src/lib/util/vbiparse.c
+++ b/src/lib/util/vbiparse.c
@@ -318,7 +318,7 @@ void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, i
else
{
/* if both are frame numbers, and one is not valid BCD, pick the other */
- if ((vbi->line17 & 0xf80000) == 0xf80000 && (vbi->line18 & 0xf80000) == 0xf80000)
+ if ((vbi->line17 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE && (vbi->line18 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE)
{
if ((vbi->line17 & 0xf000) > 0x9000 || (vbi->line17 & 0xf00) > 0x900 || (vbi->line17 & 0xf0) > 0x90 || (vbi->line17 & 0xf) > 0x9)
vbi->line1718 = vbi->line18;
@@ -332,3 +332,46 @@ void vbi_parse_all(const UINT16 *source, int sourcerowpixels, int sourcewidth, i
vbi->line1718 = (vbi->line1718 << 1) | ((bits[0][bitnum] > bits[1][bitnum]) ? (bits[0][bitnum] & 1) : (bits[1][bitnum] & 1));
}
}
+
+
+/*-------------------------------------------------
+ vbi_metadata_pack - pack the VBI data down
+ into a smaller form for storage
+-------------------------------------------------*/
+
+void vbi_metadata_pack(UINT8 *dest, UINT32 framenum, const vbi_metadata *vbi)
+{
+ dest[0] = framenum >> 16;
+ dest[1] = framenum >> 8;
+ dest[2] = framenum >> 0;
+ dest[3] = vbi->white;
+ dest[4] = vbi->line16 >> 16;
+ dest[5] = vbi->line16 >> 8;
+ dest[6] = vbi->line16 >> 0;
+ dest[7] = vbi->line17 >> 16;
+ dest[8] = vbi->line17 >> 8;
+ dest[9] = vbi->line17 >> 0;
+ dest[10] = vbi->line18 >> 16;
+ dest[11] = vbi->line18 >> 8;
+ dest[12] = vbi->line18 >> 0;
+ dest[13] = vbi->line1718 >> 16;
+ dest[14] = vbi->line1718 >> 8;
+ dest[15] = vbi->line1718 >> 0;
+}
+
+
+/*-------------------------------------------------
+ vbi_metadata_unpack - unpack the VBI data
+ from a smaller form into the full structure
+-------------------------------------------------*/
+
+void vbi_metadata_unpack(vbi_metadata *vbi, UINT32 *framenum, const UINT8 *source)
+{
+ *framenum = (source[0] << 16) | (source[1] << 8) | source[2];
+ vbi->white = source[3];
+ vbi->line16 = (source[4] << 16) | (source[5] << 8) | source[6];
+ vbi->line17 = (source[7] << 16) | (source[8] << 8) | source[9];
+ vbi->line18 = (source[10] << 16) | (source[11] << 8) | source[12];
+ vbi->line1718 = (source[13] << 16) | (source[14] << 8) | source[15];
+}
+
diff --git a/src/lib/util/vbiparse.h b/src/lib/util/vbiparse.h
index 5e4a594f6a1..02af240265d 100644
--- a/src/lib/util/vbiparse.h
+++ b/src/lib/util/vbiparse.h
@@ -16,6 +16,46 @@
/***************************************************************************
+ 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
***************************************************************************/
@@ -44,5 +84,11 @@ int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift)
/* parse everything from a video frame */
void vbi_parse_all(const UINT16 *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 *dest, UINT32 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 *framenum, const UINT8 *source);
+
#endif /* __VBIPARSE_H__ */