From 8d535e795ef79b17394f3daeac11ed5600b36682 Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 7 May 2005 10:25:34 +0000 Subject: Removed ffmpeg code from img_encoder and corrected decoding errors in mov_encoder --- src/mov_encoder.cc | 77 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 14 deletions(-) (limited to 'src/mov_encoder.cc') diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 4eae91b..bce80f7 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.13 2005/05/07 10:25:34 deva + * + * Removed ffmpeg code from img_encoder and corrected decoding errors in mov_encoder + * * Revision 1.12 2005/05/05 20:41:38 deva * * Removed the last pieces of ffmpeg... replaced it with libfame... @@ -134,12 +138,12 @@ MovEncoder::MovEncoder(const char *filename) // frames_per_sequence is the maximum number of frames contained in a video // sequence. - fame_par.frames_per_sequence = 25 * 60 * 60 * 2; // 25 fps in two hours. + fame_par.frames_per_sequence = 1024;//25 * 60 * 60 * 2; // 25 fps in two hours. // frame_rate_num/frame_rate_den specify the number of frames per second for // playback. - fame_par.frame_rate_num = 25; // 25 / 1 fps = 25 fps - fame_par.frame_rate_den = 1; + fame_par.frame_rate_num = 10;//25; // 25 / 1 fps = 25 fps + fame_par.frame_rate_den = 30000;//1; // shape_quality is percentage determing the average binary shape accuracy in // video with arbitrary shape. @@ -148,7 +152,7 @@ MovEncoder::MovEncoder(const char *filename) // 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 = 42; // FIXME: No idea what this should be!? + fame_par.search_range = 10; // FIXME: No idea what this should be!? // verbose when set to 1 outputs information on copyright, modules used and // current frame on standard error. @@ -175,18 +179,33 @@ void MovEncoder::encode(Frame *dvframe) encode_audio(dvframe); } + +#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); +} + void MovEncoder::encode_video(Frame *dvframe) { // Decode DV Frame to YUV + int w = 720; + int h = 576; + unsigned char rgb[720*576*4]; + unsigned char *pixels[3]; int pitches[3]; - pitches[0] = yuv.w; - pitches[1] = yuv.h; - pitches[2] = yuv.p; - pixels[0] = yuv.y; - pixels[1] = yuv.u; - pixels[2] = yuv.v; + pixels[ 0 ] = rgb; + pixels[ 1 ] = NULL; + pixels[ 2 ] = NULL; + + pitches[ 0 ] = 720 * 3; + pitches[ 1 ] = 0; + pitches[ 2 ] = 0; if(!dvdecoder) { dvdecoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); @@ -203,14 +222,44 @@ void MovEncoder::encode_video(Frame *dvframe) dv_decode_full_frame(dvdecoder, dvframe->data, - e_dv_color_yuv, + e_dv_color_rgb, pixels, pitches); - + + /* + e_dv_color_yuv, + (uint8_t**) &yuv.y, //pixels, + (int*) &yuv.w);//pitches); + */ + // cvt rgb to yuv + for (int y=0; y