aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDevin Heitmueller <dheitmueller@kernellabs.com>2009-12-21 00:58:14 (GMT)
committerDevin Heitmueller <dheitmueller@kernellabs.com>2009-12-21 00:58:14 (GMT)
commit19fc0ce79ffa26733ab0440a72d0a354f1ca99d3 (patch)
tree5ac654d3c5613dd70afa6b21dc8376a61e57de18 /src
parent16a8ae6996f40ebc3b3fb37a28d689ece4de4bbc (diff)
djh - make the VBI buffer allocation dynamic, to handle drivers like cx88 which have a frame size greater than 65535 (cx88 by default does 2048 * 17 * 2).
Diffstat (limited to 'src')
-rw-r--r--src/vbidata.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/vbidata.c b/src/vbidata.c
index ee1f19d..0a67d22 100644
--- a/src/vbidata.c
+++ b/src/vbidata.c
@@ -46,7 +46,7 @@ struct vbidata_s
int fd;
int open;
vbiscreen_t *vs;
- uint8_t buf[ 65536 ];
+ uint8_t *buf;
int wanttop;
int wanttext;
@@ -56,6 +56,7 @@ struct vbidata_s
unsigned int linewidth;
unsigned int numlines;
unsigned int vbi_clkin;
+ unsigned int frame_size;
unsigned int colour;
int row, ital;
@@ -1018,8 +1019,21 @@ static void vbidata_open_device( vbidata_t *vbi )
frame_rate = vfmt.fmt.vbi.sampling_rate * 2 / 1.006976 / 1000 / 1000;
vbi->vbi_clkin = round(frame_rate);
- printf("linewidth=%d numlines=%d clkin=%d\n", vbi->linewidth,
- vbi->numlines, vbi->vbi_clkin);
+ vbi->frame_size = vbi->linewidth * vbi->numlines * 2;
+ vbi->buf = malloc(vbi->frame_size);
+ if (vbi->buf == NULL) {
+ fprintf( stderr, "vbidata: Could not allocate vbi frame [%s]\n",
+ strerror( errno ) );
+ close(vbi->fd);
+ vbi->open = 0;
+ return;
+ }
+
+ if( vbi->verbose ) {
+ fprintf( stderr, "vbidata: lwidth=%d numlines=%d clkin=%d fsize=%d\n",
+ vbi->linewidth, vbi->numlines, vbi->vbi_clkin,
+ vbi->frame_size );
+ }
}
static void vbidata_close_device( vbidata_t *vbi )
@@ -1175,8 +1189,7 @@ void vbidata_capture_xds( vbidata_t *vbi, int xds )
void vbidata_process_frame( vbidata_t *vbi, int printdebug )
{
if( vbi->open ) {
- unsigned int frame_size = vbi->linewidth * vbi->numlines * 2;
- if( read( vbi->fd, vbi->buf, frame_size ) < frame_size ) {
+ if( read( vbi->fd, vbi->buf, vbi->frame_size ) < vbi->frame_size ) {
if( vbi->verbose ) {
fprintf( stderr, "vbidata: Can't read vbi data: %s\n",
strerror( errno ) );

Privacy Policy