diff options
| author | 2008-07-16 14:25:14 +0000 | |
|---|---|---|
| committer | 2008-07-16 14:25:14 +0000 | |
| commit | 894fcaad2847cbd87b0850a42980c30d74069450 (patch) | |
| tree | b667ef113686058466b48db8684824ad84270bb1 | |
| parent | 34b353c1e07d01dc7a6d35e9980263351d85488b (diff) | |
Added logic to parse out the white flag.
| -rw-r--r-- | src/lib/util/vbiparse.c | 35 | ||||
| -rw-r--r-- | src/lib/util/vbiparse.h | 8 | ||||
| -rw-r--r-- | src/tools/makemeta.c | 10 |
3 files changed, 42 insertions, 11 deletions
diff --git a/src/lib/util/vbiparse.c b/src/lib/util/vbiparse.c index 4abb627a748..4dca2ccb5a7 100644 --- a/src/lib/util/vbiparse.c +++ b/src/lib/util/vbiparse.c @@ -26,11 +26,11 @@ ***************************************************************************/ /*------------------------------------------------- - vbi_parse_line - parse a Philips code from a - line of video data + vbi_parse_manchester_code - parse a Manchester + code from a line of video data -------------------------------------------------*/ -int vbi_parse_line(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT8 *result) +int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT8 *result) { UINT8 srcabs[MAX_SOURCE_WIDTH]; UINT8 min, max, mid, srcabsval; @@ -136,3 +136,32 @@ int vbi_parse_line(const UINT16 *source, int sourcewidth, int sourceshift, int e } return expectedbits; } + + +/*------------------------------------------------- + vbi_parse_white_flag - compute the "white + flag" from a line of video data +-------------------------------------------------*/ + +int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift) +{ + int minval = 0xff; + int maxval = 0x00; + int avgval = 0x00; + int diff; + int x; + + /* compute minimum, maximum, and average values across the line */ + for (x = 0; x < sourcewidth; x++) + { + UINT8 yval = source[x] >> sourceshift; + minval = MIN(yval, minval); + maxval = MAX(yval, maxval); + avgval += yval; + } + avgval /= sourcewidth; + diff = maxval - minval; + + /* if there's a spread of at least 0x20, and the average is above 3/4 of the center, call it good */ + return (diff >= 0x20) && (avgval >= minval + 3 * diff / 4); +} diff --git a/src/lib/util/vbiparse.h b/src/lib/util/vbiparse.h index 6bb0e267414..ed34592c159 100644 --- a/src/lib/util/vbiparse.h +++ b/src/lib/util/vbiparse.h @@ -19,7 +19,11 @@ FUNCTION PROTOTYPES ***************************************************************************/ -/* parse a Philips code from a line of video data */ -int vbi_parse_line(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT8 *result); +/* parse a Manchester code from a line of video data */ +int vbi_parse_manchester_code(const UINT16 *source, int sourcewidth, int sourceshift, int expectedbits, UINT8 *result); + +/* compute the "white flag" from a line of video data */ +int vbi_parse_white_flag(const UINT16 *source, int sourcewidth, int sourceshift); + #endif /* __VBIPARSE_H__ */ diff --git a/src/tools/makemeta.c b/src/tools/makemeta.c index e569de7c487..7cfb220f3f8 100644 --- a/src/tools/makemeta.c +++ b/src/tools/makemeta.c @@ -150,9 +150,7 @@ static int generate_from_avi(const char *aviname) int i; /* line 11 contains the white flag */ - white = 0; - if (*BITMAP_ADDR16(bitmap, 11*2 + field, bitmap->width / 2) > 0x8000) - white = 1; + white = vbi_parse_white_flag(BITMAP_ADDR16(bitmap, 11*2 + field, 0), bitmap->width, 8); /* output metadata for *previous* field */ if (frame > 0 || field > 0) @@ -166,18 +164,18 @@ static int generate_from_avi(const char *aviname) /* line 16 contains stop code and other interesting bits */ line16 = 0; - if (vbi_parse_line(BITMAP_ADDR16(bitmap, 16*2 + field, 0), bitmap->width, 8, 24, bits) == 24) + if (vbi_parse_manchester_code(BITMAP_ADDR16(bitmap, 16*2 + field, 0), bitmap->width, 8, 24, bits) == 24) for (i = 0; i < 24; i++) line16 = (line16 << 1) | bits[i]; /* line 17 and 18 contain frame/chapter/lead in/out encodings */ line17 = 0; - if (vbi_parse_line(BITMAP_ADDR16(bitmap, 17*2 + field, 0), bitmap->width, 8, 24, bits) == 24) + if (vbi_parse_manchester_code(BITMAP_ADDR16(bitmap, 17*2 + field, 0), bitmap->width, 8, 24, bits) == 24) for (i = 0; i < 24; i++) line17 = (line17 << 1) | bits[i]; line18 = 0; - if (vbi_parse_line(BITMAP_ADDR16(bitmap, 18*2 + field, 0), bitmap->width, 8, 24, bits) == 24) + if (vbi_parse_manchester_code(BITMAP_ADDR16(bitmap, 18*2 + field, 0), bitmap->width, 8, 24, bits) == 24) for (i = 0; i < 24; i++) line18 = (line18 << 1) | bits[i]; |
