Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PageMagickOverwrite Class Reference

Implementation of the Overwrite frame source. More...

Inheritance diagram for PageMagickOverwrite:

Inheritance graph
[legend]
Collaboration diagram for PageMagickOverwrite:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void Initialise (PageMagickInfo *)
void GetFrame (uint8_t *pixels, int16_t **audio, int i)
void GetFrame (uint8_t *pixels, int width, int height, int16_t **audio, int i)
void Close ()

Private Attributes

PageMagickInfoinfo

Detailed Description

Implementation of the Overwrite frame source.

Definition at line 717 of file page_magick.cc.


Member Function Documentation

void PageMagickOverwrite::Close  )  [virtual]
 

Reimplemented from PageMagickFrames.

Definition at line 852 of file page_magick.cc.

References PageMagickInfo::begin, PageMagickInfo::end, PageMagickInfo::GetCommon(), and info.

00853 {
00854     cerr << ">>> Deleting " << info->begin << " << " << info->end << endl;
00855     info->GetCommon() ->getPlayList() ->Delete( info->begin, info->end );
00856 }

void PageMagickOverwrite::GetFrame uint8_t *  pixels,
int  width,
int  height,
int16_t **  audio,
int  i
[virtual]
 

Reimplemented from PageMagickFrames.

Definition at line 813 of file page_magick.cc.

References AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY, common, AudioResampleFactory< input_t, output_t >::createAudioResample(), PageMagickInfo::frequency, Frame::GetAudioInfo(), GetFramePool(), KinoCommon::getPlayList(), info, AudioResample< input_t, output_t >::output, AudioResample< input_t, output_t >::Resample(), PageMagickInfo::samples_this_frame, and AudioResample< input_t, output_t >::size.

00814 {
00815     Frame* infoFrame = GetFramePool()->GetFrame();
00816     common->getPlayList() ->GetFrame( i, *( infoFrame ) );
00817 
00818     if ( audio )
00819     {
00820         AudioInfo ainfo;
00821         infoFrame->GetAudioInfo( ainfo );
00822         if ( ainfo.channels )
00823         {
00824             AudioResample<int16_ne_t,int16_ne_t> *resampler = AudioResampleFactory<int16_ne_t,int16_ne_t>::createAudioResample(
00825                                     AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY, info->frequency, false );
00826             resampler->Resample( *infoFrame );
00827             info->samples_this_frame = resampler->size / ( 2 * ainfo.channels );
00828             int16_t *p = resampler->output;
00829             for ( int s = 0; s < info->samples_this_frame; s++ )
00830                 for ( int c = 0; c < ainfo.channels; c++ )
00831                     audio[ c ][ s ] = *p++;
00832             delete resampler;
00833         }
00834     }
00835     if ( pixels )
00836     {
00837         infoFrame->decoder->quality = DV_QUALITY_BEST;
00838         infoFrame->ExtractRGB( pixels );
00839         if ( ( infoFrame->GetWidth() != width || infoFrame->GetHeight() != height ) )
00840         {
00841             GdkPixbuf * i1 = gdk_pixbuf_new_from_data( pixels, GDK_COLORSPACE_RGB, FALSE, 8,
00842                             infoFrame->GetWidth(), infoFrame->GetHeight(), infoFrame->GetWidth() * 3, NULL, NULL );
00843             GdkPixbuf *i2 = gdk_pixbuf_scale_simple( i1, width, height, GDK_INTERP_HYPER );
00844             memcpy( pixels, gdk_pixbuf_get_pixels( i2 ), width * height * 3 );
00845             g_object_unref( i2 );
00846             g_object_unref( i1 );
00847         }
00848     }
00849     GetFramePool()->DoneWithFrame( infoFrame );
00850 }

void PageMagickOverwrite::GetFrame uint8_t *  pixels,
int16_t **  audio,
int  i
[virtual]
 

Reimplemented from PageMagickFrames.

Definition at line 782 of file page_magick.cc.

References AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY, common, AudioResampleFactory< input_t, output_t >::createAudioResample(), PageMagickInfo::frequency, Frame::GetAudioInfo(), GetFramePool(), KinoCommon::getPlayList(), info, AudioResample< input_t, output_t >::output, AudioResample< input_t, output_t >::Resample(), PageMagickInfo::samples_this_frame, and AudioResample< input_t, output_t >::size.

