--- libvideo-capture-v4l-perl-0.901.orig/VBI/Makefile.PL +++ libvideo-capture-v4l-perl-0.901/VBI/Makefile.PL @@ -3,4 +3,5 @@ WriteMakefile( 'NAME' => 'Video::Capture::VBI', 'VERSION_FROM' => 'VBI.pm', + CCFLAGS => '-fPIC', ); --- libvideo-capture-v4l-perl-0.901.orig/VBI/VBI.c +++ libvideo-capture-v4l-perl-0.901/VBI/VBI.c @@ -0,0 +1,1489 @@ +/* + * This file was generated automatically by xsubpp version 1.9508 from the + * contents of VBI.xs. Do not edit this file, edit VBI.xs instead. + * + * ANY CHANGES MADE HERE WILL BE LOST! + * + */ + +#line 1 "VBI.xs" +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include +#include +#include + +#include "../gppport.h" + +/* loosely based on the program vbidecode.cc by Ralph Metzler */ + +typedef unsigned int UI; +typedef unsigned char u8; +typedef U16 u16; + +/* calculates odd parity, medium-efficient */ +static int +parodd(U32 data) +{ + u8 p4[16] = { 0,1,1,0, 1,0,0,1, 1,0,0,1, 0,1,1,0 }; + int parity = 1; + + do { + parity ^= p4[data & 15]; + data >>= 4; + } while (data); + + return parity; +} + +static u8 invtab[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; + +static u8 unhamtab[256] = { + 0x01, 0xff, 0x81, 0x01, 0xff, 0x00, 0x01, 0xff, + 0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07, + 0xff, 0x00, 0x01, 0xff, 0x00, 0x80, 0xff, 0x00, + 0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff, + 0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07, + 0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x87, + 0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff, + 0x86, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07, + 0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09, + 0x02, 0x82, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff, + 0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff, + 0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x83, 0x03, + 0x04, 0xff, 0xff, 0x05, 0x84, 0x04, 0x04, 0xff, + 0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07, + 0xff, 0x05, 0x05, 0x85, 0x04, 0xff, 0xff, 0x05, + 0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff, + 0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09, + 0x0a, 0xff, 0xff, 0x0b, 0x8a, 0x0a, 0x0a, 0xff, + 0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff, + 0xff, 0x0b, 0x0b, 0x8b, 0x0a, 0xff, 0xff, 0x0b, + 0x0c, 0x8c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff, + 0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07, + 0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x8d, 0x0d, + 0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff, + 0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x89, + 0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09, + 0x88, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09, + 0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff, + 0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09, + 0x0f, 0xff, 0x8f, 0x0f, 0xff, 0x0e, 0x0f, 0xff, + 0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff, + 0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x8e, 0xff, 0x0e, +}; + +#define VBI_BPL 2048 + +#define FREQ_PAL 35.468950 +#define FREQ_NTSC 28.636363 +#define FREQ FREQ_PAL + +#define FREQ_VT_PAL 6.9375 +#define FREQ_VT_NTSC 5.72725 +#define FREQ_VT FREQ_VT_PAL /* Replace by FREQ_VT_NTSC and pray that it works */ +/*#define FREQ_VT 6.165*/ /* teletext-like signal on france, 0xe7 instead of 0x27 */ +#define FREQ_CRYPT 4.5 /* found on premiere */ +#define FREQ_VPS 2.5 /* probably only pal */ +#define FREQ_VDAT 2.0 /* videodat */ +#define FREQ_VC 0.77 /* videocrypt, just ignore */ + +#define VBI_VT 0x0001 +#define VBI_VPS 0x0002 +#define VBI_VDAT 0x0004 +#define VBI_VC 0x0008 +#define VBI_OTHER 0x0010 +#define VBI_EMPTY 0x8000 + +typedef long FP; + +#define FP_BITS 16 +#define FP_0_5 D2FP(0.5) + +#define D2FP(d) ((FP)((d) * (1<> FP_BITS) + +#define VT_COLS 40 +#define VT_LINES 36 + +typedef struct { + UI types; /* required types */ + + int offset; /* signal offset */ + int did_agc : 1; /* did we already do agc this frame? */ + + int y; /* the line number */ + u8 *line; /* the current line */ + FP step; /* the bit step */ + FP pos; /* position */ +} decoder; + +static void +decoder_init (decoder *dec, UI types) +{ + dec->types = types; + dec->did_agc = 0; +} + +static void +decoder_scan_start (decoder *dec, UI a, UI b) +{ + u8 *p = dec->line + a; + UI med = 128 - dec->offset; + do + { + if (*p >= med) + break; + } + while (++p < dec->line + b); + + /* find maximum */ + while (p[1] > p[0]) + p++; + + dec->pos = I2FP (p - dec->line); +} + + +static u8 +get_byte (decoder *dec) +{ + u8 byte; + int bit = 8; + + /* if the next bit is a one bit, try to re-center the decoder on it */ + if ((dec->offset + dec->line[FP2I(dec->pos)]) & 0x80) + { + /*if (dec->line[FP2I(dec->pos)] < dec->line[FP2I(dec->pos)+1]) + dec->pos += I2FP(1);*/ /* why is this casuing checksum errors? */ + /*if (dec->line[FP2I(dec->pos)] < dec->line[FP2I(dec->pos)-1]) + dec->pos -= I2FP(1);*/ + } + + byte=0; + do + { + byte >>= 1; + byte |= ((dec->offset + dec->line[FP2I(dec->pos)]) & 0x80); + dec->pos += dec->step; + } + while (--bit); + + return byte; +} + +/* get shift-encoded byte */ +static u8 +get_byte_SE (decoder *dec) +{ + u8 byte; + int bit = 8; + + do + { + byte >>= 1; + byte |= (dec->line[FP2I(dec->pos)] + > dec->line[FP2I(dec->pos + dec->step/2)]) << 7; + dec->pos += dec->step; + } + while (--bit); + + /* if the next bit is a one bit, try to re-center the decoder on it */ + if (dec->line[FP2I(dec->pos)] > 128-dec->offset) + { + if (dec->line[FP2I(dec->pos)] > dec->line[FP2I(dec->pos)+1]) + dec->pos += I2FP(1); + if (dec->line[FP2I(dec->pos)] < dec->line[FP2I(dec->pos)-1]) + dec->pos -= I2FP(1); + } + + return byte; +} + +static u8 +unham4(u8 a) +{ + return unhamtab[a] & 15; +} + +static u8 +unham8(u8 a, u8 b) +{ + u8 c1 = unhamtab[a]; + u8 c2 = unhamtab[b]; + + if ( (c1|c2) & 0x40) + /* 2 bit error */; + + return (c1 & 15) + | (c2 << 4); +} + +static u16 unham16(u8 a, u8 b, u8 c) +{ + U32 d = (((c << 8) | b) << 8) | c; + int A = parodd (d & 0x555555); + int B = parodd (d & 0x666666); + int C = parodd (d & 0x787878); + int D = parodd (d & 0x007f80); + int E = parodd (d & 0x7f8000); + int F = parodd (d & 0xffffff); + int bit; + + d = (((d >> 16) & 0x7f) << 11) + | (((d >> 8) & 0x7f) << 4) + | (((d >> 4) & 0x07) << 1) + | (((d >> 2) & 0x01) ); + + if (A&B&C&D&E) + return d; + if (F) + return -1; /* double bit error */ + + /* correct the single bit error */ + return d ^ (1 << (31 - 16*E + 8*D + 4*C + 2*B + A)); +} + +static unsigned char +rev (unsigned char x) +{ + return ((x>>7)&1)<<0 | + ((x>>6)&1)<<1 | + ((x>>5)&1)<<2 | + ((x>>4)&1)<<3 | + ((x>>3)&1)<<4 | + ((x>>2)&1)<<5 | + ((x>>1)&1)<<6 | + ((x>>0)&1)<<7; +} + +static SV * +decoder_decode_vps (decoder *dec, u8 *data) +{ + AV *av = newAV (); + + av_push (av, newSViv (VBI_VPS)); + av_push (av, newSVpvn (data+3, 1)); + av_push (av, newSViv (data[4] & 3)); /* "unknown", "stereo ", "mono ", "dual " */ + /* ch, day, mon, hour, min */ + av_push (av, newSViv (rev (data[ 4]) <<12 & 0xf000 + | rev (data[10]) & 0x00c0 + | rev (data[12]) <<10 & 0x0c00 + | rev (data[13]) << 2 & 0x0300 + | rev (data[13]) & 0x003f)); + av_push (av, newSViv (rev (data[10]) >> 1 & 31)); + av_push (av, newSViv (rev (data[10]) << 3 & 8 | rev (data[11]) >> 5)); + av_push (av, newSViv (rev (data[11]) & 31)); + av_push (av, newSViv (rev (data[12]) >> 2)); + av_push (av, newSViv (rev (data[14]))); + + return newRV_noinc ((SV*)av); +} + +static SV * +decoder_decode_vt (decoder *dec, u8 *data) +{ + AV *av = newAV (); + u8 mpag = unham8 (data[3], data[4]); + u8 mag = mpag & 7; + u8 pack = (mpag & 0xf8) >> 3; + + av_push (av, newSViv (VBI_VT)); + av_push (av, newSViv (mag)); + av_push (av, newSViv (pack)); + + switch (pack) + { + /* ets300-706 */ + case 0: + av_push (av, newSVpvn (data+5, 40)); + av_push (av, newSViv (unham8 (data[5], data[6]) | (mag << 8))); + av_push (av, newSViv (unham8 (data[7], data[8]) + | (unham8 (data[9], data[10]) << 8) + | (unham8 (data[11], data[12]) << 16))); + break; + case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: + case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: + case 21: case 22: case 23: case 24: case 25: + av_push (av, newSVpvn (data+5, 40)); + break; + case 26: case 27: case 28: case 29: /* enhancement packets */ + av_push (av, newSViv (unham4 (data[5]))); + av_push (av, newSViv (unham16 (data[ 6], data[ 7], data[ 8]))); + av_push (av, newSViv (unham16 (data[ 9], data[10], data[11]))); + av_push (av, newSViv (unham16 (data[12], data[13], data[14]))); + av_push (av, newSViv (unham16 (data[15], data[16], data[17]))); + av_push (av, newSViv (unham16 (data[18], data[19], data[20]))); + av_push (av, newSViv (unham16 (data[21], data[22], data[23]))); + av_push (av, newSViv (unham16 (data[24], data[25], data[26]))); + av_push (av, newSViv (unham16 (data[27], data[28], data[29]))); + av_push (av, newSViv (unham16 (data[30], data[31], data[32]))); + av_push (av, newSViv (unham16 (data[33], data[34], data[35]))); + av_push (av, newSViv (unham16 (data[36], data[37], data[38]))); + av_push (av, newSViv (unham16 (data[39], data[40], data[41]))); + av_push (av, newSViv (unham16 (data[42], data[43], data[44]))); + break; + /* ets300-706 & ets300-231 */ + case 30: + { + UI dc = unham4 (data[5]); + av_push (av, newSViv (dc)); + if ((dc >> 1) == 0) + { + av_push (av, newSViv (unham8 (data[6], data[7]) | (mag << 8))); + av_push (av, newSViv (unham8 (data[8], data[9]) + | unham8 (data[10], data[11]) << 8)); + av_push (av, newSViv (rev (data[12]) << 8 | rev (data[13]))); + } + else if ((dc >> 1) == 8) + { + /* pdc */ + } + } + break; + case 31: + { + UI ft = unham4 (data[5]); + UI al = unham4 (data[6]); + UI i, addr = 0; + + /* ets300-708, IDL */ + /* http://sunsite.cnlab-switch.ch/ftp/mirror/internet-drafts/draft-ietf-ipvbi-tv-signal-00.txt */ + + for(i=0; ipos; + u8 data[6]; + + av_push (av, newSViv (VBI_OTHER)); + + dec->step = D2FP (FREQ / FREQ_CRYPT); /* found on premiere */ + data [0] = get_byte (dec); + data [1] = get_byte (dec); + data [2] = get_byte (dec); + if (data[0] == 0x55 && data[1] == 0xd0 && data[2] == 0x18) + { + /* premiere */ + av_push (av, newSViv (1)); + } + else + av_push (av, newSViv (0)); + + return newRV_noinc ((SV*)av); +} + +static SV * +decoder_decode_empty (decoder *dec) +{ + AV *av = newAV (); + av_push (av, newSViv (VBI_EMPTY)); + return newRV_noinc ((SV*)av); +} + +static SV * +decoder_decode (decoder *dec, UI y, u8 *line) +{ + UI type; + u8 data[45]; /* 45 bytes per line are max. */ + UI i; + int did_agc; + + type = VBI_VT | VBI_EMPTY | VBI_OTHER | VBI_VC; /* can be everywhere */ + if (y == 16 - 7) type |= VBI_VPS; + if (y > 17 - 7) type |= VBI_VDAT; + + type &= dec->types; + + /* don't do anything unless we need to */ + if (type) + { + dec->line = line; + dec->y = y; + dec->pos = 0; + + did_agc = dec->did_agc; + + /* maybe do agc? */ + if (!dec->did_agc || y == 20-7) + { + u8 *n = line + 120; + u8 max = 0, min = 255; + do + { + if (*n > max) max = *n; + if (*n < min) min = *n; + } + while (++n < line + 300); + + if (max > min + 30) + { + dec->offset = 128 - (((int)max + (int)min) >> 1); + dec->did_agc = 1; + } + } + + if (dec->did_agc) + { + if (type & VBI_VT) + { + dec->step = D2FP (FREQ / FREQ_VT); + decoder_scan_start (dec, 50, 350); + + data[0] = get_byte (dec); + if ((data[0] & 0xfe) == 0x54) + { + data[1] = get_byte (dec); + switch (data[1]) + { + case 0x27: + dec->pos -= dec->step * 2; + case 0x4e: + dec->pos -= dec->step * 2; + case 0x9d: + dec->pos -= dec->step * 2; + case 0x75: + dec->pos -= dec->step * 2; + case 0xd5: + dec->pos -= dec->step * 2; + data[1] = 0x55; + case 0x55: + break; + default: + ; /* no teletext page */ + } + + if (data[1] == 0x55) + { + data[2] = get_byte (dec); + if (data[2] == 0x27 || data[2] == 0xe7) + { + for (i = 3; i < 45; i++) + data[i] = get_byte (dec); + return decoder_decode_vt (dec, data); + } + } + } + } + + if (type & VBI_VPS) + { + decoder_scan_start (dec, 150, 260); + dec->step = D2FP (FREQ / FREQ_VPS); /* shift encoding, two "pixels"/bit (skip the 2nd) */ + data[0] = get_byte_SE (dec); + if (data[0] == 0xff) + { + data[1] = get_byte_SE (dec); + if (data[1] == 0x5d || data[1] == 0x5f) + { + for (i = 2; i < 16; i++) + data[i] = get_byte_SE (dec); + return decoder_decode_vps (dec, data); + } + } + } + +#if 0 + if (type & VBI_VDAT) + { + dec->step = D2FP (FREQ / FREQ_VDAT); + decoder_scan_start (dec, 150, 200); + } + + if (type & VBI_VC) + { + dec->step = D2FP (FREQ / FREQ_VC); + decoder_scan_start (dec, 150, 200); + } +#endif + + /* watch out for empty lines, test signals etc.. */ + if (type & VBI_OTHER) + { + dec->did_agc = did_agc; /* other signals do not affect agc, yet */ + + dec->step = D2FP (FREQ); + decoder_scan_start (dec, 100, 500); + if (dec->pos < I2FP (450)) + return decoder_decode_other (dec); + } + } + + dec->did_agc = did_agc; + + if (type & VBI_EMPTY) + return decoder_decode_empty (dec); + } + + return 0; +} + +/* vtx decoding routines taken from videotext-0.6.971023, + * Copyright (c) 1994-96 Martin Buck */ + +#define VTX_COLMASK 0x07 +#define VTX_BGMASK (0x07 << 3) +#define VTX_G1 (1 << 6) +#define VTX_GRSEP (1 << 8) +#define VTX_HIDDEN (1 << 9) +#define VTX_BOX (1 << 10) +#define VTX_FLASH (1 << 11) +#define VTX_DOUBLE1 (1 << 12) +#define VTX_DOUBLE2 (1 << 13) +#define VTX_INVERT (1 << 14) +#define VTX_DOUBLE (VTX_DOUBLE1 | VTX_DOUBLE2) + +static const u8 g0_to_iso_table[256] = + " " + " !\"#$%&'()*+,-./0123456789:;<=>?" + "@ABCDEFGHIJKLMNOPQRSTUVWXYZAOU^#" + "-abcdefghijklmnopqrstuvwxyzaous#" + " " + " " + " " + " "; + +/* one-to-one copy */ +static int +decode_vtpage (u8 *src, UI lines, u8 *chr, u16 *attr) +{ + UI line, col, pos, graphics, grhold, doubleht, nextattr = 0; + u16 *lastattr, default_attrib = 7, next_attrib; + u8 c, *lastchr, default_chr = ' '; + UI lang; + + lang = 4; + pos = 0; + doubleht = 0; + + for (line = 0; line < lines; line++) { + lastchr = &default_chr; + lastattr = &default_attrib; + graphics = grhold = 0; + if (doubleht && pos > 40) { + for (col = 0; col <= 39; col++) { + if (attr[pos - 40] & VTX_DOUBLE1) { + chr[pos] = chr[pos - 40]; + chr[pos - 40] = ' '; + attr[pos] = (attr[pos - 40] & ~VTX_DOUBLE1) | VTX_DOUBLE2; + } else { + chr[pos] = ' '; + attr[pos] = attr[pos - 40]; + } + pos++; + } + doubleht = 0; + } else { + for (col = 0; col <= 39; col++) { + c = src[pos]; + if (parodd(c)) { + chr[pos] = 254; /* Parity error */ + attr[pos] = 7; + /* return 0 */ /*?*/ + } else if ((c & 0x7f) >= 32) { /* Normal character */ + c &= 0x7f; + if (!graphics || (c >= 64 && c <= 95)) { + chr[pos] = g0_to_iso_table [c]; + attr[pos] = *lastattr; + } else { + chr[pos] = c + (c >= 96 ? 64 : 96); + attr[pos] = *lastattr | VTX_G1; + } + } else { + c &= 0x7f; + chr[pos] = ((grhold && graphics ) ? *lastchr : ' '); + if (c <= 7) { /* Set alphanumerics-color */ + attr[pos] = *lastattr; + next_attrib = (*lastattr & ~(VTX_COLMASK | VTX_HIDDEN)) + c; + nextattr = 1; + graphics = 0; + } else if (c == 8 || c == 9) { /* Flash on/off */ + attr[pos] = (*lastattr & ~VTX_FLASH) + VTX_FLASH * (c == 8); + } else if (c == 10 || c == 11) { /* End/start box */ + attr[pos] = (*lastattr & ~VTX_BOX) + VTX_BOX * (c == 11); + } else if (c == 12 || c == 13) { /* Normal/double height */ + attr[pos] = (*lastattr & ~VTX_DOUBLE1) + VTX_DOUBLE1 * (c == 13); + if (c == 13) + doubleht = 1; + } else if (c == 14 || c == 15 || c == 27) { /* SO, SI, ESC (ignored) */ + attr[pos] = *lastattr; + } else if (c >= 16 && c <= 23) { /* Set graphics-color */ + attr[pos] = *lastattr; + next_attrib = (*lastattr & ~(VTX_COLMASK | VTX_HIDDEN)) + c - 16; + nextattr = 1; + graphics = 1; + } else if (c == 24) { /* Conceal display */ + attr[pos] = *lastattr | VTX_HIDDEN; + } else if (c == 25 || c == 26) { /* Contiguous/separated graphics */ + attr[pos] = (*lastattr & ~VTX_GRSEP) + VTX_GRSEP * (c == 26); + } else if (c == 28) { /* Black background */ + attr[pos] = *lastattr & ~VTX_BGMASK; + } else if (c == 29) { /* Set background */ + attr[pos] = (*lastattr & ~VTX_BGMASK) + ((*lastattr & VTX_COLMASK) << 3); + } else if (c == 30 || c == 31) { /* Hold/release graphics */ + attr[pos] = *lastattr; + grhold = (c == 30); + if (grhold && graphics) + chr[pos] = *lastchr; + } else { + return 0; + } + } + lastchr = chr + pos; + if (nextattr) { + lastattr = &next_attrib; + nextattr = 0; + } else { + lastattr = attr + pos; + } + pos++; + } + } + } + return 1; +} + +static SV * +decode_ansi (u8 *chr, u16 *atr) +{ + UI x; + SV *sv = newSVpvn ("", 0); + u16 o; + + for (x=0; x < VT_COLS; x++) + { + u16 a = *atr++; + if (x == 0 || (a & 0x07) != (o & 0x07)) + sv_catpvf (sv, "\x1b[3%dm", a & 7); + if (x == 0 || (a & 0x38) != (o & 0x38)) + sv_catpvf (sv, "\x1b[4%dm", (o & 0x38)>>3); + if (x == 0 || (a & VTX_FLASH) != (o & VTX_FLASH)) + sv_catpvf (sv, "\x1b[%sm", a & VTX_FLASH ? "7" : ""); + + sv_catpvf (sv, "%c", a & VTX_G1 ? 'x' : *chr); + + chr++; + o = a; + } + + sv_catpv (sv, "\x1b[37;40;0m"); + + return sv; +} + +#define valid_packet(sv) (SvPOK(packet) && SvCUR(packet) == 40) +#define consume_byte(store) \ + if (bp >= 39) \ + { \ + SV **sv = av_fetch(stream, pi, 0); pi++; \ + if (!sv) \ + goto eostream; \ + packet = *sv; \ + if (!valid_packet (pascket)) \ + goto skip; \ + p = SvPV_nolen (packet); \ + bp = 0; \ + } \ + (store) = p[++bp] + +static void +decode_stream (AV *stream) +{ + dSP; + + while (av_len (stream) >= 0) + { + UI pi = 1; + SV *packet = *av_fetch(stream, 0, 1); + + if (valid_packet (packet)) + { + u8 *p = SvPV_nolen(packet); + u8 bp = p[0] == 0xff ? p[1] : unham4 (p[0])*3+1; + + if (bp <= 12*3+1 && p[bp] == 0xa1) + { + u8 buf[4]; + + consume_byte (buf[0]); consume_byte (buf[1]); + consume_byte (buf[2]); consume_byte (buf[3]); + + { + u16 sh = unham8 (buf[0], buf[1]) | unham8 (buf[2], buf[3]) << 8; + u8 bt = sh & 0x1f; + u16 bl = sh >> 5; + SV *block = sv_2mortal (newSVpvn (&bt, 1)); + + while (bl--) + { + consume_byte (buf[0]); + sv_catpvn (block, buf, 1); + } + + EXTEND (SP, 1); + PUSHs (block); + + /* optimize, do only when still in first packet! */ + do { + if (bp >= 39) + break; + + bp++; + if (p[bp] == 0xa1) + { + p[0] = 0xff; + p[1] = bp; + pi--; + break; + } + } while (p[bp] = 0x5e); + } + } + } + +skip: + while (pi--) + SvREFCNT_dec(av_shift(stream)); + } +eostream: + + PUTBACK; +} + +static u8 * +unham_block (u8 *src, UI len, u8 *dst, UI dlen) +{ + u16 sh = *src | (len-1)<<5; + u8 sum = ( sh & 15) + + ((sh >> 4) & 15) + + ((sh >> 8) & 15) + + ((sh >> 12) & 15); + + if (len < 5) + return 0; + + sum += unham8 (src[1], src[2]); + src += 3; len -= 3; + + dlen--; + + if (len < dlen) + return 0; + + while (dlen) + { + *dst = unham8 (src[0], src[1]); + sum += (*dst >> 4) + (*dst & 15); +#if 0 + printf ("%02x ", *dst); +#endif + dst++; src += 2; dlen--; + } +#if 0 + printf ("\n"); + printf ("sh = %04x, len = %02x, sum = %02x\n", sh, len, sum); +#endif + if (sum) + return 0; + + return src; +} + +/* must not be a macro, see nvec */ +static U32 +vec(u8 *d, UI bit, UI len) +{ + U32 word = bit >> 3; + + /*printf ("vec(%d,%d) %d (%d)\n",bit,len,(bit & 7) + len,(bit & 7) + len < 32);*/ + assert ((bit & 7) + len < 32); + + word = (d[word] ) + | (d[word+1] << 8) + | (d[word+2] << 16) + | (d[word+3] << 24); + + return (word >> (bit & 7)) & (((U32)1 << len) - 1); +} + +#define hv_store_sv(name,value) hv_store (hv, #name, strlen(#name), (SV*)(value), 0) +#define hv_store_iv(name,value) hv_store_sv (name, newSViv (value)) +#define nvec(bits) vec (c, (ofs += (bits)) - (bits), (bits)) + +#define decode_escape_sequences(av) \ + { \ + UI no_escapes = nvec (8); \ + av = newAV (); \ + while (no_escapes--) \ + { \ + AV *esc = newAV (); \ + av_push (esc, newSViv (nvec (10))); \ + av_push (esc, newSViv (nvec (6))); \ + av_push (esc, newSViv (nvec (8))); \ + av_push (av, newRV_noinc((SV*)esc)); \ + } \ + } + +#define decode_transparent_string(sv, len) \ + { \ + UI l = len; \ + sv = newSVpvn (s, l); \ + s += l; \ + while (l--) \ + SvPV_nolen (sv)[l] &= 0x7f; \ + } + +#define decode_descriptor_loop(av, ll) \ + av = newAV (); \ + while (ll--) \ + { \ + AV *desc = newAV (); \ + av_push (desc, newSViv (nvec (6))); \ + av_push (desc, newSViv (nvec (6))); \ + av_push (desc, newSViv (nvec (8))); \ + av_push (av, newRV_noinc((SV*)desc)); \ + } + +static void +decode_epg (HV *hv, UI appid, u8 *c, u8 *s) +{ + UI ofs = 16; + UI len; + AV *av; + SV *sv; + + hv_store_iv (ca_mode, nvec(2)); + hv_store_iv (_copyright, nvec(1)); + + ofs++; /* reserved */ + + switch (appid) + { + case 1: + { + hv_store_iv (epg_version, nvec( 6)); + hv_store_iv (epg_version_swo, nvec( 6)); + hv_store_iv (no_navigation, nvec(16)); + hv_store_iv (no_osd, nvec(16)); + hv_store_iv (no_message, nvec(16)); + hv_store_iv (no_navigation_swo,nvec(16)); + hv_store_iv (no_osd_swo, nvec(16)); + hv_store_iv (no_message_swo, nvec(16)); + len = nvec(8); + hv_store_iv (this_network_op, nvec( 8)); + decode_transparent_string (sv, nvec (5)); + hv_store_sv (service_name, sv); + hv_store_iv (no_updates, nvec( 1)); + + ofs += 2; + + av = newAV (); + while (len--) + { + HV *hv = newHV (); + int LTO; + hv_store_iv (cni, nvec (16)); + LTO = nvec (7) * 15; + if (nvec(1)) + LTO = -LTO; + hv_store_iv (lto, LTO); + hv_store_iv (no_days, nvec( 5)); + decode_transparent_string (sv, nvec( 5)); + hv_store_sv (netwop_name, sv); + hv_store_iv (default_alphabet, nvec( 7)); + hv_store_iv (prog_start_no, nvec(16)); + hv_store_iv (prog_stop_no, nvec(16)); + hv_store_iv (prog_stop_no_swo, nvec(16)); + hv_store_iv (network_add_info, nvec(11)); + + av_push (av, newRV_noinc ((SV*)hv)); + } + hv_store_sv (networks, newRV_noinc ((SV*)av)); + break; + } + case 2: + { + UI background_reuse; + + hv_store_iv (block_no, nvec(16)); + hv_store_iv (audio_mode, vec(c, ofs, 12) & 3); + hv_store_iv (feature_flags, nvec(12)); + hv_store_iv (netwop_no, nvec( 8)); + hv_store_iv (start_time, nvec(16)); + hv_store_iv (start_date, nvec(16)); + hv_store_iv (stop_time, nvec(16)); + hv_store_iv (_pil, nvec(20)); + hv_store_iv (parental_rating, nvec( 4)); + hv_store_iv (editorial_rating,nvec( 3)); + { + UI no_themes = nvec( 3); + UI no_sortcrit = nvec( 3); + UI descriptor_looplength = nvec( 6); + background_reuse = nvec( 1); + + av = newAV (); + while (no_themes--) + av_push (av, newSViv (nvec (8))); + hv_store_sv (themes, newRV_noinc((SV*)av)); + + av = newAV (); + while (no_sortcrit--) + av_push (av, newSViv (nvec (8))); + hv_store_sv (sortcrits, newRV_noinc((SV*)av)); + + decode_descriptor_loop (av, descriptor_looplength); + hv_store_sv (descriptors, newRV_noinc((SV*)av)); + + ofs = (ofs+7) & ~7; + + decode_escape_sequences (av); + hv_store_sv (title_escape_sequences, newRV_noinc((SV*)av)); + decode_transparent_string (sv, nvec (8)); + hv_store_sv (title, sv); + } + + if (background_reuse) + hv_store_iv (title_length, nvec (16)); + else + { + decode_escape_sequences (av); + hv_store_sv (shortinfo_escape_sequences, newRV_noinc((SV*)av)); + decode_transparent_string (sv, nvec (8)); + hv_store_sv (shortinfo, sv); + + len = nvec (3); + ofs += 2; + switch (len) + { + case 0: + decode_escape_sequences (av); + hv_store_sv (longinfo_escape_sequences, newRV_noinc((SV*)av)); + decode_transparent_string (sv, nvec (8)); + hv_store_sv (longinfo, sv); + break; + case 1: + decode_escape_sequences (av); + hv_store_sv (longinfo_escape_sequences, newRV_noinc((SV*)av)); + decode_transparent_string (sv, nvec (10)); + hv_store_sv (longinfo, sv); + break; + default: + printf ("UNKNOWN LONGINFO TYPE %d\n", len); + } + } + + break; + } + case 3: + { + UI descriptor_ll; + hv_store_iv (block_no, nvec(16)); + hv_store_iv (header_size, nvec( 2)); + len = nvec(4); + hv_store_iv (message_size, nvec( 3)); + ofs++; + descriptor_ll = nvec(6); + decode_descriptor_loop (av, descriptor_ll); + hv_store_sv (descriptors, newRV_noinc((SV*)av)); + ofs = (ofs+7) & ~7; + + decode_escape_sequences (av); + hv_store_sv (header_escape_sequences, newRV_noinc((SV*)av)); + + decode_transparent_string (sv, nvec(8)); + hv_store_sv (header, sv); + + hv_store_iv (message_attribute,nvec(8)); + + av = newAV (); + while (len--) + { + AV *av2; + UI len; + HV *hv = newHV (); + + hv_store_iv (next_id, nvec(16)); + hv_store_iv (next_type, nvec( 4)); + + len = nvec(4); + av2 = newAV (); + while (len--) + { + UI kind = nvec(8); + av_push (av2, newSViv (kind)); + switch (kind) + { + case 0x02: case 0x10: case 0x11: case 0x18: + case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: + case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: + case 0x40: case 0x41: + av_push (av2, newSViv (nvec ( 8))); + break; + + case 0x80: case 0x81: + av_push (av2, newSViv (nvec (16))); + break; + + case 0xc0: + av_push (av2, newSViv (nvec (12))); + av_push (av2, newSViv (nvec (12))); + break; + + case 0xc8: case 0xc9: + av_push (av2, newSViv (nvec (24))); + break; + + default: + abort (); + } + } + hv_store_sv (attributes, newRV_noinc((SV*)av2)); + + decode_escape_sequences (av2); + hv_store_sv (header_escape_sequences, newRV_noinc((SV*)av2)); + decode_transparent_string (sv, nvec(8)); + hv_store_sv (event, sv); + + av_push (av, newRV_noinc((SV*)hv)); + } + hv_store_sv (events, newRV_noinc((SV*)av)); + + break; + } + case 4: + { + UI block_no = nvec (16); + UI descriptor_ll; + UI msg_len; + hv_store_iv (block_no, block_no); + hv_store_iv (message_attribute,nvec(8)); + hv_store_iv (header_size, nvec(3)); + hv_store_iv (message_size, nvec(3)); + descriptor_ll = nvec(6); + if (!block_no) + { + decode_escape_sequences (av); + hv_store_sv (message_escape_sequences, newRV_noinc((SV*)av)); + msg_len = nvec(10); + ofs += 6; + } + + decode_escape_sequences (av); + hv_store_sv (header_escape_sequences, newRV_noinc((SV*)av)); + + decode_transparent_string (sv, nvec(8)); + hv_store_sv (header, sv); + + if (!block_no) + { + decode_transparent_string (sv, msg_len); + hv_store_sv (message, sv); + } + + decode_descriptor_loop (av, descriptor_ll); + hv_store_sv (descriptors, newRV_noinc((SV*)av)); + break; + } + case 5: + { + UI descriptor_ll; + hv_store_iv (block_no, nvec(16)); + descriptor_ll = nvec(6); + decode_descriptor_loop (av, descriptor_ll); + hv_store_sv (descriptors, newRV_noinc((SV*)av)); + ofs = (ofs+7) & ~7; + + decode_escape_sequences (av); + hv_store_sv (message_escape_sequences, newRV_noinc((SV*)av)); + + decode_transparent_string (sv, nvec(10)); + hv_store_sv (message, sv); + + break; + } + default: + printf ("UNKNOWN EPG DATATYPE ($%02x)\n", appid); + } +} + +static SV * +decode_block(u8 *b, UI len, AV *bi) +{ + dSP; + u8 ctrl[1024]; + u8 bt = *b; + + if (bt == 0) + { + if ((b = unham_block (b, len, ctrl, (len-1)>>1 ))) + { + UI app_no = ctrl[0]; + UI app; + av_clear (bi); + for (app=1; app<=app_no; app++) + av_store (bi, app, newSViv (vec (ctrl, app*16-8, 16))); + } + } + else if (len >= 5) + { + if (bt <= av_len (bi) && SvOK(*av_fetch (bi, bt, 0))) + { + u16 appid = SvIV (*av_fetch (bi, bt, 0)); + if (appid == 0) /* EPG */ + { + if ((b = unham_block (b, len, ctrl, unham8 (b[3], b[4]) | (unham4 (b[5]) << 8) & 1023))) + { + HV *hv = newHV (); + /* _now_ we have an epg structure. decode it */ + + appid = vec(ctrl,10,6); + EXTEND (SP, 2); + PUSHs (sv_2mortal (newSViv (appid))); + PUSHs (sv_2mortal (newRV_noinc ((SV*)hv))); + + decode_epg (hv, appid, ctrl, b); + } + else + printf ("checksum error found block %d, len %d, appid = %d (clen 0)\n", bt, len, appid); + } + else + /* other applications not defined (to my knowledge) */; + } + else + /* no bundle info: can't parse yet */; + } + + PUTBACK; +} + +#line 1210 "VBI.c" +XS(XS_Video__Capture__VBI_unham4); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_unham4) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::unham4(data)"); + { + SV * data = ST(0); + int RETVAL; + dXSTARG; +#line 1208 "VBI.xs" + STRLEN len; + unsigned char *d = (unsigned char *)SvPV (data, len); + + if (len < 1) + croak ("unham4: length must be at least 1"); + + RETVAL = unham4 (*d); +#line 1229 "VBI.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__VBI_unham8); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_unham8) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::unham8(data)"); + { + SV * data = ST(0); + int RETVAL; + dXSTARG; +#line 1222 "VBI.xs" + STRLEN len; + unsigned char *d = (unsigned char *)SvPV (data, len); + + if (len < 2) + croak ("unham8: length must be at least 2"); + + RETVAL = unham8 (d[0], d[1]); +#line 1253 "VBI.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__VBI_decode_field); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_decode_field) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::decode_field(field, types)"); + SP -= items; + { + SV * field = ST(0); + unsigned int types = (unsigned int)SvUV(ST(1)); +#line 1237 "VBI.xs" + UI lines = SvCUR(field) / VBI_BPL; + UI line; + decoder dec; + + decoder_init (&dec, types); + + EXTEND (SP, lines); + for (line = 0; line < lines; line++) + { + SV *sv = decoder_decode (&dec, line, ((u8*)SvPV_nolen(field)) + line * VBI_BPL); + if (sv) + PUSHs (sv_2mortal (sv)); + } +#line 1283 "VBI.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__VBI_decode_vtpage); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_decode_vtpage) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::decode_vtpage(data)"); + SP -= items; + { + SV * data = ST(0); +#line 1255 "VBI.xs" + u8 chr[VT_COLS*VT_LINES]; + u16 atr[VT_COLS*VT_LINES]; + UI lines; + + if (!SvPOK(data)) + XSRETURN_EMPTY; + + lines = SvCUR(data) / VT_COLS; + + if (lines > VT_LINES) + croak ("videotext cannot have more than %d lines (argument has %d lines)\n", VT_LINES, lines); + + Zero(chr, VT_COLS*VT_LINES, u8); + Zero(atr, VT_COLS*VT_LINES, u16); + if (decode_vtpage (SvPV_nolen(data), lines, chr, atr)) + { + AV *av = newAV (); + UI n; + + for (n = 0; n < VT_COLS*lines; n++) + av_push (av, newSViv (atr[n])); + + EXTEND (SP, 2); + PUSHs (sv_2mortal (newSVpvn (chr, VT_COLS*lines))); + PUSHs (sv_2mortal (newRV_noinc ((SV*)av))); + } +#line 1325 "VBI.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__VBI_decode_ansi); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_decode_ansi) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::decode_ansi(chr, atr)"); + SP -= items; + { + SV * chr = ST(0); + SV * atr = ST(1); +#line 1289 "VBI.xs" + UI lines = SvCUR(chr) / VT_COLS; + UI attr_i = 0; + u8 *_chr = SvPV_nolen (chr); + u16 _atr[VT_COLS]; + + EXTEND (SP, lines); + + while (lines--) + { + UI attr_j; + for(attr_j = 0; attr_j < VT_COLS; attr_j++) + _atr[attr_j] = SvIV (*av_fetch ((AV*)SvRV (atr), attr_i+attr_j, 1)); + + PUSHs (sv_2mortal (decode_ansi (_chr, _atr))); + + _chr += VT_COLS; + attr_i += VT_COLS; + } +#line 1360 "VBI.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__VBI_bcd2dec); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI_bcd2dec) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::bcd2dec(bcd)"); + { + unsigned int bcd = (unsigned int)SvUV(ST(0)); + unsigned int RETVAL; + dXSTARG; +#line 1312 "VBI.xs" + UI digit = 1; + RETVAL = 0; + while (bcd) + { + if ((bcd & 15) > 9) + XSRETURN_EMPTY; + + RETVAL += (bcd & 15) * digit; + digit *= 10; + bcd >>= 4; + } +#line 1388 "VBI.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__VBI__EPG_decode_stream); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI__EPG_decode_stream) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::EPG::decode_stream(stream)"); + SP -= items; + { + SV * stream = ST(0); +#line 1334 "VBI.xs" + if (!SvROK(stream) || SvTYPE(SvRV(stream)) != SVt_PVAV) + croak ("decode_epg stream works on arrayrefs"); + + PUTBACK; + decode_stream ((AV*)SvRV(stream)); + SPAGAIN; +#line 1410 "VBI.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__VBI__EPG_decode_block); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__VBI__EPG_decode_block) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::VBI::EPG::decode_block(block, bundle)"); + SP -= items; + { + SV * block = ST(0); + SV * bundle = ST(1); + SV * RETVAL; +#line 1346 "VBI.xs" + if (!SvROK(bundle) || SvTYPE(SvRV(bundle)) != SVt_PVAV) + croak ("bundle info must be arrayref"); + + PUTBACK; + decode_block (SvPV_nolen(block), SvCUR(block), (AV*)SvRV(bundle)); + SPAGAIN; +#line 1434 "VBI.c" + PUTBACK; + return; + } +} + +#ifdef __cplusplus +extern "C" +#endif +XS(boot_Video__Capture__VBI); /* prototype to pass -Wmissing-prototypes */ +XS(boot_Video__Capture__VBI) +{ + dXSARGS; + char* file = __FILE__; + + XS_VERSION_BOOTCHECK ; + + newXSproto("Video::Capture::VBI::unham4", XS_Video__Capture__VBI_unham4, file, "$"); + newXSproto("Video::Capture::VBI::unham8", XS_Video__Capture__VBI_unham8, file, "$"); + newXSproto("Video::Capture::VBI::decode_field", XS_Video__Capture__VBI_decode_field, file, "$$"); + newXSproto("Video::Capture::VBI::decode_vtpage", XS_Video__Capture__VBI_decode_vtpage, file, "$"); + newXS("Video::Capture::VBI::decode_ansi", XS_Video__Capture__VBI_decode_ansi, file); + newXS("Video::Capture::VBI::bcd2dec", XS_Video__Capture__VBI_bcd2dec, file); + newXSproto("Video::Capture::VBI::EPG::decode_stream", XS_Video__Capture__VBI__EPG_decode_stream, file, "$"); + newXSproto("Video::Capture::VBI::EPG::decode_block", XS_Video__Capture__VBI__EPG_decode_block, file, "$$"); + + /* Initialisation Section */ + +#line 1354 "VBI.xs" +{ + HV *stash = gv_stashpvn("Video::Capture::VBI", 19, TRUE); + + newCONSTSUB(stash,"VBI_VT", newSViv(VBI_VT)); + newCONSTSUB(stash,"VBI_VPS", newSViv(VBI_VPS)); + newCONSTSUB(stash,"VBI_VDAT", newSViv(VBI_VDAT)); + newCONSTSUB(stash,"VBI_VC", newSViv(VBI_VC)); + newCONSTSUB(stash,"VBI_EMPTY", newSViv(VBI_EMPTY)); + newCONSTSUB(stash,"VBI_OTHER", newSViv(VBI_OTHER)); + + newCONSTSUB(stash,"VTX_COLMASK",newSViv(VTX_COLMASK)); + newCONSTSUB(stash,"VTX_GRSEP", newSViv(VTX_GRSEP)); + newCONSTSUB(stash,"VTX_HIDDEN", newSViv(VTX_HIDDEN)); + newCONSTSUB(stash,"VTX_BOX", newSViv(VTX_BOX)); + newCONSTSUB(stash,"VTX_FLASH", newSViv(VTX_FLASH)); + newCONSTSUB(stash,"VTX_DOUBLE1",newSViv(VTX_DOUBLE1)); + newCONSTSUB(stash,"VTX_DOUBLE2",newSViv(VTX_DOUBLE2)); + newCONSTSUB(stash,"VTX_INVERT", newSViv(VTX_INVERT)); + newCONSTSUB(stash,"VTX_DOUBLE", newSViv(VTX_DOUBLE)); +} + +#line 1484 "VBI.c" + + /* End of Initialisation Section */ + + XSRETURN_YES; +} + --- libvideo-capture-v4l-perl-0.901.orig/VBI/VBI.xs +++ libvideo-capture-v4l-perl-0.901/VBI/VBI.xs @@ -482,7 +482,7 @@ case 0x55: break; default: - ; /* no teletext page */ + break; /* no teletext page */ } if (data[1] == 0x55) --- libvideo-capture-v4l-perl-0.901.orig/debian/changelog +++ libvideo-capture-v4l-perl-0.901/debian/changelog @@ -0,0 +1,59 @@ +libvideo-capture-v4l-perl (0.901-1) unstable; urgency=low + + * New upstream release + * New maintainer (in response to Matthias' mail, see + http://lists.debian.org/debian-devel/2006/05/msg02947.html) + Debian Perl Group + via Zak B. Elep + * debian/control: + + Bump Standards-Version. + + Bump debhelper to version 5; set debian/compat accordingly. + * debian/copyright: + + Update maintenance notes. + * Added debian/watch . + + -- Zak B. Elep Thu, 29 Jun 2006 13:50:30 +0800 + +libvideo-capture-v4l-perl (0.225-1) unstable; urgency=low + + * New Upstream version. + * Fix FTBFS. Closes:#318547. + + -- Matthias Urlichs Mon, 23 Jan 2006 11:03:18 +0100 + +libvideo-capture-v4l-perl (0.224-5) unstable; urgency=low + + * Missed a -fPIC in a sub-Makefile, minor compile fixes. + - Closes: #258991, #259440 + * Don't nest examples/ directories. + + -- Matthias Urlichs Thu, 15 Jul 2004 10:24:22 +0200 + +libvideo-capture-v4l-perl (0.224-4) unstable; urgency=low + + * Makefile.PL: CFLAGS => CCFLAGS + + -- Matthias Urlichs Mon, 12 Jul 2004 18:21:16 +0200 + +libvideo-capture-v4l-perl (0.224-2) unstable; urgency=low + + * Use -fPIC. + - Closes: #258680 + - Thanks to Goswin Brederlow . + + -- Matthias Urlichs Sun, 11 Jul 2004 07:14:51 +0200 + +libvideo-capture-v4l-perl (0.224-1) unstable; urgency=low + + * New Upstream version. + - minor updates + + -- Matthias Urlichs Wed, 7 Jul 2004 22:14:35 +0200 + +libvideo-capture-v4l-perl (0.222-1) unstable; urgency=low + + * Initial Release. + - Closes: #256806 (ITP) + + -- Matthias Urlichs Tue, 29 Jun 2004 09:57:09 +0200 + --- libvideo-capture-v4l-perl-0.901.orig/debian/control +++ libvideo-capture-v4l-perl-0.901/debian/control @@ -0,0 +1,23 @@ +Source: libvideo-capture-v4l-perl +Section: perl +Priority: optional +Maintainer: Debian Perl Group +Uploaders: Zak B. Elep , Carlo Segre +Build-Depends: debhelper (>= 5.0.0), perl (>= 5.8.0-7) +Standards-Version: 3.7.2 + +Package: libvideo-capture-v4l-perl +Architecture: any +Depends: ${perl:Depends}, ${shlibs:Depends} +Description: Perl interface to the Video4linux framegrabber interface + This package contains Perl modules which interface to + the Video4linux frame grabber. + . + The following Perl modules are included in this package: + . + * Video::Capture::V4l - Video4linux framegrabber interface + * Video::Capture::VBI - Functions to manipulate vbi fields & lines + * Video::Frequencies - Many, many frequency constants and lists + * Video::RTjpeg - Real time, jpeg-like video compression + * Video::XawTV - read, create and edit .xawtvrc files + --- libvideo-capture-v4l-perl-0.901.orig/debian/compat +++ libvideo-capture-v4l-perl-0.901/debian/compat @@ -0,0 +1 @@ +5 --- libvideo-capture-v4l-perl-0.901.orig/debian/watch +++ libvideo-capture-v4l-perl-0.901/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://www.cpan.org/modules/by-module/Video/Video-Capture-V4l-(.*)\.tar\.gz --- libvideo-capture-v4l-perl-0.901.orig/debian/copyright +++ libvideo-capture-v4l-perl-0.901/debian/copyright @@ -0,0 +1,31 @@ +This is the debian package for the Video-Capture-V4l module. +It was created by Matthias Urlichs using dh-make-perl. +It is now maintained by Zak B. Elep . + +The upstream author is: +Marc Lehmann . + +The README file states: + LICENSE + This module is available under GPL only (see the file COPYING for + details), if you want an exception please contact the author, who + might grant exceptions freely ;) + +The file COPYING contains a verbatim copy of version 2 of the GNU +General Public License. + + +The RTjpeg encoder which is included in this package is (C) 1998 Justin +Schoeman (justin@suntiger.ee.up.ac.za). The RTjpeg/codec/README file states: + + License+Disclaimer + ================== + This code is distributed under GPLv2 (in other words, do what you + like with it, but don't sell it, and give credit if you use it). + THIS SOFTWARE IS IN NO WAY GUARANTEED TO WORK. IF YOU USE IT AND IT + DOESN'T WORK, OR MESSES UP YOUR COMPUTER, IT'S YOUR OWN PROBLEM. + + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + --- libvideo-capture-v4l-perl-0.901.orig/debian/rules +++ libvideo-capture-v4l-perl-0.901/debian/rules @@ -0,0 +1,101 @@ +#!/usr/bin/make -f +# This debian/rules file is provided as a template for normal perl +# packages. It was created by Marc Brockschmidt for +# the Debian Perl Group (http://pkg-perl.alioth.debian.org/) but may +# be used freely wherever it is useful. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# If set to a true value then MakeMaker's prompt function will +# always return the default without waiting for user input. +export PERL_MM_USE_DEFAULT=1 + +PACKAGE=$(shell dh_listpackages) + +ifndef PERL +PERL = /usr/bin/perl +endif + +TMP =$(CURDIR)/debian/$(PACKAGE) + +# Allow disabling build optimation by setting noopt in +# $DEB_BUILD_OPTIONS +CFLAGS = -Wall -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +build: build-stamp +build-stamp: + dh_testdir + + # Add commands to compile the package here + $(PERL) Makefile.PL INSTALLDIRS=vendor + $(MAKE) OPTIMIZE="$(CFLAGS)" LD_RUN_PATH="" + + touch build-stamp + +clean: + dh_testdir + dh_testroot + + # Add commands to clean up after the build process here + -$(MAKE) realclean + + dh_clean build-stamp install-stamp + +install: install-stamp +install-stamp: + dh_testdir + dh_testroot + dh_clean -k + + # Add here commands to install the package into debian/tmp. + #$(MAKE) test + $(MAKE) install DESTDIR=$(TMP) PREFIX=/usr + + # As this is a architecture dependent package, we are not supposed to install + # stuff to /usr/share/perl5. MakeMaker creates the dirs, we delete them from + # the deb: + rmdir --ignore-fail-on-non-empty --parents $(TMP)/usr/share/perl5 + + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs TODO README RTjpeg/codec/README + dh_installexamples examples/* + find debian/libvideo-capture-v4l-perl -name SCCS -print0 -prune | \ + xargs -0r rm -rf +# dh_installmenu +# dh_installcron +# dh_installman + dh_installchangelogs Changes + dh_link +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + dh_strip +endif + dh_compress + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary --- libvideo-capture-v4l-perl-0.901.orig/Makefile.PL +++ libvideo-capture-v4l-perl-0.901/Makefile.PL @@ -9,6 +9,7 @@ 'NAME' => 'Video::Frequencies', DISTNAME => 'Video-Capture-V4l', 'VERSION_FROM' => 'V4l/V4l.pm', + CCFLAGS => '-fPIC', linkext => {LINKTYPE => ''}, DIR => ['V4l','VBI','RTjpeg'], ); --- libvideo-capture-v4l-perl-0.901.orig/V4l/Makefile.PL +++ libvideo-capture-v4l-perl-0.901/V4l/Makefile.PL @@ -8,5 +8,6 @@ WriteMakefile( 'NAME' => 'Video::Capture::V4l', 'VERSION_FROM' => 'V4l.pm', + CCFLAGS => '-fPIC', LIBS => '-lpthread', ); --- libvideo-capture-v4l-perl-0.901.orig/V4l/V4l.c +++ libvideo-capture-v4l-perl-0.901/V4l/V4l.c @@ -0,0 +1,2150 @@ +/* + * This file was generated automatically by xsubpp version 1.9508 from the + * contents of V4l.xs. Do not edit this file, edit V4l.xs instead. + * + * ANY CHANGES MADE HERE WILL BE LOST! + * + */ + +#line 1 "V4l.xs" +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include +#include +#include +#include + +#include +#include +#include + +#define NEED_newCONSTSUB +#include "../gppport.h" + +#ifndef pTHX_ +#define pTHX_ +#endif + +#define XSRETURN_bool(bool) if (bool) XSRETURN_YES; else XSRETURN_NO; + +#define VBI_BPF (2048*32) + +typedef struct video_capability *Video__Capture__V4l__Capability; +typedef struct video_channel *Video__Capture__V4l__Channel; +typedef struct video_audio *Video__Capture__V4l__Audio; +typedef struct video_picture *Video__Capture__V4l__Picture; +typedef struct video_tuner *Video__Capture__V4l__Tuner; + +static void +attach_struct (SV *sv, size_t bytes) +{ + void *ptr; + + sv = SvRV (sv); + Newz (0, ptr, bytes, void*); + + sv_magic (sv, 0, '~', 0, bytes); + mg_find(sv, '~')->mg_ptr = ptr; +} + +static SV * +new_struct (SV *sv, size_t bytes, const char *pkg) +{ + SV *rv = newRV_noinc (sv); + attach_struct (rv, bytes); + return sv_bless (rv, gv_stashpv ((char *)pkg, TRUE)); +} + +static void * +old_struct (SV *sv, const char *name) +{ + /* TODO: check name */ + return mg_find (SvRV(sv), '~')->mg_ptr; +} + +static int +framesize (unsigned int format, unsigned int pixels) +{ + if (format==VIDEO_PALETTE_RGB565) return pixels*2; + if (format==VIDEO_PALETTE_RGB24) return pixels*3; + if (format==VIDEO_PALETTE_RGB555) return pixels*2; + if (format==VIDEO_PALETTE_HI240) return pixels*1; + if (format==VIDEO_PALETTE_GREY) return pixels*1; + if (format==VIDEO_PALETTE_RGB32) return pixels*4; + if (format==VIDEO_PALETTE_UYVY) return pixels*2; + if (format==VIDEO_PALETTE_YUYV) return pixels*2; + /* everything below is very probably WRONG */ + if (format==VIDEO_PALETTE_YUV410P) return pixels*2; + if (format==VIDEO_PALETTE_YUV411) return pixels*2; + if (format==VIDEO_PALETTE_YUV411P) return pixels*2; + if (format==VIDEO_PALETTE_YUV420) return pixels*3/2; + if (format==VIDEO_PALETTE_YUV420P) return pixels*3/2; + if (format==VIDEO_PALETTE_YUV422) return pixels*2; + if (format==VIDEO_PALETTE_YUV422P) return pixels*2; + if (format==VIDEO_PALETTE_PLANAR) return pixels*2; + if (format==VIDEO_PALETTE_RAW) return pixels*8; + return 0; +} + +struct private { + int fd; + unsigned char *mmap_base; + struct video_mbuf vm; +}; + +static int +private_free (pTHX_ SV *obj, MAGIC *mg) +{ + struct private *p = (struct private *)mg->mg_ptr; + munmap (p->mmap_base, p->vm.size); + return 0; +} + +static MGVTBL vtbl_private = {0, 0, 0, 0, private_free}; + +static struct private * +find_private (SV *sv) +{ + HV *hv = (HV*)SvRV(sv); + MAGIC *mg = mg_find ((SV*)hv, '~'); + + if (!mg) + { + struct private p; + p.fd = SvIV (*hv_fetch (hv, "fd", 2, 0)); + if (ioctl (p.fd, VIDIOCGMBUF, &p.vm) == 0) + { + p.mmap_base = (unsigned char *)mmap (0, p.vm.size, PROT_READ|PROT_WRITE, MAP_SHARED, p.fd, 0); + if (p.mmap_base) + { + sv_magic ((SV*)hv, 0, '~', (char*)&p, sizeof p); + mg = mg_find ((SV*)hv, '~'); + mg->mg_virtual = &vtbl_private; + } + } + } + + return (struct private *) (mg ? mg->mg_ptr : 0); +} + +typedef unsigned char u8; +typedef unsigned int UI; + +#define get_field(field) (*hv_fetch ((HV*)SvRV (self), #field, strlen(#field), 0)) + +/* only one thread currently */ +typedef struct vbi_frame { + struct vbi_frame *next; + int size; + char data[VBI_BPF]; +} vbi_frame; +static vbi_frame *vbi_head, *vbi_tail, + *vbi_free; +static int vbi_fd; +static UI vbi_max; +static pthread_t vbi_snatcher; +static pthread_mutex_t vbi_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t vbi_cond = PTHREAD_COND_INITIALIZER; + +static void * +vbi_snatcher_thread (void *arg) +{ + /* try to become a realtime process. */ +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + { + struct sched_param sp; + + sp.sched_priority = (sched_get_priority_max (SCHED_FIFO) + + sched_get_priority_min (SCHED_FIFO)) / 2 - 1; + pthread_setschedparam (pthread_self (), SCHED_FIFO, &sp); + } +#endif + for(;;) + { + vbi_frame *next; + + pthread_mutex_lock (&vbi_lock); + if (vbi_free) + { + next = vbi_free; + vbi_free = vbi_free->next; + pthread_mutex_unlock (&vbi_lock); + + next->next = 0; + next->size = read (vbi_fd, next->data, VBI_BPF); + + pthread_mutex_lock (&vbi_lock); + + if (vbi_tail) + vbi_tail->next = next; + else + vbi_head = vbi_tail = next; + + vbi_tail = next; + vbi_max--; + + pthread_cond_signal (&vbi_cond); + pthread_mutex_unlock (&vbi_lock); + } + else + { + static struct timespec to = { 0, 1000000000 / 70 }; /* skip almost a frame */ + + pthread_mutex_unlock (&vbi_lock); + pthread_testcancel (); + nanosleep (&to, 0); + } + } +} + +#line 203 "V4l.c" +XS(XS_Video__Capture__V4l__VBI_field); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__VBI_field) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::VBI::field(self)"); + { + SV * self = ST(0); + SV * RETVAL; +#line 201 "V4l.xs" + int fd = SvIV(get_field(fd)); + + if (vbi_fd == fd) + { + vbi_frame *next; + + pthread_mutex_lock (&vbi_lock); + while (!vbi_head) + pthread_cond_wait (&vbi_cond, &vbi_lock); + + RETVAL = newSVpvn (vbi_head->data, vbi_head->size); + + vbi_max++; + next = vbi_head->next; + + vbi_head->next = vbi_free; + vbi_free = vbi_head; + + vbi_head = next; + + if (!next) + vbi_tail = vbi_head; + + pthread_mutex_unlock (&vbi_lock); + } + else + { + int len; + + RETVAL = newSVpvn ("", 0); + SvGROW (RETVAL, VBI_BPF); + len = read (fd, SvPV_nolen (RETVAL), VBI_BPF); + SvCUR_set (RETVAL, len); + } + +#line 249 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__VBI_backlog); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__VBI_backlog) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::VBI::backlog(self, backlog)"); + { + SV * self = ST(0); + unsigned int backlog = (unsigned int)SvUV(ST(1)); +#line 244 "V4l.xs" +{ + while (vbi_max != backlog) + { + vbi_frame *f; + + pthread_mutex_lock (&vbi_lock); + + if (vbi_max < backlog) + { + f = malloc (sizeof (vbi_frame)); + f->next = vbi_free; + vbi_free = f; + vbi_max++; + } + else + { + if (vbi_free) + { + f = vbi_free; + vbi_free = vbi_free->next; + free (f); + vbi_max--; + } + } + + pthread_mutex_unlock (&vbi_lock); + } + + if (backlog) + { + if (!vbi_fd) + { + vbi_fd = SvIV(get_field(fd)); + pthread_create (&vbi_snatcher, 0, vbi_snatcher_thread, 0); + } + } + else + { + if (vbi_fd) + { + pthread_cancel (vbi_snatcher); + pthread_join (vbi_snatcher, 0); + vbi_fd = 0; + } + + /* no locking necessary, in theory */ + while (vbi_head) + { + vbi_frame *next = vbi_head->next; + + free (vbi_head); + vbi_head = next; + } + + vbi_tail = 0; + } +} +#line 323 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__VBI_queued); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__VBI_queued) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::VBI::queued(self)"); + { + int RETVAL; + dXSTARG; +#line 305 "V4l.xs" + if (vbi_fd) + { + /* FIXME: lock/unlock */ + pthread_mutex_lock (&vbi_lock); + RETVAL = !!vbi_head; + pthread_mutex_unlock (&vbi_lock); + } + else + RETVAL = 1; +#line 347 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l_capture); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_capture) +{ + dXSARGS; + if (items < 4 || items > 5) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::capture(sv, frame, width, height, format = VIDEO_PALETTE_RGB24)"); + { + SV * sv = ST(0); + unsigned int frame = (unsigned int)SvUV(ST(1)); + unsigned int width = (unsigned int)SvUV(ST(2)); + unsigned int height = (unsigned int)SvUV(ST(3)); + unsigned int format; + SV * RETVAL; + + if (items < 5) + format = VIDEO_PALETTE_RGB24; + else { + format = (unsigned int)SvUV(ST(4)); + } +#line 327 "V4l.xs" +{ + struct private *p; + if ((p = find_private (sv))) + { + struct video_mmap vm; + vm.frame = frame; + vm.height = height; + vm.width = width; + vm.format = format; + if (ioctl (p->fd, VIDIOCMCAPTURE, &vm) == 0) + { + SV *fr = newSV (0); + SvUPGRADE (fr, SVt_PV); + SvREADONLY_on (fr); + SvPVX (fr) = p->mmap_base + p->vm.offsets[frame]; + SvCUR_set (fr, framesize (format, width*height)); + SvLEN_set (fr, 0); + SvPOK_only (fr); + RETVAL = fr; + } + else + XSRETURN_EMPTY; + } + else + XSRETURN_EMPTY; +} +#line 399 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l_sync); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_sync) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::sync(sv, frame)"); + SP -= items; + { + SV * sv = ST(0); + int frame = (int)SvIV(ST(1)); +#line 361 "V4l.xs" +{ + struct private *p; + if ((p = find_private (sv)) + && ioctl (p->fd, VIDIOCSYNC, &frame) == 0) + XSRETURN_YES; + else + XSRETURN_EMPTY; +} +#line 425 "V4l.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__V4l__freq); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__freq) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_freq(fd, fr)"); + { + int fd = (int)SvIV(ST(0)); + unsigned long fr = (unsigned long)SvUV(ST(1)); + unsigned long RETVAL; + dXSTARG; +#line 375 "V4l.xs" + if (items > 1) + { + fr = ((fr<<4)+499)/1000; + ioctl (fd, VIDIOCSFREQ, &fr); + } + if (GIMME_V != G_VOID) + { + if (ioctl (fd, VIDIOCGFREQ, &fr) == 0) + RETVAL = (fr*1000+7)>>4; + else + XSRETURN_EMPTY; + } + else + XSRETURN (0); +#line 457 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__capabilities_new); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__capabilities_new) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_capabilities_new(fd)"); + { + int fd = (int)SvIV(ST(0)); + SV * RETVAL; +#line 397 "V4l.xs" + RETVAL = new_struct (newSViv (fd), sizeof (struct video_capability), "Video::Capture::V4l::Capability"); +#line 474 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__channel_new); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__channel_new) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_channel_new(fd)"); + { + int fd = (int)SvIV(ST(0)); + SV * RETVAL; +#line 405 "V4l.xs" + RETVAL = new_struct (newSViv (fd), sizeof (struct video_channel), "Video::Capture::V4l::Channel"); +#line 492 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__tuner_new); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__tuner_new) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_tuner_new(fd)"); + { + int fd = (int)SvIV(ST(0)); + SV * RETVAL; +#line 413 "V4l.xs" + RETVAL = new_struct (newSViv (fd), sizeof (struct video_tuner), "Video::Capture::V4l::Tuner"); +#line 510 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__audio_new); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__audio_new) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_audio_new(fd)"); + { + int fd = (int)SvIV(ST(0)); + SV * RETVAL; +#line 421 "V4l.xs" + RETVAL = new_struct (newSViv (fd), sizeof (struct video_audio), "Video::Capture::V4l::Audio"); +#line 528 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__picture_new); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__picture_new) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::_picture_new(fd)"); + { + int fd = (int)SvIV(ST(0)); + SV * RETVAL; +#line 429 "V4l.xs" + RETVAL = new_struct (newSViv (fd), sizeof (struct video_picture), "Video::Capture::V4l::Picture"); +#line 546 "V4l.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_get); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_get) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::get(sv)"); + { + SV * sv = ST(0); +#line 439 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCGCAP, old_struct (sv, "Video::Capture::V4l::Capability")) == 0); +#line 563 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Channel_get); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_get) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::get(sv)"); + { + SV * sv = ST(0); +#line 447 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCGCHAN, old_struct (sv, "Video::Capture::V4l::Channel")) == 0); +#line 578 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Channel_set); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_set) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::set(sv)"); + { + SV * sv = ST(0); +#line 453 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCSCHAN, old_struct (sv, "Video::Capture::V4l::Channel")) == 0); +#line 593 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Tuner_get); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_get) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::get(sv)"); + { + SV * sv = ST(0); +#line 461 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCGTUNER, old_struct (sv, "Video::Capture::V4l::Tuner")) == 0); +#line 608 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Tuner_set); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_set) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::set(sv)"); + { + SV * sv = ST(0); +#line 467 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCSTUNER, old_struct (sv, "Video::Capture::V4l::Tuner")) == 0); +#line 623 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Audio_get); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_get) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::get(sv)"); + { + SV * sv = ST(0); +#line 475 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCGAUDIO, old_struct (sv, "Video::Capture::V4l::Audio")) == 0); +#line 638 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Audio_set); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_set) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::set(sv)"); + { + SV * sv = ST(0); +#line 481 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCSAUDIO, old_struct (sv, "Video::Capture::V4l::Audio")) == 0); +#line 653 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Picture_get); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_get) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::get(sv)"); + { + SV * sv = ST(0); +#line 489 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCGPICT, old_struct (sv, "Video::Capture::V4l::Picture")) == 0); +#line 668 "V4l.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l__Picture_set); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_set) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::set(sv)"); + { + SV * sv = ST(0); +#line 495 "V4l.xs" + XSRETURN_bool (ioctl (SvIV (SvRV (sv)), VIDIOCSPICT, old_struct (sv, "Video::Capture::V4l::Picture")) == 0); +#line 683 "V4l.c" + } + XSRETURN_EMPTY; +} + + +/* INCLUDE: Including './genacc |' from 'V4l.xs' */ + +XS(XS_Video__Capture__V4l__Capability_name); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_name) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::name(s, name=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + char * name; + char * RETVAL; + dXSTARG; + + if (items < 2) + name = 0; + else { + name = (char *)SvPV_nolen(ST(1)); + } +#line 17 "./genacc |" + if (items==1) + { RETVAL = s->name; } + else + { croak ("attribute 'name' is readonly"); } +#line 713 "V4l.c" + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_type); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_type) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::type(s, type=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int type; + int RETVAL; + dXSTARG; + + if (items < 2) + type = 0; + else { + type = (int)SvIV(ST(1)); + } +#line 29 "./genacc |" + if (items==1) + { RETVAL = s->type; } + else + { croak ("attribute 'type' is readonly"); } +#line 741 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_channels); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_channels) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::channels(s, channels=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int channels; + int RETVAL; + dXSTARG; + + if (items < 2) + channels = 0; + else { + channels = (int)SvIV(ST(1)); + } +#line 41 "./genacc |" + if (items==1) + { RETVAL = s->channels; } + else + { croak ("attribute 'channels' is readonly"); } +#line 769 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_audios); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_audios) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::audios(s, audios=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int audios; + int RETVAL; + dXSTARG; + + if (items < 2) + audios = 0; + else { + audios = (int)SvIV(ST(1)); + } +#line 53 "./genacc |" + if (items==1) + { RETVAL = s->audios; } + else + { croak ("attribute 'audios' is readonly"); } +#line 797 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_maxwidth); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_maxwidth) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::maxwidth(s, maxwidth=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int maxwidth; + int RETVAL; + dXSTARG; + + if (items < 2) + maxwidth = 0; + else { + maxwidth = (int)SvIV(ST(1)); + } +#line 65 "./genacc |" + if (items==1) + { RETVAL = s->maxwidth; } + else + { croak ("attribute 'maxwidth' is readonly"); } +#line 825 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_maxheight); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_maxheight) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::maxheight(s, maxheight=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int maxheight; + int RETVAL; + dXSTARG; + + if (items < 2) + maxheight = 0; + else { + maxheight = (int)SvIV(ST(1)); + } +#line 77 "./genacc |" + if (items==1) + { RETVAL = s->maxheight; } + else + { croak ("attribute 'maxheight' is readonly"); } +#line 853 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_minwidth); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_minwidth) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::minwidth(s, minwidth=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int minwidth; + int RETVAL; + dXSTARG; + + if (items < 2) + minwidth = 0; + else { + minwidth = (int)SvIV(ST(1)); + } +#line 89 "./genacc |" + if (items==1) + { RETVAL = s->minwidth; } + else + { croak ("attribute 'minwidth' is readonly"); } +#line 881 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Capability_minheight); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Capability_minheight) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Capability::minheight(s, minheight=0)"); + { + Video__Capture__V4l__Capability s = old_struct (ST(0), "Video::Capture::V4l::Capability"); + int minheight; + int RETVAL; + dXSTARG; + + if (items < 2) + minheight = 0; + else { + minheight = (int)SvIV(ST(1)); + } +#line 101 "./genacc |" + if (items==1) + { RETVAL = s->minheight; } + else + { croak ("attribute 'minheight' is readonly"); } +#line 909 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_channel); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_channel) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::channel(s, channel=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + int channel; + int RETVAL; + dXSTARG; + + if (items < 2) + channel = 0; + else { + channel = (int)SvIV(ST(1)); + } +#line 116 "./genacc |" + if (items==1) + { RETVAL = s->channel; } + else + { s->channel = channel; } +#line 937 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_name); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_name) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::name(s, name=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + char * name; + char * RETVAL; + dXSTARG; + + if (items < 2) + name = 0; + else { + name = (char *)SvPV_nolen(ST(1)); + } +#line 128 "./genacc |" + if (items==1) + { RETVAL = s->name; } + else + { croak ("attribute 'name' is readonly"); } +#line 965 "V4l.c" + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_tuners); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_tuners) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::tuners(s, tuners=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + int tuners; + int RETVAL; + dXSTARG; + + if (items < 2) + tuners = 0; + else { + tuners = (int)SvIV(ST(1)); + } +#line 140 "./genacc |" + if (items==1) + { RETVAL = s->tuners; } + else + { croak ("attribute 'tuners' is readonly"); } +#line 993 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_flags); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_flags) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::flags(s, flags=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + U32 flags; + U32 RETVAL; + dXSTARG; + + if (items < 2) + flags = 0; + else { + flags = (unsigned long)SvUV(ST(1)); + } +#line 152 "./genacc |" + if (items==1) + { RETVAL = s->flags; } + else + { croak ("attribute 'flags' is readonly"); } +#line 1021 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_type); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_type) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::type(s, type=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + U16 type; + U16 RETVAL; + dXSTARG; + + if (items < 2) + type = 0; + else { + type = (unsigned short)SvUV(ST(1)); + } +#line 164 "./genacc |" + if (items==1) + { RETVAL = s->type; } + else + { croak ("attribute 'type' is readonly"); } +#line 1049 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Channel_norm); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Channel_norm) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Channel::norm(s, norm=0)"); + { + Video__Capture__V4l__Channel s = old_struct (ST(0), "Video::Capture::V4l::Channel"); + U16 norm; + U16 RETVAL; + dXSTARG; + + if (items < 2) + norm = 0; + else { + norm = (unsigned short)SvUV(ST(1)); + } +#line 176 "./genacc |" + if (items==1) + { RETVAL = s->norm; } + else + { s->norm = norm; } +#line 1077 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_audio); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_audio) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::audio(s, audio=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + int audio; + int RETVAL; + dXSTARG; + + if (items < 2) + audio = 0; + else { + audio = (int)SvIV(ST(1)); + } +#line 191 "./genacc |" + if (items==1) + { RETVAL = s->audio; } + else + { s->audio = audio; } +#line 1105 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_volume); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_volume) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::volume(s, volume=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 volume; + U16 RETVAL; + dXSTARG; + + if (items < 2) + volume = 0; + else { + volume = (unsigned short)SvUV(ST(1)); + } +#line 203 "./genacc |" + if (items==1) + { RETVAL = s->volume; } + else + { s->volume = volume; } +#line 1133 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_bass); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_bass) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::bass(s, bass=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 bass; + U16 RETVAL; + dXSTARG; + + if (items < 2) + bass = 0; + else { + bass = (unsigned short)SvUV(ST(1)); + } +#line 215 "./genacc |" + if (items==1) + { RETVAL = s->bass; } + else + { s->bass = bass; } +#line 1161 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_treble); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_treble) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::treble(s, treble=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 treble; + U16 RETVAL; + dXSTARG; + + if (items < 2) + treble = 0; + else { + treble = (unsigned short)SvUV(ST(1)); + } +#line 227 "./genacc |" + if (items==1) + { RETVAL = s->treble; } + else + { s->treble = treble; } +#line 1189 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_flags); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_flags) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::flags(s, flags=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U32 flags; + U32 RETVAL; + dXSTARG; + + if (items < 2) + flags = 0; + else { + flags = (unsigned long)SvUV(ST(1)); + } +#line 239 "./genacc |" + if (items==1) + { RETVAL = s->flags; } + else + { s->flags = flags; } +#line 1217 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_name); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_name) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::name(s, name=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + char * name; + char * RETVAL; + dXSTARG; + + if (items < 2) + name = 0; + else { + name = (char *)SvPV_nolen(ST(1)); + } +#line 251 "./genacc |" + if (items==1) + { RETVAL = s->name; } + else + { croak ("attribute 'name' is readonly"); } +#line 1245 "V4l.c" + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_mode); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_mode) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::mode(s, mode=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 mode; + U16 RETVAL; + dXSTARG; + + if (items < 2) + mode = 0; + else { + mode = (unsigned short)SvUV(ST(1)); + } +#line 263 "./genacc |" + if (items==1) + { RETVAL = s->mode; } + else + { s->mode = mode; } +#line 1273 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_balance); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_balance) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::balance(s, balance=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 balance; + U16 RETVAL; + dXSTARG; + + if (items < 2) + balance = 0; + else { + balance = (unsigned short)SvUV(ST(1)); + } +#line 275 "./genacc |" + if (items==1) + { RETVAL = s->balance; } + else + { s->balance = balance; } +#line 1301 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Audio_step); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Audio_step) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Audio::step(s, step=0)"); + { + Video__Capture__V4l__Audio s = old_struct (ST(0), "Video::Capture::V4l::Audio"); + U16 step; + U16 RETVAL; + dXSTARG; + + if (items < 2) + step = 0; + else { + step = (unsigned short)SvUV(ST(1)); + } +#line 287 "./genacc |" + if (items==1) + { RETVAL = s->step; } + else + { s->step = step; } +#line 1329 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_brightness); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_brightness) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::brightness(s, brightness=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 brightness; + U16 RETVAL; + dXSTARG; + + if (items < 2) + brightness = 0; + else { + brightness = (unsigned short)SvUV(ST(1)); + } +#line 302 "./genacc |" + if (items==1) + { RETVAL = s->brightness; } + else + { s->brightness = brightness; } +#line 1357 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_hue); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_hue) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::hue(s, hue=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 hue; + U16 RETVAL; + dXSTARG; + + if (items < 2) + hue = 0; + else { + hue = (unsigned short)SvUV(ST(1)); + } +#line 314 "./genacc |" + if (items==1) + { RETVAL = s->hue; } + else + { s->hue = hue; } +#line 1385 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_colour); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_colour) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::colour(s, colour=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 colour; + U16 RETVAL; + dXSTARG; + + if (items < 2) + colour = 0; + else { + colour = (unsigned short)SvUV(ST(1)); + } +#line 326 "./genacc |" + if (items==1) + { RETVAL = s->colour; } + else + { s->colour = colour; } +#line 1413 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_contrast); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_contrast) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::contrast(s, contrast=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 contrast; + U16 RETVAL; + dXSTARG; + + if (items < 2) + contrast = 0; + else { + contrast = (unsigned short)SvUV(ST(1)); + } +#line 338 "./genacc |" + if (items==1) + { RETVAL = s->contrast; } + else + { s->contrast = contrast; } +#line 1441 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_whiteness); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_whiteness) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::whiteness(s, whiteness=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 whiteness; + U16 RETVAL; + dXSTARG; + + if (items < 2) + whiteness = 0; + else { + whiteness = (unsigned short)SvUV(ST(1)); + } +#line 350 "./genacc |" + if (items==1) + { RETVAL = s->whiteness; } + else + { s->whiteness = whiteness; } +#line 1469 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_depth); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_depth) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::depth(s, depth=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 depth; + U16 RETVAL; + dXSTARG; + + if (items < 2) + depth = 0; + else { + depth = (unsigned short)SvUV(ST(1)); + } +#line 362 "./genacc |" + if (items==1) + { RETVAL = s->depth; } + else + { s->depth = depth; } +#line 1497 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Picture_palette); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Picture_palette) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Picture::palette(s, palette=0)"); + { + Video__Capture__V4l__Picture s = old_struct (ST(0), "Video::Capture::V4l::Picture"); + U16 palette; + U16 RETVAL; + dXSTARG; + + if (items < 2) + palette = 0; + else { + palette = (unsigned short)SvUV(ST(1)); + } +#line 374 "./genacc |" + if (items==1) + { RETVAL = s->palette; } + else + { s->palette = palette; } +#line 1525 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_tuner); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_tuner) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::tuner(s, tuner=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + int tuner; + int RETVAL; + dXSTARG; + + if (items < 2) + tuner = 0; + else { + tuner = (int)SvIV(ST(1)); + } +#line 389 "./genacc |" + if (items==1) + { RETVAL = s->tuner; } + else + { s->tuner = tuner; } +#line 1553 "V4l.c" + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_name); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_name) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::name(s, name=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + char * name; + char * RETVAL; + dXSTARG; + + if (items < 2) + name = 0; + else { + name = (char *)SvPV_nolen(ST(1)); + } +#line 401 "./genacc |" + if (items==1) + { RETVAL = s->name; } + else + { croak ("attribute 'name' is readonly"); } +#line 1581 "V4l.c" + sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_rangelow); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_rangelow) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::rangelow(s, rangelow=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + unsigned long rangelow; + unsigned long RETVAL; + dXSTARG; + + if (items < 2) + rangelow = 0; + else { + rangelow = (unsigned long)SvUV(ST(1)); + } +#line 413 "./genacc |" + if (items==1) + { RETVAL = s->rangelow; } + else + { croak ("attribute 'rangelow' is readonly"); } +#line 1609 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_rangehigh); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_rangehigh) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::rangehigh(s, rangehigh=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + unsigned long rangehigh; + unsigned long RETVAL; + dXSTARG; + + if (items < 2) + rangehigh = 0; + else { + rangehigh = (unsigned long)SvUV(ST(1)); + } +#line 425 "./genacc |" + if (items==1) + { RETVAL = s->rangehigh; } + else + { croak ("attribute 'rangehigh' is readonly"); } +#line 1637 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_flags); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_flags) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::flags(s, flags=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + U32 flags; + U32 RETVAL; + dXSTARG; + + if (items < 2) + flags = 0; + else { + flags = (unsigned long)SvUV(ST(1)); + } +#line 437 "./genacc |" + if (items==1) + { RETVAL = s->flags; } + else + { croak ("attribute 'flags' is readonly"); } +#line 1665 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_mode); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_mode) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::mode(s, mode=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + U16 mode; + U16 RETVAL; + dXSTARG; + + if (items < 2) + mode = 0; + else { + mode = (unsigned short)SvUV(ST(1)); + } +#line 449 "./genacc |" + if (items==1) + { RETVAL = s->mode; } + else + { s->mode = mode; } +#line 1693 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l__Tuner_signal); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l__Tuner_signal) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::Tuner::signal(s, signal=0)"); + { + Video__Capture__V4l__Tuner s = old_struct (ST(0), "Video::Capture::V4l::Tuner"); + U16 signal; + U16 RETVAL; + dXSTARG; + + if (items < 2) + signal = 0; + else { + signal = (unsigned short)SvUV(ST(1)); + } +#line 461 "./genacc |" + if (items==1) + { RETVAL = s->signal; } + else + { croak ("attribute 'signal' is readonly"); } +#line 1721 "V4l.c" + XSprePUSH; PUSHu((UV)RETVAL); + } + XSRETURN(1); +} + + +/* INCLUDE: Returning to 'V4l.xs' from './genacc |' */ + +XS(XS_Video__Capture__V4l_bgr2rgb); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_bgr2rgb) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::bgr2rgb(fr)"); + { + SV * fr = ST(0); +#line 570 "V4l.xs" +{ + u8 *data, *end; + + end = SvEND (fr); + + for (data = SvPV_nolen (fr); data < end; data += 3) + { + data[0] ^= data[2]; + data[2] ^= data[0]; + data[0] ^= data[2]; + } +} +#line 1751 "V4l.c" + ST(0) = fr; + SvSETMAGIC(ST(0)); + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l_reduce2); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_reduce2) +{ + dXSARGS; + if (items != 2) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::reduce2(fr, w)"); + { + SV * fr = ST(0); + UI w = (UI)SvIV(ST(1)); + SV * RETVAL; +#line 590 "V4l.xs" +{ + u8 *src, *dst, *end; + + src = SvPV_nolen (fr); + dst = SvPV_nolen (fr); + + w *= 3; + + do + { + end = src + w; + do + { + dst[1] = ((UI)src[0] + (UI)src[3]) >> 1; src++; + dst[2] = ((UI)src[0] + (UI)src[3]) >> 1; src++; + dst[0] = ((UI)src[0] + (UI)src[3]) >> 1; src++; + src += 3; + dst += 3; + } + while (src < end); + src = end + w; + } + while (src < (u8*)SvEND (fr)); + + SvCUR_set (fr, dst - (u8*)SvPV_nolen (fr)); +} +#line 1795 "V4l.c" + ST(0) = fr; + SvSETMAGIC(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__Capture__V4l_normalize); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_normalize) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::normalize(fr)"); + { + SV * fr = ST(0); +#line 623 "V4l.xs" +{ + u8 mfr = 255, max = 0; + u8 *src, *dst, *end; + + end = SvEND (fr); + dst = SvPV_nolen (fr); + + for (src = SvPV_nolen (fr); src < end; src++) + { + if (*src > max) max = *src; + if (*src < mfr) mfr = *src; + } + + if (max != mfr) + for (src = SvPV_nolen (fr); src < end; ) + *dst++ = ((UI)*src++ - mfr) * 255 / (max-mfr); +} +#line 1828 "V4l.c" + ST(0) = fr; + SvSETMAGIC(ST(0)); + } + XSRETURN_EMPTY; +} + +XS(XS_Video__Capture__V4l_findmin); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_findmin) +{ + dXSARGS; + if (items < 2 || items > 4) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::findmin(db, fr, start=0, count=0)"); + SP -= items; + { + SV * db = ST(0); + SV * fr = ST(1); + UI start; + UI count; + + if (items < 3) + start = 0; + else { + start = (UI)SvIV(ST(2)); + } + + if (items < 4) + count = 0; + else { + count = (UI)SvIV(ST(3)); + } +#line 650 "V4l.xs" +{ + UI diff, min = -1; + int mindata, data; + u8 *src, *dst, *end, *efr; + UI datasize = SvCUR (fr); + UI framesize = datasize + sizeof(int); + + src = SvPV_nolen (db) + start * framesize; + if (src < (u8*)SvPV_nolen (db) || src > (u8*)SvEND (db)) + src = SvPV_nolen (db); + + end = src + count * framesize; + if (end <= src || end > (u8*)SvEND (db)) + end = SvEND (db); + + do + { + data = *((int *)src); src += sizeof (int); + + dst = SvPV_nolen (fr); + efr = src + datasize; + diff = 0; + + do + { + int dif = (int)*src++ - (int)*dst++; + diff += dif*dif; + } + while (src < efr); + + if (min > diff) + { + min = diff; + mindata = data; + } + } + while (src < end); + + EXTEND (sp, 2); + PUSHs (sv_2mortal (newSViv (mindata))); + PUSHs (sv_2mortal (newSViv ((min << 8) / SvCUR (fr)))); +} +#line 1902 "V4l.c" + PUTBACK; + return; + } +} + +XS(XS_Video__Capture__V4l_linreg); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__Capture__V4l_linreg) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::Capture::V4l::linreg(array)"); + SP -= items; + { + SV * array = ST(0); +#line 697 "V4l.xs" +{ + AV *xy = (AV*) SvRV (array); + I32 i; + I32 n = (av_len (xy)+1)>>1; + double x_ = 0, y_ = 0; + double sxy = 0, sxx = 0, syy = 0; + + for (i=0; i>1; + double c = 0; + double c2 = 0; + + for (i=0; i254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); + strm[0]=(u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); for(ci=1; ci<=63; ci++) if(data[RTjpeg_ZZ[ci]]>0) --- libvideo-capture-v4l-perl-0.901.orig/RTjpeg/codec/modules/RTb2s.c +++ libvideo-capture-v4l-perl-0.901/RTjpeg/codec/modules/RTb2s.c @@ -2,7 +2,7 @@ { int ci=1, co=1, tmp; - (u8)strm[0]=(u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); + strm[0]=(u8)(data[RTjpeg_ZZ[0]]>254) ? 254:((data[RTjpeg_ZZ[0]]<0)?0:data[RTjpeg_ZZ[0]]); for(ci=1; ci<=bt8; ci++) if(data[RTjpeg_ZZ[ci]]>0) --- libvideo-capture-v4l-perl-0.901.orig/RTjpeg/Makefile.PL +++ libvideo-capture-v4l-perl-0.901/RTjpeg/Makefile.PL @@ -3,6 +3,7 @@ WriteMakefile( NAME => 'Video::RTjpeg', VERSION_FROM => 'RTjpeg.pm', + CCFLAGS => '-fPIC', OBJECT => '$(BASEEXT)$(OBJ_EXT) codec/RTjpeg.o', ); @@ -11,6 +12,6 @@ cd codec && . compose.sh codec/RTjpeg.o: codec/RTjpeg.c codec/RTjpeg.h - \$(CCCMD) \$(CCCDLFLAGS) -o \$@ \$< + \$(CCCMD) \$(CCCDLFLAGS) -fPIC -o \$@ \$< EOF } --- libvideo-capture-v4l-perl-0.901.orig/RTjpeg/RTjpeg.c +++ libvideo-capture-v4l-perl-0.901/RTjpeg/RTjpeg.c @@ -0,0 +1,275 @@ +/* + * This file was generated automatically by xsubpp version 1.9508 from the + * contents of RTjpeg.xs. Do not edit this file, edit RTjpeg.xs instead. + * + * ANY CHANGES MADE HERE WILL BE LOST! + * + */ + +#line 1 "RTjpeg.xs" +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include +#include +#include + +#include "../gppport.h" + +#include "codec/RTjpeg.h" + +static int fwidth, fheight; + +#line 25 "RTjpeg.c" +XS(XS_Video__RTjpeg_init_compress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_init_compress) +{ + dXSARGS; + if (items != 3) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::init_compress(width, height, Q)"); + { + int width = (int)SvIV(ST(0)); + int height = (int)SvIV(ST(1)); + U8 Q = (U8)SvUV(ST(2)); + SV * RETVAL; +#line 25 "RTjpeg.xs" + fwidth = width; + fheight = height; + RETVAL = newSVpv ("", 0); + SvGROW (RETVAL, sizeof (RTjpeg_tables)); + SvCUR_set (RETVAL, sizeof (RTjpeg_tables)); + RTjpeg_init_compress ((u32 *)SvPV_nolen (RETVAL), width, height, Q); +#line 44 "RTjpeg.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__RTjpeg_init_decompress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_init_decompress) +{ + dXSARGS; + if (items != 3) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::init_decompress(tables, width, height)"); + { + SV * tables = ST(0); + int width = (int)SvIV(ST(1)); + int height = (int)SvIV(ST(2)); +#line 40 "RTjpeg.xs" + fwidth = width; + fheight = height; + RTjpeg_init_decompress ((u32 *)SvPV_nolen (tables), width, height); +#line 65 "RTjpeg.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__RTjpeg_compress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_compress) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::compress(YCrCb422_data)"); + { + SV * YCrCb422_data = ST(0); + SV * RETVAL; +#line 48 "RTjpeg.xs" + RETVAL = newSVpv ("", 0); + SvGROW (RETVAL, (fwidth * fheight * 3 + 2) / 2); + SvCUR_set (RETVAL, RTjpeg_compress (SvPV_nolen (RETVAL), SvPV_nolen (YCrCb422_data))); +#line 83 "RTjpeg.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__RTjpeg_decompress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_decompress) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::decompress(RTjpeg_data)"); + { + SV * RTjpeg_data = ST(0); + SV * RETVAL; +#line 58 "RTjpeg.xs" + RETVAL = newSVpv ("", 0); + SvGROW (RETVAL, fwidth * fheight * 2); + SvCUR_set (RETVAL, fwidth * fheight * 2); + RTjpeg_decompress (SvPV_nolen (RTjpeg_data), SvPV_nolen (RETVAL)); +#line 104 "RTjpeg.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__RTjpeg_init_mcompress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_init_mcompress) +{ + dXSARGS; + if (items != 0) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::init_mcompress()"); + { + + RTjpeg_init_mcompress(); + } + XSRETURN_EMPTY; +} + +XS(XS_Video__RTjpeg_mcompress); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_mcompress) +{ + dXSARGS; + if (items < 2 || items > 7) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::mcompress(YCrCb422_data, lmask, cmask=(lmask)>>1, x=0, y=0, w=fwidth, h=fheight)"); + { + SV * YCrCb422_data = ST(0); + U16 lmask = (unsigned short)SvUV(ST(1)); + U16 cmask; + int x; + int y; + int w; + int h; + SV * RETVAL; + + if (items < 3) + cmask = (lmask)>>1; + else { + cmask = (unsigned short)SvUV(ST(2)); + } + + if (items < 4) + x = 0; + else { + x = (int)SvIV(ST(3)); + } + + if (items < 5) + y = 0; + else { + y = (int)SvIV(ST(4)); + } + + if (items < 6) + w = fwidth; + else { + w = (int)SvIV(ST(5)); + } + + if (items < 7) + h = fheight; + else { + h = (int)SvIV(ST(6)); + } +#line 78 "RTjpeg.xs" + RETVAL = newSVpv ("", 0); + SvGROW (RETVAL, (fwidth * fheight * 3 + 2) / 2); + SvCUR_set (RETVAL, RTjpeg_mcompress (SvPV_nolen (RETVAL), SvPV_nolen (YCrCb422_data), lmask, cmask, + x, y, w, h)); +#line 174 "RTjpeg.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__RTjpeg_yuvrgb); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_yuvrgb) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::yuvrgb(yuv_data)"); + { + SV * yuv_data = ST(0); + SV * RETVAL; +#line 89 "RTjpeg.xs" + RETVAL = newSVpv ("", 0); + SvGROW (RETVAL, fwidth * fheight * 3); + SvCUR_set (RETVAL, fwidth * fheight * 3); + RTjpeg_yuvrgb (SvPV_nolen (yuv_data), SvPV_nolen (RETVAL)); +#line 195 "RTjpeg.c" + ST(0) = RETVAL; + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + +XS(XS_Video__RTjpeg__exit); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg__exit) +{ + dXSARGS; + if (items < 0 || items > 1) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::_exit(retcode=0)"); + { + int retcode; + + if (items < 1) + retcode = 0; + else { + retcode = (int)SvIV(ST(0)); + } +#line 100 "RTjpeg.xs" + _exit (retcode); +#line 218 "RTjpeg.c" + } + XSRETURN_EMPTY; +} + +XS(XS_Video__RTjpeg_fdatasync); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Video__RTjpeg_fdatasync) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Video::RTjpeg::fdatasync(fd)"); + { + int fd = (int)SvIV(ST(0)); +#line 106 "RTjpeg.xs" +#ifdef _POSIX_SYNCHRONIZED_IO + fdatasync (fd); +#endif +#line 235 "RTjpeg.c" + } + XSRETURN_EMPTY; +} + +#ifdef __cplusplus +extern "C" +#endif +XS(boot_Video__RTjpeg); /* prototype to pass -Wmissing-prototypes */ +XS(boot_Video__RTjpeg) +{ + dXSARGS; + char* file = __FILE__; + + XS_VERSION_BOOTCHECK ; + + newXSproto("Video::RTjpeg::init_compress", XS_Video__RTjpeg_init_compress, file, "$$$"); + newXSproto("Video::RTjpeg::init_decompress", XS_Video__RTjpeg_init_decompress, file, "$$$"); + newXSproto("Video::RTjpeg::compress", XS_Video__RTjpeg_compress, file, "$"); + newXSproto("Video::RTjpeg::decompress", XS_Video__RTjpeg_decompress, file, "$"); + newXSproto("Video::RTjpeg::init_mcompress", XS_Video__RTjpeg_init_mcompress, file, ""); + newXSproto("Video::RTjpeg::mcompress", XS_Video__RTjpeg_mcompress, file, "$$;$$$$$"); + newXSproto("Video::RTjpeg::yuvrgb", XS_Video__RTjpeg_yuvrgb, file, "$"); + newXSproto("Video::RTjpeg::_exit", XS_Video__RTjpeg__exit, file, ";$"); + newXSproto("Video::RTjpeg::fdatasync", XS_Video__RTjpeg_fdatasync, file, "$"); + + /* Initialisation Section */ + +#line 111 "RTjpeg.xs" +{ + HV *stash = gv_stashpvn("Video::RTjpeg", 13, TRUE); + + //newCONSTSUB(stash,"VBI_VT", newSViv(VBI_VT)); +} + +#line 270 "RTjpeg.c" + + /* End of Initialisation Section */ + + XSRETURN_YES; +} +