From 3b5893ffa6d4a761eff0d97c7223eecd4fc123c9 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 16 May 2005 13:25:52 +0000 Subject: Moved video setting to configuration file. Fine tuned setting for 2.4ghz server --- etc/miav.conf | 8 +++++ src/mov_encoder.cc | 86 +++++++++++++--------------------------------------- src/server_status.cc | 17 +++++++++-- 3 files changed, 43 insertions(+), 68 deletions(-) diff --git a/etc/miav.conf b/etc/miav.conf index 240d2a0..2ab5b48 100644 --- a/etc/miav.conf +++ b/etc/miav.conf @@ -23,3 +23,11 @@ server_port = 30000 # Where top store the files recieved by the server server_root = "/tmp/miav_files" +# Video output controls. A sequence of I and P, where I is keyframes +# which is fast to create, but uses a lot of discspace. +# B uses changes since last frame, is more cpu intensive, but uses a +# lot less diskspace than I frames +frame_sequence = "IPPPPPPPPPP" + +# quality in % - 100% is best quality +frame_quality = 80 diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 9e4e6f5..143fa2b 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,11 @@ /* * $Log$ + * Revision 1.19 2005/05/16 13:25:52 deva + * + * Moved video setting to configuration file. + * Fine tuned setting for 2.4ghz server + * * Revision 1.18 2005/05/16 11:13:24 deva * * Optimized some encoding parameters. @@ -79,6 +84,8 @@ #include +#include "miav_config.h" + #include "debug.h" //av_alloc_format_context //av_destruct_packet_nofree @@ -147,14 +154,13 @@ MovEncoder::MovEncoder(const char *filename) // to JPEG), whereas P and B frames are motion compressed, respectively // predicted from past reference (I or P) frame, or bidirectionally predicted // from past and future reference frame. - static const char coding[] = "IPPPPPPPPPPPPPPPPPPPPPPP\0"; - fame_par.coding = coding; + fame_par.coding = config->readString("frame_sequence")->c_str(); // quality is a percentage, which controls compression versus quality. - fame_par.quality = 80; // FIXME: This should be in config file! + fame_par.quality = config->readInt("frame_quality"); - ///////////////////////////// - fame_par.bitrate = 0; /* video bitrate (0=VBR)*/ + // Bitrate + fame_par.bitrate = 0; // video bitrate (0=VBR) // slices_per_frame is the number of frame slices per frame. More slices provide // better error recovery. There must be at least one slice per frame, and at most @@ -163,7 +169,7 @@ MovEncoder::MovEncoder(const char *filename) // frames_per_sequence is the maximum number of frames contained in a video // sequence. - fame_par.frames_per_sequence = 1024;//25 * 60 * 60 * 2; // 25 fps in two hours. + fame_par.frames_per_sequence = 0xffffffff; // Unlimited length // frame_rate_num/frame_rate_den specify the number of frames per second for // playback. @@ -172,20 +178,21 @@ MovEncoder::MovEncoder(const char *filename) // shape_quality is percentage determing the average binary shape accuracy in // video with arbitrary shape. - fame_par.shape_quality = 1; + fame_par.shape_quality = 100; // Original shape // search_range specifies the motion estimation search range in pixel unit. // Small search ranges work best with slow motion videos, whereas larger search // ranges are rather for fast motion videos. - fame_par.search_range = 10; // FIXME: No idea what this should be!? + fame_par.search_range = 0; // Adaptive search range // verbose when set to 1 outputs information on copyright, modules used and // current frame on standard error. - fame_par.verbose = 0; + fame_par.verbose = 1; - static const char profilename[] = "My Profile\0"; - fame_par.profile = profilename; /* profile name */ - fame_par.total_frames = 0; /* total number of frames */ + static const char profilename[] = "MIaV\0"; + fame_par.profile = profilename; // profile name + fame_par.total_frames = 0; // total number of frames + // fame_par.stats = NULL; // No need for statistics at the moment fame_init(fame_context, &fame_par, fame_buffer, FAME_BUFFER_SIZE); @@ -210,40 +217,17 @@ void MovEncoder::encode(Frame *dvframe) encode_audio(dvframe); } -//#define RGB - -#ifdef RGB -#define _CLAMP(x) (unsigned char) ((x)<0?0:(((x)>255)?255:(x))) - -inline void rgb_to_yuv(unsigned char *rgb, unsigned char &y, unsigned char &u, unsigned char &v) -{ - y = _CLAMP( 0.257 * rgb[0] + 0.504 * rgb[1] + 0.098 * rgb[2] + 16); - v = _CLAMP( 0.439 * rgb[0] - 0.368 * rgb[1] - 0.071 * rgb[2] + 128); - u = _CLAMP(-0.148 * rgb[0] - 0.291 * rgb[1] + 0.439 * rgb[2] + 128); -} -#endif - void MovEncoder::encode_video(Frame *dvframe) { if(!f) return; // The file was not opened. - // Decode DV Frame to YUV + // Decode DV Frame to YUV422 int w = 720; int h = 576; unsigned char *pixels[3]; int pitches[3]; -#ifdef RGB - pixels[ 0 ] = rgb; - pixels[ 1 ] = NULL; - pixels[ 2 ] = NULL; - - pitches[ 0 ] = 720 * 3; - pitches[ 1 ] = 0; - pitches[ 2 ] = 0; -#endif - if(!dvdecoder) { dvdecoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); dvdecoder->quality = DV_QUALITY_BEST; @@ -257,34 +241,6 @@ void MovEncoder::encode_video(Frame *dvframe) dvdecoder->num_dif_seqs = 12; } -#ifdef RGB - dv_decode_full_frame(dvdecoder, - dvframe->data, - e_dv_color_rgb, - pixels, - pitches); - - // cvt rgb to yuv - for (int y=0; y +#define UPD 25 ServerStatus::ServerStatus() { + gettimeofday(&oldtime, NULL); + for(int cnt = 0; cnt < BUFFERSIZE; cnt++) { - frametime[cnt] = 0; + frametime[cnt] = 41660 * UPD; } - gettimeofday(&oldtime, NULL); + gettimeofday(&time, NULL); } @@ -62,6 +70,9 @@ ServerStatus::~ServerStatus() void ServerStatus::checkPoint() { + static int frame = 0; + frame++; + if(frame % UPD != 0) return; for(int cnt = BUFFERSIZE - 1; cnt > 0; cnt--) { frametime[cnt] = frametime[cnt-1]; } @@ -76,7 +87,7 @@ void ServerStatus::checkPoint() for(int cnt = 0; cnt < BUFFERSIZE; cnt++) { total += (double)frametime[cnt]; } - fprintf(stderr, "[ms: %d, fps: %f]\n", frametime[0], 1000000.0 / (total / (double)BUFFERSIZE) ); + fprintf(stderr, "[ms: %d, fps: %f]\n", frametime[0] / UPD, (1000000.0 / (total / (double)BUFFERSIZE)) * UPD ); } -- cgit v1.2.3