00783 {
00784     Frame* infoFrame = GetFramePool()->GetFrame();
00785     common->getPlayList() ->GetFrame( i, *( infoFrame ) );
00786 
00787     if ( pixels )
00788     {
00789         infoFrame->decoder->quality = DV_QUALITY_BEST;
00790         infoFrame->ExtractRGB( pixels );
00791     }
00792 
00793     if ( audio )
00794     {
00795         AudioInfo ainfo;
00796         infoFrame->GetAudioInfo( ainfo );
00797         if ( ainfo.channels )
00798         {
00799             AudioResample<int16_ne_t,int16_ne_t> * resampler = AudioResampleFactory<int16_ne_t,int16_ne_t>::createAudioResample(
00800                                             AUDIO_RESAMPLE_SRC_SINC_BEST_QUALITY, info->frequency, false );
00801             resampler->Resample( *infoFrame );
00802             info->samples_this_frame = resampler->size / ( 2 * ainfo.channels );
00803             int16_t *p = resampler->output;
00804             for ( int s = 0; s < info->samples_this_frame; s++ )
00805                 for ( int c = 0; c < ainfo.channels; c++ )
00806                     audio[ c ][ s ] = *p++;
00807             delete resampler;
00808         }
00809     }
00810     GetFramePool()->DoneWithFrame( infoFrame );
00811 }

void PageMagickOverwrite::Initialise PageMagickInfo  )  [virtual]
 

Reimplemented from PageMagickFrames.

Definition at line 728 of file page_magick.cc.

References PageMagickInfo::begin, PageMagickInfo::end, PageMagickInfo::GetCommon(), PageMagickInfo::increment, lookup_widget(), PageMagickInfo::reverse, PageMagickInfo::SetAnteFrame(), PageMagickInfo::SetBegin(), PageMagickInfo::SetEnd(), and PageMagickInfo::SetPostFrame().

00729 {
00730     this->info = info;
00731     // Obtain begining and ending of sequence
00732     info->SetBegin( 0 );
00733     info->SetEnd( info->GetCommon() ->getPlayList() ->GetNumFrames() - 1 );
00734     info->increment = 1;
00735     info->reverse = false;
00736 
00737     GtkEntry *startSpin = GTK_ENTRY( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "spinbutton_magick_start" ) );
00738     GtkEntry *endSpin = GTK_ENTRY( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "spinbutton_magick_end" ) );
00739 
00740     if ( info->GetCommon() ->getPlayList() ->GetNumFrames() != 0 )
00741     {
00742         info->SetBegin( atoi( gtk_entry_get_text( startSpin ) ) );
00743         info->SetEnd( atoi( gtk_entry_get_text( endSpin ) ) );
00744         GtkToggleButton *limit = GTK_TOGGLE_BUTTON( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "checkbutton_magick_frame_limit" ) );
00745         if ( gtk_toggle_button_get_active( limit ) )
00746         {
00747             GtkEntry * spin = GTK_ENTRY( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "spinbutton_magick_limit" ) );
00748             GtkMenu *menu = GTK_MENU( gtk_option_menu_get_menu( GTK_OPTION_MENU( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "optionmenu_magick_frame_offset" ) ) ) );
00749             GtkWidget *active_item = gtk_menu_get_active( menu );
00750             if ( g_list_index ( GTK_MENU_SHELL ( menu ) ->children, active_item ) == 1 )
00751             {
00752                 int end = info->begin + atoi( gtk_entry_get_text( spin ) ) - 1;
00753                 if ( end < info->end )
00754                     info->SetEnd( end );
00755             }
00756             else
00757             {
00758                 info->SetBegin( info->end - atoi( gtk_entry_get_text( spin ) ) + 1 );
00759             }
00760         }
00761         info->SetAnteFrame( info->begin - 1 );
00762         info->SetPostFrame( info->end + 1 );
00763     }
00764     else
00765     {
00766         throw _( "No frames available for rewriting." );
00767     }
00768 
00769     // Determine speed
00770     GtkToggleButton *speed = GTK_TOGGLE_BUTTON( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "checkbutton_speed" ) );
00771     if ( gtk_toggle_button_get_active( speed ) )
00772     {
00773         GtkRange * range = GTK_RANGE( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "hscale_speed" ) );
00774         info->increment = range->adjustment->value;
00775     }
00776 
00777     // Determine direction
00778     GtkToggleButton *reverse = GTK_TOGGLE_BUTTON( lookup_widget( info->GetCommon() ->getPageMagick() ->window, "checkbutton_reverse" ) );
00779     info->reverse = gtk_toggle_button_get_active( reverse );
00780 }


Member Data Documentation

PageMagickInfo* PageMagickOverwrite::info [private]
 

Definition at line 720 of file page_magick.cc.

Referenced by Close(), and GetFrame().


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 22:13:19 2007 for Kino by  doxygen 1.4.2