aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
committerGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
commit9ee950dde5943ee4083c2a0176ad4a1da4b49220 (patch)
tree2c5de44cea4582a75ba172617eb7526985346de2 /common
parentbc7f101b0c874e21473aca15d9b08de8bd164392 (diff)
v3.76
Diffstat (limited to 'common')
-rw-r--r--common/Subdir.mk4
-rw-r--r--common/capture.c233
-rw-r--r--common/capture.h13
-rw-r--r--common/commands.c12
-rw-r--r--common/commands.h2
-rw-r--r--common/frequencies.c53
6 files changed, 117 insertions, 200 deletions
diff --git a/common/Subdir.mk b/common/Subdir.mk
index 58aba3d..4888899 100644
--- a/common/Subdir.mk
+++ b/common/Subdir.mk
@@ -1,4 +1,5 @@
+
OBJS-common-capture := \
common/sound.o \
common/webcam.o \
@@ -14,6 +15,9 @@ OBJS-common-input := \
common/joystick.o \
common/midictrl.o
+# RegEdit.c is good old K&R ...
+common/RegEdit.o : CFLAGS += -Wno-missing-prototypes -Wno-strict-prototypes
+
common/channel-no-x11.o:: common/channel.c
$(CC) $(CFLAGS) -DNO_X11=1 -Wp,-MD,$*.dep -c -o $@ $<
@sed -e "s|.*\.o:|$@::|" < $*.dep > $*.d && rm -f $*.dep
diff --git a/common/capture.c b/common/capture.c
index 5bca96e..97e272f 100644
--- a/common/capture.c
+++ b/common/capture.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -18,8 +20,8 @@
#include "capture.h"
#include "webcam.h"
-#define MAX_THREADS 4
-#define REORDER_SIZE 8
+#define MAX_THREADS 4
+#define REORDER_SIZE 32
/*-------------------------------------------------------------------------*/
/* data fifos (audio/video) */
@@ -114,172 +116,39 @@ flushit(void *arg)
}
/*-------------------------------------------------------------------------*/
-/* color space conversion / compression functions + thread */
+/* color space conversion / compression thread */
-struct ng_convert_handle {
+struct ng_convthread_handle {
/* converter data / state */
- struct ng_video_fmt ifmt;
- struct ng_video_fmt ofmt;
- int isize;
- int osize;
- struct ng_video_conv *conv;
- void *chandle;
+ struct ng_convert_handle *c;
/* thread data */
- struct FIFO *in;
- struct FIFO *out;
+ struct FIFO *in;
+ struct FIFO *out;
};
-struct ng_convert_handle*
-ng_convert_alloc(struct ng_video_conv *conv,
- struct ng_video_fmt *i,
- struct ng_video_fmt *o)
-{
- struct ng_convert_handle *h;
-
- h = malloc(sizeof(*h));
- if (NULL == h)
- return 0;
- memset(h,0,sizeof(*h));
-
- /* fixup output image size to match incoming */
- o->width = i->width;
- o->height = i->height;
- if (0 == o->bytesperline)
- o->bytesperline = o->width * ng_vfmt_to_depth[o->fmtid] / 8;
-
- h->ifmt = *i;
- h->ofmt = *o;
- if (conv)
- h->conv = conv;
- return h;
-}
-
-void
-ng_convert_init(struct ng_convert_handle *h)
-{
- if (0 == h->ifmt.bytesperline)
- h->ifmt.bytesperline = h->ifmt.width *
- ng_vfmt_to_depth[h->ifmt.fmtid] / 8;
- if (0 == h->ofmt.bytesperline)
- h->ofmt.bytesperline = h->ofmt.width *
- ng_vfmt_to_depth[h->ofmt.fmtid] / 8;
-
- h->isize = h->ifmt.height * h->ifmt.bytesperline;
- if (0 == h->isize)
- h->isize = h->ifmt.width * h->ifmt.height * 3;
- h->osize = h->ofmt.height * h->ofmt.bytesperline;
- if (0 == h->osize)
- h->osize = h->ofmt.width * h->ofmt.height * 3;
-
- if (h->conv)
- h->chandle = h->conv->init(&h->ofmt,h->conv->priv);
-
- if (debug) {
- fprintf(stderr,"convert-in : %dx%d %s (size=%d)\n",
- h->ifmt.width, h->ifmt.height,
- ng_vfmt_to_desc[h->ifmt.fmtid], h->isize);
- fprintf(stderr,"convert-out: %dx%d %s (size=%d)\n",
- h->ofmt.width, h->ofmt.height,
- ng_vfmt_to_desc[h->ofmt.fmtid], h->osize);
- }
-}
-
-static void
-ng_convert_copyframe(struct ng_video_buf *dest,
- struct ng_video_buf *src)
-{
- int i,sw,dw;
- unsigned char *sp,*dp;
-
- dw = dest->fmt.width * ng_vfmt_to_depth[dest->fmt.fmtid] / 8;
- sw = src->fmt.width * ng_vfmt_to_depth[src->fmt.fmtid] / 8;
- if (src->fmt.bytesperline == sw && dest->fmt.bytesperline == dw) {
- /* can copy in one go */
- memcpy(dest->data, src->data,
- src->fmt.bytesperline * src->fmt.height);
- } else {
- /* copy line by line */
- dp = dest->data;
- sp = src->data;
- for (i = 0; i < src->fmt.height; i++) {
- memcpy(dp,sp,dw);
- dp += dest->fmt.bytesperline;
- sp += src->fmt.bytesperline;
- }
- }
-}
-
-struct ng_video_buf*
-ng_convert_frame(struct ng_convert_handle *h,
- struct ng_video_buf *dest,
- struct ng_video_buf *buf)
-{
- if (NULL == buf)
- return NULL;
-
- if (NULL == dest && NULL != h->conv)
- dest = ng_malloc_video_buf(&h->ofmt,h->osize);
-
- if (NULL != dest) {
- dest->fmt = h->ofmt;
- dest->size = h->osize;
- if (NULL != h->conv) {
- h->conv->frame(h->chandle,dest,buf);
- } else {
- ng_convert_copyframe(dest,buf);
- }
- dest->info = buf->info;
- ng_release_video_buf(buf);
- buf = dest;
- }
-
-#if 1 /* FIXME */
- if (NULL != webcam && 0 == webcam_put(webcam,buf)) {
- free(webcam);
- webcam = NULL;
- }
-#endif
- return buf;
-}
-
-void
-ng_convert_fini(struct ng_convert_handle *h)
-{
- if (h->conv)
- h->conv->fini(h->chandle);
- free(h);
-}
-
-struct ng_video_buf*
-ng_convert_single(struct ng_convert_handle *h, struct ng_video_buf *in)
-{
- struct ng_video_buf *out;
-
- ng_convert_init(h);
- out = ng_convert_frame(h,NULL,in);
- ng_convert_fini(h);
- return out;
-}
-
void*
ng_convert_thread(void *arg)
{
- struct ng_convert_handle *h = arg;
+ struct ng_convthread_handle *h = arg;
struct ng_video_buf *in, *out;
if (debug)
fprintf(stderr,"convert_thread start [pid=%d]\n",getpid());
- ng_convert_init(h);
+ ng_convert_init(h->c);
for (;;) {
in = fifo_get(h->in);
if (NULL == in)
break;
- out = ng_convert_frame(h,NULL,in);
+ out = ng_convert_frame(h->c,NULL,in);
+ if (NULL != webcam && 0 == webcam_put(webcam,out)) {
+ free(webcam);
+ webcam = NULL;
+ }
fifo_put(h->out,out);
}
fifo_put(h->out,NULL);
- ng_convert_fini(h);
+ ng_convert_fini(h->c);
if (debug)
fprintf(stderr,"convert_thread done [pid=%d]\n",getpid());
return NULL;
@@ -335,7 +204,7 @@ ng_grabber_findconv(struct ng_video_fmt *fmt,
/* check all available conversion functions */
for (i = 0;;) {
- conv = ng_conv_find(fmt->fmtid, &i);
+ conv = ng_conv_find_to(fmt->fmtid, &i);
if (NULL == conv)
break;
gfmt = *fmt;
@@ -403,7 +272,7 @@ struct movie_handle {
/* video converter thread */
struct FIFO cfifo;
int cthreads;
- struct ng_convert_handle *hconv[MAX_THREADS];
+ struct ng_convthread_handle *hconv[MAX_THREADS];
pthread_t tconv[MAX_THREADS];
/* audio */
@@ -416,6 +285,9 @@ struct movie_handle {
pthread_t taudio;
pthread_t raudio;
long long ats;
+
+ long long rdrift;
+ long long vdrift;
};
static void*
@@ -508,7 +380,10 @@ record_audio_thread(void *arg)
break;
if (0 == buf->size)
continue;
- h->ats = buf->info.ts;
+ h->ats = buf->info.ts;
+ h->rts = ng_get_timestamp() - h->start;
+ h->rdrift = h->rts - h->ats;
+ h->vdrift = h->vts - h->ats;
if (0 != fifo_put(&h->afifo,buf))
free(buf);
}
@@ -542,7 +417,7 @@ movie_writer_init(char *moviename, char *audioname,
/* audio */
if (audio->fmtid != AUDIO_NONE) {
- h->dsp = ng_dsp_open(dsp,audio,&h->hdsp);
+ h->dsp = ng_dsp_open(dsp,audio,1,&h->hdsp);
if (NULL == h->dsp) {
free(h);
return NULL;
@@ -578,7 +453,9 @@ movie_writer_init(char *moviename, char *audioname,
fifo_init(&h->cfifo,"conv",slots,1);
pthread_create(&h->tvideo,NULL,writer_video_thread,h);
for (i = 0; i < h->cthreads; i++) {
- h->hconv[i] = ng_convert_alloc(conv,&gfmt,video);
+ h->hconv[i] = malloc(sizeof(struct ng_convthread_handle));
+ memset(h->hconv[i],0,sizeof(struct ng_convthread_handle));
+ h->hconv[i]->c = ng_convert_alloc(conv,&gfmt,video);
h->hconv[i]->in = &h->cfifo;
h->hconv[i]->out = &h->vfifo;
pthread_create(&h->tconv[i],NULL,ng_convert_thread,
@@ -704,33 +581,23 @@ movie_writer_stop(struct movie_handle *h)
static void
movie_print_timestamps(struct movie_handle *h)
{
- long long adiff,vdiff;
char line[128];
if (NULL == rec_status)
return;
- h->rts = ng_get_timestamp() - h->start;
- adiff = h->ats - h->rts;
- vdiff = h->vts - h->rts;
-#if 0
- sprintf(line,"real: %d.%03ds audio: %d.%03ds video: %d.%03ds",
- (int)((h->rts / 1000000000)),
- (int)((h->rts % 1000000000) / 1000000),
- (int)((h->ats / 1000000000)),
- (int)((h->ats % 1000000000) / 1000000),
- (int)((h->vts / 1000000000)),
- (int)((h->vts % 1000000000) / 1000000));
-#else
- sprintf(line,"real: %d.%03ds audio: %c%d.%03ds video: %c%d.%03ds",
- (int)((h->rts / 1000000000)),
- (int)((h->rts % 1000000000) / 1000000),
- (adiff > 0) ? '+' : '-',
- (int)((abs(adiff) / 1000000000)),
- (int)((abs(adiff) % 1000000000) / 1000000),
- (vdiff > 0) ? '+' : '-',
- (int)((abs(vdiff) / 1000000000)),
- (int)((abs(vdiff) % 1000000000) / 1000000));
-#endif
+
+ sprintf(line,"rec %d:%02d.%02d - a/r: %c%d.%02ds [%d], a/v: %c%d.%02ds [%d]",
+ (int)(h->rts / 1000000000 / 60),
+ (int)(h->rts / 1000000000 % 60),
+ (int)((h->rts % 1000000000) / 10000000),
+ (h->rdrift > 0) ? '+' : '-',
+ (int)((abs(h->rdrift) / 1000000000)),
+ (int)((abs(h->rdrift) % 1000000000) / 10000000),
+ (int)(h->rdrift * h->fps / 1000000000000),
+ (h->vdrift > 0) ? '+' : '-',
+ (int)((abs(h->vdrift) / 1000000000)),
+ (int)((abs(h->vdrift) % 1000000000) / 10000000),
+ (int)(h->vdrift * h->fps / 1000000000000));
rec_status(line);
}
@@ -745,21 +612,25 @@ movie_grab_put_video(struct movie_handle *h, struct ng_video_buf **ret)
/* fetch next frame */
buf = ng_grabber_grab_image(0);
- if (NULL == buf)
+ if (NULL == buf) {
+ if (debug)
+ fprintf(stderr,"grab_put_video: grab image failed\n");
return -1;
+ }
#if 0 /* FIXME */
buf = ng_filter_single(cur_filter,buf);
#endif
/* rate control */
- expected = buf->info.ts * h->fps / 1000000000000;
- if (expected < h->frames) {
+ expected = (buf->info.ts - h->vdrift) * h->fps / 1000000000000;
+ if (expected < h->frames-1) {
if (debug > 1)
- fprintf(stderr,"rate: ignoring frame\n");
+ fprintf(stderr,"rate: ignoring frame [%d %d]\n",
+ expected, h->frames);
ng_release_video_buf(buf);
return 0;
}
- if (expected > h->frames) {
+ if (expected > h->frames+1) {
fprintf(stderr,"rate: queueing frame twice (%d)\n",
expected-h->frames);
buf->info.twice++;
diff --git a/common/capture.h b/common/capture.h
index 55eba30..118483e 100644
--- a/common/capture.h
+++ b/common/capture.h
@@ -15,19 +15,6 @@ void fifo_init(struct FIFO *fifo, char *name, int slots, int writers);
int fifo_put(struct FIFO *fifo, void *data);
void* fifo_get(struct FIFO *fifo);
-
-struct ng_convert_handle;
-struct ng_convert_handle* ng_convert_alloc(struct ng_video_conv *conv,
- struct ng_video_fmt *i,
- struct ng_video_fmt *o);
-
-void ng_convert_init(struct ng_convert_handle *h);
-struct ng_video_buf* ng_convert_frame(struct ng_convert_handle *h,
- struct ng_video_buf *dest,
- struct ng_video_buf *buf);
-void ng_convert_fini(struct ng_convert_handle *h);
-struct ng_video_buf* ng_convert_single(struct ng_convert_handle *h,
- struct ng_video_buf *in);
void* ng_convert_thread(void *arg);
int ng_grabber_setformat(struct ng_video_fmt *fmt, int fix_ratio);
diff --git a/common/commands.c b/common/commands.c
index 6f1c577..0587861 100644
--- a/common/commands.c
+++ b/common/commands.c
@@ -61,7 +61,7 @@ int do_overlay;
char *snapbase = "snap";
int have_shmem;
-struct ng_video_fmt x11_fmt;
+int cur_tv_width,cur_tv_height;
int cur_movie,cur_attrs[256];
/* current hardware driver */
@@ -1007,8 +1007,8 @@ static int snap_handler(char *hname, int argc, char **argv)
if (0 == strcasecmp(argv[1],"full")) {
/* nothing */
} else if (0 == strcasecmp(argv[1],"win")) {
- fmt.width = x11_fmt.width;
- fmt.height = x11_fmt.height;
+ fmt.width = cur_tv_width;
+ fmt.height = cur_tv_height;
} else if (2 == sscanf(argv[1],"%dx%d",&fmt.width,&fmt.height)) {
/* nothing */
} else {
@@ -1096,8 +1096,10 @@ static int webcam_handler(char *hname, int argc, char **argv)
the webcam happy */
if (capture_get_hook)
capture_get_hook();
- fmt = x11_fmt;
- fmt.fmtid = VIDEO_RGB24;
+ memset(&fmt,0,sizeof(fmt));
+ fmt.fmtid = VIDEO_RGB24;
+ fmt.width = cur_tv_width;
+ fmt.height = cur_tv_height;
buf = ng_grabber_get_image(&fmt);
if (buf)
ng_release_video_buf(buf);
diff --git a/common/commands.h b/common/commands.h
index 8ee1531..f3ac2b4 100644
--- a/common/commands.h
+++ b/common/commands.h
@@ -52,7 +52,7 @@ extern int debug;
extern int do_overlay;
extern char *snapbase;
extern int have_shmem;
-extern struct ng_video_fmt x11_fmt;
+extern int cur_tv_width,cur_tv_height;
extern int cur_movie,cur_attrs[256];
extern struct movie_parm m_parm;
diff --git a/common/frequencies.c b/common/frequencies.c
index 4863736..c41555d 100644
--- a/common/frequencies.c
+++ b/common/frequencies.c
@@ -694,6 +694,57 @@ static struct CHANLIST pal_australia[] = {
{ "69", 814250 },
};
+static struct CHANLIST pal_australia_optus[] = {
+ { "1", 138250 },
+ { "2", 147250 },
+ { "3", 154250 },
+ { "4", 161250 },
+ { "5", 168250 },
+ { "6", 175250 },
+ { "7", 182250 },
+ { "8", 189250 },
+ { "9", 196250 },
+ { "10", 209250 },
+ { "11", 216250 },
+ { "12", 224250 },
+ { "13", 231250 },
+ { "14", 238250 },
+ { "15", 245250 },
+ { "16", 252250 },
+ { "17", 259250 },
+ { "18", 266250 },
+ { "19", 273250 },
+ { "20", 280250 },
+ { "21", 287250 },
+ { "22", 294250 },
+ { "23", 303250 },
+ { "24", 310250 },
+ { "25", 317250 },
+ { "26", 324250 },
+ { "27", 338250 },
+ { "28", 345250 },
+ { "29", 352250 },
+ { "30", 359250 },
+ { "31", 366250 },
+ { "32", 373250 },
+ { "33", 380250 },
+ { "34", 387250 },
+ { "35", 394250 },
+ { "36", 401250 },
+ { "37", 408250 },
+ { "38", 415250 },
+ { "39", 422250 },
+ { "40", 429250 },
+ { "41", 436250 },
+ { "42", 443250 },
+ { "43", 450250 },
+ { "44", 457250 },
+ { "45", 464250 },
+ { "46", 471250 },
+ { "47", 478250 },
+ { "48", 485250 },
+ };
+
/* --------------------------------------------------------------------- */
/* europe */
@@ -1221,6 +1272,7 @@ struct CHANLISTS chanlists[] = {
{ "southafrica", pal_bcast_za, CHAN_COUNT(pal_bcast_za) },
{ "argentina", argentina, CHAN_COUNT(argentina) },
{ "canada-cable", ntsc_cable_ca, CHAN_COUNT(ntsc_cable_ca) },
+ { "australia-optus", pal_australia_optus, CHAN_COUNT(pal_australia_optus) },
{ NULL, NULL, 0 } /* EOF */
};
@@ -1241,6 +1293,7 @@ struct STRTAB chanlist_names[] = {
{ 13, "southafrica" },
{ 14, "argentina" },
{ 15, "canada-cable" },
+ { 16, "australia-optus" },
{ -1, NULL }
};

Privacy Policy