]> git.pld-linux.org Git - packages/cinelerra-cv.git/blame - remove-support-v4l-buzz-k2-6-38.diff
- ffmpeg-devel >= 0.7.1 required
[packages/cinelerra-cv.git] / remove-support-v4l-buzz-k2-6-38.diff
CommitLineData
b1359752
AM
1diff -Nru cinelerra.orig//cinelerra/channelpicker.C cinelerra/cinelerra/channelpicker.C
2--- cinelerra.orig//cinelerra/channelpicker.C 2010-11-24 18:18:03.000000000 -0500
3+++ cinelerra/cinelerra/channelpicker.C 2011-02-17 13:31:30.147880002 -0500
4@@ -39,7 +39,7 @@
5 #include "recordgui.h"
6 #include "recordmonitor.h"
7 #include "theme.h"
8-#include "vdevicebuz.h"
9+//#include "vdevicebuz.h"
10 #include "vdeviceprefs.h"
11 #include "videodevice.h"
12
13@@ -280,7 +280,7 @@
14 // printf("PrefsChannelPicker::PrefsChannelPicker 1\n");
15 this->mwindow = mwindow;
16 this->prefs = prefs;
17- VDeviceBUZ::get_inputs(&input_sources);
18+// VDeviceBUZ::get_inputs(&input_sources);
19 }
20
21 PrefsChannelPicker::~PrefsChannelPicker()
22diff -Nru cinelerra.orig//cinelerra/Makefile.am cinelerra/cinelerra/Makefile.am
23--- cinelerra.orig//cinelerra/Makefile.am 2010-11-24 18:18:03.000000000 -0500
24+++ cinelerra/cinelerra/Makefile.am 2011-02-17 13:31:30.147880002 -0500
25@@ -305,10 +305,8 @@
26 vattachmentpoint.C \
27 vautomation.C \
28 vdevicebase.C \
29- vdevicebuz.C \
30 vdevicedvb.C \
31 vdeviceprefs.C \
32- vdevicev4l.C \
33 vdevicev4l2.C \
34 vdevicev4l2jpeg.C \
35 vdevicex11.C \
36diff -Nru cinelerra.orig//cinelerra/reversemake cinelerra/cinelerra/reversemake
37--- cinelerra.orig//cinelerra/reversemake 2010-11-24 18:18:03.000000000 -0500
38+++ cinelerra/cinelerra/reversemake 2011-02-17 13:31:30.151880002 -0500
39@@ -32,10 +32,8 @@
40 make $OBJDIR/vedits.o
41 make $OBJDIR/vedit.o
42 make $OBJDIR/vdevicex11.o
43-make $OBJDIR/vdevicev4l.o
44 make $OBJDIR/vdeviceprefs.o
45 make $OBJDIR/vdevicelml.o
46-make $OBJDIR/vdevicebuz.o
47 make $OBJDIR/vdevicebase.o
48 make $OBJDIR/vdevice1394.o
49 make $OBJDIR/vautomation.o
50diff -Nru cinelerra.orig//cinelerra/vdevicebuz.C cinelerra/cinelerra/vdevicebuz.C
51--- cinelerra.orig//cinelerra/vdevicebuz.C 2010-11-24 18:18:03.000000000 -0500
52+++ cinelerra/cinelerra/vdevicebuz.C 1969-12-31 19:00:00.000000000 -0500
53@@ -1,796 +0,0 @@
54-
55-/*
56- * CINELERRA
57- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
58- *
59- * This program is free software; you can redistribute it and/or modify
60- * it under the terms of the GNU General Public License as published by
61- * the Free Software Foundation; either version 2 of the License, or
62- * (at your option) any later version.
63- *
64- * This program is distributed in the hope that it will be useful,
65- * but WITHOUT ANY WARRANTY; without even the implied warranty of
66- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67- * GNU General Public License for more details.
68- *
69- * You should have received a copy of the GNU General Public License
70- * along with this program; if not, write to the Free Software
71- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
72- *
73- */
74-
75-// ALPHA C++ can't compile 64 bit headers
76-#undef _LARGEFILE_SOURCE
77-#undef _LARGEFILE64_SOURCE
78-#undef _FILE_OFFSET_BITS
79-
80-#include "assets.h"
81-#include "bcsignals.h"
82-#include "channel.h"
83-#include "chantables.h"
84-#include "condition.h"
85-#include "file.inc"
86-#include "mutex.h"
87-#include "picture.h"
88-#include "playbackconfig.h"
89-#include "preferences.h"
90-#include "recordconfig.h"
91-#include "strategies.inc"
92-#include "vdevicebuz.h"
93-#include "vframe.h"
94-#include "videoconfig.h"
95-#include "videodevice.h"
96-
97-#include <errno.h>
98-#include <stdint.h>
99-#include <linux/kernel.h>
100-//#include <linux/videodev2.h>
101-#include <linux/videodev.h>
102-#include <fcntl.h>
103-#include <sys/ioctl.h>
104-#include <sys/mman.h>
105-#include <unistd.h>
106-
107-
108-
109-#define READ_TIMEOUT 5000000
110-
111-
112-VDeviceBUZInput::VDeviceBUZInput(VDeviceBUZ *device)
113- : Thread(1, 1, 0)
114-{
115- this->device = device;
116- buffer = 0;
117- buffer_size = 0;
118- total_buffers = 0;
119- current_inbuffer = 0;
120- current_outbuffer = 0;
121- done = 0;
122- output_lock = new Condition(0, "VDeviceBUZInput::output_lock");
123- buffer_lock = new Mutex("VDeviceBUZInput::buffer_lock");
124-}
125-
126-VDeviceBUZInput::~VDeviceBUZInput()
127-{
128- if(Thread::running())
129- {
130- done = 1;
131- Thread::cancel();
132- Thread::join();
133- }
134-
135- if(buffer)
136- {
137- for(int i = 0; i < total_buffers; i++)
138- {
139- delete [] buffer[i];
140- }
141- delete [] buffer;
142- delete [] buffer_size;
143- }
144- delete output_lock;
145- delete buffer_lock;
146-}
147-
148-void VDeviceBUZInput::start()
149-{
150-// Create buffers
151- total_buffers = device->device->in_config->capture_length;
152- buffer = new char*[total_buffers];
153- buffer_size = new int[total_buffers];
154- bzero(buffer_size, sizeof(int) * total_buffers);
155- for(int i = 0; i < total_buffers; i++)
156- {
157- buffer[i] = new char[INPUT_BUFFER_SIZE];
158- }
159-
160- Thread::start();
161-}
162-
163-void VDeviceBUZInput::run()
164-{
165- struct buz_sync bsync;
166-
167-// Wait for frame
168- while(1)
169- {
170- Thread::enable_cancel();
171- if(ioctl(device->jvideo_fd, BUZIOC_SYNC, &bsync) < 0)
172- {
173- perror("VDeviceBUZInput::run BUZIOC_SYNC");
174- if(done) return;
175- Thread::disable_cancel();
176- }
177- else
178- {
179- Thread::disable_cancel();
180-
181-
182-
183- int new_buffer = 0;
184- buffer_lock->lock("VDeviceBUZInput::run");
185-// Save only if the current buffer is free.
186- if(!buffer_size[current_inbuffer])
187- {
188- new_buffer = 1;
189-// Copy to input buffer
190- memcpy(buffer[current_inbuffer],
191- device->input_buffer + bsync.frame * device->breq.size,
192- bsync.length);
193-
194-// Advance input buffer number and decrease semaphore.
195- buffer_size[current_inbuffer] = bsync.length;
196- increment_counter(&current_inbuffer);
197- }
198-
199- buffer_lock->unlock();
200-
201- if(ioctl(device->jvideo_fd, BUZIOC_QBUF_CAPT, &bsync.frame))
202- perror("VDeviceBUZInput::run BUZIOC_QBUF_CAPT");
203-
204- if(new_buffer) output_lock->unlock();
205- }
206- }
207-}
208-
209-void VDeviceBUZInput::get_buffer(char **ptr, int *size)
210-{
211-// Increase semaphore to wait for buffer.
212- int result = output_lock->timed_lock(READ_TIMEOUT, "VDeviceBUZInput::get_buffer");
213-
214-
215-// The driver has its own timeout routine but it doesn't work because
216-// because the tuner lock is unlocked and relocked with no delay.
217-// int result = 0;
218-// output_lock->lock("VDeviceBUZInput::get_buffer");
219-
220- if(!result)
221- {
222-// Take over buffer table
223- buffer_lock->lock("VDeviceBUZInput::get_buffer");
224- *ptr = buffer[current_outbuffer];
225- *size = buffer_size[current_outbuffer];
226- buffer_lock->unlock();
227- }
228- else
229- {
230-//printf("VDeviceBUZInput::get_buffer 1\n");
231- output_lock->unlock();
232- }
233-}
234-
235-void VDeviceBUZInput::put_buffer()
236-{
237- buffer_lock->lock("VDeviceBUZInput::put_buffer");
238- buffer_size[current_outbuffer] = 0;
239- buffer_lock->unlock();
240- increment_counter(&current_outbuffer);
241-}
242-
243-void VDeviceBUZInput::increment_counter(int *counter)
244-{
245- (*counter)++;
246- if(*counter >= total_buffers) *counter = 0;
247-}
248-
249-void VDeviceBUZInput::decrement_counter(int *counter)
250-{
251- (*counter)--;
252- if(*counter < 0) *counter = total_buffers - 1;
253-}
254-
255-
256-
257-
258-
259-
260-
261-
262-
263-
264-
265-
266-
267-
268-
269-VDeviceBUZ::VDeviceBUZ(VideoDevice *device)
270- : VDeviceBase(device)
271-{
272- reset_parameters();
273- render_strategies.append(VRENDER_MJPG);
274- tuner_lock = new Mutex("VDeviceBUZ::tuner_lock");
275-}
276-
277-VDeviceBUZ::~VDeviceBUZ()
278-{
279- close_all();
280- delete tuner_lock;
281-}
282-
283-int VDeviceBUZ::reset_parameters()
284-{
285- jvideo_fd = 0;
286- input_buffer = 0;
287- output_buffer = 0;
288- frame_buffer = 0;
289- frame_size = 0;
290- frame_allocated = 0;
291- input_error = 0;
292- last_frame_no = 0;
293- temp_frame = 0;
294- user_frame = 0;
295- mjpeg = 0;
296- total_loops = 0;
297- output_number = 0;
298- input_thread = 0;
299- brightness = 32768;
300- hue = 32768;
301- color = 32768;
302- contrast = 32768;
303- whiteness = 32768;
304-}
305-
306-int VDeviceBUZ::close_input_core()
307-{
308- if(input_thread)
309- {
310- delete input_thread;
311- input_thread = 0;
312- }
313-
314-
315- if(device->r)
316- {
317- if(jvideo_fd) close(jvideo_fd);
318- jvideo_fd = 0;
319- }
320-
321- if(input_buffer)
322- {
323- if(input_buffer > 0)
324- munmap(input_buffer, breq.count * breq.size);
325- input_buffer = 0;
326- }
327-}
328-
329-int VDeviceBUZ::close_output_core()
330-{
331-//printf("VDeviceBUZ::close_output_core 1\n");
332- if(device->w)
333- {
334- int n = -1;
335-// if(ioctl(jvideo_fd, BUZIOC_QBUF_PLAY, &n) < 0)
336-// perror("VDeviceBUZ::close_output_core BUZIOC_QBUF_PLAY");
337- if(jvideo_fd) close(jvideo_fd);
338- jvideo_fd = 0;
339- }
340- if(output_buffer)
341- {
342- if(output_buffer > 0)
343- munmap(output_buffer, breq.count * breq.size);
344- output_buffer = 0;
345- }
346- if(temp_frame)
347- {
348- delete temp_frame;
349- temp_frame = 0;
350- }
351- if(mjpeg)
352- {
353- mjpeg_delete(mjpeg);
354- mjpeg = 0;
355- }
356- if(user_frame)
357- {
358- delete user_frame;
359- user_frame = 0;
360- }
361-//printf("VDeviceBUZ::close_output_core 2\n");
362- return 0;
363-}
364-
365-
366-int VDeviceBUZ::close_all()
367-{
368-//printf("VDeviceBUZ::close_all 1\n");
369- close_input_core();
370-//printf("VDeviceBUZ::close_all 1\n");
371- close_output_core();
372-//printf("VDeviceBUZ::close_all 1\n");
373- if(frame_buffer) delete frame_buffer;
374-//printf("VDeviceBUZ::close_all 1\n");
375- reset_parameters();
376-//printf("VDeviceBUZ::close_all 2\n");
377- return 0;
378-}
379-
380-#define COMPOSITE_TEXT "Composite"
381-#define SVIDEO_TEXT "S-Video"
382-#define BUZ_COMPOSITE 0
383-#define BUZ_SVIDEO 1
384-
385-void VDeviceBUZ::get_inputs(ArrayList<Channel*> *input_sources)
386-{
387- Channel *new_source = new Channel;
388-
389- new_source = new Channel;
390- strcpy(new_source->device_name, COMPOSITE_TEXT);
391- input_sources->append(new_source);
392-
393- new_source = new Channel;
394- strcpy(new_source->device_name, SVIDEO_TEXT);
395- input_sources->append(new_source);
396-}
397-
398-int VDeviceBUZ::open_input()
399-{
400- device->channel->use_norm = 1;
401- device->channel->use_input = 1;
402-
403- device->picture->use_brightness = 1;
404- device->picture->use_contrast = 1;
405- device->picture->use_color = 1;
406- device->picture->use_hue = 1;
407- device->picture->use_whiteness = 1;
408-
409-// Can't open input until after the channel is set
410- return 0;
411-}
412-
413-int VDeviceBUZ::open_output()
414-{
415-// Can't open output until after the channel is set
416- return 0;
417-}
418-
419-int VDeviceBUZ::set_channel(Channel *channel)
420-{
421- if(!channel) return 0;
422-
423- tuner_lock->lock("VDeviceBUZ::set_channel");
424-
425- if(device->r)
426- {
427- close_input_core();
428- open_input_core(channel);
429- }
430- else
431- {
432- close_output_core();
433- open_output_core(channel);
434- }
435-
436- tuner_lock->unlock();
437-
438-
439- return 0;
440-}
441-
442-void VDeviceBUZ::create_channeldb(ArrayList<Channel*> *channeldb)
443-{
444- ;
445-}
446-
447-int VDeviceBUZ::set_picture(PictureConfig *picture)
448-{
449- this->brightness = (int)((float)picture->brightness / 100 * 32767 + 32768);
450- this->hue = (int)((float)picture->hue / 100 * 32767 + 32768);
451- this->color = (int)((float)picture->color / 100 * 32767 + 32768);
452- this->contrast = (int)((float)picture->contrast / 100 * 32767 + 32768);
453- this->whiteness = (int)((float)picture->whiteness / 100 * 32767 + 32768);
454-
455-
456- tuner_lock->lock("VDeviceBUZ::set_picture");
457- if(device->r)
458- {
459- close_input_core();
460- open_input_core(0);
461- }
462- else
463- {
464- close_output_core();
465- open_output_core(0);
466- }
467- tuner_lock->unlock();
468-//
469-//
470-// TRACE("VDeviceBUZ::set_picture 1");
471-// tuner_lock->lock("VDeviceBUZ::set_picture");
472-// TRACE("VDeviceBUZ::set_picture 2");
473-//
474-//
475-//
476-// struct video_picture picture_params;
477-// // This call takes a long time in 2.4.22
478-// if(ioctl(jvideo_fd, VIDIOCGPICT, &picture_params) < 0)
479-// perror("VDeviceBUZ::set_picture VIDIOCGPICT");
480-// picture_params.brightness = brightness;
481-// picture_params.hue = hue;
482-// picture_params.colour = color;
483-// picture_params.contrast = contrast;
484-// picture_params.whiteness = whiteness;
485-// // This call takes a long time in 2.4.22
486-// if(ioctl(jvideo_fd, VIDIOCSPICT, &picture_params) < 0)
487-// perror("VDeviceBUZ::set_picture VIDIOCSPICT");
488-// if(ioctl(jvideo_fd, VIDIOCGPICT, &picture_params) < 0)
489-// perror("VDeviceBUZ::set_picture VIDIOCGPICT");
490-//
491-//
492-// TRACE("VDeviceBUZ::set_picture 10");
493-//
494-//
495-// tuner_lock->unlock();
496-
497- return 0;
498-}
499-
500-int VDeviceBUZ::get_norm(int norm)
501-{
502- switch(norm)
503- {
504- case NTSC: return VIDEO_MODE_NTSC; break;
505- case PAL: return VIDEO_MODE_PAL; break;
506- case SECAM: return VIDEO_MODE_SECAM; break;
507- }
508-}
509-
510-int VDeviceBUZ::read_buffer(VFrame *frame)
511-{
512- tuner_lock->lock("VDeviceBUZ::read_buffer");
513- if(!jvideo_fd) open_input_core(0);
514-
515-// Get buffer from thread
516- char *buffer = 0;
517- int buffer_size = 0;
518- if(input_thread)
519- input_thread->get_buffer(&buffer, &buffer_size);
520-
521- if(buffer)
522- {
523- frame->allocate_compressed_data(buffer_size);
524- frame->set_compressed_size(buffer_size);
525-
526-// Transfer fields to frame
527- if(device->odd_field_first)
528- {
529- long field2_offset = mjpeg_get_field2((unsigned char*)buffer, buffer_size);
530- long field1_len = field2_offset;
531- long field2_len = buffer_size - field2_offset;
532-
533- memcpy(frame->get_data(), buffer + field2_offset, field2_len);
534- memcpy(frame->get_data() + field2_len, buffer, field1_len);
535- }
536- else
537- {
538- bcopy(buffer, frame->get_data(), buffer_size);
539- }
540-
541- input_thread->put_buffer();
542- tuner_lock->unlock();
543- }
544- else
545- {
546- tuner_lock->unlock();
547- Timer timer;
548-// Allow other threads to lock the tuner_lock under NPTL.
549- timer.delay(100);
550- }
551-
552-
553- return 0;
554-}
555-
556-int VDeviceBUZ::open_input_core(Channel *channel)
557-{
558- jvideo_fd = open(device->in_config->buz_in_device, O_RDONLY);
559-
560- if(jvideo_fd <= 0)
561- {
562- fprintf(stderr, "VDeviceBUZ::open_input %s: %s\n",
563- device->in_config->buz_in_device,
564- strerror(errno));
565- jvideo_fd = 0;
566- return 1;
567- }
568-
569-// Create input sources
570- get_inputs(&device->input_sources);
571-
572-// Set current input source
573- if(channel)
574- {
575- for(int i = 0; i < 2; i++)
576- {
577- struct video_channel vch;
578- vch.channel = channel->input;
579- vch.norm = get_norm(channel->norm);
580-
581-//printf("VDeviceBUZ::open_input_core 2 %d %d\n", vch.channel, vch.norm);
582- if(ioctl(jvideo_fd, VIDIOCSCHAN, &vch) < 0)
583- perror("VDeviceBUZ::open_input_core VIDIOCSCHAN ");
584- }
585- }
586-
587-
588-// Throw away
589-// struct video_capability vc;
590-// if(ioctl(jvideo_fd, VIDIOCGCAP, &vc) < 0)
591-// perror("VDeviceBUZ::open_input VIDIOCGCAP");
592-
593-// API dependant initialization
594- if(ioctl(jvideo_fd, BUZIOC_G_PARAMS, &bparm) < 0)
595- perror("VDeviceBUZ::open_input BUZIOC_G_PARAMS");
596-
597- bparm.HorDcm = 1;
598- bparm.VerDcm = 1;
599- bparm.TmpDcm = 1;
600- bparm.field_per_buff = 2;
601- bparm.img_width = device->in_config->w;
602- bparm.img_height = device->in_config->h / bparm.field_per_buff;
603- bparm.img_x = 0;
604- bparm.img_y = 0;
605-// bparm.APPn = 0;
606-// bparm.APP_len = 14;
607- bparm.APP_len = 0;
608- bparm.odd_even = 0;
609- bparm.decimation = 0;
610- bparm.quality = device->quality;
611- bzero(bparm.APP_data, sizeof(bparm.APP_data));
612-
613- if(ioctl(jvideo_fd, BUZIOC_S_PARAMS, &bparm) < 0)
614- perror("VDeviceBUZ::open_input BUZIOC_S_PARAMS");
615-
616-// printf("open_input %d %d %d %d %d %d %d %d %d %d %d %d\n",
617-// bparm.HorDcm,
618-// bparm.VerDcm,
619-// bparm.TmpDcm,
620-// bparm.field_per_buff,
621-// bparm.img_width,
622-// bparm.img_height,
623-// bparm.img_x,
624-// bparm.img_y,
625-// bparm.APP_len,
626-// bparm.odd_even,
627-// bparm.decimation,
628-// bparm.quality);
629-
630- breq.count = device->in_config->capture_length;
631- breq.size = INPUT_BUFFER_SIZE;
632- if(ioctl(jvideo_fd, BUZIOC_REQBUFS, &breq) < 0)
633- perror("VDeviceBUZ::open_input BUZIOC_REQBUFS");
634-
635-//printf("open_input %s %d %d %d %d\n", device->in_config->buz_in_device, breq.count, breq.size, bparm.img_width, bparm.img_height);
636- if((input_buffer = (char*)mmap(0,
637- breq.count * breq.size,
638- PROT_READ,
639- MAP_SHARED,
640- jvideo_fd,
641- 0)) == MAP_FAILED)
642- perror("VDeviceBUZ::open_input mmap");
643-
644-
645-// Set picture quality
646- struct video_picture picture_params;
647-// This call takes a long time in 2.4.22
648- if(ioctl(jvideo_fd, VIDIOCGPICT, &picture_params) < 0)
649- perror("VDeviceBUZ::set_picture VIDIOCGPICT");
650- picture_params.brightness = brightness;
651- picture_params.hue = hue;
652- picture_params.colour = color;
653- picture_params.contrast = contrast;
654- picture_params.whiteness = whiteness;
655-// This call takes a long time in 2.4.22
656- if(ioctl(jvideo_fd, VIDIOCSPICT, &picture_params) < 0)
657- perror("VDeviceBUZ::set_picture VIDIOCSPICT");
658- if(ioctl(jvideo_fd, VIDIOCGPICT, &picture_params) < 0)
659- perror("VDeviceBUZ::set_picture VIDIOCGPICT");
660-
661-
662-
663-
664-// Start capturing
665- for(int i = 0; i < breq.count; i++)
666- {
667- if(ioctl(jvideo_fd, BUZIOC_QBUF_CAPT, &i) < 0)
668- perror("VDeviceBUZ::open_input BUZIOC_QBUF_CAPT");
669- }
670-
671-
672- input_thread = new VDeviceBUZInput(this);
673- input_thread->start();
674-//printf("VDeviceBUZ::open_input_core 2\n");
675- return 0;
676-}
677-
678-int VDeviceBUZ::open_output_core(Channel *channel)
679-{
680-//printf("VDeviceBUZ::open_output 1\n");
681- total_loops = 0;
682- output_number = 0;
683- jvideo_fd = open(device->out_config->buz_out_device, O_RDWR);
684- if(jvideo_fd <= 0)
685- {
686- perror("VDeviceBUZ::open_output");
687- return 1;
688- }
689-
690-
691-// Set current input source
692- if(channel)
693- {
694- struct video_channel vch;
695- vch.channel = channel->input;
696- vch.norm = get_norm(channel->norm);
697-
698- if(ioctl(jvideo_fd, VIDIOCSCHAN, &vch) < 0)
699- perror("VDeviceBUZ::open_output_core VIDIOCSCHAN ");
700- }
701-
702- breq.count = 10;
703- breq.size = INPUT_BUFFER_SIZE;
704- if(ioctl(jvideo_fd, BUZIOC_REQBUFS, &breq) < 0)
705- perror("VDeviceBUZ::open_output BUZIOC_REQBUFS");
706- if((output_buffer = (char*)mmap(0,
707- breq.count * breq.size,
708- PROT_READ | PROT_WRITE,
709- MAP_SHARED,
710- jvideo_fd,
711- 0)) == MAP_FAILED)
712- perror("VDeviceBUZ::open_output mmap");
713-
714- if(ioctl(jvideo_fd, BUZIOC_G_PARAMS, &bparm) < 0)
715- perror("VDeviceBUZ::open_output BUZIOC_G_PARAMS");
716-
717- bparm.decimation = 1;
718- bparm.HorDcm = 1;
719- bparm.field_per_buff = 2;
720- bparm.TmpDcm = 1;
721- bparm.VerDcm = 1;
722- bparm.img_width = device->out_w;
723- bparm.img_height = device->out_h / bparm.field_per_buff;
724- bparm.img_x = 0;
725- bparm.img_y = 0;
726- bparm.odd_even = 0;
727-
728- if(ioctl(jvideo_fd, BUZIOC_S_PARAMS, &bparm) < 0)
729- perror("VDeviceBUZ::open_output BUZIOC_S_PARAMS");
730-//printf("VDeviceBUZ::open_output 2\n");
731- return 0;
732-}
733-
734-
735-
736-int VDeviceBUZ::write_buffer(VFrame *frame, EDL *edl)
737-{
738-//printf("VDeviceBUZ::write_buffer 1\n");
739- tuner_lock->lock("VDeviceBUZ::write_buffer");
740-
741- if(!jvideo_fd) open_output_core(0);
742-
743- VFrame *ptr = 0;
744- if(frame->get_color_model() != BC_COMPRESSED)
745- {
746- if(!temp_frame) temp_frame = new VFrame;
747- if(!mjpeg)
748- {
749- mjpeg = mjpeg_new(device->out_w, device->out_h, 2);
750- mjpeg_set_quality(mjpeg, device->quality);
751- mjpeg_set_float(mjpeg, 0);
752- }
753- ptr = temp_frame;
754- mjpeg_compress(mjpeg,
755- frame->get_rows(),
756- frame->get_y(),
757- frame->get_u(),
758- frame->get_v(),
759- frame->get_color_model(),
760- device->cpus);
761- temp_frame->allocate_compressed_data(mjpeg_output_size(mjpeg));
762- temp_frame->set_compressed_size(mjpeg_output_size(mjpeg));
763- bcopy(mjpeg_output_buffer(mjpeg), temp_frame->get_data(), mjpeg_output_size(mjpeg));
764- }
765- else
766- ptr = frame;
767-
768-// Wait for frame to become available
769-// Caused close_output_core to lock up.
770-// if(total_loops >= 1)
771-// {
772-// if(ioctl(jvideo_fd, BUZIOC_SYNC, &output_number) < 0)
773-// perror("VDeviceBUZ::write_buffer BUZIOC_SYNC");
774-// }
775-
776- if(device->out_config->buz_swap_fields)
777- {
778- long field2_offset = mjpeg_get_field2((unsigned char*)ptr->get_data(),
779- ptr->get_compressed_size());
780- long field2_len = ptr->get_compressed_size() - field2_offset;
781- memcpy(output_buffer + output_number * breq.size,
782- ptr->get_data() + field2_offset,
783- field2_len);
784- memcpy(output_buffer + output_number * breq.size +field2_len,
785- ptr->get_data(),
786- field2_offset);
787- }
788- else
789- {
790- bcopy(ptr->get_data(),
791- output_buffer + output_number * breq.size,
792- ptr->get_compressed_size());
793- }
794-
795- if(ioctl(jvideo_fd, BUZIOC_QBUF_PLAY, &output_number) < 0)
796- perror("VDeviceBUZ::write_buffer BUZIOC_QBUF_PLAY");
797-
798- output_number++;
799- if(output_number >= breq.count)
800- {
801- output_number = 0;
802- total_loops++;
803- }
804- tuner_lock->unlock();
805-//printf("VDeviceBUZ::write_buffer 2\n");
806-
807- return 0;
808-}
809-
810-void VDeviceBUZ::new_output_buffer(VFrame *output,
811- int colormodel)
812-{
813-//printf("VDeviceBUZ::new_output_buffer 1 %d\n", colormodel);
814- if(user_frame)
815- {
816- if(colormodel != user_frame->get_color_model())
817- {
818- delete user_frame;
819- user_frame = 0;
820- }
821- }
822-
823- if(!user_frame)
824- {
825- switch(colormodel)
826- {
827- case BC_COMPRESSED:
828- user_frame = new VFrame;
829- break;
830- default:
831- user_frame = new VFrame(0,
832- device->out_w,
833- device->out_h,
834- colormodel,
835- -1);
836- break;
837- }
838- }
839- user_frame->set_shm_offset(0);
840- output = user_frame;
841-//printf("VDeviceBUZ::new_output_buffer 2\n");
842-}
843-
844-
845-ArrayList<int>* VDeviceBUZ::get_render_strategies()
846-{
847- return &render_strategies;
848-}
849-
850diff -Nru cinelerra.orig//cinelerra/vdevicebuz.h cinelerra/cinelerra/vdevicebuz.h
851--- cinelerra.orig//cinelerra/vdevicebuz.h 2010-11-24 18:18:03.000000000 -0500
852+++ cinelerra/cinelerra/vdevicebuz.h 1969-12-31 19:00:00.000000000 -0500
853@@ -1,130 +0,0 @@
854-
855-/*
856- * CINELERRA
857- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
858- *
859- * This program is free software; you can redistribute it and/or modify
860- * it under the terms of the GNU General Public License as published by
861- * the Free Software Foundation; either version 2 of the License, or
862- * (at your option) any later version.
863- *
864- * This program is distributed in the hope that it will be useful,
865- * but WITHOUT ANY WARRANTY; without even the implied warranty of
866- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
867- * GNU General Public License for more details.
868- *
869- * You should have received a copy of the GNU General Public License
870- * along with this program; if not, write to the Free Software
871- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
872- *
873- */
874-
875-#ifndef VDEVICEBUZ_H
876-#define VDEVICEBUZ_H
877-
878-#include "buz.h"
879-#include "channel.inc"
880-#include "condition.inc"
881-#include "guicast.h"
882-#include "libmjpeg.h"
883-#include "mutex.inc"
884-#include "thread.h"
885-#include "vdevicebase.h"
886-#include "vdevicebuz.inc"
887-#include "vframe.inc"
888-
889-
890-#define INPUT_BUFFER_SIZE 0x40000
891-
892-// Let's get real. The Buz driver doesn't work. If the buffers overflow
893-// for enough time it locks up and can't be recovered except by a
894-// SIGINT and restart. We need to cascade the buffer reading in another
895-// ring buffer thread, have it read continuously, and cancel it if it
896-// dies. How about if we do this in SCHED_RR and wait for it to die before
897-// implementing cancellation?
898-
899-
900-class VDeviceBUZInput : public Thread
901-{
902-public:
903- VDeviceBUZInput(VDeviceBUZ *device);
904- ~VDeviceBUZInput();
905- void start();
906- void run();
907- void get_buffer(char **ptr, int *size);
908- void put_buffer();
909- void increment_counter(int *counter);
910- void decrement_counter(int *counter);
911- VDeviceBUZ *device;
912-
913- char **buffer;
914- int *buffer_size;
915- int total_buffers;
916- int current_inbuffer;
917- int current_outbuffer;
918- Condition *output_lock;
919- Mutex *buffer_lock;
920- int done;
921-};
922-
923-
924-class VDeviceBUZ : public VDeviceBase
925-{
926-public:
927- VDeviceBUZ(VideoDevice *device);
928- ~VDeviceBUZ();
929-
930- friend class VDeviceBUZInput;
931-
932- int open_input();
933- int open_output();
934- int close_all();
935- int read_buffer(VFrame *frame);
936- int write_buffer(VFrame *frames, EDL *edl);
937- int reset_parameters();
938- ArrayList<int>* get_render_strategies();
939- int set_channel(Channel *channel);
940- int get_norm(int norm);
941- static void get_inputs(ArrayList<Channel*> *input_sources);
942- int set_picture(PictureConfig *picture);
943- int get_best_colormodel(int colormodel);
944- void create_channeldb(ArrayList<Channel*> *channeldb);
945- void new_output_buffer(VFrame *output, int colormodel);
946-
947-
948-private:
949- int open_input_core(Channel *channel);
950- int close_input_core();
951- int open_output_core(Channel *channel);
952- int close_output_core();
953-
954- int jvideo_fd;
955- char *input_buffer, *frame_buffer, *output_buffer;
956- long frame_size, frame_allocated;
957- int input_error;
958-// quicktime_mjpeg_hdr jpeg_header;
959- long last_frame_no;
960- ArrayList<int> render_strategies;
961-// Temporary frame for compressing output data
962- VFrame *temp_frame;
963-// Frame given to user to acquire data
964- VFrame *user_frame;
965- mjpeg_t *mjpeg;
966- Mutex *tuner_lock;
967- VDeviceBUZInput *input_thread;
968-
969- struct buz_params bparm;
970- struct buz_requestbuffers breq;
971-// Can't CSYNC the first loop
972- int total_loops;
973-// Number of output frame to load
974- int output_number;
975-
976- int brightness;
977- int hue;
978- int color;
979- int contrast;
980- int whiteness;
981-};
982-
983-#endif
984diff -Nru cinelerra.orig//cinelerra/vdevicebuz.inc cinelerra/cinelerra/vdevicebuz.inc
985--- cinelerra.orig//cinelerra/vdevicebuz.inc 2010-11-24 18:18:03.000000000 -0500
986+++ cinelerra/cinelerra/vdevicebuz.inc 1969-12-31 19:00:00.000000000 -0500
987@@ -1,28 +0,0 @@
988-
989-/*
990- * CINELERRA
991- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
992- *
993- * This program is free software; you can redistribute it and/or modify
994- * it under the terms of the GNU General Public License as published by
995- * the Free Software Foundation; either version 2 of the License, or
996- * (at your option) any later version.
997- *
998- * This program is distributed in the hope that it will be useful,
999- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1000- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1001- * GNU General Public License for more details.
1002- *
1003- * You should have received a copy of the GNU General Public License
1004- * along with this program; if not, write to the Free Software
1005- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1006- *
1007- */
1008-
1009-#ifndef VDEVICEBUZ_INC
1010-#define VDEVICEBUZ_INC
1011-
1012-class VDeviceBUZ;
1013-class VDeviceBUZInput;
1014-
1015-#endif
1016diff -Nru cinelerra.orig//cinelerra/vdevicev4l.C cinelerra/cinelerra/vdevicev4l.C
1017--- cinelerra.orig//cinelerra/vdevicev4l.C 2010-11-24 18:18:03.000000000 -0500
1018+++ cinelerra/cinelerra/vdevicev4l.C 1969-12-31 19:00:00.000000000 -0500
1019@@ -1,574 +0,0 @@
1020-
1021-/*
1022- * CINELERRA
1023- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
1024- *
1025- * This program is free software; you can redistribute it and/or modify
1026- * it under the terms of the GNU General Public License as published by
1027- * the Free Software Foundation; either version 2 of the License, or
1028- * (at your option) any later version.
1029- *
1030- * This program is distributed in the hope that it will be useful,
1031- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1032- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1033- * GNU General Public License for more details.
1034- *
1035- * You should have received a copy of the GNU General Public License
1036- * along with this program; if not, write to the Free Software
1037- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1038- *
1039- */
1040-
1041-// V4L2 is incompatible with large file support
1042-// ALPHA C++ can't compile 64 bit headers
1043-#undef _FILE_OFFSET_BITS
1044-#undef _LARGEFILE_SOURCE
1045-#undef _LARGEFILE64_SOURCE
1046-
1047-
1048-#include "assets.h"
1049-#include "bcsignals.h"
1050-#include "channel.h"
1051-#include "chantables.h"
1052-#include "clip.h"
1053-#include "file.h"
1054-#include "picture.h"
1055-#include "preferences.h"
1056-#include "quicktime.h"
1057-#include "recordconfig.h"
1058-#include "vdevicev4l.h"
1059-#include "vframe.h"
1060-#include "videodevice.h"
1061-
1062-#include <unistd.h>
1063-#include <sys/ioctl.h>
1064-#include <fcntl.h>
1065-#include <sys/mman.h>
1066-#include <string.h>
1067-
1068-VDeviceV4L::VDeviceV4L(VideoDevice *device)
1069- : VDeviceBase(device)
1070-{
1071- initialize();
1072-}
1073-
1074-VDeviceV4L::~VDeviceV4L()
1075-{
1076-}
1077-
1078-int VDeviceV4L::initialize()
1079-{
1080- capture_buffer = 0;
1081- capture_frame_number = 0;
1082- read_frame_number = 0;
1083- shared_memory = 0;
1084- initialization_complete = 0;
1085- return 0;
1086-}
1087-
1088-int VDeviceV4L::open_input()
1089-{
1090- device->channel->use_frequency = 1;
1091- device->channel->use_fine = 1;
1092- device->channel->use_norm = 1;
1093- device->channel->use_input = 1;
1094-
1095-
1096- device->picture->use_brightness = 1;
1097- device->picture->use_contrast = 1;
1098- device->picture->use_color = 1;
1099- device->picture->use_hue = 1;
1100- device->picture->use_whiteness = 1;
1101-
1102- if((input_fd = open(device->in_config->v4l_in_device, O_RDWR)) < 0)
1103- {
1104- perror("VDeviceV4L::open_input");
1105- return 1;
1106- }
1107- else
1108- {
1109- v4l1_get_inputs();
1110- close(input_fd);
1111- }
1112- return 0;
1113-}
1114-
1115-int VDeviceV4L::close_all()
1116-{
1117- close_v4l();
1118- return 0;
1119-}
1120-
1121-int VDeviceV4L::close_v4l()
1122-{
1123- unmap_v4l_shmem();
1124- if(input_fd != -1) close(input_fd);
1125- return 0;
1126-}
1127-
1128-int VDeviceV4L::unmap_v4l_shmem()
1129-{
1130- if(capture_buffer)
1131- {
1132- if(shared_memory)
1133- munmap(capture_buffer, capture_params.size);
1134- else
1135- delete capture_buffer;
1136- capture_buffer = 0;
1137- }
1138- return 0;
1139-}
1140-
1141-int VDeviceV4L::v4l_init()
1142-{
1143- int i;
1144-
1145- input_fd = open(device->in_config->v4l_in_device, O_RDWR);
1146-
1147- if(input_fd < 0)
1148- perror("VDeviceV4L::v4l_init");
1149- else
1150- {
1151- set_cloexec_flag(input_fd, 1);
1152- set_mute(0);
1153- if(ioctl(input_fd, VIDIOCGWIN, &window_params) < 0)
1154- perror("VDeviceV4L::v4l_init VIDIOCGWIN");
1155- window_params.x = 0;
1156- window_params.y = 0;
1157- window_params.width = device->in_config->w;
1158- window_params.height = device->in_config->h;
1159- window_params.chromakey = 0;
1160- window_params.flags = 0;
1161- window_params.clipcount = 0;
1162- if(ioctl(input_fd, VIDIOCSWIN, &window_params) < 0)
1163- perror("VDeviceV4L::v4l_init VIDIOCSWIN");
1164- if(ioctl(input_fd, VIDIOCGWIN, &window_params) < 0)
1165- perror("VDeviceV4L::v4l_init VIDIOCGWIN");
1166-
1167- device->in_config->w = window_params.width;
1168- device->in_config->h = window_params.height;
1169-
1170- PictureConfig picture(0);
1171- set_picture(&picture);
1172-
1173- if(ioctl(input_fd, VIDIOCGMBUF, &capture_params) < 0)
1174- perror("VDeviceV4L::v4l_init VIDIOCGMBUF");
1175-
1176- capture_buffer = (char*)mmap(0,
1177- capture_params.size,
1178- PROT_READ|PROT_WRITE,
1179- MAP_SHARED,
1180- input_fd,
1181- 0);
1182-
1183- capture_frame_number = 0;
1184-
1185- if(capture_buffer == MAP_FAILED)
1186- {
1187-// Use read instead.
1188- perror("VDeviceV4L::v4l_init mmap");
1189- shared_memory = 0;
1190- capture_buffer = new char[capture_params.size];
1191- }
1192- else
1193- {
1194-// Get all frames capturing
1195- shared_memory = 1;
1196- }
1197- }
1198- got_first_frame = 0;
1199- return 0;
1200-}
1201-
1202-void VDeviceV4L::v4l1_start_capture()
1203-{
1204- for(int i = 0; i < MIN(capture_params.frames, device->in_config->capture_length); i++)
1205- capture_frame(i);
1206-}
1207-
1208-
1209-
1210-
1211-
1212-
1213-
1214-
1215-int VDeviceV4L::v4l1_get_inputs()
1216-{
1217- struct video_channel channel_struct;
1218- int i = 0, done = 0;
1219- char *new_source;
1220-
1221- while(!done && i < 20)
1222- {
1223- channel_struct.channel = i;
1224- if(ioctl(input_fd, VIDIOCGCHAN, &channel_struct) < 0)
1225- {
1226-// Finished
1227- done = 1;
1228- }
1229- else
1230- {
1231- Channel *channel = new Channel;
1232- strcpy(channel->device_name, channel_struct.name);
1233- device->input_sources.append(channel);
1234- }
1235- i++;
1236- }
1237- return 0;
1238-}
1239-
1240-int VDeviceV4L::set_mute(int muted)
1241-{
1242-// Open audio, which obviously is controlled by the video driver.
1243-// and apparently resets the input source.
1244- v4l1_set_mute(muted);
1245-}
1246-
1247-int VDeviceV4L::v4l1_set_mute(int muted)
1248-{
1249- struct video_audio audio;
1250-
1251- if(ioctl(input_fd, VIDIOCGAUDIO, &audio))
1252- if(ioctl(input_fd, VIDIOCGAUDIO, &audio) < 0)
1253- perror("VDeviceV4L::ioctl VIDIOCGAUDIO");
1254-
1255- audio.volume = 65535;
1256- audio.bass = 65535;
1257- audio.treble = 65535;
1258- if(muted)
1259- audio.flags |= VIDEO_AUDIO_MUTE | VIDEO_AUDIO_VOLUME;
1260- else
1261- audio.flags &= ~VIDEO_AUDIO_MUTE;
1262-
1263- if(ioctl(input_fd, VIDIOCSAUDIO, &audio) < 0)
1264- perror("VDeviceV4L::ioctl VIDIOCSAUDIO");
1265- return 0;
1266-}
1267-
1268-
1269-int VDeviceV4L::set_cloexec_flag(int desc, int value)
1270-{
1271- int oldflags = fcntl(desc, F_GETFD, 0);
1272- if(oldflags < 0) return oldflags;
1273- if(value != 0)
1274- oldflags |= FD_CLOEXEC;
1275- else
1276- oldflags &= ~FD_CLOEXEC;
1277- return fcntl(desc, F_SETFD, oldflags);
1278-}
1279-
1280-
1281-
1282-
1283-
1284-int VDeviceV4L::get_best_colormodel(Asset *asset)
1285-{
1286- int result = BC_RGB888;
1287-
1288-// Get best colormodel for hardware acceleration
1289-
1290- result = File::get_best_colormodel(asset, device->in_config->driver);
1291-
1292-
1293-// Need to get color model before opening device but don't call this
1294-// unless you want to open the device either.
1295- if(!initialization_complete)
1296- {
1297- device_colormodel = translate_colormodel(result);
1298- this->colormodel = result;
1299- v4l_init();
1300- initialization_complete = 1;
1301- }
1302-// printf("VDeviceV4L::get_best_colormodel %c%c%c%c\n",
1303-// ((char*)&device_colormodel)[0],
1304-// ((char*)&device_colormodel)[1],
1305-// ((char*)&device_colormodel)[2],
1306-// ((char*)&device_colormodel)[3]);
1307- return result;
1308-}
1309-
1310-unsigned long VDeviceV4L::translate_colormodel(int colormodel)
1311-{
1312- unsigned long result = 0;
1313- switch(colormodel)
1314- {
1315- case BC_YUV422: result = VIDEO_PALETTE_YUV422; break;
1316- case BC_YUV420P: result = VIDEO_PALETTE_YUV420P; break;
1317- case BC_YUV422P: result = VIDEO_PALETTE_YUV422P; break;
1318- case BC_YUV411P: result = VIDEO_PALETTE_YUV411P; break;
1319- case BC_RGB888: result = VIDEO_PALETTE_RGB24; break;
1320- default: result = VIDEO_PALETTE_RGB24; break;
1321- }
1322-//printf("VDeviceV4L::translate_colormodel %d\n", result);
1323- return result;
1324-}
1325-
1326-int VDeviceV4L::set_channel(Channel *channel)
1327-{
1328- return v4l1_set_channel(channel);
1329-}
1330-
1331-int VDeviceV4L::v4l1_set_channel(Channel *channel)
1332-{
1333- struct video_channel channel_struct;
1334- struct video_tuner tuner_struct;
1335- unsigned long new_freq;
1336-
1337-// Mute changed the input to TV
1338-// set_mute(1);
1339-
1340-//printf("VDeviceV4L::v4l1_set_channel 1 %d\n", channel->input);
1341-// Read norm/input defaults
1342- channel_struct.channel = channel->input;
1343- if(ioctl(input_fd, VIDIOCGCHAN, &channel_struct) < 0)
1344- perror("VDeviceV4L::v4l1_set_channel VIDIOCGCHAN");
1345-
1346-// Set norm/input
1347- channel_struct.channel = channel->input;
1348- channel_struct.norm = v4l1_get_norm(channel->norm);
1349- if(ioctl(input_fd, VIDIOCSCHAN, &channel_struct) < 0)
1350- perror("VDeviceV4L::v4l1_set_channel VIDIOCSCHAN");
1351-
1352- if(channel_struct.flags & VIDEO_VC_TUNER)
1353- {
1354-// Read tuner defaults
1355- tuner_struct.tuner = channel->input;
1356- if(ioctl(input_fd, VIDIOCGTUNER, &tuner_struct) < 0)
1357- perror("VDeviceV4L::v4l1_set_channel VIDIOCGTUNER");
1358-
1359-// Set tuner
1360- tuner_struct.mode = v4l1_get_norm(channel->norm);
1361- if(ioctl(input_fd, VIDIOCSTUNER, &tuner_struct) < 0)
1362- perror("VDeviceV4L::v4l1_set_channel VIDIOCSTUNER");
1363-
1364- new_freq = chanlists[channel->freqtable].list[channel->entry].freq;
1365- new_freq = (int)(new_freq * 0.016);
1366- new_freq += channel->fine_tune;
1367-
1368- if(ioctl(input_fd, VIDIOCSFREQ, &new_freq) < 0)
1369- perror("VDeviceV4L::v4l1_set_channel VIDIOCSFREQ");
1370- }
1371-// set_mute(0);
1372- return 0;
1373-}
1374-
1375-int VDeviceV4L::v4l1_get_norm(int norm)
1376-{
1377- switch(norm)
1378- {
1379- case NTSC: return VIDEO_MODE_NTSC; break;
1380- case PAL: return VIDEO_MODE_PAL; break;
1381- case SECAM: return VIDEO_MODE_SECAM; break;
1382- }
1383- return 0;
1384-}
1385-
1386-int VDeviceV4L::set_picture(PictureConfig *picture)
1387-{
1388- v4l1_set_picture(picture);
1389-}
1390-
1391-
1392-int VDeviceV4L::v4l1_set_picture(PictureConfig *picture)
1393-{
1394- int brightness = (int)((float)picture->brightness / 100 * 32767 + 32768);
1395- int hue = (int)((float)picture->hue / 100 * 32767 + 32768);
1396- int color = (int)((float)picture->color / 100 * 32767 + 32768);
1397- int contrast = (int)((float)picture->contrast / 100 * 32767 + 32768);
1398- int whiteness = (int)((float)picture->whiteness / 100 * 32767 + 32768);
1399-
1400- if(ioctl(input_fd, VIDIOCGPICT, &picture_params) < 0)
1401- perror("VDeviceV4L::v4l1_set_picture VIDIOCGPICT");
1402- picture_params.brightness = brightness;
1403- picture_params.hue = hue;
1404- picture_params.colour = color;
1405- picture_params.contrast = contrast;
1406- picture_params.whiteness = whiteness;
1407-// Bogus. Values are only set in the capture routine.
1408- picture_params.depth = 3;
1409- picture_params.palette = device_colormodel;
1410- if(ioctl(input_fd, VIDIOCSPICT, &picture_params) < 0)
1411- perror("VDeviceV4L::v4l1_set_picture VIDIOCSPICT");
1412- if(ioctl(input_fd, VIDIOCGPICT, &picture_params) < 0)
1413- perror("VDeviceV4L::v4l1_set_picture VIDIOCGPICT");
1414- return 0;
1415-}
1416-
1417-
1418-int VDeviceV4L::capture_frame(int capture_frame_number)
1419-{
1420- struct video_mmap params;
1421- params.frame = capture_frame_number;
1422- params.width = device->in_config->w;
1423- params.height = device->in_config->h;
1424-// Required to actually set the palette.
1425- params.format = device_colormodel;
1426-// Tells the driver the buffer is available for writing
1427- if(ioctl(input_fd, VIDIOCMCAPTURE, &params) < 0)
1428- perror("VDeviceV4L::capture_frame VIDIOCMCAPTURE");
1429- return 0;
1430-}
1431-
1432-int VDeviceV4L::wait_v4l_frame()
1433-{
1434-//printf("VDeviceV4L::wait_v4l_frame 1 %d\n", capture_frame_number);
1435- if(ioctl(input_fd, VIDIOCSYNC, &capture_frame_number))
1436- perror("VDeviceV4L::wait_v4l_frame VIDIOCSYNC");
1437-//printf("VDeviceV4L::wait_v4l_frame 2 %d\n", capture_frame_number);
1438- return 0;
1439-}
1440-
1441-int VDeviceV4L::read_v4l_frame(VFrame *frame)
1442-{
1443- frame_to_vframe(frame, (unsigned char*)capture_buffer + capture_params.offsets[capture_frame_number]);
1444- return 0;
1445-}
1446-
1447-#ifndef MIN
1448-#define MIN(x, y) ((x) < (y) ? (x) : (y))
1449-#endif
1450-
1451-int VDeviceV4L::frame_to_vframe(VFrame *frame, unsigned char *input)
1452-{
1453- int inwidth, inheight;
1454- int width, height;
1455-
1456- inwidth = window_params.width;
1457- inheight = window_params.height;
1458-
1459- width = MIN(inwidth, frame->get_w());
1460- height = MIN(inheight, frame->get_h());
1461-//printf("VDeviceV4L::frame_to_vframe %d %d\n", colormodel, frame->get_color_model());
1462-
1463- if(frame->get_color_model() == colormodel)
1464- {
1465- switch(frame->get_color_model())
1466- {
1467- case BC_RGB888:
1468- {
1469- unsigned char *row_in;
1470- unsigned char *row_out_start, *row_out_end;
1471- int bytes_per_inrow = inwidth * 3;
1472- int bytes_per_outrow = frame->get_bytes_per_line();
1473- unsigned char **rows_out = frame->get_rows();
1474-
1475- for(int i = 0; i < frame->get_h(); i++)
1476- {
1477- row_in = input + bytes_per_inrow * i;
1478- row_out_start = rows_out[i];
1479- row_out_end = row_out_start +
1480- MIN(bytes_per_outrow, bytes_per_inrow);
1481-
1482- while(row_out_start < row_out_end)
1483- {
1484- *row_out_start++ = row_in[2];
1485- *row_out_start++ = row_in[1];
1486- *row_out_start++ = row_in[0];
1487- row_in += 3;
1488- }
1489- }
1490- break;
1491- }
1492-
1493- case BC_YUV420P:
1494- case BC_YUV411P:
1495- memcpy(frame->get_y(), input, width * height);
1496- memcpy(frame->get_u(), input + width * height, width * height / 4);
1497- memcpy(frame->get_v(), input + width * height + width * height / 4, width * height / 4);
1498- break;
1499-
1500- case BC_YUV422P:
1501- memcpy(frame->get_y(), input, width * height);
1502- memcpy(frame->get_u(), input + width * height, width * height / 2);
1503- memcpy(frame->get_v(), input + width * height + width * height / 2, width * height / 2);
1504- break;
1505-
1506- case BC_YUV422:
1507- memcpy(frame->get_data(),
1508- input,
1509- VFrame::calculate_data_size(width,
1510- height,
1511- -1,
1512- frame->get_color_model()));
1513- break;
1514- }
1515- }
1516- else
1517- {
1518- VFrame *in_frame = new VFrame(input,
1519- inwidth,
1520- inheight,
1521- colormodel,
1522- -1);
1523- cmodel_transfer(frame->get_rows(),
1524- in_frame->get_rows(),
1525- frame->get_y(),
1526- frame->get_u(),
1527- frame->get_v(),
1528- in_frame->get_y(),
1529- in_frame->get_u(),
1530- in_frame->get_v(),
1531- 0,
1532- 0,
1533- inwidth,
1534- inheight,
1535- 0,
1536- 0,
1537- frame->get_w(),
1538- frame->get_h(),
1539- colormodel,
1540- frame->get_color_model(),
1541- 0,
1542- inwidth,
1543- inheight);
1544- }
1545- return 0;
1546-}
1547-
1548-
1549-
1550-int VDeviceV4L::next_frame(int previous_frame)
1551-{
1552- int result = previous_frame + 1;
1553-
1554- if(result >= MIN(capture_params.frames, device->in_config->capture_length)) result = 0;
1555- return result;
1556-}
1557-
1558-int VDeviceV4L::read_buffer(VFrame *frame)
1559-{
1560- int result = 0;
1561-
1562-SET_TRACE
1563- if(shared_memory)
1564- {
1565-// Read the current frame
1566- if(!got_first_frame) v4l1_start_capture();
1567- wait_v4l_frame();
1568- read_v4l_frame(frame);
1569-// Free this frame up for capturing
1570- capture_frame(capture_frame_number);
1571-// Advance the frame to capture.
1572- capture_frame_number = next_frame(capture_frame_number);
1573- }
1574- else
1575- {
1576- read(input_fd, capture_buffer, capture_params.size);
1577- }
1578- got_first_frame = 1;
1579-SET_TRACE
1580-
1581- return 0;
1582-}
1583-
1584-
1585-
1586-
1587-
1588-
1589-
1590-
1591-
1592-
1593-
1594diff -Nru cinelerra.orig//cinelerra/vdevicev4l.h cinelerra/cinelerra/vdevicev4l.h
1595--- cinelerra.orig//cinelerra/vdevicev4l.h 2010-11-24 18:18:03.000000000 -0500
1596+++ cinelerra/cinelerra/vdevicev4l.h 1969-12-31 19:00:00.000000000 -0500
1597@@ -1,83 +0,0 @@
1598-
1599-/*
1600- * CINELERRA
1601- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
1602- *
1603- * This program is free software; you can redistribute it and/or modify
1604- * it under the terms of the GNU General Public License as published by
1605- * the Free Software Foundation; either version 2 of the License, or
1606- * (at your option) any later version.
1607- *
1608- * This program is distributed in the hope that it will be useful,
1609- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1610- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1611- * GNU General Public License for more details.
1612- *
1613- * You should have received a copy of the GNU General Public License
1614- * along with this program; if not, write to the Free Software
1615- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1616- *
1617- */
1618-
1619-#ifndef VDEVICEV4L_H
1620-#define VDEVICEV4L_H
1621-
1622-#include "vdevicebase.h"
1623-#include <linux/videodev.h>
1624-#include "videodevice.inc"
1625-
1626-class VDeviceV4L : public VDeviceBase
1627-{
1628-public:
1629- VDeviceV4L(VideoDevice *device);
1630- ~VDeviceV4L();
1631-
1632- int initialize();
1633- int open_input();
1634- int close_all();
1635- int read_buffer(VFrame *frame);
1636- int get_best_colormodel(Asset *asset);
1637- int set_channel(Channel *channel);
1638- int set_picture(PictureConfig *picture);
1639-
1640-private:
1641- int set_cloexec_flag(int desc, int value);
1642- int set_mute(int muted);
1643- int v4l1_get_inputs();
1644- int v4l1_set_mute(int muted);
1645- unsigned long translate_colormodel(int colormodel);
1646- int v4l1_set_channel(Channel *channel);
1647- int v4l1_get_norm(int norm);
1648- int v4l1_set_picture(PictureConfig *picture);
1649- void v4l1_start_capture();
1650- int capture_frame(int capture_frame_number);
1651- int wait_v4l_frame();
1652- int read_v4l_frame(VFrame *frame);
1653- int frame_to_vframe(VFrame *frame, unsigned char *input);
1654- int next_frame(int previous_frame);
1655- int close_v4l();
1656- int unmap_v4l_shmem();
1657- int v4l_init();
1658-
1659- int input_fd, output_fd;
1660-// FourCC Colormodel for device
1661- unsigned long device_colormodel;
1662-// BC colormodel for device
1663- int colormodel;
1664-
1665-// Video4Linux
1666- struct video_capability cap1;
1667- struct video_window window_params;
1668- struct video_picture picture_params;
1669- struct video_mbuf capture_params; // Capture for Video4Linux
1670-
1671-// Common
1672- char *capture_buffer; // sequentual capture buffers for v4l1 or read buffer for v4l2
1673- int capture_frame_number; // number of frame to capture into
1674- int read_frame_number; // number of the captured frame to read
1675- int shared_memory; // Capturing directly to memory
1676- int initialization_complete;
1677- int got_first_frame;
1678-};
1679-
1680-#endif
1681diff -Nru cinelerra.orig//cinelerra/vdevicev4l.inc cinelerra/cinelerra/vdevicev4l.inc
1682--- cinelerra.orig//cinelerra/vdevicev4l.inc 2010-11-24 18:18:03.000000000 -0500
1683+++ cinelerra/cinelerra/vdevicev4l.inc 1969-12-31 19:00:00.000000000 -0500
1684@@ -1,27 +0,0 @@
1685-
1686-/*
1687- * CINELERRA
1688- * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
1689- *
1690- * This program is free software; you can redistribute it and/or modify
1691- * it under the terms of the GNU General Public License as published by
1692- * the Free Software Foundation; either version 2 of the License, or
1693- * (at your option) any later version.
1694- *
1695- * This program is distributed in the hope that it will be useful,
1696- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1697- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1698- * GNU General Public License for more details.
1699- *
1700- * You should have received a copy of the GNU General Public License
1701- * along with this program; if not, write to the Free Software
1702- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1703- *
1704- */
1705-
1706-#ifndef VDEVICEV4L_INC
1707-#define VDEVICEV4L_INC
1708-
1709-class VDeviceV4L;
1710-
1711-#endif
1712diff -Nru cinelerra.orig//cinelerra/videodevice.C cinelerra/cinelerra/videodevice.C
1713--- cinelerra.orig//cinelerra/videodevice.C 2010-11-24 18:18:03.000000000 -0500
1714+++ cinelerra/cinelerra/videodevice.C 2011-02-17 13:41:53.239880001 -0500
1715@@ -39,9 +39,9 @@
1716 #ifdef HAVE_FIREWIRE
1717 #include "vdevice1394.h"
1718 #endif
1719-#include "vdevicebuz.h"
1720+//#include "vdevicebuz.h"
1721 #include "vdevicedvb.h"
1722-#include "vdevicev4l.h"
1723+//#include "vdevicev4l.h"
1724 #include "vdevicev4l2.h"
1725 #include "vdevicev4l2jpeg.h"
1726 #include "vdevicex11.h"
1727@@ -203,7 +203,6 @@
1728 result = input_base->open_input();
1729 break;
1730
1731-
1732 #ifdef HAVE_VIDEO4LINUX2
1733 case VIDEO4LINUX2:
1734 new_device_base();
1735@@ -250,8 +249,8 @@
1736 {
1737 switch(in_config->driver)
1738 {
1739- case VIDEO4LINUX:
1740- return input_base = new VDeviceV4L(this);
1741+ //case VIDEO4LINUX:
1742+ // return input_base = new VDeviceV4L(this);
1743
1744 #ifdef HAVE_VIDEO4LINUX2
1745 case VIDEO4LINUX2:
1746@@ -264,8 +263,8 @@
1747 case SCREENCAPTURE:
1748 return input_base = new VDeviceX11(this, 0);
1749
1750- case CAPTURE_BUZ:
1751- return input_base = new VDeviceBUZ(this);
1752+ //case CAPTURE_BUZ:
1753+ // return input_base = new VDeviceBUZ(this);
1754
1755 #ifdef HAVE_FIREWIRE
1756 case CAPTURE_FIREWIRE:
1757@@ -662,9 +661,9 @@
1758 //printf("VideoDevice::open_output 1 %d\n", out_config->driver);
1759 switch(out_config->driver)
1760 {
1761- case PLAYBACK_BUZ:
1762- output_base = new VDeviceBUZ(this);
1763- break;
1764+ //case PLAYBACK_BUZ:
1765+ // output_base = new VDeviceBUZ(this);
1766+ // break;
1767 case PLAYBACK_X11:
1768 case PLAYBACK_X11_XV:
1769 case PLAYBACK_X11_GL:
1770diff -Nru cinelerra.orig//cinelerra/videodevice.h cinelerra/cinelerra/videodevice.h
1771--- cinelerra.orig//cinelerra/videodevice.h 2010-11-24 18:18:03.000000000 -0500
1772+++ cinelerra/cinelerra/videodevice.h 2011-02-17 13:31:30.167880002 -0500
1773@@ -40,9 +40,9 @@
1774 #include "thread.h"
1775 #include "picture.inc"
1776 #include "vdevicebase.inc"
1777-#include "vdevicebuz.inc"
1778+//#include "vdevicebuz.inc"
1779 #include "vdevicelml.inc"
1780-#include "vdevicev4l.inc"
1781+//#include "vdevicev4l.inc"
1782 #include "vdevicex11.inc"
1783 #include "videoconfig.inc"
1784 #include "videowindow.inc"
1785--- cinelerra-cv/cinelerra/Makefile.am~ 2011-04-06 20:33:34.474397085 +0200
1786+++ cinelerra-cv/cinelerra/Makefile.am 2011-04-06 20:36:44.323074826 +0200
1787@@ -628,7 +628,6 @@
1788 vautomation.h \
1789 vdevice1394.h \
1790 vdevicebase.h \
1791- vdevicebuz.h \
1792 vdevicedvb.h \
1793 vdevicelml.h \
1794 vdeviceprefs.h \
1795--- cinelerra-cv/cinelerra/Makefile.am~ 2011-04-06 20:37:25.104939175 +0200
1796+++ cinelerra-cv/cinelerra/Makefile.am 2011-04-06 20:40:03.768860034 +0200
1797@@ -631,7 +631,6 @@
1798 vdevicedvb.h \
1799 vdevicelml.h \
1800 vdeviceprefs.h \
1801- vdevicev4l.h \
1802 vdevicev4l2.h \
1803 vdevicev4l2jpeg.h \
1804 vdevicex11.h \
This page took 0.407396 seconds and 4 git commands to generate.