From 9640339f2e9dc126406f6b6f8a091b924898b4f5 Mon Sep 17 00:00:00 2001 From: deva Date: Sun, 25 Sep 2005 20:59:02 +0000 Subject: *** empty log message *** --- src/.cvsignore | 6 +- src/Makefile.am | 7 +- src/audio_encoder.cc | 4 +- src/camera.cc | 19 +- src/camera.h | 4 +- src/dvfile.cc | 8 +- src/font.h | 3152 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/img_encoder.cc | 10 +- src/img_encoder.h | 6 +- src/mainwindow.cc | 2 +- src/messagebox.h | 2 +- src/miav.cc | 4 + src/miav.h | 5 + src/mov_encoder.cc | 2 +- src/player.cc | 46 +- src/player.h | 21 +- src/videowidget.cc | 4 +- src/yuv_draw.cc | 198 ++++ src/yuv_draw.h | 61 + 19 files changed, 3525 insertions(+), 36 deletions(-) create mode 100644 src/font.h create mode 100644 src/yuv_draw.cc create mode 100644 src/yuv_draw.h diff --git a/src/.cvsignore b/src/.cvsignore index 722a241..d1ba933 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -5,4 +5,8 @@ miav *.moc.o *.moc.cc .libs -.deps \ No newline at end of file +.deps +test_miav_config +test_file +compile_test_miav_config +compile_test_file \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index c7e6a7d..3adaf25 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,7 +42,8 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \ socket.cc \ thread.cc \ util.cc \ - videowidget.cc + videowidget.cc \ + yuv_draw.cc EXTRA_DIST = \ aboutwindow.h \ @@ -57,6 +58,7 @@ EXTRA_DIST = \ dvfile.h \ encoder.h \ file.h \ + font.h \ frame.h \ frame_stream.h \ historywidget.h \ @@ -89,7 +91,8 @@ EXTRA_DIST = \ socket.h \ thread.h \ util.h \ - videowidget.h + videowidget.h \ + yuv_draw.h miav_LDADD := $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList o; fi ) diff --git a/src/audio_encoder.cc b/src/audio_encoder.cc index 6bebe0c..8972e9a 100644 --- a/src/audio_encoder.cc +++ b/src/audio_encoder.cc @@ -62,7 +62,7 @@ void AudioEncoder::thread_main() unsigned int queuesize = 0; // Run with slightly lower priority than MovEncoderWriter - nice(2); + // nice(2); Frame *in_frame = NULL; Frame *out_frame = NULL; @@ -92,7 +92,7 @@ void AudioEncoder::thread_main() pthread_mutex_unlock( input_mutex ); // Unlock output mutex - sleep_1_frame(); + sleep_0_2_frame(); } // Check for end of stream diff --git a/src/camera.cc b/src/camera.cc index 4cb9ad9..d24f9af 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -100,18 +100,22 @@ Camera::~Camera() delete encode_queue; } -void Camera::setCpr(char *newcpr) +void Camera::setCpr(char *newcpr, char* name) { - if(initialized) encoder->setCpr(newcpr); - else info->error("Camera not initialized."); - + if(initialized) { + encoder->setCpr(newcpr); + player->setCpr(newcpr, name); // For the text overlay + } else { + info->error("Camera not initialized."); + } } void Camera::start() { - if(initialized) { + if(initialized) { + player->startrecord(); // For the text overlay encoder->start(); decoder->start(); } else { @@ -122,6 +126,7 @@ void Camera::start() void Camera::stop(n_savestate save) { if(initialized) { + player->stoprecord(); // For the textoverlay decoder->stop(save); encoder->stop(save); } else { @@ -164,9 +169,9 @@ int Camera::getQueueLength() return encode_queue->length(); } -void Camera::resize(int w, int h) +void Camera::resize(int w, int h, bool s) { - player->resize(w,h); + player->resize(w,h,s); } #endif/* USE_GUI */ diff --git a/src/camera.h b/src/camera.h index eee8bd7..beb1260 100644 --- a/src/camera.h +++ b/src/camera.h @@ -64,7 +64,7 @@ public: const int port, int width, int height); - void setCpr(char *newcpr); + void setCpr(char *newcpr, char* name); // Camera actions void start(); @@ -76,7 +76,7 @@ public: int getQueueLength(); // Indirect call to player->resize - void resize(int width, int height); + void resize(int width, int height, bool showtext); private: // Info object passed to all sub objects. diff --git a/src/dvfile.cc b/src/dvfile.cc index 7eab867..7d83255 100644 --- a/src/dvfile.cc +++ b/src/dvfile.cc @@ -28,8 +28,7 @@ #include "dvfile.h" #include "dv.h" - -#include +#include "util.h" dvfile::dvfile(Info* i) { @@ -45,12 +44,9 @@ dvfile::~dvfile() unsigned char *dvfile::readFrame() { - struct timespec ts; unsigned char *frame = new unsigned char[DVPACKAGE_SIZE]; - ts.tv_sec = 0; - ts.tv_nsec = 1000000000L / 25L; // 1/25s - nanosleep(&ts, NULL); + sleep_1_frame(); if(fp) { while(fread(frame, DVPACKAGE_SIZE, 1, fp) == 0) { diff --git a/src/font.h b/src/font.h new file mode 100644 index 0000000..64b5723 --- /dev/null +++ b/src/font.h @@ -0,0 +1,3152 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * font.h + * + * Thu Sep 22 15:40:39 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_FONT_H__ +#define __MIAV_FONT_H__ + +#define FONT_HEIGHT 10 +#define FONT_WIDTH 8 + +const char palette[] = { + "\0\0\0\0\0\0\0\0\0\0" // 0 - 9 + "\0\0\0\0\0\0\0\0\0\0" // 10 - 19 + "\0\0\0\0\0\0\0\0\0\0" // 20 - 29 + "\0\0\0\0\0\0\0\0\0\0" // 30 - 39 + "\0\0\0\0\0\0\0\0\0\0" // 40 - 49 + "\0\0\0\0\0\0\0\0\0\0" // 50 - 59 + "\0\0\0\0\0\0\0\0\0\0" // 60 - 69 + "\0\0\0\0\0\0\0\0\0\0" // 70 - 79 + "\0\0\0\0\0\0\0\0\0\0" // 80 - 89 + "\0\0\0\0\0\0\0\0\0\0" // 90 - 99 + "\0\0\0\0\0\0\0\0\0\0" //100 -109 + "\0\0\0\0\0\0\0\0\0\0" //110 -119 + "\255\0\0\0\0\0\0\0\0\0" //120 -129 + "\0\0\0\0\0\0\0\0\0\0" //130 -139 + "\0\0\0\0\0\0\0\0\0\0" //140 -149 + "\0\0\0\0\0\0\0\0\0\0" //150 -159 + "\0\0\0\0\0\0\0\0\0\0" //160 -169 + "\0\0\0\0\0\0\0\0\0\0" //170 -179 + "\0\0\0\0\0\0\0\0\0\0" //180 -189 + "\0\0\0\0\0\0\0\0\0\0" //190 -199 + "\0\0\0\0\0\0\0\0\0\0" //200 -209 + "\0\0\0\0\0\0\0\0\0\0" //210 -219 + "\0\0\0\0\0\0\0\0\0\0" //220 -229 + "\0\0\0\0\0\0\0\0\0\0" //230 -239 + "\0\0\0\0\0\0\0\0\0\0" //240 -249 + "\0\0\0\0\0\0" //250 -255 +}; + +const unsigned char letter[FONT_WIDTH + 1][FONT_HEIGHT][255] = { + { // 0 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 1 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 2 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 3 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 4 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 5 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 6 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 7 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 8 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 9 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // 10 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 11 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 12 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 13 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 14 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 15 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 16 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 17 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 18 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 19 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // 20 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 21 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 22 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 23 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 24 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 25 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 26 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 27 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 28 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 29 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // 30 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 31 + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 32 space + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 33 ! + " x ", + " x ", + " x ", + " x ", + " x ", + " x ", + " x ", + " ", + " x ", + " x ", + }, + { // 34 " + " ", + " x x ", + " x x ", + " x x ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // 35 # + " x x ", + " x x ", + "xxxxxxx ", + " x x ", + " x x ", + " x x ", + " x x ", + "xxxxxxx ", + " x x ", + " x x ", + }, + { // 36 $ + " x ", + " xxxxx ", + " x x x ", + "x x x ", + " x x ", + " xxxxx ", + "x x x ", + " x x x ", + " xxxxx ", + " x ", + }, + { // 37 % + " xx x ", + "x x x ", + " xx x ", + " x ", + " x ", + " x ", + " x ", + " x xx ", + "x x x ", + "x xx ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + }, + { // + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + } +}; + + +#endif/*__MIAV_FONT_H__*/ diff --git a/src/img_encoder.cc b/src/img_encoder.cc index 1516fc0..9282dc0 100644 --- a/src/img_encoder.cc +++ b/src/img_encoder.cc @@ -37,6 +37,10 @@ #include "debug.h" +extern "C" { +#include +} + #include "jpeg_mem_dest.h" // Use libdv @@ -103,12 +107,14 @@ void ImgEncoder::encode(Frame *dvframe, int quality) unsigned char rgb[720*576*4]; getRGB(dvframe, rgb); - writeJPEGFile(quality, (JSAMPLE*)rgb, 720, 576); + writeJPEGFile(quality, rgb, 720, 576); } -void ImgEncoder::writeJPEGFile(int quality, JSAMPLE * image_buffer, int image_width, int image_height) +void ImgEncoder::writeJPEGFile(int quality, unsigned char *rgb, int image_width, int image_height) { + JSAMPLE *image_buffer = (JSAMPLE*)rgb; + size_t buffersize = (image_width * image_height * 3) + JPEG_HEADER_PAD; char *jpeg_output_buffer = new char [buffersize]; struct jpeg_compress_struct cinfo; diff --git a/src/img_encoder.h b/src/img_encoder.h index 7237f48..e60e33b 100644 --- a/src/img_encoder.h +++ b/src/img_encoder.h @@ -40,10 +40,6 @@ #include "frame.h" #include "util.h" -extern "C" { -#include -} - //#include //#include @@ -59,7 +55,7 @@ public: ~ImgEncoder(); void encode(Frame *frame, int quality); void writeJPEGFile(int quality, - JSAMPLE * image_buffer, // Points to large array of R,G,B-order data + unsigned char *image_buffer, // Points to large array of R,G,B-order data int image_width, // Number of columns in image int image_height); // Number of rows in image diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 136f5c5..e709fe8 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -445,7 +445,7 @@ void MainWindow::cpr_clicked() clear(); lbl_name->setText(oldname); lbl_cpr->setText(oldcpr); - camera->setCpr((char*)lbl_cpr->text().ascii()); + camera->setCpr((char*)lbl_cpr->text().ascii(), (char*)lbl_name->text().ascii()); } } diff --git a/src/messagebox.h b/src/messagebox.h index 32753d7..c6786ca 100644 --- a/src/messagebox.h +++ b/src/messagebox.h @@ -69,7 +69,7 @@ typedef enum { * Textstrings */ #define TXT_OK "Ok" -#define TXT_CANCEL "Annulér" +#define TXT_CANCEL "Annullér" #define TXT_YES "Ja" #define TXT_NO "Nej" #define TXT_MAYBE "Mĺske" diff --git a/src/miav.cc b/src/miav.cc index dbb8b28..2efd2bf 100644 --- a/src/miav.cc +++ b/src/miav.cc @@ -47,6 +47,9 @@ typedef enum { MODE_SERVER } run_mode; +#ifdef USE_GUI +QApplication *miav_app; +#endif/*USE_GUI*/ /** * This function starts the MIaV gui. @@ -55,6 +58,7 @@ int grab(int argc, char *argv[]) { #ifdef USE_GUI QApplication miav_grab( argc, argv ); + miav_app = &miav_grab; MiavConfig cfg(ETC"/miav.conf", NULL); InfoGui info(&miav_grab, NULL, &cfg); diff --git a/src/miav.h b/src/miav.h index 6d5068a..ce7842a 100644 --- a/src/miav.h +++ b/src/miav.h @@ -34,4 +34,9 @@ #include "socket.h" #include "queue.h" +#ifdef USE_GUI +#include +extern QApplication *miav_app; +#endif/*USE_GUI*/ + #endif/*__LIBMIAV_H__*/ diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 209362b..cf45ae0 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -87,7 +87,7 @@ void MovEncoder::thread_main() int insize = 0; // Run with slightly lower priority than MovEncoderWriter AND AudioEncoder - nice(2); + //nice(3); FrameVector *item; Frame *in_frame; diff --git a/src/player.cc b/src/player.cc index de4e335..2f0638f 100644 --- a/src/player.cc +++ b/src/player.cc @@ -55,6 +55,8 @@ Player::Player(Info *ginfo, { // No errors has ocurred... yet! noErrors = true; + + yuv_draw = new YUVDraw(); width = w; height = h; @@ -71,11 +73,18 @@ Player::Player(Info *ginfo, initSDL(); bypass = false; + + // Do not show the text + showtext = false; + recording = false; + recording_prev = !recording; + cprchanged = false; } Player::~Player() { deinitSDL(); + if(yuv_draw) delete yuv_draw; } void Player::reinitSDL() @@ -130,6 +139,8 @@ void Player::initSDL() rect.y = 0; rect.w = width; rect.h = height; + + yuv_draw->setOverlay(overlay); } void Player::player() @@ -184,7 +195,7 @@ void Player::player() first = false; } - SDL_LockYUVOverlay(overlay); + if(SDL_LockYUVOverlay(overlay) == -1) info->error("SDL_LockYUVOverlay failed."); // libdv img decode to yuv dv_decode_full_frame(decoder, @@ -193,6 +204,19 @@ void Player::player() overlay->pixels, pitches); + if(showtext) { + if(cprchanged) { + yuv_draw->setBottomText(cpr); + cprchanged = false; + } + if(recording != recording_prev) { + if(recording) yuv_draw->setTopText("Recording"); + else yuv_draw->setTopText("Stopped"); + recording_prev = recording; + } + yuv_draw->draw(); + } + SDL_UnlockYUVOverlay(overlay); SDL_DisplayYUVOverlay(overlay, &rect); delete frame; @@ -240,7 +264,7 @@ void Player::stop() // FIXME: Worst case genario: the loop takes more than 1 second // to stop displaying => crash, due to deinitialization // of SDL, while calling it.! -void Player::resize(int w, int h) +void Player::resize(int w, int h, bool s) { // Tell loop to stop bypass = true; @@ -260,6 +284,24 @@ void Player::resize(int w, int h) // Tell loop to go on. bypass = false; + + showtext = s; +} + +void Player::setCpr(char *newcpr, char* name) +{ + sprintf(cpr, "ID: %s - %s", newcpr, name); + cprchanged = true; +} + +void Player::startrecord() +{ + recording = true; +} + +void Player::stoprecord() +{ + recording = false; } #endif /* USE_GUI */ diff --git a/src/player.h b/src/player.h index 9cfd440..14d08ac 100644 --- a/src/player.h +++ b/src/player.h @@ -53,6 +53,8 @@ #include +#include "yuv_draw.h" + //#define DISPLAYWIDTH 720 // FIXME: These numbers suck! //#define DISPLAYHEIGHT 576 @@ -70,11 +72,17 @@ public: pthread_mutex_t *gmutex); ~Player(); + // These functions are used to set the overlay text. + void setCpr(char *newcpr, char* name); + void startrecord(); + void stoprecord(); + + // Start and stop runnning video (freeze/unfreeze) void start(); void stop(); // Used to reinitialize the SDL output width a new size - void resize(int width, int height); + void resize(int width, int height, bool showtext); void thread_main(); @@ -93,6 +101,13 @@ private: // Set to true, whenever a resize is requested. volatile bool bypass; + // Vars for the text overlay + volatile bool showtext; + volatile bool recording; + bool recording_prev; + volatile bool cprchanged; + char cpr[256]; + Info *info; void player(); @@ -109,8 +124,10 @@ private: SDL_Surface *screen; SDL_Overlay *overlay; + + YUVDraw *yuv_draw; }; -#endif +#endif/*__RTVIDEOREC_PLAYER_H*/ #endif /* USE_GUI */ diff --git a/src/videowidget.cc b/src/videowidget.cc index 37cd5d5..61b5c8e 100644 --- a/src/videowidget.cc +++ b/src/videowidget.cc @@ -60,7 +60,7 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event) if(!parent) { // We are a fullscreen window QString ids; setenv("SDL_WINDOWID", ids.setNum(oldWindow->winId()), 1); - camera->resize(oldWindow->width(), oldWindow->height()); + camera->resize(oldWindow->width(), oldWindow->height(), false); destroy(); } else { // We are a nested window // first delete old instance (if any) @@ -69,7 +69,7 @@ void VideoWidget::mouseReleaseEvent(QMouseEvent *event) fs->showFullScreen(); fs->setFixedWidth(config->readInt("pixel_width")); fs->setFixedHeight(config->readInt("pixel_height")); - camera->resize(fs->width(), fs->height()); + camera->resize(fs->width(), fs->height(), true); } } diff --git a/src/yuv_draw.cc b/src/yuv_draw.cc new file mode 100644 index 0000000..30427b3 --- /dev/null +++ b/src/yuv_draw.cc @@ -0,0 +1,198 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * yuv_draw.cc + * + * Thu Sep 22 12:35:28 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#include "yuv_draw.h" + +// for miav_app +#include "miav.h" + +//#include "font.h" +#include + +#define TEXT_MARGIN 10 + +YUVDraw::YUVDraw() +{ + overlay = NULL; + + // One line of text! + top_pixmap = new QPixmap(720 - TEXT_MARGIN, 20); + bottom_pixmap = new QPixmap(720 - TEXT_MARGIN, 20); + + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + top_grey[x][y] = 255; + } + } + + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + bottom_grey[x][y] = 255; + } + } + +} + +YUVDraw::~YUVDraw() +{ + delete top_pixmap; + delete bottom_pixmap; +} + +void YUVDraw::setOverlay(SDL_Overlay* o) +{ + overlay = o; +} + +void YUVDraw::addPixel(int x, int y, int val) +{ + if(overlay->w < x) return; // Out of range + if(overlay->h < y) return; // Out of range + + Uint8 **pixels = overlay->pixels; + Uint16 *pitches = overlay->pitches; + + Uint8* pixel = &pixels[0][(2 * x) + (y * pitches[0])]; + + if(val > 0) *pixel = (255<*pixel+val?255:*pixel+val); + else *pixel = (0>*pixel+val?0:*pixel+val); +} + + +void YUVDraw::setTopText(char* text) +{ + miav_app->lock(); + top_pixmap->fill(); + + QPainter painter; + painter.begin(top_pixmap); + painter.setFont( QFont( "Arial", 12, QFont::Bold ) ); + painter.setPen( Qt::black ); + painter.drawText(0, 15, text); + painter.end(); + + QImage image = top_pixmap->convertToImage(); + + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + top_grey[x][y] = qGray(image.pixel(x, y)); + } + } + miav_app->unlock(); +} + +void YUVDraw::setBottomText(char* text) +{ + miav_app->lock(); + bottom_pixmap->fill(); + + QPainter painter; + painter.begin(bottom_pixmap); + painter.setFont( QFont( "Arial", 12, QFont::Bold ) ); + painter.setPen( Qt::black ); + painter.drawText(0, 15, text); + painter.end(); + + QImage image = bottom_pixmap->convertToImage(); + + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + bottom_grey[x][y] = qGray(image.pixel(x, y)); + } + } + miav_app->unlock(); +} + +void YUVDraw::draw() +{ + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + if(top_grey[x][y] != 255) addPixel(x + TEXT_MARGIN, y + TEXT_MARGIN, 255 - top_grey[x][y]); + } + } + + for(int x = 0; x < 720 - TEXT_MARGIN; x++) { + for(int y = 0; y < 20; y++) { + if(bottom_grey[x][y] != 255) addPixel(x + TEXT_MARGIN, (556 - TEXT_MARGIN)+ y, 255 - bottom_grey[x][y]); + } + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* +void YUVDraw::setText(int xoffset, int yoffset, char* text, int val) +{ + for(unsigned int i = 0; i < strlen(text); i++) { + for(int x = 0; x < FONT_WIDTH; x++) { + for(int y = 0; y < FONT_HEIGHT; y++) { + unsigned char col = palette[letter[(int)text[i]][y][x]]; + if(col) col += val; + addPixel(i * FONT_WIDTH + x + xoffset, y + yoffset, col); + } + } + } +} +*/ + +/* +typedef struct{ + Uint32 format; + int w, h; + int planes; + Uint16 *pitches; + Uint8 **pixels; + Uint32 hw_overlay:1; +} SDL_Overlay; +*/ diff --git a/src/yuv_draw.h b/src/yuv_draw.h new file mode 100644 index 0000000..c0cebf6 --- /dev/null +++ b/src/yuv_draw.h @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * yuv_draw.h + * + * Thu Sep 22 12:35:28 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_YUV_DRAW_H__ +#define __MIAV_YUV_DRAW_H__ + +#include + +#include +#include +#include + +class YUVDraw { +public: + YUVDraw(); + ~YUVDraw(); + + void setOverlay(SDL_Overlay* overlay); + + void addPixel(int x, int y, int val); + + void setTopText(char* text); + void setBottomText(char* text); + + void draw(); + +private: + SDL_Overlay* overlay; + + QPixmap *top_pixmap; + unsigned char top_grey[720][20]; + + QPixmap *bottom_pixmap; + unsigned char bottom_grey[720][20]; +}; + +#endif/*__MIAV_YUV_DRAW_H__*/ -- cgit v1.2.3