From 90712e97bdc219492235f3ae04f3e707ae10e161 Mon Sep 17 00:00:00 2001 From: deva Date: Sun, 1 May 2005 11:25:56 +0000 Subject: Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. --- src/encoder.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'src/encoder.cc') diff --git a/src/encoder.cc b/src/encoder.cc index 9498cb9..21e418d 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -25,6 +25,9 @@ */ /* * $Log$ + * Revision 1.18 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.17 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -36,6 +39,10 @@ #include +// Use libdv +#include +#include + Encoder::Encoder(Error* err, const char *gip, const int gport, @@ -126,7 +133,12 @@ void Encoder::freeze() } -void Encoder::shoot() +/* + * shoot + * Set the shoot bit in the network header on the current frame. + * return the decodet (rgba) version af that frame, for thumbnail show. + */ +void Encoder::shoot(unsigned char *rgb) { if(!s) { s = new Socket(port, errobj); @@ -134,6 +146,7 @@ void Encoder::shoot() n = new Network(s, errobj); } if(!errobj->hasError()) shoot_request = 1 - shoot_request; + getScreenshot(rgb); } @@ -181,4 +194,48 @@ void Encoder::stop(n_savestate save) { } } + +void Encoder::getScreenshot(unsigned char *rgb) +{ + Frame *frame; + + unsigned char *pixels[3]; + int pitches[3]; + + pixels[ 0 ] = rgb; + pixels[ 1 ] = NULL; + pixels[ 2 ] = NULL; + + pitches[ 0 ] = 720 * 3; + pitches[ 1 ] = 0; + pitches[ 2 ] = 0; + + dv_decoder_t *decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); + decoder->quality = DV_QUALITY_BEST; + + frame = queue->peek(); + if(!frame) { + memset(rgb, 0, sizeof(rgb)); + return; + } + + dv_parse_header(decoder, frame->data); + + /* + decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate + decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v + decoder->std = e_dv_std_iec_61834; + decoder->num_dif_seqs = 12; + */ + + // libdv img decode to rgb + dv_decode_full_frame(decoder, + frame->data, + e_dv_color_rgb, + pixels, + pitches); + + dv_decoder_free(decoder); +} + #endif /*USE_GUI*/ -- cgit v1.2.3