summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/lib.h7
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp48
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h10
-rw-r--r--noncore/multimedia/opieplayer2/nullvideo.c43
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp23
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.h10
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h31
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp0
-rw-r--r--noncore/multimedia/opieplayer2/yuv2rgb.c1
13 files changed, 178 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index b2143a0..748ae1f 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,227 +1,234 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 LJP <>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <qimage.h>
#include <qtextstream.h>
#include <qpe/resource.h>
#include <qfile.h>
#include <qgfx_qws.h>
#include <qdirectpainter_qws.h>
#include "xinevideowidget.h"
#include "frame.h"
#include "lib.h"
typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
int width, int height,int bytes );
extern "C" {
vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video);
int null_is_showing_video( vo_driver_t* self );
void null_set_show_video( vo_driver_t* self, int show );
int null_is_fullscreen( vo_driver_t* self );
void null_set_fullscreen( vo_driver_t* self, int screen );
int null_is_scaling( vo_driver_t* self );
void null_set_scaling( vo_driver_t* self, int scale );
void null_set_gui_width( vo_driver_t* self, int width );
void null_set_gui_height( vo_driver_t* self, int height );
void null_set_mode( vo_driver_t* self, int depth, int rgb );
+ void null_set_videoGamma( vo_driver_t* self , int value );
void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data);
}
using namespace XINE;
Lib::Lib(XineVideoWidget* widget) {
m_video = false;
m_wid = widget;
printf("Lib");
QCString str( getenv("HOME") );
str += "/Settings/opiexine.cf";
// get the configuration
// not really OO, should be an extra class, later
if ( !QFile(str).exists() ) {
QFile f(str);
f.open(IO_WriteOnly);
QTextStream ts( &f );
ts << "misc.memcpy_method:glibc\n";
f.close();
}
m_config = xine_config_file_init( str.data() );
// allocate oss for sound
// and fb for framebuffer
m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ;
m_videoOutput = ::init_video_out_plugin( m_config, NULL );
if (m_wid != 0 ) {
printf("!0\n" );
resize ( m_wid-> size ( ));
::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
m_wid-> setImage ( new QImage ( Resource::loadImage("")));
m_wid->repaint();
}
null_display_handler( m_videoOutput,
xine_display_frame,
this );
m_xine = xine_init( m_videoOutput,
m_audioOutput, m_config );
// install the event handler
xine_register_event_listener( m_xine, xine_event_handler, this );
}
Lib::~Lib() {
free( m_config );
xine_remove_event_listener( m_xine, xine_event_handler );
xine_exit( m_xine );
/* FIXME either free or delete but valgrind bitches against both */
//free( m_videoOutput );
//delete m_audioOutput;
}
void Lib::resize ( const QSize &s )
{
if ( s. width ( ) && s. height ( )) {
::null_set_gui_width( m_videoOutput, s. width() );
::null_set_gui_height(m_videoOutput, s. height() );
}
}
QCString Lib::version() {
QCString str( xine_get_str_version() );
return str;
};
int Lib::majorVersion() {
return xine_get_major_version();
}
int Lib::minorVersion() {
return xine_get_minor_version();
};
int Lib::subVersion() {
return xine_get_sub_version();
}
int Lib::play( const QString& fileName,
int startPos,
int start_time ) {
QString str = fileName.stripWhiteSpace();
//workaround OpiePlayer bug
//f (str.right(1) == QString::fromLatin1("/") )
// str = str.mid( str.length() -1 );
return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(),
startPos, start_time);
}
void Lib::stop() {
qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
xine_stop(m_xine );
}
void Lib::pause(){
xine_set_speed( m_xine, SPEED_PAUSE );
}
int Lib::speed() {
return xine_get_speed( m_xine );
}
void Lib::setSpeed( int speed ) {
xine_set_speed( m_xine, speed );
}
int Lib::status(){
return xine_get_status( m_xine );
}
int Lib::currentPosition(){
return xine_get_current_position( m_xine );
}
int Lib::currentTime() {
return xine_get_current_time( m_xine );
};
int Lib::length() {
return xine_get_stream_length( m_xine );
}
bool Lib::isSeekable() {
return xine_is_stream_seekable(m_xine);
}
Frame Lib::currentFrame() {
Frame frame;
return frame;
};
int Lib::error() {
return xine_get_error( m_xine );
};
void Lib::handleXineEvent( xine_event_t* t ) {
if ( t->type == XINE_EVENT_PLAYBACK_FINISHED )
emit stopped();
}
void Lib::setShowVideo( bool video ) {
m_video = video;
::null_set_show_video( m_videoOutput, video );
}
bool Lib::isShowingVideo() {
return ::null_is_showing_video( m_videoOutput );
}
void Lib::showVideoFullScreen( bool fullScreen ) {
::null_set_fullscreen( m_videoOutput, fullScreen );
}
bool Lib::isVideoFullScreen() {
return ::null_is_fullscreen( m_videoOutput );
}
void Lib::setScaling( bool scale ) {
::null_set_scaling( m_videoOutput, scale );
}
+
+void Lib::setGamma( int value ) {
+ //qDebug( QString( "%1").arg(value) );
+ ::null_set_videoGamma( m_videoOutput, value );
+}
+
bool Lib::isScaling() {
return ::null_is_scaling( m_videoOutput );
}
void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
((Lib*)user_data)->handleXineEvent( t );
}
void Lib::xine_display_frame( void* user_data, uint8_t *frame,
int width, int height, int bytes ) {
((Lib*)user_data)->drawFrame( frame, width, height, bytes );
}
void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
if (!m_video ) {
qWarning("not showing video now");
return;
}
// qWarning("called draw frame %d %d", width, height);
m_wid->setImage( frame, width, height, bytes );
// m_wid->repaint(false);
}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index abd8c65..b9d0a8a 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,146 +1,153 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 LJP <>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ZECKEXINELIB_H
#define ZECKEXINELIB_H
#include <qcstring.h>
#include <qstring.h>
#include <qobject.h>
#include <xine.h>
class XineVideoWidget;
namespace XINE {
/**
* Lib wrapps the simple interface
* of libxine for easy every day use
* This will become a full C++ Wrapper
* It supports playing, pausing, info,
* stooping, seeking.
*/
class Frame;
class Lib : public QObject {
Q_OBJECT
public:
Lib(XineVideoWidget* = 0);
~Lib();
QCString version();
int majorVersion()/*const*/;
int minorVersion()/*const*/;
int subVersion()/*const*/;
void resize ( const QSize &s );
int play( const QString& fileName,
int startPos = 0,
int start_time = 0 );
void stop() /*const*/;
void pause()/*const*/;
int speed() /*const*/;
void setSpeed( int speed = SPEED_PAUSE );
int status() /*const*/;
int currentPosition()/*const*/;
//in seconds
int currentTime()/*const*/;
int length() /*const*/;
bool isSeekable()/*const*/;
/**
* Whether or not to show video output
*/
void setShowVideo(bool video);
/**
* is we show video
*/
bool isShowingVideo() /*const*/;
/**
*
*/
void showVideoFullScreen( bool fullScreen );
/**
*
*/
bool isVideoFullScreen()/*const*/ ;
/**
*
*/
bool isScaling();
/**
*
*/
void setScaling( bool );
+
+ /**
+ * Set the Gamma value for video output
+ * @param int the value between -100 and 100, 0 is original
+ */
+ void setGamma( int );
+
/**
* test
*/
Frame currentFrame()/*const*/;
/**
* Returns the error code
*/
int error() /*const*/;
signals:
void stopped();
private:
int m_bytes_per_pixel;
bool m_video:1;
XineVideoWidget *m_wid;
xine_t *m_xine;
config_values_t *m_config;
vo_driver_t *m_videoOutput;
ao_driver_t* m_audioOutput;
void handleXineEvent( xine_event_t* t );
void drawFrame( uint8_t* frame, int width, int height, int bytes );
// C -> C++ bridge for the event system
static void xine_event_handler( void* user_data, xine_event_t* t);
static void xine_display_frame( void* user_data, uint8_t* frame ,
int width, int height, int bytes );
};
};
#endif
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index d984022..4ec5989 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,282 +1,324 @@
+/*
+                This file is part of the Opie Project
+
+              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
+ Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
+ Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program 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
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+
+// this file is based on work by trolltech
+
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/config.h>
#include <qvaluelist.h>
#include <qobject.h>
#include <qdir.h>
#include "mediaplayerstate.h"
//#define MediaPlayerDebug(x) qDebug x
#define MediaPlayerDebug(x)
MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
: QObject( parent, name ) {
Config cfg( "OpiePlayer" );
readConfig( cfg );
isStreaming = false;
}
MediaPlayerState::~MediaPlayerState() {
-// Config cfg( "OpiePlayer" );
-// writeConfig( cfg );
-
}
void MediaPlayerState::readConfig( Config& cfg ) {
cfg.setGroup("Options");
isFullscreen = cfg.readBoolEntry( "FullScreen" );
isScaled = cfg.readBoolEntry( "Scaling" );
isLooping = cfg.readBoolEntry( "Looping" );
isShuffled = cfg.readBoolEntry( "Shuffle" );
usePlaylist = cfg.readBoolEntry( "UsePlayList" );
+ videoGamma = cfg.readNumEntry( "VideoGamma" );
usePlaylist = TRUE;
isPlaying = FALSE;
isStreaming = FALSE;
isPaused = FALSE;
curPosition = 0;
curLength = 0;
curView = 'l';
}
void MediaPlayerState::writeConfig( Config& cfg ) const {
cfg.setGroup("Options");
cfg.writeEntry("FullScreen", isFullscreen );
cfg.writeEntry("Scaling", isScaled );
cfg.writeEntry("Looping", isLooping );
cfg.writeEntry("Shuffle", isShuffled );
cfg.writeEntry("UsePlayList", usePlaylist );
+ cfg.writeEntry( "VideoGamma", videoGamma );
}
// public stuff
bool MediaPlayerState::streaming() {
return isStreaming;
}
bool MediaPlayerState::fullscreen() {
return isFullscreen;
}
bool MediaPlayerState::scaled() {
return isScaled;
}
bool MediaPlayerState::looping() {
return isLooping;
}
bool MediaPlayerState::shuffled() {
return isShuffled;
}
bool MediaPlayerState:: playlist() {
return usePlaylist;
}
bool MediaPlayerState::paused() {
return isPaused;
}
bool MediaPlayerState::playing() {
return isPlaying;
}
bool MediaPlayerState::stop() {
return isStoped;
}
long MediaPlayerState::position() {
return curPosition;
}
long MediaPlayerState::length() {
return curLength;
}
char MediaPlayerState::view() {
return curView;
}
// slots
void MediaPlayerState::setIsStreaming( bool b ) {
if ( isStreaming == b ) {
return;
}
isStreaming = b;
}
void MediaPlayerState::setFullscreen( bool b ) {
if ( isFullscreen == b ) {
return;
}
isFullscreen = b;
emit fullscreenToggled(b);
}
void MediaPlayerState::setBlanked( bool b ) {
if ( isBlanked == b ) {
return;
}
isBlanked = b;
emit blankToggled(b);
}
void MediaPlayerState::setScaled( bool b ) {
if ( isScaled == b ) {
return;
}
isScaled = b;
emit scaledToggled(b);
}
void MediaPlayerState::setLooping( bool b ) {
if ( isLooping == b ) {
return;
}
isLooping = b;
emit loopingToggled(b);
}
void MediaPlayerState::setShuffled( bool b ) {
if ( isShuffled == b ) {
return;
}
isShuffled = b;
emit shuffledToggled(b);
}
void MediaPlayerState::setPlaylist( bool b ) {
if ( usePlaylist == b ) {
return;
}
usePlaylist = b;
emit playlistToggled(b);
}
void MediaPlayerState::setPaused( bool b ) {
if ( isPaused == b ) {
isPaused = FALSE;
emit pausedToggled(FALSE);
return;
}
isPaused = b;
emit pausedToggled(b);
}
void MediaPlayerState::setPlaying( bool b ) {
if ( isPlaying == b ) {
return;
}
isPlaying = b;
isStoped = !b;
emit playingToggled(b);
}
void MediaPlayerState::setStop( bool b ) {
if ( isStoped == b ) {
return;
}
isStoped = b;
emit stopToggled(b);
}
void MediaPlayerState::setPosition( long p ) {
if ( curPosition == p ) {
return;
}
curPosition = p;
emit positionChanged(p);
}
void MediaPlayerState::updatePosition( long p ){
if ( curPosition == p ) {
return;
}
curPosition = p;
emit positionUpdated(p);
}
+void MediaPlayerState::setVideoGamma( int v ){
+ if ( videoGamma == v ) {
+ return;
+ }
+ videoGamma = v;
+ emit videoGammaChanged( v );
+}
+
void MediaPlayerState::setLength( long l ) {
if ( curLength == l ) {
return;
}
curLength = l;
emit lengthChanged(l);
}
void MediaPlayerState::setView( char v ) {
if ( curView == v ) {
return;
}
curView = v;
emit viewChanged(v);
}
void MediaPlayerState::setPrev(){
emit prev();
}
void MediaPlayerState::setNext() {
emit next();
}
void MediaPlayerState::setList() {
setPlaying( FALSE );
setView('l');
}
void MediaPlayerState::setVideo() {
setView('v');
}
void MediaPlayerState::setAudio() {
setView('a');
}
void MediaPlayerState::toggleFullscreen() {
setFullscreen( !isFullscreen );
}
void MediaPlayerState::toggleScaled() {
setScaled( !isScaled);
}
void MediaPlayerState::toggleLooping() {
setLooping( !isLooping);
}
void MediaPlayerState::toggleShuffled() {
setShuffled( !isShuffled);
}
void MediaPlayerState::togglePlaylist() {
setPlaylist( !usePlaylist);
}
void MediaPlayerState::togglePaused() {
setPaused( !isPaused);
}
void MediaPlayerState::togglePlaying() {
setPlaying( !isPlaying);
}
void MediaPlayerState::toggleBlank() {
setBlanked( !isBlanked);
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 215a2a8..4fef8e0 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,135 +1,139 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+// this file is based on work by trolltech
+
#ifndef MEDIA_PLAYER_STATE_H
#define MEDIA_PLAYER_STATE_H
#include <qobject.h>
class MediaPlayerDecoder;
class Config;
class MediaPlayerState : public QObject {
Q_OBJECT
public:
MediaPlayerState( QObject *parent, const char *name );
~MediaPlayerState();
bool isPaused;
bool isPlaying;
bool isStoped;
bool streaming();
bool fullscreen();
bool scaled();
bool looping();
bool shuffled();
bool playlist();
bool paused();
bool playing();
bool stop();
long position();
long length();
char view();
public slots:
void setIsStreaming( bool b );
void setFullscreen( bool b );
void setScaled( bool b );
void setLooping( bool b );
void setShuffled( bool b );
void setPlaylist( bool b );
void setPaused( bool b );
void setPlaying( bool b );
void setStop( bool b );
void setPosition( long p );
void updatePosition( long p );
void setLength( long l );
void setView( char v );
void setBlanked( bool b );
+ void setVideoGamma( int v );
void setPrev();
void setNext();
void setList();
void setVideo();
void setAudio();
void toggleFullscreen();
void toggleScaled();
void toggleLooping();
void toggleShuffled();
void togglePlaylist();
void togglePaused();
void togglePlaying();
void toggleBlank();
void writeConfig( Config& cfg ) const;
signals:
void fullscreenToggled( bool );
void scaledToggled( bool );
void loopingToggled( bool );
void shuffledToggled( bool );
void playlistToggled( bool );
void pausedToggled( bool );
void playingToggled( bool );
void stopToggled( bool );
void positionChanged( long ); // When the slider is moved
void positionUpdated( long ); // When the media file progresses
void lengthChanged( long );
void viewChanged( char );
void blankToggled( bool );
+ void videoGammaChanged( int );
void prev();
void next();
private:
bool isStreaming;
bool isFullscreen;
bool isScaled;
bool isBlanked;
bool isLooping;
bool isShuffled;
bool usePlaylist;
long curPosition;
long curLength;
char curView;
-
+ int videoGamma;
void readConfig( Config& cfg );
};
#endif // MEDIA_PLAYER_STATE_H
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c
index bd52869..ceda333 100644
--- a/noncore/multimedia/opieplayer2/nullvideo.c
+++ b/noncore/multimedia/opieplayer2/nullvideo.c
@@ -1,672 +1,713 @@
+/*
+                This file is part of the Opie Project
+
+              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
+ Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
+ Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program 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
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
/*#include <xine.h>*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <xine/video_out.h>
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
#include <xine/configfile.h>
#include <pthread.h>
#include "alphablend.h"
#include "yuv2rgb.h"
#define printf(x,...)
/* the caller for our event draw handler */
typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
int width, int height,int bytes );
typedef struct null_driver_s null_driver_t;
struct null_driver_s {
vo_driver_t vo_driver;
uint32_t m_capabilities;
int m_show_video;
int m_video_fullscreen;
int m_is_scaling;
int depth, bpp, bytes_per_pixel;
int yuv2rgb_mode;
int yuv2rgb_swap;
- int zuv2rgb_gamma;
+ int yuv2rgb_gamma;
uint8_t *yuv2rgb_cmap;
yuv2rgb_factory_t *yuv2rgb_factory;
vo_overlay_t *overlay;
int user_ratio;
double output_scale_factor;
int last_frame_output_width;
int last_frame_output_height;
int gui_width;
int gui_height;
int gui_changed;
double display_ratio;
void* caller;
display_xine_frame_t frameDis;
};
typedef struct opie_frame_s opie_frame_t;
struct opie_frame_s {
vo_frame_t frame;
char* name;
int version;
int width;
int height;
int ratio_code;
int format;
int flags;
int user_ratio;
double ratio_factor;
int ideal_width;
int ideal_height;
int output_width, output_height;
int gui_width, gui_height;
uint8_t *chunk[3];
yuv2rgb_t *yuv2rgb;
uint8_t *rgb_dst;
int yuv_stride;
int stripe_height, stripe_inc;
int bytes_per_line;
uint8_t *data;
// int show_video;
null_driver_t *output;
};
static uint32_t null_get_capabilities(vo_driver_t *self ){
null_driver_t* this = (null_driver_t*)self;
printf("capabilities\n");
return this->m_capabilities;
}
static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
opie_frame_t *frame = (opie_frame_t *) vo_img ;
printf("frame copy\n");
if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video
if (frame->format == IMGFMT_YV12) {
frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst,
src[0], src[1], src[2]);
} else {
frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
src[0]);
}
frame->rgb_dst += frame->stripe_inc;
printf("returning\n");
}
static void null_frame_field (vo_frame_t *vo_img, int which_field) {
opie_frame_t *frame = (opie_frame_t *) vo_img ;
printf("field\n\n");
switch (which_field) {
case VO_TOP_FIELD:
frame->rgb_dst = (uint8_t *)frame->data;
frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
break;
case VO_BOTTOM_FIELD:
frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ;
frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
break;
case VO_BOTH_FIELDS:
frame->rgb_dst = (uint8_t *)frame->data;
break;
}
}
/* take care of the frame*/
static void null_frame_dispose( vo_frame_t* vo_img){
opie_frame_t* frame = (opie_frame_t*)vo_img;
printf("frame_dispose\n");
if( frame->data )
free( frame->data );
free (frame);
}
/* end take care of frames*/
static vo_frame_t* null_alloc_frame( vo_driver_t* self ){
null_driver_t* this = (null_driver_t*)self;
opie_frame_t* frame;
frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) );
memset( frame, 0, sizeof( opie_frame_t) );
pthread_mutex_init (&frame->frame.mutex, NULL);
printf("alloc_frame\n");
frame->name = "opie\0";
frame->version = 1;
frame->output = this;
// frame->show_video = this->m_show_video;
/* initialize the frame*/
frame->frame.driver = self;
/*frame.frame.free = null_frame_free;*/
frame->frame.copy = null_frame_copy;
frame->frame.field = null_frame_field;
frame->frame.dispose = null_frame_dispose;
frame->yuv2rgb = 0;
/*
* colorspace converter for this frame
*/
frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory);
return (vo_frame_t*) frame;
}
// size specific
static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) {
if (!this->m_is_scaling /*|| !this->m_show_video*/) {
printf("Not scaling\n");
frame->ideal_width = frame->width;
frame->ideal_height = frame->height;
frame->ratio_factor = 1.0;
} else {
double image_ratio, desired_ratio, corr_factor;
image_ratio = (double) frame->width / (double) frame->height;
switch (frame->user_ratio) {
case ASPECT_AUTO:
switch (frame->ratio_code) {
case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */
case XINE_ASPECT_RATIO_PAN_SCAN:
desired_ratio = 16.0 /9.0;
break;
case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */
desired_ratio = 2.11/1.0;
break;
case XINE_ASPECT_RATIO_SQUARE: /* square pels */
case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */
desired_ratio = image_ratio;
break;
case 0: /* forbidden -> 4:3 */
printf ("video_out_fb: invalid ratio, using 4:3\n");
default:
printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n",
frame->ratio_code);
case XINE_ASPECT_RATIO_4_3: /* 4:3 */
desired_ratio = 4.0 / 3.0;
break;
}
break;
case ASPECT_ANAMORPHIC:
desired_ratio = 16.0 / 9.0;
break;
case ASPECT_DVB:
desired_ratio = 2.0 / 1.0;
break;
case ASPECT_SQUARE:
desired_ratio = image_ratio;
break;
case ASPECT_FULL:
default:
desired_ratio = 4.0 / 3.0;
}
frame->ratio_factor = this->display_ratio * desired_ratio;
corr_factor = frame->ratio_factor / image_ratio ;
if (fabs(corr_factor - 1.0) < 0.005) {
frame->ideal_width = frame->width;
frame->ideal_height = frame->height;
} else {
if (corr_factor >= 1.0) {
frame->ideal_width = frame->width * corr_factor + 0.5;
frame->ideal_height = frame->height;
} else {
frame->ideal_width = frame->width;
frame->ideal_height = frame->height / corr_factor + 0.5;
}
}
}
printf("return from helper\n");
}
static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) {
double x_factor, y_factor;
/*
* make the frame fit into the given destination area
*/
x_factor = (double) this->gui_width / (double) frame->ideal_width;
y_factor = (double) this->gui_height / (double) frame->ideal_height;
if ( x_factor < y_factor ) {
frame->output_width = (double) frame->ideal_width * x_factor ;
frame->output_height = (double) frame->ideal_height * x_factor ;
} else {
frame->output_width = (double) frame->ideal_width * y_factor ;
frame->output_height = (double) frame->ideal_height * y_factor ;
}
#define LOG 1
#ifdef LOG
printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n",
frame->width, frame->height,
frame->output_width, frame->output_height,
( frame->width != frame->output_width
|| frame->height != frame->output_height
? ", software scaling"
: "" )
);
#endif
}
// size specific
static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
uint32_t width, uint32_t height,
int ratio_code, int format, int flags ){
null_driver_t* this = (null_driver_t*) self;
opie_frame_t* frame = (opie_frame_t*)img;
/* not needed now */
printf("update_frame_format\n");
printf("al crash aye?\n");
flags &= VO_BOTH_FIELDS;
/* find out if we need to adapt this frame */
if ((width != frame->width)
|| (height != frame->height)
|| (ratio_code != frame->ratio_code)
|| (flags != frame->flags)
|| (format != frame->format)
|| (this->user_ratio != frame->user_ratio)
|| (this->gui_width != frame-> gui_width )
|| (this-> gui_height != frame-> gui_height)) {
frame->width = width;
frame->height = height;
frame->ratio_code = ratio_code;
frame->flags = flags;
frame->format = format;
frame->user_ratio = this->user_ratio;
this->gui_changed = 0;
// frame->show_video = this->m_show_video;
frame->gui_width = this->gui_width;
frame->gui_height = this->gui_height;
null_compute_ideal_size (this, frame);
null_compute_rgb_size (this, frame);
/*
* (re-) allocate
*/
if( frame->data ) {
if(frame->chunk[0] ){
free( frame->chunk[0] );
frame->chunk[0] = NULL;
}
if(frame->chunk[1] ){
free ( frame->chunk[1] );
frame->chunk[1] = NULL;
}
if(frame->chunk[2] ){
free ( frame->chunk[2] );
frame->chunk[2] = NULL;
}
free ( frame->data );
}
printf("after freeing\n");
frame->data = xine_xmalloc (frame->output_width * frame->output_height *
this->bytes_per_pixel );
if( format == IMGFMT_YV12 ) {
frame->frame.pitches[0] = 8*((width + 7) / 8);
frame->frame.pitches[1] = 8*((width + 15) / 16);
frame->frame.pitches[2] = 8*((width + 15) / 16);
frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]);
frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]);
frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]);
}else{
frame->frame.pitches[0] = 8*((width + 3) / 4);
frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,
(void **)&frame->chunk[0]);
frame->chunk[1] = NULL;
frame->chunk[2] = NULL;
}
frame->format = format;
frame->width = width;
frame->height = height;
frame->stripe_height = 16 * frame->output_height / frame->height;
frame->bytes_per_line = frame->output_width * this->bytes_per_pixel;
/*
* set up colorspace converter
*/
if(1 /*this->m_show_video*/ ){
printf("showing video\n");
switch (flags) {
case VO_TOP_FIELD:
case VO_BOTTOM_FIELD:
frame->yuv2rgb->configure (frame->yuv2rgb,
frame->width,
16,
2*frame->frame.pitches[0],
2*frame->frame.pitches[1],
frame->output_width,
frame->stripe_height,
frame->bytes_per_line*2);
frame->yuv_stride = frame->bytes_per_line*2;
break;
case VO_BOTH_FIELDS:
frame->yuv2rgb->configure (frame->yuv2rgb,
frame->width,
16,
frame->frame.pitches[0],
frame->frame.pitches[1],
frame->output_width,
frame->stripe_height,
frame->bytes_per_line);
frame->yuv_stride = frame->bytes_per_line;
break;
}
}
}
printf("after gui changed\n");
/*
* reset dest pointers
*/
if (frame->data) {
switch (flags) {
case VO_TOP_FIELD:
frame->rgb_dst = (uint8_t *)frame->data;
frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
break;
case VO_BOTTOM_FIELD:
frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ;
frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
break;
case VO_BOTH_FIELDS:
frame->rgb_dst = (uint8_t *)frame->data;
frame->stripe_inc = frame->stripe_height * frame->bytes_per_line;
break;
}
}
printf("done\n");
}
static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){
null_driver_t* this = (null_driver_t*) self;
opie_frame_t* frame = (opie_frame_t*)frame_gen;
display_xine_frame_t display = this->frameDis;
printf("display frame\n");
// if( this->m_show_video ) { // return if not displaying
printf("calling home aye\n" );
if( display != NULL ) {
(*display)(this->caller, frame->data,
frame->output_width, frame->output_height,
frame->bytes_per_line );
printf("display done hope you enyoyed the frame");
}
// }
frame->frame.displayed (&frame->frame);
}
// blending related
static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay,
opie_frame_t *frame) {
int i;
clut_t* clut = (clut_t*) overlay->color;
if (!overlay->rgb_clut) {
for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) {
*((uint32_t *)&clut[i]) =
frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb,
clut[i].y, clut[i].cb, clut[i].cr);
}
overlay->rgb_clut++;
}
if (!overlay->clip_rgb_clut) {
clut = (clut_t*) overlay->clip_color;
for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) {
*((uint32_t *)&clut[i]) =
frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb,
clut[i].y, clut[i].cb, clut[i].cr);
}
overlay->clip_rgb_clut++;
}
}
static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) {
null_driver_t *this = (null_driver_t *) this_gen;
opie_frame_t *frame = (opie_frame_t *) frame_gen;
printf("overlay blend\n");
if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0)
return;
/* Alpha Blend here */
if (overlay->rle) {
if( !overlay->rgb_clut || !overlay->clip_rgb_clut)
null_overlay_clut_yuv2rgb(this,overlay,frame);
switch(this->bpp) {
case 16:
blend_rgb16( (uint8_t *)frame->data, overlay,
frame->output_width, frame->output_height,
frame->width, frame->height);
break;
case 24:
blend_rgb24( (uint8_t *)frame->data, overlay,
frame->output_width, frame->output_height,
frame->width, frame->height);
break;
case 32:
blend_rgb32( (uint8_t *)frame->data, overlay,
frame->output_width, frame->output_height,
frame->width, frame->height);
break;
default:
/* It should never get here */
break;
}
}
}
static int null_get_property( vo_driver_t* self,
int property ){
printf("property get\n");
return 0;
}
static int null_set_property( vo_driver_t* self,
int property,
int value ){
printf("set property\n");
return value;
}
static void null_get_property_min_max( vo_driver_t* self,
int property, int *min,
int *max ){
printf("min max\n");
*max = 0;
*min = 0;
}
static int null_gui_data_exchange( vo_driver_t* self,
int data_type,
void *data ){
return 0;
}
static void null_exit( vo_driver_t* self ){
null_driver_t* this = (null_driver_t*)self;
free ( this );
}
static int null_redraw_needed( vo_driver_t* self ){
return 0;
}
vo_driver_t* init_video_out_plugin( config_values_t* conf,
void* video ){
null_driver_t *vo;
vo = (null_driver_t*)malloc( sizeof(null_driver_t ) );
/* memset? */
memset(vo,0, sizeof(null_driver_t ) );
vo->m_show_video = 0; // false
vo->m_video_fullscreen = 0;
vo->m_is_scaling = 0;
vo->user_ratio = ASPECT_AUTO;
vo->display_ratio = 1.0;
vo->gui_width = 16;
vo->gui_height = 8;
vo->frameDis = NULL;
/* install callback handlers*/
vo->vo_driver.get_capabilities = null_get_capabilities;
vo->vo_driver.alloc_frame = null_alloc_frame;
vo->vo_driver.update_frame_format = null_update_frame_format;
vo->vo_driver.display_frame = null_display_frame;
vo->vo_driver.overlay_blend = null_overlay_blend;
vo->vo_driver.get_property = null_get_property;
vo->vo_driver.set_property = null_set_property;
vo->vo_driver.get_property_min_max = null_get_property_min_max;
vo->vo_driver.gui_data_exchange = null_gui_data_exchange;
vo->vo_driver.exit = null_exit;
vo->vo_driver.redraw_needed = null_redraw_needed;
/* capabilities */
vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12;
vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap,
vo->yuv2rgb_cmap);
printf("done initialisation\n");
return (vo_driver_t*) vo;
}
static vo_info_t vo_info_null = {
5,
"null plugin",
NULL,
VISUAL_TYPE_FB,
5
};
vo_info_t *get_video_out_plugin_info(){
vo_info_null.description = _("xine video output plugin using null device");
return &vo_info_null;
}
/* this is special for this device */
/**
* We know that we will be controled by the XINE LIB++
*/
/**
*
*/
int null_is_showing_video( vo_driver_t* self ){
null_driver_t* this = (null_driver_t*)self;
return this->m_show_video;
}
void null_set_show_video( vo_driver_t* self, int show ) {
((null_driver_t*)self)->m_show_video = show;
}
int null_is_fullscreen( vo_driver_t* self ){
return ((null_driver_t*)self)->m_video_fullscreen;
}
void null_set_fullscreen( vo_driver_t* self, int screen ){
((null_driver_t*)self)->m_video_fullscreen = screen;
}
int null_is_scaling( vo_driver_t* self ){
return ((null_driver_t*)self)->m_is_scaling;
}
+
+void null_set_videoGamma( vo_driver_t* self , int value ) {
+ ((null_driver_t*) self) ->yuv2rgb_gamma = value;
+ ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value );
+}
+
void null_set_scaling( vo_driver_t* self, int scale ){
((null_driver_t*)self)->m_is_scaling = scale;
}
void null_set_gui_width( vo_driver_t* self, int width ){
((null_driver_t*)self)->gui_width = width;
}
void null_set_gui_height( vo_driver_t* self, int height ){
((null_driver_t*)self)->gui_height = height;
}
+
+
void null_set_mode( vo_driver_t* self, int depth, int rgb ){
null_driver_t* this = (null_driver_t*)self;
this->bytes_per_pixel = (depth + 7 ) / 8;
this->bpp = this->bytes_per_pixel * 8;
this->depth = depth;
printf("depth %d %d\n", depth, this->bpp);
printf("pixeltype %d\n", rgb );
switch ( this->depth ){
case 32:
if( rgb == 0 )
this->yuv2rgb_mode = MODE_32_RGB;
else
this->yuv2rgb_mode = MODE_32_BGR;
case 24:
if( this->bpp == 32 ) {
if(rgb == 0 )
this->yuv2rgb_mode = MODE_32_RGB;
else
this->yuv2rgb_mode = MODE_32_BGR;
}else{
if( rgb == 0 )
this->yuv2rgb_mode = MODE_24_RGB;
else
this->yuv2rgb_mode = MODE_24_BGR;
};
break;
case 16:
if( rgb == 0 )
this->yuv2rgb_mode = MODE_16_RGB;
else
this->yuv2rgb_mode = MODE_16_BGR;
break;
case 15:
if( rgb == 0 )
this->yuv2rgb_mode = MODE_15_RGB;
else
this->yuv2rgb_mode = MODE_15_BGR;
break;
case 8:
if( rgb == 0 )
this->yuv2rgb_mode = MODE_8_RGB;
else
this->yuv2rgb_mode = MODE_8_BGR;
break;
};
//free(this->yuv2rgb_factory );
// this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap,
// this->yuv2rgb_cmap);
};
void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) {
null_driver_t* this = (null_driver_t*) self;
this->caller = user_data;
this->frameDis = t;
}
+
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6c4d07f..3bd04bc 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1063 +1,1064 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpe/qpetoolbar.h>
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <qpe/mimetype.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qdir.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qtextstream.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
//only needed for the random play
#include <stdlib.h>
#include "audiowidget.h"
#include "videowidget.h"
extern MediaPlayerState *mediaPlayerState;
PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
: PlayListWidgetGui( parent, name, fl ) {
d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
this , SLOT(addSelected() ) );
d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
this , SLOT(removeSelected() ) );
d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
this , SLOT( btnPlay( bool) ), TRUE );
d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
(void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
(void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
(void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
pmPlayList->insertSeparator(-1);
(void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
(void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
Config cfg( "OpiePlayer" );
bool b= cfg.readBoolEntry("FullScreen", 0);
mediaPlayerState->setFullscreen( b );
pmView->setItemChecked( -16, b );
(void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) );
(void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) );
(void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) );
QVBox *stretch2 = new QVBox( vbox1 );
connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) );
connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) );
connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) );
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
this,SLOT( playIt( QListViewItem *) ) );
connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
this,SLOT( playIt( QListViewItem *) ) );
connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
+ connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) );
readConfig( cfg );
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
loadList(DocLnk( currentPlaylist ) );
setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
// see which skins are installed
videoScan=FALSE;
audioScan=FALSE;
populateSkinsMenu();
initializeStates();
}
PlayListWidget::~PlayListWidget() {
// WTF?!@?!
if ( d->current ) {
delete d->current;
}
delete d;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->playing() );
d->tbLoop->setOn( mediaPlayerState->looping() );
d->tbShuffle->setOn( mediaPlayerState->shuffled() );
setPlaylist( true );
}
void PlayListWidget::readConfig( Config& cfg ) {
cfg.setGroup( "PlayList" );
QString currentString = cfg.readEntry( "current", "" );
int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
for ( int i = 0; i < noOfFiles; i++ ) {
QString entryName;
entryName.sprintf( "File%i", i + 1 );
QString linkFile = cfg.readEntry( entryName );
if( QFileInfo( linkFile ).exists() ) {
DocLnk lnk( linkFile );
if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) {
d->selectedFiles->addToSelection( lnk );
}
}
}
d->selectedFiles->setSelectedItem( currentString );
}
void PlayListWidget::writeConfig( Config& cfg ) const {
d->selectedFiles->writeCurrent( cfg );
cfg.setGroup( "PlayList" );
int noOfFiles = 0;
d->selectedFiles->first();
do {
const DocLnk *lnk = d->selectedFiles->current();
if ( lnk ) {
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
cfg.writeEntry( entryName, lnk->linkFile() );
// if this link does exist, add it so we have the file
// next time...
if ( !QFile::exists( lnk->linkFile() ) ) {
// the way writing lnks doesn't really check for out
// of disk space, but check it anyway.
if ( !lnk->writeLink() ) {
QMessageBox::critical( 0, tr("Out of space"),
tr( "There was a problem saving "
"the playlist.\n"
"Your playlist "
"may be missing some entries\n"
"the next time you start it." )
);
}
}
noOfFiles++;
}
}
while ( d->selectedFiles->next() );
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = FALSE;
if ( mediaPlayerState->playlist() ) {
if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
}
else
mediaPlayerState->setPlaying( TRUE );
}
void PlayListWidget::clearList() {
while ( first() ) {
d->selectedFiles->removeSelected();
}
}
void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
switch (mouse) {
case 1:
break;
case 2:
{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
m.exec( QCursor::pos() );
}
break;
}
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;audio/*");
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit ) {
if( QFileInfo( Adit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **Adit );
}
}
}
void PlayListWidget::addAllMusicToList() {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo(dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
}
void PlayListWidget::addAllVideoToList() {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( QFileInfo( dit.current()->file() ).exists() ) {
d->selectedFiles->addToSelection( **dit );
}
}
}
void PlayListWidget::setDocument( const QString& fileref ) {
//qDebug( fileref );
fromSetDocument = TRUE;
if ( fileref.isNull() ) {
QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
return;
}
if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
readm3u( fileref );
} else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
readPls( fileref );
} else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
clearList();
loadList( DocLnk( fileref ) );
d->selectedFiles->first();
} else {
clearList();
addToSelection( DocLnk( fileref ) );
d->setDocumentUsed = TRUE;
mediaPlayerState->setPlaying( FALSE );
qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
qApp->processEvents();
setCaption( tr("OpiePlayer") );
}
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
switch ( tabWidget->currentPageIndex() ) {
case 0: //playlist
{
// qDebug("playlist");
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
} else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
return d->files->selected();
}
}
break;
case 1://audio
{
// qDebug("audioView");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) {
insanityBool = TRUE;
return dit;
}
}
}
break;
case 2: // video
{
// qDebug("videoView");
QListIterator<DocLnk> Vdit( vFiles.children() );
for ( ; Vdit.current(); ++Vdit ) {
if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) {
insanityBool = TRUE;
return Vdit;
}
}
}
break;
};
return 0;
}
bool PlayListWidget::prev() {
if ( mediaPlayerState->playlist() ) {
if ( mediaPlayerState->shuffled() ) {
const DocLnk *cur = current();
int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
for ( int i = 0; i < j; i++ ) {
if ( !d->selectedFiles->next() )
d->selectedFiles->first();
}
if ( cur == current() )
if ( !d->selectedFiles->next() ) {
d->selectedFiles->first();
}
return TRUE;
} else {
if ( !d->selectedFiles->prev() ) {
if ( mediaPlayerState->looping() ) {
return d->selectedFiles->last();
} else {
return FALSE;
}
}
return TRUE;
}
} else {
return mediaPlayerState->looping();
}
}
bool PlayListWidget::next() {
if ( mediaPlayerState->playlist() ) {
if ( mediaPlayerState->shuffled() ) {
return prev();
} else {
if ( !d->selectedFiles->next() ) {
if ( mediaPlayerState->looping() ) {
return d->selectedFiles->first();
} else {
return FALSE;
}
}
return TRUE;
}
} else {
return mediaPlayerState->looping();
}
}
bool PlayListWidget::first() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->first();
else
return mediaPlayerState->looping();
}
bool PlayListWidget::last() {
if ( mediaPlayerState->playlist() )
return d->selectedFiles->last();
else
return mediaPlayerState->looping();
}
void PlayListWidget::saveList() {
QString filename;
InputDialog *fileDlg = 0l;
fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
if ( d->current )
delete d->current;
filename = fileDlg->text();//+".playlist";
// qDebug("saving playlist "+filename+".playlist");
Config cfg( filename +".playlist");
writeConfig( cfg );
DocLnk lnk;
lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
lnk.setIcon("opieplayer2/playlist2");
lnk.setName( filename); //sets file name
// qDebug(filename);
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
}
Config config( "OpiePlayer" );
config.writeEntry("CurrentPlaylist",filename);
setCaption(tr("OpiePlayer: ")+filename);
d->selectedFiles->first();
if(fileDlg) {
delete fileDlg;
}
}
void PlayListWidget::loadList( const DocLnk & lnk) {
QString name= lnk.name();
// qDebug("currentList is "+name);
if( name.length()>1) {
setCaption("OpiePlayer: "+name);
// qDebug("load list "+ name+".playlist");
clearList();
Config cfg( name+".playlist");
readConfig(cfg);
tabWidget->setCurrentPage(0);
Config config( "OpiePlayer" );
config.writeEntry("CurrentPlaylist", name);
// d->selectedFiles->first();
}
}
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown ) {
d->playListFrame->show();
} else {
d->playListFrame->hide();
}
}
void PlayListWidget::addSelected() {
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
break;
case 1: { //audio
QListViewItemIterator it( audioView );
// iterate through all items of the listview
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
}
}
audioView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
}
break;
case 2: { // video
QListViewItemIterator it( videoView );
// iterate through all items of the listview
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it.current()->text(0) ) {
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
}
}
videoView->setSelected( it.current(),FALSE);
}
}
tabWidget->setCurrentPage(0);
}
break;
};
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
void PlayListWidget::playIt( QListViewItem *it) {
if(!it) return;
mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch (tabWidget->currentPageIndex()) {
case 1: {
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
}
}
}
break;
case 2: {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit ) {
if( dit.current()->name() == it->text(0)) {
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
}
}
}
break;
case 0:
break;
};
tabWidget->setCurrentPage(0);
}
}
void PlayListWidget::tabChanged(QWidget *) {
switch ( tabWidget->currentPageIndex()) {
case 0:
{
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(TRUE);
d->tbAddToList->setEnabled(FALSE);
}
break;
case 1:
{
audioView->clear();
populateAudioView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 2:
{
videoView->clear();
populateVideoView();
if( !tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->hide();
}
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 3:
{
if( tbDeletePlaylist->isHidden() ) {
tbDeletePlaylist->show();
}
playLists->reread();
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
mediaPlayerState->setPlaying(b);
}
break;
case 1:
{
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying(b);
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(1);
d->selectedFiles->unSelect();
insanityBool=FALSE;
}// audioView->clearSelection();
break;
case 2:
{
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying(b);
qApp->processEvents();
d->selectedFiles->removeSelected( );
tabWidget->setCurrentPage(2);
d->selectedFiles->unSelect();
insanityBool=FALSE;
}// videoView->clearSelection();
break;
};
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
(tr("You really want to delete\nthis playlist?")),
(tr("Yes")), (tr("No")), 0 )){
case 0: // Yes clicked,
QFile().remove(playLists->selected()->file());
QFile().remove(playLists->selected()->linkFile());
playLists->reread();
break;
case 1: // Cancel
break;
};
}
void PlayListWidget::playSelected() {
btnPlay( TRUE);
}
void PlayListWidget::scanForAudio() {
// qDebug("scan for audio");
files.detachChildren();
QListIterator<DocLnk> sdit( files.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&files, "audio/*");
audioScan = TRUE;
}
void PlayListWidget::scanForVideo() {
// qDebug("scan for video");
vFiles.detachChildren();
QListIterator<DocLnk> sdit( vFiles.children() );
for ( ; sdit.current(); ++sdit ) {
delete sdit.current();
}
Global::findDocuments(&vFiles, "video/*");
videoScan = TRUE;
}
void PlayListWidget::populateAudioView() {
audioView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!audioScan) {
scanForAudio();
}
QListIterator<DocLnk> dit( files.children() );
QListIterator<FileSystem> it ( fs );
QString storage;
for ( ; dit.current(); ++dit ) {
for( ; it.current(); ++it ){
const QString name = (*it)->name();
const QString path = (*it)->path();
if(dit.current()->file().find(path) != -1 ) {
storage = name;
}
}
QListViewItem * newItem;
if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
long size;
if( dit.current()->file().left(4) == "http" )
size=0;
else
size = QFile( dit.current()->file() ).size();
newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage);
newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
}
}
}
void PlayListWidget::populateVideoView() {
videoView->clear();
StorageInfo storageInfo;
const QList<FileSystem> &fs = storageInfo.fileSystems();
if(!videoScan ) {
scanForVideo();
}
QListIterator<DocLnk> Vdit( vFiles.children() );
QListIterator<FileSystem> it ( fs );
videoView->clear();
QString storage;
for ( ; Vdit.current(); ++Vdit ) {
for( ; it.current(); ++it ) {
const QString name = (*it)->name();
const QString path = (*it)->path();
if( Vdit.current()->file().find(path) != -1 ) {
storage=name;
}
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file() ).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
QString::number( QFile( Vdit.current()->file() ).size() ), storage );
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
}
}
}
void PlayListWidget::openFile() {
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->text();
qDebug( "Selected filename is " + filename );
if( filename.right( 3 ) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
} else {
// this doesnt need fixing
DocLnk lnk;
lnk.setName( filename ); //sets file name
lnk.setFile( filename ); //sets File property
//qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
lnk.setExec( "opieplayer" );
lnk.setIcon( "opieplayer2/MPEGPlayer" );
if( !lnk.writeLink() ) {
qDebug( "Writing doclink did not work" );
}
d->selectedFiles->addToSelection( lnk );
}
}
if( fileDlg ) {
delete fileDlg;
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();
break;
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu
break;
case Key_F12: //home
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
case Key_Q: //add to playlist
addSelected();
break;
case Key_R: //remove from playlist
removeSelected();
break;
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
case Key_Space:
// playSelected(); puh
break;
case Key_1:
tabWidget->setCurrentPage( 0 );
break;
case Key_2:
tabWidget->setCurrentPage( 1 );
break;
case Key_3:
tabWidget->setCurrentPage( 2 );
break;
case Key_4:
tabWidget->setCurrentPage( 3 );
break;
case Key_Down:
if ( !d->selectedFiles->next() )
d->selectedFiles->first();
break;
case Key_Up:
if ( !d->selectedFiles->prev() )
// d->selectedFiles->last();
break;
}
}
void PlayListWidget::readm3u( const QString &filename ) {
qDebug( "m3u filename is " + filename );
QFile f( filename );
if( f.open( IO_ReadOnly ) ) {
QTextStream t(&f);
QString s;//, first, second;
int i=0;
while ( !t.atEnd() ) {
s=t.readLine();
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
DocLnk lnk( s );
QFileInfo f( s );
QString name = f.baseName();
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
lnk.setName( name );
s=s.replace( QRegExp( "\\" ), "/" );
lnk.setFile( s );
lnk.writeLink();
qDebug( "add " + name);
d->selectedFiles->addToSelection( lnk );
} else { // is url
s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QString name;
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7 );
} else {
name = s;
}
lnk.setName( name );
if( s.at( s.length() - 4) == '.' ) {
lnk.setFile( s );
} else {
lnk.setFile( s + "/" );
}
lnk.setType( "audio/x-mpegurl" );
lnk.writeLink();
d->selectedFiles->addToSelection( lnk );
}
i++;
}
}
}
}
f.close();
}
void PlayListWidget::writem3u() {
InputDialog *fileDlg;
fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
fileDlg->exec();
QString filename, list;
if( fileDlg->result() == 1 ) {
filename = fileDlg->text();
qDebug( filename );
int noOfFiles = 0;
d->selectedFiles->first();
do {
// we dont check for existance because of url's
// qDebug(d->selectedFiles->current()->file());
// so maybe we should do some net checking to ,-)
// no, cause it takes to long...
list += d->selectedFiles->current()->file() + "\n";
noOfFiles++;
}
while ( d->selectedFiles->next() );
qDebug( list );
if( filename.left( 1) != "/" ) {
filename=QPEApplication::documentDir() + "/" + filename;
}
if( filename.right( 3 ) != "m3u" ) {
filename=filename+".m3u";
}
QFile f( filename );
f.open( IO_WriteOnly );
f.writeBlock( list, list.length() );
f.close();
}
if( fileDlg ) {
delete fileDlg;
}
}
void PlayListWidget::readPls( const QString &filename ) {
qDebug( "pls filename is " + filename );
QFile f( filename );
if( f.open( IO_ReadOnly ) ) {
QTextStream t( &f );
QString s;//, first, second;
int i = 0;
while ( !t.atEnd() ) {
s = t.readLine();
if( s.left(4) == "File" ) {
s = s.right( s.length() - 6 );
s.replace( QRegExp( "%20" )," ");
qDebug( "adding " + s + " to playlist" );
// numberofentries=2
// File1=http
// Title
// Length
// Version
// File2=http
s = s.replace( QRegExp( "\\" ), "/" );
DocLnk lnk( s );
QFileInfo f( s );
QString name = f.baseName();
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
}
name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
lnk.setName( name );
if( s.at( s.length() - 4) == '.') // if this is probably a file
lnk.setFile( s );
else { //if its a url
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
lnk.setFile( s );
}
lnk.setType( "audio/x-mpegurl" );
//qDebug("DocLnk add "+name);
d->selectedFiles->addToSelection( lnk );
}
}
i++;
}
}
void PlayListWidget::pmViewActivated(int index) {
// qDebug("%d", index);
switch(index) {
case -16:
{
mediaPlayerState->toggleFullscreen();
bool b=mediaPlayerState->fullscreen();
pmView->setItemChecked( index, b);
Config cfg( "OpiePlayer" );
cfg.writeEntry( "FullScreen", b );
}
break;
};
}
void PlayListWidget::populateSkinsMenu() {
int item = 0;
defaultSkinIndex = 0;
QString skinName;
Config cfg( "OpiePlayer" );
cfg.setGroup("Options" );
QString skin = cfg.readEntry( "Skin", "default" );
QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
skinsDir.setFilter( QDir::Dirs );
skinsDir.setSorting(QDir::Name );
const QFileInfoList *skinslist = skinsDir.entryInfoList();
QFileInfoListIterator it( *skinslist );
QFileInfo *fi;
while ( ( fi = it.current() ) ) {
skinName = fi->fileName();
qDebug( fi->fileName() );
if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
item = skinsMenu->insertItem( fi->fileName() ) ;
}
if( skinName == "default" ) {
defaultSkinIndex = item;
}
if( skinName == skin ) {
skinsMenu->setItemChecked( item, TRUE );
}
++it;
}
}
void PlayListWidget::skinsMenuActivated( int item ) {
for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
skinsMenu->setItemChecked( i, FALSE );
}
skinsMenu->setItemChecked( item, TRUE );
Config cfg( "OpiePlayer" );
cfg.setGroup("Options");
cfg.writeEntry("Skin", skinsMenu->text( item ) );
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 2742252..dcfdd48 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,120 +1,120 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef PLAY_LIST_WIDGET_H
#define PLAY_LIST_WIDGET_H
#include <qmainwindow.h>
#include <qpe/applnk.h>
#include <qtabwidget.h>
#include <qpe/fileselector.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include "playlistwidgetgui.h"
//class PlayListWidgetPrivate;
class Config;
class QListViewItem;
class QListView;
class QPoint;
class QAction;
class QLabel;
class PlayListWidget : public PlayListWidgetGui {
Q_OBJECT
public:
PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
~PlayListWidget();
DocLnkSet files;
DocLnkSet vFiles;
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef;
// retrieve the current playlist entry (media file link)
const DocLnk *current();
void useSelectedDocument();
int selected;
public slots:
bool first();
bool last();
bool next();
bool prev();
void writeConfig( Config& cfg ) const;
protected:
void keyReleaseEvent( QKeyEvent *e);
private:
int defaultSkinIndex;
bool audioScan, videoScan;
void readm3u(const QString &);
void readPls(const QString &);
void initializeStates();
void readConfig( Config& cfg );
void populateAudioView();
void populateVideoView();
private slots:
void populateSkinsMenu();
void skinsMenuActivated(int);
void pmViewActivated(int);
void writem3u();
void scanForAudio();
void scanForVideo();
void openFile();
void setDocument( const QString& fileref );
void addToSelection( const DocLnk& ); // Add a media file to the playlist
void addToSelection( QListViewItem* ); // Add a media file to the playlist
void setPlaylist( bool ); // Show/Hide the playlist
void clearList();
void addAllToList();
void addAllMusicToList();
void addAllVideoToList();
void saveList(); // Save the playlist
void loadList( const DocLnk &); // Load a playlist
void playIt( QListViewItem *);
void btnPlay(bool);
void deletePlaylist();
void addSelected();
void removeSelected();
void tabChanged(QWidget*);
void viewPressed( int, QListViewItem *, const QPoint&, int);
void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
void playSelected();
};
#endif // PLAY_LIST_WIDGET_H
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index 6ecd016..250833c 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,207 +1,226 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/storage.h>
#include <qpe/mimetype.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpopupmenu.h>
#include <qaction.h>
#include <qcursor.h>
#include <qdir.h>
#include <qlayout.h>
#include "playlistselection.h"
#include "playlistwidget.h"
#include "mediaplayerstate.h"
#include "inputDialog.h"
//only needed for the random play
#include <stdlib.h>
#include "audiowidget.h"
#include "videowidget.h"
#include "mediaplayerstate.h"
extern MediaPlayerState *mediaPlayerState;
PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl )
: QMainWindow( parent, name, fl ) {
d = new PlayListWidgetPrivate;
d->setDocumentUsed = FALSE;
d->current = NULL;
setBackgroundMode( PaletteButton );
setToolBarsMovable( FALSE );
// Create Toolbar
QPEToolBar *toolbar = new QPEToolBar( this );
toolbar->setHorizontalStretchable( TRUE );
// Create Menubar
QPEMenuBar *menu = new QPEMenuBar( toolbar );
menu->setMargin( 0 );
bar = new QPEToolBar( this );
bar->setLabel( tr( "Play Operations" ) );
tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
tbDeletePlaylist->setFlat( TRUE );
tbDeletePlaylist->setFixedSize( 20, 20 );
tbDeletePlaylist->hide();
pmPlayList = new QPopupMenu( this );
menu->insertItem( tr( "File" ), pmPlayList );
pmView = new QPopupMenu( this );
menu->insertItem( tr( "View" ), pmView );
pmView->isCheckable();
skinsMenu = new QPopupMenu( this );
pmView->insertItem( tr( "Skins" ), skinsMenu );
skinsMenu->isCheckable();
+ gammaMenu = new QPopupMenu( this );
+ pmView->insertItem( tr( "Gamma" ), gammaMenu );
+ gammaMenu->setMinimumHeight( 50 );
+
+ gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
+ gammaSlider->setRange( -100, 100 );
+ gammaSlider->setTickmarks( QSlider::Left );
+ gammaSlider->setTickInterval( 20 );
+ gammaSlider->setFocusPolicy( QWidget::NoFocus );
+ gammaSlider->setValue( 0 );
+ gammaSlider->setMinimumHeight( 50 );
+
+ gammaLCD = new QLCDNumber( 3, gammaMenu );
+
+ gammaMenu->insertItem( gammaSlider );
+ gammaMenu->insertItem( gammaLCD );
+
+ connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) );
+
vbox5 = new QVBox( this );
QVBox *vbox4 = new QVBox( vbox5 );
QHBox *hbox6 = new QHBox( vbox4 );
tabWidget = new QTabWidget( hbox6, "tabWidget" );
QWidget *pTab;
pTab = new QWidget( tabWidget, "pTab" );
tabWidget->insertTab( pTab,"Playlist");
QGridLayout *Playout = new QGridLayout( pTab );
Playout->setSpacing( 2);
Playout->setMargin( 2);
// Add the playlist area
QVBox *vbox3 = new QVBox( pTab );
d->playListFrame = vbox3;
QHBox *hbox2 = new QHBox( vbox3 );
d->selectedFiles = new PlayListSelection( hbox2 );
vbox1 = new QVBox( hbox2 );
QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
QWidget *aTab;
aTab = new QWidget( tabWidget, "aTab" );
QGridLayout *Alayout = new QGridLayout( aTab );
Alayout->setSpacing( 2 );
Alayout->setMargin( 2 );
audioView = new QListView( aTab, "Audioview" );
audioView->addColumn( tr( "Title" ), 140 );
audioView->addColumn( tr( "Size" ), -1 );
audioView->addColumn( tr( "Media" ), -1 );
audioView->setColumnAlignment( 1, Qt::AlignRight );
audioView->setColumnAlignment( 2, Qt::AlignRight );
audioView->setAllColumnsShowFocus( TRUE );
audioView->setSorting( 0, TRUE );
audioView->setMultiSelection( TRUE );
audioView->setSelectionMode( QListView::Extended );
Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
tabWidget->insertTab( aTab, tr( "Audio" ) );
QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
QWidget *vTab;
vTab = new QWidget( tabWidget, "vTab" );
QGridLayout *Vlayout = new QGridLayout( vTab );
Vlayout->setSpacing( 2 );
Vlayout->setMargin( 2 );
videoView = new QListView( vTab, "Videoview" );
videoView->addColumn( tr( "Title" ), 140);
videoView->addColumn( tr( "Size" ), -1 );
videoView->addColumn(tr( "Media" ), -1 );
videoView->setColumnAlignment( 1, Qt::AlignRight );
videoView->setColumnAlignment( 2, Qt::AlignRight );
videoView->setAllColumnsShowFocus( TRUE );
videoView->setSorting( 0, TRUE );
videoView->setMultiSelection( TRUE );
videoView->setSelectionMode( QListView::Extended );
Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
tabWidget->insertTab( vTab, tr( "Video" ) );
//playlists list
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
QGridLayout *Llayout = new QGridLayout( LTab );
Llayout->setSpacing( 2 );
Llayout->setMargin( 2 );
playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy
Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
tabWidget->insertTab( LTab, tr( "Lists" ) );
setCentralWidget( vbox5 );
}
PlayListWidgetGui::~PlayListWidgetGui() {
}
void PlayListWidgetGui::setView( char view ) {
if ( view == 'l' )
showMaximized();
else
hide();
}
void PlayListWidgetGui::setActiveWindow() {
// qDebug("SETTING active window");
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
index 4c8d737..61fd40d 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h
@@ -1,126 +1,130 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef PLAY_LIST_WIDGET_GUI_H
#define PLAY_LIST_WIDGET_GUI_H
#include <qmainwindow.h>
#include <qpe/applnk.h>
#include <qpe/resource.h>
#include <qpe/qpemenubar.h>
#include <qtabwidget.h>
#include <qpe/fileselector.h>
#include <qpushbutton.h>
#include <qpopupmenu.h>
#include <qaction.h>
-
+#include <qslider.h>
+#include <qlcdnumber.h>
class PlayListWidgetPrivate;
class PlayListSelection;
class Config;
class QPEToolBar;
class QListViewItem;
class QListView;
class QPoint;
class QAction;
class QLabel;
class PlayListWidgetPrivate {
public:
QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
QFrame *playListFrame;
FileSelector *files;
PlayListSelection *selectedFiles;
bool setDocumentUsed;
DocLnk *current;
};
class ToolButton : public QToolButton {
public:
ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
: QToolButton( parent, name ) {
setTextLabel( name );
setPixmap( Resource::loadPixmap( icon ) );
setAutoRaise( TRUE );
setFocusPolicy( QWidget::NoFocus );
setToggleButton( t );
connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
QPEMenuToolFocusManager::manager()->addWidget( this );
}
};
class MenuItem : public QAction {
public:
MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
: QAction( text, QString::null, 0, 0 ) {
connect( this, SIGNAL( activated() ), handler, slot );
addTo( parent );
}
};
class PlayListWidgetGui : public QMainWindow {
Q_OBJECT
public:
PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 );
~PlayListWidgetGui();
protected:
QTabWidget * tabWidget;
QListView *audioView, *videoView, *playlistView;
QLabel *libString;
QPopupMenu *pmView ;
+ QPopupMenu *gammaMenu;
+ QSlider *gammaSlider;
+ QLCDNumber *gammaLCD;
bool fromSetDocument;
bool insanityBool;
QString setDocFileRef;
// retrieve the current playlist entry (media file link)
QPushButton *tbDeletePlaylist;
int selected;
QPopupMenu *pmPlayList;
FileSelector* playLists;
QPopupMenu *skinsMenu;
PlayListWidgetPrivate *d; // Private implementation data
QVBox *vbox1;
QVBox *vbox5;
QPEToolBar *bar;
void setActiveWindow(); // need to handle this to show the right view
void setView( char );
};
#endif
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 12d80ba..d18fde5 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,202 +1,207 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qtimer.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include "xinecontrol.h"
#include "mediaplayerstate.h"
#include "videowidget.h"
extern MediaPlayerState *mediaPlayerState;
extern VideoWidget *videoUI;
XineControl::XineControl( QObject *parent, const char *name )
: QObject( parent, name ) {
libXine = new XINE::Lib(videoUI->vidWidget() );
connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & )));
connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
+ connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
disabledSuspendScreenSaver = FALSE;
}
XineControl::~XineControl() {
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = FALSE;
// Re-enable the suspend mode
QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
#endif
delete libXine;
}
void XineControl::play( const QString& fileName ) {
hasVideoChannel=FALSE;
hasAudioChannel=FALSE;
m_fileName = fileName;
- qDebug("<<FILENAME: " + fileName + ">>>>");
+ //qDebug("<<FILENAME: " + fileName + ">>>>");
libXine->play( fileName );
mediaPlayerState->setPlaying( true );
// default to audio view until we know how to handle video
// MediaDetect mdetect;
char whichGui = mdetect.videoOrAudio( fileName );
if (whichGui == 'f') {
qDebug("Nicht erkannter Dateityp");
return;
}
if (whichGui == 'a') {
libXine->setShowVideo( false );
hasAudioChannel=TRUE;
} else {
libXine->setShowVideo( true );
hasVideoChannel=TRUE;
}
// determine if slider is shown
mediaPlayerState->setIsStreaming( !libXine->isSeekable() );
// which gui (video / audio)
mediaPlayerState->setView( whichGui );
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( !disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = TRUE;
// Stop the screen from blanking and power saving state
QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
<< ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend );
}
#endif
length();
position();
}
void XineControl::nextMedia() {
mediaPlayerState->setNext();
}
+void XineControl::setGamma( int value ) {
+ libXine->setGamma( value );
+}
+
void XineControl::stop( bool isSet ) {
if ( !isSet) {
libXine->stop( );
mediaPlayerState->setList();
// mediaPlayerState->setPlaying( false );
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = FALSE;
// Re-enable the suspend mode
QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
#endif
} else {
// play again
}
}
/**
* Pause playback
* @isSet
*/
void XineControl::pause( bool isSet) {
if (isSet) {
libXine->pause();
} else {
libXine->play( m_fileName, 0, m_currentTime);
}
}
/**
* get current time in playback
*/
long XineControl::currentTime() {
// todo: jede sekunde überprüfen
m_currentTime = libXine->currentTime();
return m_currentTime;
QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
}
/**
* Set the length of the media file
*/
void XineControl::length() {
m_length = libXine->length();
mediaPlayerState->setLength( m_length );
}
/**
* Reports the position the xine backend is at right now
* @return long the postion in seconds
*/
long XineControl::position() {
m_position = ( currentTime() );
mediaPlayerState->updatePosition( m_position );
long emitPos = (long)m_position;
emit positionChanged( emitPos );
if(mediaPlayerState->isPlaying)
// needs to be stopped the media is stopped
QTimer::singleShot( 1000, this, SLOT( position() ) );
// qDebug("POSITION : %d", m_position);
return m_position;
}
/**
* Set videoplayback to fullscreen
* @param isSet
*/
void XineControl::setFullscreen( bool isSet ) {
libXine->showVideoFullScreen( isSet);
}
/**
* Seek to a position in the track
* @param second the second to jump to
*/
void XineControl::seekTo( long second ) {
libXine->play( m_fileName , 0, (int)second );
}
void XineControl::videoResized ( const QSize &s ) {
libXine-> resize ( s );
}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 4263b36..1de610b 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -1,79 +1,106 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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
-..}^=.=       =       ; Library General Public License for more
+..}^=.=       =       ; General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
+  -_. . .   )=.  = General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef XINECONTROL_H
#define XINECONTROL_H
#include "lib.h"
#include "mediadetect.h"
#include <qobject.h>
class XineControl : public QObject {
Q_OBJECT
public:
XineControl( QObject *parent = 0, const char *name =0 );
~XineControl();
bool hasVideo() const { return hasVideoChannel; }
bool hasAudio() const { return hasAudioChannel; }
public slots:
void play( const QString& fileName );
void stop( bool );
+
+ /**
+ * Pause the media stream
+ * @param if pause or not
+ */
void pause( bool );
+
+ /**
+ * Set videos fullscreen
+ * @param yes or no
+ */
void setFullscreen( bool );
+
+ /**
+ *
+ */
long currentTime();
void seekTo( long );
// get length of media file and set it
void length();
long position();
+
+ /**
+ * Proceed to the next media file in playlist
+ */
void nextMedia();
+
void videoResized ( const QSize &s );
+ /**
+ * Set the gamma value of the video output
+ * @param int value between -100 and 100, 0 is original
+ */
+ void setGamma( int );
+
+
private:
XINE::Lib *libXine;
MediaDetect mdetect;
long m_currentTime;
long m_position;
int m_length;
QString m_fileName;
bool disabledSuspendScreenSaver : 1;
bool hasVideoChannel : 1;
bool hasAudioChannel : 1;
+
signals:
void positionChanged( long );
};
#endif
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index bc95d86..d06d62a 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
diff --git a/noncore/multimedia/opieplayer2/yuv2rgb.c b/noncore/multimedia/opieplayer2/yuv2rgb.c
index 22bb4cb..e8e86e6 100644
--- a/noncore/multimedia/opieplayer2/yuv2rgb.c
+++ b/noncore/multimedia/opieplayer2/yuv2rgb.c
@@ -1,3168 +1,3167 @@
/*
* yuv2rgb.c
*
* This file is part of xine, a unix video player.
*
* based on work from mpeg2dec:
* Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
*
* mpeg2dec 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.
*
* mpeg2dec 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "yuv2rgb.h"
#include <xine/xineutils.h>
static int prof_scale_line = -1;
static scale_line_func_t find_scale_line_func(int step);
const int32_t Inverse_Table_6_9[8][4] = {
{117504, 138453, 13954, 34903}, /* no sequence_display_extension */
{117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
{104597, 132201, 25675, 53279}, /* unspecified */
{104597, 132201, 25675, 53279}, /* reserved */
{104448, 132798, 24759, 53109}, /* FCC */
{104597, 132201, 25675, 53279}, /* ITU-R Rec. 624-4 System B, G */
{104597, 132201, 25675, 53279}, /* SMPTE 170M */
{117579, 136230, 16907, 35559} /* SMPTE 240M (1987) */
};
static void *my_malloc_aligned (size_t alignment, size_t size, void **chunk) {
char *pMem;
pMem = xine_xmalloc (size+alignment);
*chunk = pMem;
while ((int) pMem % alignment)
pMem++;
return pMem;
}
static int yuv2rgb_configure (yuv2rgb_t *this,
int source_width, int source_height,
int y_stride, int uv_stride,
int dest_width, int dest_height,
int rgb_stride) {
/*
printf ("yuv2rgb setup (%d x %d => %d x %d)\n", source_width, source_height,
dest_width, dest_height);
*/
if (prof_scale_line == -1)
prof_scale_line = xine_profiler_allocate_slot("xshm scale line");
this->source_width = source_width;
this->source_height = source_height;
this->y_stride = y_stride;
this->uv_stride = uv_stride;
this->dest_width = dest_width;
this->dest_height = dest_height;
this->rgb_stride = rgb_stride;
if (this->y_chunk) {
free (this->y_chunk);
this->y_buffer = this->y_chunk = NULL;
}
if (this->u_chunk) {
free (this->u_chunk);
this->u_buffer = this->u_chunk = NULL;
}
if (this->v_chunk) {
free (this->v_chunk);
this->v_buffer = this->v_chunk = NULL;
}
this->step_dx = source_width * 32768 / dest_width;
this->step_dy = source_height * 32768 / dest_height;
this->scale_line = find_scale_line_func(this->step_dx);
if ((source_width == dest_width) && (source_height == dest_height)) {
this->do_scale = 0;
/*
* space for two y-lines (for yuv2rgb_mlib)
* u,v subsampled 2:1
*/
this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
if (!this->y_buffer)
return 0;
this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
if (!this->u_buffer)
return 0;
this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
if (!this->v_buffer)
return 0;
} else {
this->do_scale = 1;
/*
* space for two y-lines (for yuv2rgb_mlib)
* u,v subsampled 2:1
*/
this->y_buffer = my_malloc_aligned (16, 2*dest_width, &this->y_chunk);
if (!this->y_buffer)
return 0;
this->u_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->u_chunk);
if (!this->u_buffer)
return 0;
this->v_buffer = my_malloc_aligned (16, (dest_width+1)/2, &this->v_chunk);
if (!this->v_buffer)
return 0;
}
return 1;
}
static void scale_line_gen (uint8_t *source, uint8_t *dest,
int width, int step) {
/*
* scales a yuv source row to a dest row, with interpolation
* (good quality, but slow)
*/
int p1;
int p2;
int dx;
xine_profiler_start_count(prof_scale_line);
p1 = *source++;
p2 = *source++;
dx = 0;
/*
* the following code has been optimized by Scott Smith <ssmith@akamai.com>:
*
* ok now I have a meaningful optimization for yuv2rgb.c:scale_line_gen.
* it removes the loop from within the while() loop by separating it out
* into 3 cases: where you are enlarging the line (<32768), where you are
* between 50% and 100% of the original line (<=65536), and where you are
* shrinking it by a lot. anyways, I went from 200 delivered / 100+
* skipped to 200 delivered / 80 skipped for the enlarging case. I
* noticed when looking at the assembly that the compiler was able to
* unroll these while(width) loops, whereas before it was trying to
* unroll the while(dx>32768) loops. so the compiler is better able to
* deal with this code.
*/
if (step < 32768) {
while (width) {
*dest = p1 + (((p2-p1) * dx)>>15);
dx += step;
if (dx > 32768) {
dx -= 32768;
p1 = p2;
p2 = *source++;
}
dest ++;
width --;
}
} else if (step <= 65536) {
while (width) {
*dest = p1 + (((p2-p1) * dx)>>15);
dx += step;
if (dx > 65536) {
dx -= 65536;
p1 = *source++;
p2 = *source++;
} else {
dx -= 32768;
p1 = p2;
p2 = *source++;
}
dest ++;
width --;
}
} else {
while (width) {
int offs;
*dest = p1 + (((p2-p1) * dx)>>15);
dx += step;
offs=((dx-1)>>15);
dx-=offs<<15;
source+=offs-2;
p1=*source++;
p2=*source++;
dest ++;
width --;
}
}
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 16 output pixels from 15 source pixels using shifts.
* Useful for scaling a PAL mpeg2 dvd input source to 4:3 format on
* a monitor using square pixels.
* (720 x 576 ==> 768 x 576)
*/
static void scale_line_15_16 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 16) >= 0) {
p1 = source[0];
dest[0] = p1;
p2 = source[1];
dest[1] = (1*p1 + 7*p2) >> 3;
p1 = source[2];
dest[2] = (1*p2 + 7*p1) >> 3;
p2 = source[3];
dest[3] = (1*p1 + 3*p2) >> 2;
p1 = source[4];
dest[4] = (1*p2 + 3*p1) >> 2;
p2 = source[5];
dest[5] = (3*p1 + 5*p2) >> 3;
p1 = source[6];
dest[6] = (3*p2 + 5*p1) >> 3;
p2 = source[7];
dest[7] = (1*p1 + 1*p1) >> 1;
p1 = source[8];
dest[8] = (1*p2 + 1*p1) >> 1;
p2 = source[9];
dest[9] = (5*p1 + 3*p2) >> 3;
p1 = source[10];
dest[10] = (5*p2 + 3*p1) >> 3;
p2 = source[11];
dest[11] = (3*p1 + 1*p2) >> 2;
p1 = source[12];
dest[12] = (3*p2 + 1*p1) >> 2;
p2 = source[13];
dest[13] = (7*p1 + 1*p2) >> 3;
p1 = source[14];
dest[14] = (7*p2 + 1*p1) >> 3;
dest[15] = p1;
source += 15;
dest += 16;
}
if ((width += 16) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 7*source[1]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 7*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 3*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[3] + 3*source[4]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[4] + 5*source[5]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[5] + 5*source[6]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[6] + 1*source[7]) >> 1;
if (--width <= 0) goto done;
*dest++ = (1*source[7] + 1*source[8]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[8] + 3*source[9]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[9] + 3*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[10] + 1*source[11]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[11] + 1*source[12]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[12] + 1*source[13]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[13] + 1*source[14]) >> 3;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 53 output pixels from 45 source pixels using shifts.
* Useful for scaling a NTSC mpeg2 dvd input source to 16:9 display
* resulution
* fullscreen resolution, or to 16:9 format on a monitor using square
* pixels.
* (720 x 480 ==> 848 x 480)
*/
static void scale_line_45_53 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 53) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 7*p2) >> 3;
p1 = source[2];
dest[2] = (1*p2 + 3*p1) >> 2;
p2 = source[3];
dest[3] = (1*p1 + 1*p2) >> 1;
p1 = source[4];
dest[4] = (5*p2 + 3*p1) >> 3;
p2 = source[5];
dest[5] = (3*p1 + 1*p2) >> 2;
p1 = source[6];
dest[6] = (7*p2 + 1*p1) >> 3;
dest[7] = p1;
p2 = source[7];
dest[8] = (1*p1 + 3*p2) >> 2;
p1 = source[8];
dest[9] = (3*p2 + 5*p1) >> 3;
p2 = source[9];
dest[10] = (1*p1 + 1*p2) >> 1;
p1 = source[10];
dest[11] = (5*p2 + 3*p1) >> 3;
p2 = source[11];
dest[12] = (3*p1 + 1*p2) >> 2;
p1 = source[12];
dest[13] = p2;
dest[14] = (1*p2 + 7*p1) >> 3;
p2 = source[13];
dest[15] = (1*p1 + 3*p2) >> 2;
p1 = source[14];
dest[16] = (3*p2 + 5*p1) >> 3;
p2 = source[15];
dest[17] = (5*p1 + 3*p2) >> 3;
p1 = source[16];
dest[18] = (3*p2 + 1*p1) >> 2;
p2 = source[17];
dest[19] = (7*p1 + 1*p2) >> 3;
dest[20] = p2;
p1 = source[18];
dest[21] = (1*p2 + 7*p1) >> 3;
p2 = source[19];
dest[22] = (3*p1 + 5*p2) >> 3;
p1 = source[20];
dest[23] = (1*p2 + 1*p1) >> 1;
p2 = source[21];
dest[24] = (5*p1 + 3*p2) >> 3;
p1 = source[22];
dest[25] = (3*p2 + 1*p1) >> 2;
p2 = source[23];
dest[26] = (7*p1 + 1*p2) >> 3;
dest[27] = (1*p1 + 7*p2) >> 3;
p1 = source[24];
dest[28] = (1*p2 + 3*p1) >> 2;
p2 = source[25];
dest[29] = (3*p1 + 5*p2) >> 3;
p1 = source[26];
dest[30] = (1*p2 + 1*p1) >> 1;
p2 = source[27];
dest[31] = (5*p1 + 3*p2) >> 3;
p1 = source[28];
dest[32] = (7*p2 + 1*p1) >> 3;
p2 = source[29];
dest[33] = p1;
dest[34] = (1*p1 + 7*p2) >> 3;
p1 = source[30];
dest[35] = (1*p2 + 3*p1) >> 2;
p2 = source[31];
dest[36] = (3*p1 + 5*p2) >> 3;
p1 = source[32];
dest[37] = (5*p2 + 3*p1) >> 3;
p2 = source[33];
dest[38] = (3*p1 + 1*p2) >> 2;
p1 = source[34];
dest[39] = (7*p2 + 1*p1) >> 3;
dest[40] = p1;
p2 = source[35];
dest[41] = (1*p1 + 3*p2) >> 2;
p1 = source[36];
dest[42] = (3*p2 + 5*p1) >> 3;
p2 = source[37];
dest[43] = (1*p1 + 1*p2) >> 1;
p1 = source[38];
dest[44] = (5*p2 + 3*p1) >> 3;
p2 = source[39];
dest[45] = (3*p1 + 1*p2) >> 2;
p1 = source[40];
dest[46] = p2;
dest[47] = (1*p2 + 7*p1) >> 3;
p2 = source[41];
dest[48] = (1*p1 + 3*p2) >> 2;
p1 = source[42];
dest[49] = (3*p2 + 5*p1) >> 3;
p2 = source[43];
dest[50] = (1*p1 + 1*p2) >> 1;
p1 = source[44];
dest[51] = (3*p2 + 1*p1) >> 2;
p2 = source[45];
dest[52] = (7*p1 + 1*p2) >> 3;
source += 45;
dest += 53;
}
if ((width += 53) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 7*source[1]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 3*source[2]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 1*source[3]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[3] + 3*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[4] + 1*source[5]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[5] + 1*source[6]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[6];
if (--width <= 0) goto done;
*dest++ = (1*source[6] + 3*source[7]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[7] + 5*source[8]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[8] + 1*source[9]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[9] + 3*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[10] + 1*source[11]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[11];
if (--width <= 0) goto done;
*dest++ = (1*source[11] + 7*source[12]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[12] + 3*source[13]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[13] + 5*source[14]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[14] + 3*source[15]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[15] + 1*source[16]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[16] + 1*source[17]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[17];
if (--width <= 0) goto done;
*dest++ = (1*source[17] + 7*source[18]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[18] + 5*source[19]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[19] + 1*source[20]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[20] + 3*source[21]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[21] + 1*source[22]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[22] + 1*source[23]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[22] + 7*source[23]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[23] + 3*source[24]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[24] + 5*source[25]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[25] + 1*source[26]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[26] + 3*source[27]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[27] + 1*source[28]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[28];
if (--width <= 0) goto done;
*dest++ = (1*source[28] + 7*source[29]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[29] + 3*source[30]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[30] + 5*source[31]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[31] + 3*source[32]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[32] + 1*source[33]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[33] + 1*source[34]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[34];
if (--width <= 0) goto done;
*dest++ = (1*source[34] + 3*source[35]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[35] + 5*source[36]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[36] + 1*source[37]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[37] + 3*source[38]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[38] + 1*source[39]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[39];
if (--width <= 0) goto done;
*dest++ = (1*source[39] + 7*source[40]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[40] + 3*source[41]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[41] + 5*source[42]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[42] + 1*source[43]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[43] + 1*source[44]) >> 2;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 64 output pixels from 45 source pixels using shifts.
* Useful for scaling a PAL mpeg2 dvd input source to 1024x768
* fullscreen resolution, or to 16:9 format on a monitor using square
* pixels.
* (720 x 576 ==> 1024 x 576)
*/
static void scale_line_45_64 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 64) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 3*p2) >> 2;
p1 = source[2];
dest[2] = (5*p2 + 3*p1) >> 3;
p2 = source[3];
dest[3] = (7*p1 + 1*p2) >> 3;
dest[4] = (1*p1 + 3*p2) >> 2;
p1 = source[4];
dest[5] = (1*p2 + 1*p1) >> 1;
p2 = source[5];
dest[6] = (3*p1 + 1*p2) >> 2;
dest[7] = (1*p1 + 7*p2) >> 3;
p1 = source[6];
dest[8] = (3*p2 + 5*p1) >> 3;
p2 = source[7];
dest[9] = (5*p1 + 3*p2) >> 3;
p1 = source[8];
dest[10] = p2;
dest[11] = (1*p2 + 3*p1) >> 2;
p2 = source[9];
dest[12] = (5*p1 + 3*p2) >> 3;
p1 = source[10];
dest[13] = (7*p2 + 1*p1) >> 3;
dest[14] = (1*p2 + 7*p1) >> 3;
p2 = source[11];
dest[15] = (1*p1 + 1*p2) >> 1;
p1 = source[12];
dest[16] = (3*p2 + 1*p1) >> 2;
dest[17] = p1;
p2 = source[13];
dest[18] = (3*p1 + 5*p2) >> 3;
p1 = source[14];
dest[19] = (5*p2 + 3*p1) >> 3;
p2 = source[15];
dest[20] = p1;
dest[21] = (1*p1 + 3*p2) >> 2;
p1 = source[16];
dest[22] = (1*p2 + 1*p1) >> 1;
p2 = source[17];
dest[23] = (7*p1 + 1*p2) >> 3;
dest[24] = (1*p1 + 7*p2) >> 3;
p1 = source[18];
dest[25] = (3*p2 + 5*p1) >> 3;
p2 = source[19];
dest[26] = (3*p1 + 1*p2) >> 2;
dest[27] = p2;
p1 = source[20];
dest[28] = (3*p2 + 5*p1) >> 3;
p2 = source[21];
dest[29] = (5*p1 + 3*p2) >> 3;
p1 = source[22];
dest[30] = (7*p2 + 1*p1) >> 3;
dest[31] = (1*p2 + 3*p1) >> 2;
p2 = source[23];
dest[32] = (1*p1 + 1*p2) >> 1;
p1 = source[24];
dest[33] = (3*p2 + 1*p1) >> 2;
dest[34] = (1*p2 + 7*p1) >> 3;
p2 = source[25];
dest[35] = (3*p1 + 5*p2) >> 3;
p1 = source[26];
dest[36] = (3*p2 + 1*p1) >> 2;
p2 = source[27];
dest[37] = p1;
dest[38] = (1*p1 + 3*p2) >> 2;
p1 = source[28];
dest[39] = (5*p2 + 3*p1) >> 3;
p2 = source[29];
dest[40] = (7*p1 + 1*p2) >> 3;
dest[41] = (1*p1 + 7*p2) >> 3;
p1 = source[30];
dest[42] = (1*p2 + 1*p1) >> 1;
p2 = source[31];
dest[43] = (3*p1 + 1*p2) >> 2;
dest[44] = (1*p1 + 7*p2) >> 3;
p1 = source[32];
dest[45] = (3*p2 + 5*p1) >> 3;
p2 = source[33];
dest[46] = (5*p1 + 3*p2) >> 3;
p1 = source[34];
dest[47] = p2;
dest[48] = (1*p2 + 3*p1) >> 2;
p2 = source[35];
dest[49] = (1*p1 + 1*p2) >> 1;
p1 = source[36];
dest[50] = (7*p2 + 1*p1) >> 3;
dest[51] = (1*p2 + 7*p1) >> 3;
p2 = source[37];
dest[52] = (1*p1 + 1*p2) >> 1;
p1 = source[38];
dest[53] = (3*p2 + 1*p1) >> 2;
dest[54] = p1;
p2 = source[39];
dest[55] = (3*p1 + 5*p2) >> 3;
p1 = source[40];
dest[56] = (5*p2 + 3*p1) >> 3;
p2 = source[41];
dest[57] = (7*p1 + 1*p2) >> 3;
dest[58] = (1*p1 + 3*p2) >> 2;
p1 = source[42];
dest[59] = (1*p2 + 1*p1) >> 1;
p2 = source[43];
dest[60] = (7*p1 + 1*p2) >> 3;
dest[61] = (1*p1 + 7*p2) >> 3;
p1 = source[44];
dest[62] = (3*p2 + 5*p1) >> 3;
p2 = source[45];
dest[63] = (3*p1 + 1*p2) >> 2;
source += 45;
dest += 64;
}
if ((width += 64) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 3*source[1]) >> 2;
if (--width <= 0) goto done;
*dest++ = (5*source[1] + 3*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[2] + 1*source[3]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 3*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[3] + 1*source[4]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[4] + 1*source[5]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[4] + 7*source[5]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[5] + 5*source[6]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[6] + 3*source[7]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[7];
if (--width <= 0) goto done;
*dest++ = (1*source[7] + 3*source[8]) >> 2;
if (--width <= 0) goto done;
*dest++ = (5*source[8] + 3*source[9]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[9] + 1*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[9] + 7*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[10] + 1*source[11]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[11] + 1*source[12]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[12];
if (--width <= 0) goto done;
*dest++ = (3*source[12] + 5*source[13]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[13] + 3*source[14]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[14];
if (--width <= 0) goto done;
*dest++ = (1*source[14] + 3*source[15]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[15] + 1*source[16]) >> 1;
if (--width <= 0) goto done;
*dest++ = (7*source[16] + 1*source[17]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[16] + 7*source[17]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[17] + 5*source[18]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[18] + 1*source[19]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[19];
if (--width <= 0) goto done;
*dest++ = (3*source[19] + 5*source[20]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[20] + 3*source[21]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[21] + 1*source[22]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[21] + 3*source[22]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[22] + 1*source[23]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[23] + 1*source[24]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[23] + 7*source[24]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[24] + 5*source[25]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[25] + 1*source[26]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[26];
if (--width <= 0) goto done;
*dest++ = (1*source[26] + 3*source[27]) >> 2;
if (--width <= 0) goto done;
*dest++ = (5*source[27] + 3*source[28]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[28] + 1*source[29]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[28] + 7*source[29]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[29] + 1*source[30]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[30] + 1*source[31]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[30] + 7*source[31]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[31] + 5*source[32]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[32] + 3*source[33]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[33];
if (--width <= 0) goto done;
*dest++ = (1*source[33] + 3*source[34]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[34] + 1*source[35]) >> 1;
if (--width <= 0) goto done;
*dest++ = (7*source[35] + 1*source[36]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[35] + 7*source[36]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[36] + 1*source[37]) >> 1;
if (--width <= 0) goto done;
*dest++ = (3*source[37] + 1*source[38]) >> 2;
if (--width <= 0) goto done;
*dest++ = source[38];
if (--width <= 0) goto done;
*dest++ = (3*source[38] + 5*source[39]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[39] + 3*source[40]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[40] + 1*source[41]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[40] + 3*source[41]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[41] + 1*source[42]) >> 1;
if (--width <= 0) goto done;
*dest++ = (7*source[42] + 1*source[43]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[42] + 7*source[43]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[43] + 5*source[44]) >> 3;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 16 output pixels from 9 source pixels using shifts.
* Useful for scaling a PAL mpeg2 dvd input source to 1280x1024 fullscreen
* (720 x 576 ==> 1280 x XXX)
*/
static void scale_line_9_16 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 16) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 1*p2) >> 1;
p1 = source[2];
dest[2] = (7*p2 + 1*p1) >> 3;
dest[3] = (3*p2 + 5*p1) >> 3;
p2 = source[3];
dest[4] = (3*p1 + 1*p2) >> 2;
dest[5] = (1*p1 + 3*p2) >> 2;
p1 = source[4];
dest[6] = (5*p2 + 3*p1) >> 3;
dest[7] = (1*p2 + 7*p1) >> 3;
p2 = source[5];
dest[8] = (1*p1 + 1*p2) >> 1;
p1 = source[6];
dest[9] = p2;
dest[10] = (3*p2 + 5*p1) >> 3;
p2 = source[7];
dest[11] = (7*p1 + 1*p2) >> 3;
dest[12] = (1*p1 + 3*p2) >> 2;
p1 = source[8];
dest[13] = (3*p2 + 1*p1) >> 2;
dest[14] = (1*p2 + 7*p1) >> 3;
p2 = source[9];
dest[15] = (5*p1 + 3*p2) >> 3;
source += 9;
dest += 16;
}
if ((width += 16) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 1*source[1]) >> 1;
if (--width <= 0) goto done;
*dest++ = (7*source[1] + 1*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[1] + 5*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[2] + 1*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 3*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (5*source[3] + 3*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[3] + 7*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[4] + 1*source[5]) >> 1;
if (--width <= 0) goto done;
*dest++ = source[5];
if (--width <= 0) goto done;
*dest++ = (3*source[5] + 5*source[6]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[6] + 1*source[7]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[6] + 3*source[7]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[7] + 1*source[8]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[7] + 7*source[8]) >> 3;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 12 output pixels from 11 source pixels using shifts.
* Useful for scaling a PAL vcd input source to 4:3 display format.
*/
static void scale_line_11_12 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 12) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 7*p2) >> 3;
p1 = source[2];
dest[2] = (1*p2 + 7*p1) >> 3;
p2 = source[3];
dest[3] = (1*p1 + 3*p2) >> 2;
p1 = source[4];
dest[4] = (3*p2 + 5*p1) >> 3;
p2 = source[5];
dest[5] = (3*p1 + 5*p2) >> 3;
p1 = source[6];
dest[6] = (1*p2 + 1*p1) >> 1;
p2 = source[7];
dest[7] = (5*p1 + 3*p2) >> 3;
p1 = source[8];
dest[8] = (5*p2 + 3*p1) >> 3;
p2 = source[9];
dest[9] = (3*p1 + 1*p2) >> 2;
p1 = source[10];
dest[10] = (7*p2 + 1*p1) >> 3;
p2 = source[11];
dest[11] = (7*p1 + 1*p2) >> 3;
source += 11;
dest += 12;
}
if ((width += 12) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 7*source[1]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 7*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 3*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[3] + 5*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[4] + 5*source[5]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[5] + 1*source[6]) >> 1;
if (--width <= 0) goto done;
*dest++ = (5*source[6] + 3*source[7]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[7] + 3*source[8]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[8] + 1*source[9]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[9] + 1*source[10]) >> 3;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 24 output pixels from 11 source pixels using shifts.
* Useful for scaling a PAL vcd input source to 4:3 display format
* at 2*zoom.
*/
static void scale_line_11_24 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 24) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 1*p2) >> 1;
dest[2] = (1*p1 + 7*p2) >> 3;
p1 = source[2];
dest[3] = (5*p2 + 3*p1) >> 3;
dest[4] = (1*p2 + 7*p1) >> 3;
p2 = source[3];
dest[5] = (3*p1 + 1*p2) >> 2;
dest[6] = (1*p1 + 3*p2) >> 2;
p1 = source[4];
dest[7] = (3*p2 + 1*p1) >> 2;
dest[8] = (3*p2 + 5*p1) >> 3;
p2 = source[5];
dest[9] = (7*p1 + 1*p2) >> 3;
dest[10] = (3*p1 + 5*p2) >> 3;
p1 = source[6];
dest[11] = p2;
dest[12] = (1*p2 + 1*p1) >> 1;
dest[13] = p1;
p2 = source[7];
dest[14] = (5*p1 + 3*p2) >> 3;
dest[15] = (1*p1 + 7*p2) >> 3;
p1 = source[8];
dest[16] = (5*p2 + 3*p1) >> 3;
dest[17] = (1*p2 + 3*p1) >> 2;
p2 = source[9];
dest[18] = (3*p1 + 1*p2) >> 2;
dest[19] = (1*p1 + 3*p2) >> 2;
p1 = source[10];
dest[20] = (7*p2 + 1*p1) >> 3;
dest[21] = (3*p2 + 5*p1) >> 3;
p2 = source[11];
dest[22] = (7*p1 + 1*p2) >> 3;
dest[23] = (1*p1 + 1*p2) >> 1;
source += 11;
dest += 24;
}
if ((width += 24) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 1*source[1]) >> 1;
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 7*source[1]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[1] + 3*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 7*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[2] + 1*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 3*source[3]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[3] + 1*source[4]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[3] + 5*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[4] + 1*source[5]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[4] + 5*source[5]) >> 3;
if (--width <= 0) goto done;
*dest++ = source[5];
if (--width <= 0) goto done;
*dest++ = (1*source[5] + 1*source[6]) >> 1;
if (--width <= 0) goto done;
*dest++ = source[6];
if (--width <= 0) goto done;
*dest++ = (5*source[6] + 3*source[7]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[6] + 7*source[7]) >> 3;
if (--width <= 0) goto done;
*dest++ = (5*source[7] + 3*source[8]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[7] + 3*source[8]) >> 2;
if (--width <= 0) goto done;
*dest++ = (3*source[8] + 1*source[9]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[8] + 3*source[9]) >> 2;
if (--width <= 0) goto done;
*dest++ = (7*source[9] + 1*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[9] + 5*source[10]) >> 3;
if (--width <= 0) goto done;
*dest++ = (7*source[10] + 1*source[11]) >> 3;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 8 output pixels from 5 source pixels using shifts.
* Useful for scaling a PAL svcd input source to 4:3 display format.
*/
static void scale_line_5_8 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 8) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (3*p1 + 5*p2) >> 3;
p1 = source[2];
dest[2] = (3*p2 + 1*p1) >> 2;
dest[3] = (1*p2 + 7*p1) >> 3;
p2 = source[3];
dest[4] = (1*p1 + 1*p2) >> 1;
p1 = source[4];
dest[5] = (7*p2 + 1*p1) >> 3;
dest[6] = (1*p2 + 3*p1) >> 2;
p2 = source[5];
dest[7] = (5*p1 + 3*p2) >> 3;
source += 5;
dest += 8;
}
if ((width += 8) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (3*source[0] + 5*source[1]) >> 3;
if (--width <= 0) goto done;
*dest++ = (3*source[1] + 1*source[2]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 7*source[2]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[2] + 1*source[3]) >> 1;
if (--width <= 0) goto done;
*dest++ = (7*source[3] + 1*source[4]) >> 3;
if (--width <= 0) goto done;
*dest++ = (1*source[3] + 3*source[4]) >> 2;
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Interpolates 4 output pixels from 3 source pixels using shifts.
* Useful for scaling a NTSC svcd input source to 4:3 display format.
*/
static void scale_line_3_4 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
while ((width -= 4) >= 0) {
p1 = source[0];
p2 = source[1];
dest[0] = p1;
dest[1] = (1*p1 + 3*p2) >> 2;
p1 = source[2];
dest[2] = (1*p2 + 1*p1) >> 1;
p2 = source[3];
dest[3] = (3*p1 + 1*p2) >> 2;
source += 3;
dest += 4;
}
if ((width += 4) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (1*source[0] + 3*source[1]) >> 2;
if (--width <= 0) goto done;
*dest++ = (1*source[1] + 1*source[2]) >> 1;
done:
xine_profiler_stop_count(prof_scale_line);
}
/* Interpolate 2 output pixels from one source pixel. */
static void scale_line_1_2 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1, p2;
xine_profiler_start_count(prof_scale_line);
p1 = *source;
while ((width -= 4) >= 0) {
*dest++ = p1;
p2 = *++source;
*dest++ = (p1 + p2) >> 1;
*dest++ = p2;
p1 = *++source;
*dest++ = (p2 + p1) >> 1;
}
if ((width += 4) <= 0) goto done;
*dest++ = source[0];
if (--width <= 0) goto done;
*dest++ = (source[0] + source[1]) >> 1;
if (--width <= 0) goto done;
*dest++ = source[1];
done:
xine_profiler_stop_count(prof_scale_line);
}
/*
* Scale line with no horizontal scaling. For NTSC mpeg2 dvd input in
* 4:3 output format (720x480 -> 720x540)
*/
static void scale_line_1_1 (uint8_t *source, uint8_t *dest,
int width, int step) {
xine_profiler_start_count(prof_scale_line);
xine_fast_memcpy(dest, source, width);
xine_profiler_stop_count(prof_scale_line);
}
static scale_line_func_t find_scale_line_func(int step) {
static struct {
int src_step;
int dest_step;
scale_line_func_t func;
char *desc;
} scale_line[] = {
{ 15, 16, scale_line_15_16, "dvd 4:3(pal)" },
{ 45, 64, scale_line_45_64, "dvd 16:9(pal), fullscreen(1024x768)" },
{ 9, 16, scale_line_9_16, "dvd fullscreen(1280x1024)" },
{ 45, 53, scale_line_45_53, "dvd 16:9(ntsc)" },
{ 11, 12, scale_line_11_12, "vcd 4:3(pal)" },
{ 11, 24, scale_line_11_24, "vcd 4:3(pal) 2*zoom" },
{ 5, 8, scale_line_5_8, "svcd 4:3(pal)" },
{ 3, 4, scale_line_3_4, "svcd 4:3(ntsc)" },
{ 1, 2, scale_line_1_2, "2*zoom" },
{ 1, 1, scale_line_1_1, "non-scaled" },
};
int i;
for (i = 0; i < sizeof(scale_line)/sizeof(scale_line[0]); i++) {
if (step == scale_line[i].src_step*32768/scale_line[i].dest_step) {
printf("yuv2rgb: using %s optimized scale_line\n", scale_line[i].desc);
return scale_line[i].func;
}
}
printf("yuv2rgb: using generic scale_line with interpolation\n");
return scale_line_gen;
}
static void scale_line_2 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1;
int p2;
int dx;
p1 = *source; source+=2;
p2 = *source; source+=2;
dx = 0;
while (width) {
*dest = (p1 * (32768 - dx) + p2 * dx) / 32768;
dx += step;
while (dx > 32768) {
dx -= 32768;
p1 = p2;
p2 = *source;
source+=2;
}
dest ++;
width --;
}
}
static void scale_line_4 (uint8_t *source, uint8_t *dest,
int width, int step) {
int p1;
int p2;
int dx;
p1 = *source; source+=4;
p2 = *source; source+=4;
dx = 0;
while (width) {
*dest = (p1 * (32768 - dx) + p2 * dx) / 32768;
dx += step;
while (dx > 32768) {
dx -= 32768;
p1 = p2;
p2 = *source;
source+=4;
}
dest ++;
width --;
}
}
#define RGB(i) \
U = pu[i]; \
V = pv[i]; \
r = this->table_rV[V]; \
g = (void *) (((uint8_t *)this->table_gU[U]) + this->table_gV[V]); \
b = this->table_bU[U];
#define DST1(i) \
Y = py_1[2*i]; \
dst_1[2*i] = r[Y] + g[Y] + b[Y]; \
Y = py_1[2*i+1]; \
dst_1[2*i+1] = r[Y] + g[Y] + b[Y];
#define DST2(i) \
Y = py_2[2*i]; \
dst_2[2*i] = r[Y] + g[Y] + b[Y]; \
Y = py_2[2*i+1]; \
dst_2[2*i+1] = r[Y] + g[Y] + b[Y];
#define DST1RGB(i) \
Y = py_1[2*i]; \
dst_1[6*i] = r[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = b[Y]; \
Y = py_1[2*i+1]; \
dst_1[6*i+3] = r[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = b[Y];
#define DST2RGB(i) \
Y = py_2[2*i]; \
dst_2[6*i] = r[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = b[Y]; \
Y = py_2[2*i+1]; \
dst_2[6*i+3] = r[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = b[Y];
#define DST1BGR(i) \
Y = py_1[2*i]; \
dst_1[6*i] = b[Y]; dst_1[6*i+1] = g[Y]; dst_1[6*i+2] = r[Y]; \
Y = py_1[2*i+1]; \
dst_1[6*i+3] = b[Y]; dst_1[6*i+4] = g[Y]; dst_1[6*i+5] = r[Y];
#define DST2BGR(i) \
Y = py_2[2*i]; \
dst_2[6*i] = b[Y]; dst_2[6*i+1] = g[Y]; dst_2[6*i+2] = r[Y]; \
Y = py_2[2*i+1]; \
dst_2[6*i+3] = b[Y]; dst_2[6*i+4] = g[Y]; dst_2[6*i+5] = r[Y];
#define DST1CMAP(i) \
Y = py_1[2*i]; \
dst_1[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \
Y = py_1[2*i+1]; \
dst_1[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]];
#define DST2CMAP(i) \
Y = py_2[2*i]; \
dst_2[2*i] = this->cmap[r[Y] + g[Y] + b[Y]]; \
Y = py_2[2*i+1]; \
dst_2[2*i+1] = this->cmap[r[Y] + g[Y] + b[Y]];
static void yuv2rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint32_t * r, * g, * b;
uint32_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = (uint32_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768);
}
} else {
height = this->source_height >> 1;
do {
dst_1 = (uint32_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1(0);
DST2(0);
RGB(1);
DST2(1);
DST1(1);
RGB(2);
DST1(2);
DST2(2);
RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
/* This is very near from the yuv2rgb_c_32 code */
static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1RGB(0);
RGB(1);
DST1RGB(1);
RGB(2);
DST1RGB(2);
RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while (dy>=32768);
}
} else {
height = this->source_height >> 1;
do {
dst_1 = _dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1RGB(0);
DST2RGB(0);
RGB(1);
DST2RGB(1);
DST1RGB(1);
RGB(2);
DST1RGB(2);
DST2RGB(2);
RGB(3);
DST2RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 24;
dst_2 += 24;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
/* only trivial mods from yuv2rgb_c_24_rgb */
static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1BGR(0);
RGB(1);
DST1BGR(1);
RGB(2);
DST1BGR(2);
RGB(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
height = this->source_height >> 1;
do {
dst_1 = _dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1BGR(0);
DST2BGR(0);
RGB(1);
DST2BGR(1);
DST1BGR(1);
RGB(2);
DST1BGR(2);
DST2BGR(2);
RGB(3);
DST2BGR(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 24;
dst_2 += 24;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
/* This is exactly the same code as yuv2rgb_c_32 except for the types of */
/* r, g, b, dst_1, dst_2 */
static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint16_t * r, * g, * b;
uint16_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = (uint16_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768);
}
} else {
height = this->source_height >> 1;
do {
dst_1 = (uint16_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1(0);
DST2(0);
RGB(1);
DST2(1);
DST1(1);
RGB(2);
DST1(2);
DST2(2);
RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
/* This is exactly the same code as yuv2rgb_c_32 except for the types of */
/* r, g, b, dst_1, dst_2 */
static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = (uint8_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
height = this->source_height >> 1;
do {
dst_1 = (uint8_t*)_dst;
dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride );
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1(0);
DST2(0);
RGB(1);
DST2(1);
DST1(1);
RGB(2);
DST1(2);
DST2(2);
RGB(3);
DST2(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
/* now for something different: 256 grayscale mode */
static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
dy = 0;
dst_height = this->dest_height;
for (;;) {
scale_line (_py, _dst, this->dest_width, this->step_dx);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
_py += this->y_stride*(dy>>15);
dy &= 32767;
/* dy -= 32768;
_py += this->y_stride;
*/
}
} else {
for (height = this->source_height; --height >= 0; ) {
xine_fast_memcpy(_dst, _py, this->dest_width);
_dst += this->rgb_stride;
_py += this->y_stride;
}
}
}
/* now for something different: 256 color mode */
static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst,
uint8_t * _py, uint8_t * _pu, uint8_t * _pv)
{
int U, V, Y;
uint8_t * py_1, * py_2, * pu, * pv;
uint16_t * r, * g, * b;
uint8_t * dst_1, * dst_2;
int width, height, dst_height;
int dy;
if (this->do_scale) {
scale_line_func_t scale_line = this->scale_line;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
dst_height = this->dest_height;
for (height = 0;; ) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1CMAP(0);
RGB(1);
DST1CMAP(1);
RGB(2);
DST1CMAP(2);
RGB(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--dst_height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (dst_height <= 0)
break;
do {
dy -= 32768;
_py += this->y_stride;
scale_line (_py, this->y_buffer,
this->dest_width, this->step_dx);
if (height & 1) {
_pu += this->uv_stride;
_pv += this->uv_stride;
scale_line (_pu, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line (_pv, this->v_buffer,
this->dest_width >> 1, this->step_dx);
}
height++;
} while( dy>=32768 );
}
} else {
height = this->source_height >> 1;
do {
dst_1 = _dst;
dst_2 = _dst + this->rgb_stride;
py_1 = _py;
py_2 = _py + this->y_stride;
pu = _pu;
pv = _pv;
width = this->source_width >> 3;
do {
RGB(0);
DST1CMAP(0);
DST2CMAP(0);
RGB(1);
DST2CMAP(1);
DST1CMAP(1);
RGB(2);
DST1CMAP(2);
DST2CMAP(2);
RGB(3);
DST2CMAP(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
py_2 += 8;
dst_1 += 8;
dst_2 += 8;
} while (--width);
_dst += 2 * this->rgb_stride;
_py += 2 * this->y_stride;
_pu += this->uv_stride;
_pv += this->uv_stride;
} while (--height);
}
}
static int div_round (int dividend, int divisor)
{
if (dividend > 0)
return (dividend + (divisor>>1)) / divisor;
else
return -((-dividend + (divisor>>1)) / divisor);
}
static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped)
{
int i;
uint8_t table_Y[1024];
uint32_t * table_32 = 0;
uint16_t * table_16 = 0;
uint8_t * table_8 = 0;
int entry_size = 0;
void *table_r = 0, *table_g = 0, *table_b = 0;
int shift_r = 0, shift_g = 0, shift_b = 0;
int crv = Inverse_Table_6_9[this->matrix_coefficients][0];
int cbu = Inverse_Table_6_9[this->matrix_coefficients][1];
int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2];
int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3];
for (i = 0; i < 1024; i++) {
int j;
j = (76309 * (i - 384 - 16) + 32768) >> 16;
j = (j < 0) ? 0 : ((j > 255) ? 255 : j);
table_Y[i] = j;
}
switch (mode) {
case MODE_32_RGB:
case MODE_32_BGR:
table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t));
entry_size = sizeof (uint32_t);
table_r = table_32 + 197;
table_b = table_32 + 197 + 685;
table_g = table_32 + 197 + 2*682;
if (swapped) {
switch (mode) {
case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break;
case MODE_32_BGR: shift_r = 24; shift_g = 16; shift_b = 8; break;
}
} else {
switch (mode) {
case MODE_32_RGB: shift_r = 16; shift_g = 8; shift_b = 0; break;
case MODE_32_BGR: shift_r = 0; shift_g = 8; shift_b = 16; break;
}
}
for (i = -197; i < 256+197; i++)
((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r;
for (i = -132; i < 256+132; i++)
((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g;
for (i = -232; i < 256+232; i++)
((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b;
break;
case MODE_24_RGB:
case MODE_24_BGR:
table_8 = malloc ((256 + 2*232) * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_r = table_g = table_b = table_8 + 232;
for (i = -232; i < 256+232; i++)
((uint8_t * )table_b)[i] = table_Y[i+384];
break;
case MODE_15_BGR:
case MODE_16_BGR:
case MODE_15_RGB:
case MODE_16_RGB:
table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
entry_size = sizeof (uint16_t);
table_r = table_16 + 197;
table_b = table_16 + 197 + 685;
table_g = table_16 + 197 + 2*682;
if (swapped) {
switch (mode) {
case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break;
case MODE_16_BGR: shift_r = 8; shift_g = 5; shift_b = 3; break;
case MODE_15_RGB: shift_r = 2; shift_g = 5; shift_b = 8; break;
case MODE_16_RGB: shift_r = 3; shift_g = 5; shift_b = 8; break;
}
} else {
switch (mode) {
case MODE_15_BGR: shift_r = 0; shift_g = 5; shift_b = 10; break;
case MODE_16_BGR: shift_r = 0; shift_g = 5; shift_b = 11; break;
case MODE_15_RGB: shift_r = 10; shift_g = 5; shift_b = 0; break;
case MODE_16_RGB: shift_r = 11; shift_g = 5; shift_b = 0; break;
}
}
for (i = -197; i < 256+197; i++)
((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << shift_r;
for (i = -132; i < 256+132; i++) {
int j = table_Y[i+384] >> (((mode==MODE_16_RGB) || (mode==MODE_16_BGR)) ? 2 : 3);
if (swapped)
((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3);
else
((uint16_t *)table_g)[i] = j << 5;
}
for (i = -232; i < 256+232; i++)
((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b;
break;
case MODE_8_RGB:
case MODE_8_BGR:
table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t));
entry_size = sizeof (uint8_t);
table_r = table_8 + 197;
table_b = table_8 + 197 + 685;
table_g = table_8 + 197 + 2*682;
switch (mode) {
case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break;
case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break;
}
for (i = -197; i < 256+197; i++)
((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r;
for (i = -132; i < 256+132; i++)
((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g;
for (i = -232; i < 256+232; i++)
((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b;
break;
case MODE_8_GRAY:
return;
case MODE_PALETTE:
table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t));
entry_size = sizeof (uint16_t);
table_r = table_16 + 197;
table_b = table_16 + 197 + 685;
table_g = table_16 + 197 + 2*682;
shift_r = 10;
shift_g = 5;
shift_b = 0;
for (i = -197; i < 256+197; i++)
((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10;
for (i = -132; i < 256+132; i++)
((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5;
for (i = -232; i < 256+232; i++)
((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0;
break;
default:
fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode);
abort();
}
for (i = 0; i < 256; i++) {
this->table_rV[i] = (((uint8_t *) table_r) +
entry_size * div_round (crv * (i-128), 76309));
this->table_gU[i] = (((uint8_t *) table_g) +
entry_size * div_round (cgu * (i-128), 76309));
this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309);
this->table_bU[i] = (((uint8_t *)table_b) +
entry_size * div_round (cbu * (i-128), 76309));
}
this->gamma = 0;
this->entry_size = entry_size;
}
static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint32_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return r[y] + g[y] + b[y];
}
static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint8_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return (uint32_t) r[y] +
((uint32_t) g[y] << 8) +
((uint32_t) b[y] << 16);
}
static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint8_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return (uint32_t) b[y] +
((uint32_t) g[y] << 8) +
((uint32_t) r[y] << 16);
}
static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint16_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return r[y] + g[y] + b[y];
}
static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint8_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return r[y] + g[y] + b[y];
}
static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
return y;
}
static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v)
{
uint16_t * r, * g, * b;
r = this->table_rV[v];
g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]);
b = this->table_bU[u];
return this->cmap[r[y] + g[y] + b[y]];
}
static void yuv2rgb_c_init (yuv2rgb_factory_t *this)
{
switch (this->mode) {
case MODE_32_RGB:
case MODE_32_BGR:
this->yuv2rgb_fun = yuv2rgb_c_32;
break;
case MODE_24_RGB:
case MODE_24_BGR:
this->yuv2rgb_fun =
(this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped)
? yuv2rgb_c_24_rgb
: yuv2rgb_c_24_bgr;
break;
case MODE_15_BGR:
case MODE_16_BGR:
case MODE_15_RGB:
case MODE_16_RGB:
this->yuv2rgb_fun = yuv2rgb_c_16;
break;
case MODE_8_RGB:
case MODE_8_BGR:
this->yuv2rgb_fun = yuv2rgb_c_8;
break;
case MODE_8_GRAY:
this->yuv2rgb_fun = yuv2rgb_c_gray;
break;
case MODE_PALETTE:
this->yuv2rgb_fun = yuv2rgb_c_palette;
break;
default:
printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
abort();
}
}
static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) {
switch (this->mode) {
case MODE_32_RGB:
case MODE_32_BGR:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32;
break;
case MODE_24_RGB:
case MODE_24_BGR:
this->yuv2rgb_single_pixel_fun =
(this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped)
? yuv2rgb_single_pixel_24_rgb
: yuv2rgb_single_pixel_24_bgr;
break;
case MODE_15_BGR:
case MODE_16_BGR:
case MODE_15_RGB:
case MODE_16_RGB:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_16;
break;
case MODE_8_RGB:
case MODE_8_BGR:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8;
break;
case MODE_8_GRAY:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray;
break;
case MODE_PALETTE:
this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette;
break;
default:
printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode);
abort();
}
}
/*
* yuy2 stuff
*/
static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint32_t * r, * g, * b;
uint32_t * dst_1;
int width, height;
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = (uint32_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
/*
dy -= 32768;
_p += this->y_stride*2;
*/
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1;
int width, height;
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1RGB(0);
RGB(1);
DST1RGB(1);
RGB(2);
DST1RGB(2);
RGB(3);
DST1RGB(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
/*
dy -= 32768;
_p += this->y_stride*2;
*/
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1;
int width, height;
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1BGR(0);
RGB(1);
DST1BGR(1);
RGB(2);
DST1BGR(2);
RGB(3);
DST1BGR(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 24;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint16_t * r, * g, * b;
uint16_t * dst_1;
int width, height;
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = (uint16_t*)_dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint8_t * r, * g, * b;
uint8_t * dst_1;
int width, height;
int dy;
/* FIXME: implement unscaled version */
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1(0);
RGB(1);
DST1(1);
RGB(2);
DST1(2);
RGB(3);
DST1(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int width, height;
int dy;
uint8_t * dst;
uint8_t * y;
if (this->do_scale) {
dy = 0;
height = this->dest_height;
for (;;) {
scale_line_2 (_p, _dst, this->dest_width, this->step_dx);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
}
} else {
for (height = this->source_height; --height >= 0; ) {
dst = _dst;
y = _p;
for (width = this->source_width; --width >= 0; ) {
*dst++ = *y;
y += 2;
}
_dst += this->rgb_stride;
_p += this->y_stride*2;
}
}
}
static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p)
{
int U, V, Y;
uint8_t * py_1, * pu, * pv;
uint16_t * r, * g, * b;
uint8_t * dst_1;
int width, height;
int dy;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
dy = 0;
height = this->dest_height;
for (;;) {
dst_1 = _dst;
py_1 = this->y_buffer;
pu = this->u_buffer;
pv = this->v_buffer;
width = this->dest_width >> 3;
do {
RGB(0);
DST1CMAP(0);
RGB(1);
DST1CMAP(1);
RGB(2);
DST1CMAP(2);
RGB(3);
DST1CMAP(3);
pu += 4;
pv += 4;
py_1 += 8;
dst_1 += 8;
} while (--width);
dy += this->step_dy;
_dst += this->rgb_stride;
while (--height > 0 && dy < 32768) {
xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width);
dy += this->step_dy;
_dst += this->rgb_stride;
}
if (height <= 0)
break;
_p += this->y_stride*2*(dy>>15);
dy &= 32767;
scale_line_4 (_p+1, this->u_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_4 (_p+3, this->v_buffer,
this->dest_width >> 1, this->step_dx);
scale_line_2 (_p, this->y_buffer,
this->dest_width, this->step_dx);
}
}
static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
{
switch (this->mode) {
case MODE_32_RGB:
case MODE_32_BGR:
this->yuy22rgb_fun = yuy22rgb_c_32;
break;
case MODE_24_RGB:
case MODE_24_BGR:
this->yuy22rgb_fun =
(this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped)
? yuy22rgb_c_24_rgb
: yuy22rgb_c_24_bgr;
break;
case MODE_15_BGR:
case MODE_16_BGR:
case MODE_15_RGB:
case MODE_16_RGB:
this->yuy22rgb_fun = yuy22rgb_c_16;
break;
case MODE_8_RGB:
case MODE_8_BGR:
this->yuy22rgb_fun = yuy22rgb_c_8;
break;
case MODE_8_GRAY:
this->yuy22rgb_fun = yuy22rgb_c_gray;
break;
case MODE_PALETTE:
this->yuy22rgb_fun = yuy22rgb_c_palette;
break;
default:
printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode);
}
}
yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t));
this->cmap = factory->cmap;
this->y_chunk = this->y_buffer = NULL;
this->u_chunk = this->u_buffer = NULL;
this->v_chunk = this->v_buffer = NULL;
this->table_rV = factory->table_rV;
this->table_gU = factory->table_gU;
this->table_gV = factory->table_gV;
this->table_bU = factory->table_bU;
this->yuv2rgb_fun = factory->yuv2rgb_fun;
this->yuy22rgb_fun = factory->yuy22rgb_fun;
this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun;
this->configure = yuv2rgb_configure;
return this;
}
/*
* factory functions
*/
-
void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) {
int i;
for (i = 0; i < 256; i++) {
(uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma);
(uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma);
(uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma);
}
#ifdef ARCH_X86
mmx_yuv2rgb_set_gamma(gamma);
#endif
this->gamma = gamma;
}
int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) {
return this->gamma;
}
yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped,
uint8_t *cmap) {
yuv2rgb_factory_t *this;
#ifdef ARCH_X86
uint32_t mm = xine_mm_accel();
#endif
this = malloc (sizeof (yuv2rgb_factory_t));
this->mode = mode;
this->swapped = swapped;
this->cmap = cmap;
this->create_converter = yuv2rgb_create_converter;
this->set_gamma = yuv2rgb_set_gamma;
this->get_gamma = yuv2rgb_get_gamma;
this->matrix_coefficients = 6;
yuv2rgb_setup_tables (this, mode, swapped);
/*
* auto-probe for the best yuv2rgb function
*/
this->yuv2rgb_fun = NULL;
#ifdef ARCH_X86
if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) {
yuv2rgb_init_mmxext (this);
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using MMXEXT for colorspace transform\n");
}
if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) {
yuv2rgb_init_mmx (this);
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using MMX for colorspace transform\n");
}
#endif
#if HAVE_MLIB
if (this->yuv2rgb_fun == NULL) {
yuv2rgb_init_mlib (this);
if (this->yuv2rgb_fun != NULL)
printf ("yuv2rgb: using medialib for colorspace transform\n");
}
#endif
#ifdef __arm__
if (this->yuv2rgb_fun == NULL) {
yuv2rgb_init_arm ( this );
if(this->yuv2rgb_fun != NULL)
printf("yuv2rgb: using arm4l assembler for colorspace transform\n" );
}
#endif
if (this->yuv2rgb_fun == NULL) {
printf ("yuv2rgb: no accelerated colorspace conversion found\n");
yuv2rgb_c_init (this);
}
/*
* auto-probe for the best yuy22rgb function
*/
/* FIXME: implement mmx/mlib functions */
yuy22rgb_c_init (this);
/*
* set up single pixel function
*/
yuv2rgb_single_pixel_init (this);
return this;
}