-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 60 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 43 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.h | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 15 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 33 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 88 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/yuv2rgb.c | 17 |
13 files changed, 244 insertions, 88 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | 41 | ||
42 | #include <qgfx_qws.h> | 42 | #include <qgfx_qws.h> |
43 | #include <qdirectpainter_qws.h> | 43 | #include <qdirectpainter_qws.h> |
44 | 44 | ||
45 | #include "xinevideowidget.h" | 45 | #include "xinevideowidget.h" |
46 | #include "frame.h" | 46 | #include "frame.h" |
47 | #include "lib.h" | 47 | #include "lib.h" |
48 | 48 | ||
49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
50 | int width, int height,int bytes ); | 50 | int width, int height,int bytes ); |
51 | 51 | ||
52 | extern "C" { | 52 | extern "C" { |
53 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); | 53 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); |
54 | int null_is_showing_video( vo_driver_t* self ); | 54 | int null_is_showing_video( vo_driver_t* self ); |
55 | void null_set_show_video( vo_driver_t* self, int show ); | 55 | void null_set_show_video( vo_driver_t* self, int show ); |
56 | int null_is_fullscreen( vo_driver_t* self ); | 56 | int null_is_fullscreen( vo_driver_t* self ); |
57 | void null_set_fullscreen( vo_driver_t* self, int screen ); | 57 | void null_set_fullscreen( vo_driver_t* self, int screen ); |
58 | int null_is_scaling( vo_driver_t* self ); | 58 | int null_is_scaling( vo_driver_t* self ); |
59 | void null_set_scaling( vo_driver_t* self, int scale ); | 59 | void null_set_scaling( vo_driver_t* self, int scale ); |
60 | void null_set_gui_width( vo_driver_t* self, int width ); | 60 | void null_set_gui_width( vo_driver_t* self, int width ); |
61 | void null_set_gui_height( vo_driver_t* self, int height ); | 61 | void null_set_gui_height( vo_driver_t* self, int height ); |
62 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); | 62 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); |
63 | void null_set_videoGamma( vo_driver_t* self , int value ); | ||
63 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); | 64 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); |
64 | } | 65 | } |
65 | 66 | ||
66 | using namespace XINE; | 67 | using namespace XINE; |
67 | 68 | ||
68 | Lib::Lib(XineVideoWidget* widget) { | 69 | Lib::Lib(XineVideoWidget* widget) { |
69 | m_video = false; | 70 | m_video = false; |
70 | m_wid = widget; | 71 | m_wid = widget; |
71 | printf("Lib"); | 72 | printf("Lib"); |
72 | QCString str( getenv("HOME") ); | 73 | QCString str( getenv("HOME") ); |
73 | str += "/Settings/opiexine.cf"; | 74 | str += "/Settings/opiexine.cf"; |
74 | // get the configuration | 75 | // get the configuration |
75 | 76 | ||
76 | // not really OO, should be an extra class, later | 77 | // not really OO, should be an extra class, later |
77 | if ( !QFile(str).exists() ) { | 78 | if ( !QFile(str).exists() ) { |
78 | QFile f(str); | 79 | QFile f(str); |
79 | f.open(IO_WriteOnly); | 80 | f.open(IO_WriteOnly); |
80 | QTextStream ts( &f ); | 81 | QTextStream ts( &f ); |
81 | ts << "misc.memcpy_method:glibc\n"; | 82 | ts << "misc.memcpy_method:glibc\n"; |
82 | f.close(); | 83 | f.close(); |
83 | } | 84 | } |
84 | 85 | ||
85 | m_config = xine_config_file_init( str.data() ); | 86 | m_config = xine_config_file_init( str.data() ); |
86 | 87 | ||
87 | // allocate oss for sound | 88 | // allocate oss for sound |
88 | // and fb for framebuffer | 89 | // and fb for framebuffer |
89 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; | 90 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; |
90 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); | 91 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); |
91 | if (m_wid != 0 ) { | 92 | if (m_wid != 0 ) { |
92 | printf("!0\n" ); | 93 | printf("!0\n" ); |
93 | resize ( m_wid-> size ( )); | 94 | resize ( m_wid-> size ( )); |
94 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 95 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
95 | m_wid-> setImage ( new QImage ( Resource::loadImage(""))); | 96 | m_wid-> setImage ( new QImage ( Resource::loadImage("") ) ); |
96 | m_wid->repaint(); | 97 | m_wid->repaint(); |
97 | } | 98 | } |
98 | null_display_handler( m_videoOutput, | 99 | null_display_handler( m_videoOutput, |
99 | xine_display_frame, | 100 | xine_display_frame, |
100 | this ); | 101 | this ); |
101 | 102 | ||
102 | m_xine = xine_init( m_videoOutput, | 103 | m_xine = xine_init( m_videoOutput, |
103 | m_audioOutput, m_config ); | 104 | m_audioOutput, m_config ); |
104 | // install the event handler | 105 | // install the event handler |
105 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 106 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
106 | } | 107 | } |
107 | 108 | ||
108 | Lib::~Lib() { | 109 | Lib::~Lib() { |
109 | free( m_config ); | 110 | free( m_config ); |
110 | xine_remove_event_listener( m_xine, xine_event_handler ); | 111 | xine_remove_event_listener( m_xine, xine_event_handler ); |
111 | xine_exit( m_xine ); | 112 | xine_exit( m_xine ); |
112 | /* FIXME either free or delete but valgrind bitches against both */ | 113 | /* FIXME either free or delete but valgrind bitches against both */ |
113 | //free( m_videoOutput ); | 114 | //free( m_videoOutput ); |
114 | //delete m_audioOutput; | 115 | //delete m_audioOutput; |
115 | 116 | ||
116 | } | 117 | } |
117 | 118 | ||
118 | void Lib::resize ( const QSize &s ) | 119 | void Lib::resize ( const QSize &s ) |
119 | { | 120 | { |
120 | if ( s. width ( ) && s. height ( )) { | 121 | if ( s. width ( ) && s. height ( )) { |
121 | ::null_set_gui_width( m_videoOutput, s. width() ); | 122 | ::null_set_gui_width( m_videoOutput, s. width() ); |
122 | ::null_set_gui_height(m_videoOutput, s. height() ); | 123 | ::null_set_gui_height(m_videoOutput, s. height() ); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | QCString Lib::version() { | 127 | QCString Lib::version() { |
127 | QCString str( xine_get_str_version() ); | 128 | QCString str( xine_get_str_version() ); |
128 | return str; | 129 | return str; |
129 | }; | 130 | }; |
130 | 131 | ||
131 | int Lib::majorVersion() { | 132 | int Lib::majorVersion() { |
132 | return xine_get_major_version(); | 133 | return xine_get_major_version(); |
133 | } | 134 | } |
134 | int Lib::minorVersion() { | 135 | int Lib::minorVersion() { |
135 | return xine_get_minor_version(); | 136 | return xine_get_minor_version(); |
136 | }; | 137 | }; |
137 | 138 | ||
138 | int Lib::subVersion() { | 139 | int Lib::subVersion() { |
139 | return xine_get_sub_version(); | 140 | return xine_get_sub_version(); |
140 | } | 141 | } |
141 | int Lib::play( const QString& fileName, | 142 | int Lib::play( const QString& fileName, |
142 | int startPos, | 143 | int startPos, |
143 | int start_time ) { | 144 | int start_time ) { |
144 | QString str = fileName.stripWhiteSpace(); | 145 | QString str = fileName.stripWhiteSpace(); |
145 | //workaround OpiePlayer bug | 146 | //workaround OpiePlayer bug |
146 | //f (str.right(1) == QString::fromLatin1("/") ) | 147 | //f (str.right(1) == QString::fromLatin1("/") ) |
147 | // str = str.mid( str.length() -1 ); | 148 | // str = str.mid( str.length() -1 ); |
148 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), | 149 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), |
149 | startPos, start_time); | 150 | startPos, start_time); |
150 | } | 151 | } |
151 | void Lib::stop() { | 152 | void Lib::stop() { |
152 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 153 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
153 | xine_stop(m_xine ); | 154 | xine_stop(m_xine ); |
154 | } | 155 | } |
155 | void Lib::pause(){ | 156 | void Lib::pause(){ |
156 | xine_set_speed( m_xine, SPEED_PAUSE ); | 157 | xine_set_speed( m_xine, SPEED_PAUSE ); |
157 | } | 158 | } |
158 | int Lib::speed() { | 159 | int Lib::speed() { |
159 | return xine_get_speed( m_xine ); | 160 | return xine_get_speed( m_xine ); |
160 | } | 161 | } |
161 | void Lib::setSpeed( int speed ) { | 162 | void Lib::setSpeed( int speed ) { |
162 | xine_set_speed( m_xine, speed ); | 163 | xine_set_speed( m_xine, speed ); |
163 | } | 164 | } |
164 | int Lib::status(){ | 165 | int Lib::status(){ |
165 | return xine_get_status( m_xine ); | 166 | return xine_get_status( m_xine ); |
166 | } | 167 | } |
167 | int Lib::currentPosition(){ | 168 | int Lib::currentPosition(){ |
168 | return xine_get_current_position( m_xine ); | 169 | return xine_get_current_position( m_xine ); |
169 | } | 170 | } |
170 | int Lib::currentTime() { | 171 | int Lib::currentTime() { |
171 | return xine_get_current_time( m_xine ); | 172 | return xine_get_current_time( m_xine ); |
172 | }; | 173 | }; |
173 | int Lib::length() { | 174 | int Lib::length() { |
174 | return xine_get_stream_length( m_xine ); | 175 | return xine_get_stream_length( m_xine ); |
175 | } | 176 | } |
176 | bool Lib::isSeekable() { | 177 | bool Lib::isSeekable() { |
177 | return xine_is_stream_seekable(m_xine); | 178 | return xine_is_stream_seekable(m_xine); |
178 | } | 179 | } |
179 | Frame Lib::currentFrame() { | 180 | Frame Lib::currentFrame() { |
180 | Frame frame; | 181 | Frame frame; |
181 | return frame; | 182 | return frame; |
182 | }; | 183 | }; |
183 | int Lib::error() { | 184 | int Lib::error() { |
184 | return xine_get_error( m_xine ); | 185 | return xine_get_error( m_xine ); |
185 | }; | 186 | }; |
186 | void Lib::handleXineEvent( xine_event_t* t ) { | 187 | void Lib::handleXineEvent( xine_event_t* t ) { |
187 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) | 188 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) |
188 | emit stopped(); | 189 | emit stopped(); |
189 | } | 190 | } |
190 | void Lib::setShowVideo( bool video ) { | 191 | void Lib::setShowVideo( bool video ) { |
191 | m_video = video; | 192 | m_video = video; |
192 | ::null_set_show_video( m_videoOutput, video ); | 193 | ::null_set_show_video( m_videoOutput, video ); |
193 | } | 194 | } |
194 | bool Lib::isShowingVideo() { | 195 | bool Lib::isShowingVideo() { |
195 | return ::null_is_showing_video( m_videoOutput ); | 196 | return ::null_is_showing_video( m_videoOutput ); |
196 | } | 197 | } |
197 | void Lib::showVideoFullScreen( bool fullScreen ) { | 198 | void Lib::showVideoFullScreen( bool fullScreen ) { |
198 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 199 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
199 | } | 200 | } |
200 | bool Lib::isVideoFullScreen() { | 201 | bool Lib::isVideoFullScreen() { |
201 | return ::null_is_fullscreen( m_videoOutput ); | 202 | return ::null_is_fullscreen( m_videoOutput ); |
202 | } | 203 | } |
203 | void Lib::setScaling( bool scale ) { | 204 | void Lib::setScaling( bool scale ) { |
204 | ::null_set_scaling( m_videoOutput, scale ); | 205 | ::null_set_scaling( m_videoOutput, scale ); |
205 | } | 206 | } |
207 | |||
208 | void Lib::setGamma( int value ) { | ||
209 | //qDebug( QString( "%1").arg(value) ); | ||
210 | ::null_set_videoGamma( m_videoOutput, value ); | ||
211 | } | ||
212 | |||
206 | bool Lib::isScaling() { | 213 | bool Lib::isScaling() { |
207 | return ::null_is_scaling( m_videoOutput ); | 214 | return ::null_is_scaling( m_videoOutput ); |
208 | } | 215 | } |
209 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 216 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
210 | ((Lib*)user_data)->handleXineEvent( t ); | 217 | ((Lib*)user_data)->handleXineEvent( t ); |
211 | } | 218 | } |
212 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 219 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
213 | int width, int height, int bytes ) { | 220 | int width, int height, int bytes ) { |
214 | 221 | ||
215 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 222 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
216 | } | 223 | } |
217 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 224 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
218 | if (!m_video ) { | 225 | if (!m_video ) { |
219 | qWarning("not showing video now"); | 226 | qWarning("not showing video now"); |
220 | return; | 227 | return; |
221 | } | 228 | } |
222 | // qWarning("called draw frame %d %d", width, height); | 229 | // qWarning("called draw frame %d %d", width, height); |
223 | 230 | ||
224 | m_wid->setImage( frame, width, height, bytes ); | 231 | m_wid->setImage( frame, width, height, bytes ); |
225 | // m_wid->repaint(false); | 232 | // m_wid->repaint(false); |
226 | 233 | ||
227 | } | 234 | } |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef ZECKEXINELIB_H | 34 | #ifndef ZECKEXINELIB_H |
35 | #define ZECKEXINELIB_H | 35 | #define ZECKEXINELIB_H |
36 | 36 | ||
37 | #include <qcstring.h> | 37 | #include <qcstring.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <xine.h> | 41 | #include <xine.h> |
42 | 42 | ||
43 | class XineVideoWidget; | 43 | class XineVideoWidget; |
44 | 44 | ||
45 | namespace XINE { | 45 | namespace XINE { |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Lib wrapps the simple interface | 48 | * Lib wrapps the simple interface |
49 | * of libxine for easy every day use | 49 | * of libxine for easy every day use |
50 | * This will become a full C++ Wrapper | 50 | * This will become a full C++ Wrapper |
51 | * It supports playing, pausing, info, | 51 | * It supports playing, pausing, info, |
52 | * stooping, seeking. | 52 | * stooping, seeking. |
53 | */ | 53 | */ |
54 | class Frame; | 54 | class Frame; |
55 | class Lib : public QObject { | 55 | class Lib : public QObject { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | Lib(XineVideoWidget* = 0); | 58 | Lib(XineVideoWidget* = 0); |
59 | ~Lib(); | 59 | ~Lib(); |
60 | QCString version(); | 60 | QCString version(); |
61 | int majorVersion()/*const*/; | 61 | int majorVersion()/*const*/; |
62 | int minorVersion()/*const*/; | 62 | int minorVersion()/*const*/; |
63 | int subVersion()/*const*/; | 63 | int subVersion()/*const*/; |
64 | 64 | ||
65 | 65 | ||
66 | void resize ( const QSize &s ); | 66 | void resize ( const QSize &s ); |
67 | 67 | ||
68 | int play( const QString& fileName, | 68 | int play( const QString& fileName, |
69 | int startPos = 0, | 69 | int startPos = 0, |
70 | int start_time = 0 ); | 70 | int start_time = 0 ); |
71 | void stop() /*const*/; | 71 | void stop() /*const*/; |
72 | void pause()/*const*/; | 72 | void pause()/*const*/; |
73 | 73 | ||
74 | int speed() /*const*/; | 74 | int speed() /*const*/; |
75 | void setSpeed( int speed = SPEED_PAUSE ); | 75 | void setSpeed( int speed = SPEED_PAUSE ); |
76 | 76 | ||
77 | int status() /*const*/; | 77 | int status() /*const*/; |
78 | 78 | ||
79 | int currentPosition()/*const*/; | 79 | int currentPosition()/*const*/; |
80 | //in seconds | 80 | //in seconds |
81 | int currentTime()/*const*/; | 81 | int currentTime()/*const*/; |
82 | int length() /*const*/; | 82 | int length() /*const*/; |
83 | 83 | ||
84 | bool isSeekable()/*const*/; | 84 | bool isSeekable()/*const*/; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Whether or not to show video output | 87 | * Whether or not to show video output |
88 | */ | 88 | */ |
89 | void setShowVideo(bool video); | 89 | void setShowVideo(bool video); |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * is we show video | 92 | * is we show video |
93 | */ | 93 | */ |
94 | bool isShowingVideo() /*const*/; | 94 | bool isShowingVideo() /*const*/; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * | 97 | * |
98 | */ | 98 | */ |
99 | void showVideoFullScreen( bool fullScreen ); | 99 | void showVideoFullScreen( bool fullScreen ); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * | 102 | * |
103 | */ | 103 | */ |
104 | bool isVideoFullScreen()/*const*/ ; | 104 | bool isVideoFullScreen()/*const*/ ; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * | 107 | * |
108 | */ | 108 | */ |
109 | bool isScaling(); | 109 | bool isScaling(); |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * | 112 | * |
113 | */ | 113 | */ |
114 | void setScaling( bool ); | 114 | void setScaling( bool ); |
115 | |||
116 | /** | ||
117 | * Set the Gamma value for video output | ||
118 | * @param int the value between -100 and 100, 0 is original | ||
119 | */ | ||
120 | void setGamma( int ); | ||
121 | |||
115 | /** | 122 | /** |
116 | * test | 123 | * test |
117 | */ | 124 | */ |
118 | Frame currentFrame()/*const*/; | 125 | Frame currentFrame()/*const*/; |
119 | 126 | ||
120 | /** | 127 | /** |
121 | * Returns the error code | 128 | * Returns the error code |
122 | */ | 129 | */ |
123 | int error() /*const*/; | 130 | int error() /*const*/; |
124 | 131 | ||
125 | signals: | 132 | signals: |
126 | void stopped(); | 133 | void stopped(); |
127 | private: | 134 | private: |
128 | int m_bytes_per_pixel; | 135 | int m_bytes_per_pixel; |
129 | bool m_video:1; | 136 | bool m_video:1; |
130 | XineVideoWidget *m_wid; | 137 | XineVideoWidget *m_wid; |
131 | xine_t *m_xine; | 138 | xine_t *m_xine; |
132 | config_values_t *m_config; | 139 | config_values_t *m_config; |
133 | vo_driver_t *m_videoOutput; | 140 | vo_driver_t *m_videoOutput; |
134 | ao_driver_t* m_audioOutput; | 141 | ao_driver_t* m_audioOutput; |
135 | 142 | ||
136 | void handleXineEvent( xine_event_t* t ); | 143 | void handleXineEvent( xine_event_t* t ); |
137 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 144 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
138 | // C -> C++ bridge for the event system | 145 | // C -> C++ bridge for the event system |
139 | static void xine_event_handler( void* user_data, xine_event_t* t); | 146 | static void xine_event_handler( void* user_data, xine_event_t* t); |
140 | static void xine_display_frame( void* user_data, uint8_t* frame , | 147 | static void xine_display_frame( void* user_data, uint8_t* frame , |
141 | int width, int height, int bytes ); | 148 | int width, int height, int bytes ); |
142 | }; | 149 | }; |
143 | }; | 150 | }; |
144 | 151 | ||
145 | 152 | ||
146 | #endif | 153 | #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 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | // this file is based on work by trolltech | ||
35 | |||
1 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 37 | #include <qpe/qlibrary.h> |
3 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
4 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
5 | #include <qobject.h> | 40 | #include <qobject.h> |
6 | #include <qdir.h> | 41 | #include <qdir.h> |
7 | #include "mediaplayerstate.h" | 42 | #include "mediaplayerstate.h" |
8 | 43 | ||
9 | 44 | ||
10 | 45 | ||
11 | //#define MediaPlayerDebug(x) qDebug x | 46 | //#define MediaPlayerDebug(x) qDebug x |
12 | #define MediaPlayerDebug(x) | 47 | #define MediaPlayerDebug(x) |
13 | 48 | ||
14 | 49 | ||
15 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
16 | : QObject( parent, name ) { | 51 | : QObject( parent, name ) { |
17 | Config cfg( "OpiePlayer" ); | 52 | Config cfg( "OpiePlayer" ); |
18 | readConfig( cfg ); | 53 | readConfig( cfg ); |
19 | isStreaming = false; | 54 | isStreaming = false; |
20 | } | 55 | } |
21 | 56 | ||
22 | 57 | ||
23 | MediaPlayerState::~MediaPlayerState() { | 58 | MediaPlayerState::~MediaPlayerState() { |
24 | // Config cfg( "OpiePlayer" ); | ||
25 | // writeConfig( cfg ); | ||
26 | |||
27 | } | 59 | } |
28 | 60 | ||
29 | 61 | ||
30 | void MediaPlayerState::readConfig( Config& cfg ) { | 62 | void MediaPlayerState::readConfig( Config& cfg ) { |
31 | cfg.setGroup("Options"); | 63 | cfg.setGroup("Options"); |
32 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); | 64 | isFullscreen = cfg.readBoolEntry( "FullScreen" ); |
33 | isScaled = cfg.readBoolEntry( "Scaling" ); | 65 | isScaled = cfg.readBoolEntry( "Scaling" ); |
34 | isLooping = cfg.readBoolEntry( "Looping" ); | 66 | isLooping = cfg.readBoolEntry( "Looping" ); |
35 | isShuffled = cfg.readBoolEntry( "Shuffle" ); | 67 | isShuffled = cfg.readBoolEntry( "Shuffle" ); |
36 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); | 68 | usePlaylist = cfg.readBoolEntry( "UsePlayList" ); |
69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | ||
37 | usePlaylist = TRUE; | 70 | usePlaylist = TRUE; |
38 | isPlaying = FALSE; | 71 | isPlaying = FALSE; |
39 | isStreaming = FALSE; | 72 | isStreaming = FALSE; |
40 | isPaused = FALSE; | 73 | isPaused = FALSE; |
41 | curPosition = 0; | 74 | curPosition = 0; |
42 | curLength = 0; | 75 | curLength = 0; |
43 | curView = 'l'; | 76 | curView = 'l'; |
44 | } | 77 | } |
45 | 78 | ||
46 | 79 | ||
47 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 80 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
48 | cfg.setGroup("Options"); | 81 | cfg.setGroup( "Options" ); |
49 | cfg.writeEntry("FullScreen", isFullscreen ); | 82 | cfg.writeEntry( "FullScreen", isFullscreen ); |
50 | cfg.writeEntry("Scaling", isScaled ); | 83 | cfg.writeEntry( "Scaling", isScaled ); |
51 | cfg.writeEntry("Looping", isLooping ); | 84 | cfg.writeEntry( "Looping", isLooping ); |
52 | cfg.writeEntry("Shuffle", isShuffled ); | 85 | cfg.writeEntry( "Shuffle", isShuffled ); |
53 | cfg.writeEntry("UsePlayList", usePlaylist ); | 86 | cfg.writeEntry( "UsePlayList", usePlaylist ); |
87 | cfg.writeEntry( "VideoGamma", videoGamma ); | ||
54 | } | 88 | } |
55 | 89 | ||
56 | 90 | ||
57 | // public stuff | 91 | // public stuff |
58 | 92 | ||
59 | 93 | ||
60 | bool MediaPlayerState::streaming() { | 94 | bool MediaPlayerState::streaming() { |
61 | return isStreaming; | 95 | return isStreaming; |
62 | } | 96 | } |
63 | 97 | ||
64 | bool MediaPlayerState::fullscreen() { | 98 | bool MediaPlayerState::fullscreen() { |
65 | return isFullscreen; | 99 | return isFullscreen; |
66 | } | 100 | } |
67 | 101 | ||
68 | bool MediaPlayerState::scaled() { | 102 | bool MediaPlayerState::scaled() { |
69 | return isScaled; | 103 | return isScaled; |
70 | } | 104 | } |
71 | 105 | ||
72 | bool MediaPlayerState::looping() { | 106 | bool MediaPlayerState::looping() { |
73 | return isLooping; | 107 | return isLooping; |
74 | } | 108 | } |
75 | 109 | ||
76 | bool MediaPlayerState::shuffled() { | 110 | bool MediaPlayerState::shuffled() { |
77 | return isShuffled; | 111 | return isShuffled; |
78 | } | 112 | } |
79 | 113 | ||
80 | 114 | ||
81 | bool MediaPlayerState:: playlist() { | 115 | bool MediaPlayerState:: playlist() { |
82 | return usePlaylist; | 116 | return usePlaylist; |
83 | } | 117 | } |
84 | 118 | ||
85 | bool MediaPlayerState::paused() { | 119 | bool MediaPlayerState::paused() { |
86 | return isPaused; | 120 | return isPaused; |
87 | } | 121 | } |
88 | 122 | ||
89 | bool MediaPlayerState::playing() { | 123 | bool MediaPlayerState::playing() { |
90 | return isPlaying; | 124 | return isPlaying; |
91 | } | 125 | } |
92 | 126 | ||
93 | bool MediaPlayerState::stop() { | 127 | bool MediaPlayerState::stop() { |
94 | return isStoped; | 128 | return isStoped; |
95 | } | 129 | } |
96 | 130 | ||
97 | long MediaPlayerState::position() { | 131 | long MediaPlayerState::position() { |
98 | return curPosition; | 132 | return curPosition; |
99 | } | 133 | } |
100 | 134 | ||
101 | long MediaPlayerState::length() { | 135 | long MediaPlayerState::length() { |
102 | return curLength; | 136 | return curLength; |
103 | } | 137 | } |
104 | 138 | ||
105 | char MediaPlayerState::view() { | 139 | char MediaPlayerState::view() { |
106 | return curView; | 140 | return curView; |
107 | } | 141 | } |
108 | 142 | ||
109 | // slots | 143 | // slots |
110 | void MediaPlayerState::setIsStreaming( bool b ) { | 144 | void MediaPlayerState::setIsStreaming( bool b ) { |
111 | 145 | ||
112 | if ( isStreaming == b ) { | 146 | if ( isStreaming == b ) { |
113 | return; | 147 | return; |
114 | } | 148 | } |
115 | isStreaming = b; | 149 | isStreaming = b; |
116 | } | 150 | } |
117 | 151 | ||
118 | 152 | ||
119 | void MediaPlayerState::setFullscreen( bool b ) { | 153 | void MediaPlayerState::setFullscreen( bool b ) { |
120 | if ( isFullscreen == b ) { | 154 | if ( isFullscreen == b ) { |
121 | return; | 155 | return; |
122 | } | 156 | } |
123 | isFullscreen = b; | 157 | isFullscreen = b; |
124 | emit fullscreenToggled(b); | 158 | emit fullscreenToggled(b); |
125 | } | 159 | } |
126 | 160 | ||
127 | 161 | ||
128 | void MediaPlayerState::setBlanked( bool b ) { | 162 | void MediaPlayerState::setBlanked( bool b ) { |
129 | if ( isBlanked == b ) { | 163 | if ( isBlanked == b ) { |
130 | return; | 164 | return; |
131 | } | 165 | } |
132 | isBlanked = b; | 166 | isBlanked = b; |
133 | emit blankToggled(b); | 167 | emit blankToggled(b); |
134 | } | 168 | } |
135 | 169 | ||
136 | 170 | ||
137 | void MediaPlayerState::setScaled( bool b ) { | 171 | void MediaPlayerState::setScaled( bool b ) { |
138 | if ( isScaled == b ) { | 172 | if ( isScaled == b ) { |
139 | return; | 173 | return; |
140 | } | 174 | } |
141 | isScaled = b; | 175 | isScaled = b; |
142 | emit scaledToggled(b); | 176 | emit scaledToggled(b); |
143 | } | 177 | } |
144 | 178 | ||
145 | void MediaPlayerState::setLooping( bool b ) { | 179 | void MediaPlayerState::setLooping( bool b ) { |
146 | if ( isLooping == b ) { | 180 | if ( isLooping == b ) { |
147 | return; | 181 | return; |
148 | } | 182 | } |
149 | isLooping = b; | 183 | isLooping = b; |
150 | emit loopingToggled(b); | 184 | emit loopingToggled(b); |
151 | } | 185 | } |
152 | 186 | ||
153 | void MediaPlayerState::setShuffled( bool b ) { | 187 | void MediaPlayerState::setShuffled( bool b ) { |
154 | if ( isShuffled == b ) { | 188 | if ( isShuffled == b ) { |
155 | return; | 189 | return; |
156 | } | 190 | } |
157 | isShuffled = b; | 191 | isShuffled = b; |
158 | emit shuffledToggled(b); | 192 | emit shuffledToggled(b); |
159 | } | 193 | } |
160 | 194 | ||
161 | void MediaPlayerState::setPlaylist( bool b ) { | 195 | void MediaPlayerState::setPlaylist( bool b ) { |
162 | if ( usePlaylist == b ) { | 196 | if ( usePlaylist == b ) { |
163 | return; | 197 | return; |
164 | } | 198 | } |
165 | usePlaylist = b; | 199 | usePlaylist = b; |
166 | emit playlistToggled(b); | 200 | emit playlistToggled(b); |
167 | } | 201 | } |
168 | 202 | ||
169 | void MediaPlayerState::setPaused( bool b ) { | 203 | void MediaPlayerState::setPaused( bool b ) { |
170 | if ( isPaused == b ) { | 204 | if ( isPaused == b ) { |
171 | isPaused = FALSE; | 205 | isPaused = FALSE; |
172 | emit pausedToggled(FALSE); | 206 | emit pausedToggled(FALSE); |
173 | return; | 207 | return; |
174 | } | 208 | } |
175 | isPaused = b; | 209 | isPaused = b; |
176 | emit pausedToggled(b); | 210 | emit pausedToggled(b); |
177 | } | 211 | } |
178 | 212 | ||
179 | void MediaPlayerState::setPlaying( bool b ) { | 213 | void MediaPlayerState::setPlaying( bool b ) { |
180 | if ( isPlaying == b ) { | 214 | if ( isPlaying == b ) { |
181 | return; | 215 | return; |
182 | } | 216 | } |
183 | isPlaying = b; | 217 | isPlaying = b; |
184 | isStoped = !b; | 218 | isStoped = !b; |
185 | emit playingToggled(b); | 219 | emit playingToggled(b); |
186 | } | 220 | } |
187 | 221 | ||
188 | void MediaPlayerState::setStop( bool b ) { | 222 | void MediaPlayerState::setStop( bool b ) { |
189 | if ( isStoped == b ) { | 223 | if ( isStoped == b ) { |
190 | return; | 224 | return; |
191 | } | 225 | } |
192 | isStoped = b; | 226 | isStoped = b; |
193 | emit stopToggled(b); | 227 | emit stopToggled(b); |
194 | } | 228 | } |
195 | 229 | ||
196 | void MediaPlayerState::setPosition( long p ) { | 230 | void MediaPlayerState::setPosition( long p ) { |
197 | if ( curPosition == p ) { | 231 | if ( curPosition == p ) { |
198 | return; | 232 | return; |
199 | } | 233 | } |
200 | curPosition = p; | 234 | curPosition = p; |
201 | emit positionChanged(p); | 235 | emit positionChanged(p); |
202 | } | 236 | } |
203 | 237 | ||
204 | void MediaPlayerState::updatePosition( long p ){ | 238 | void MediaPlayerState::updatePosition( long p ){ |
205 | if ( curPosition == p ) { | 239 | if ( curPosition == p ) { |
206 | return; | 240 | return; |
207 | } | 241 | } |
208 | curPosition = p; | 242 | curPosition = p; |
209 | emit positionUpdated(p); | 243 | emit positionUpdated(p); |
210 | } | 244 | } |
211 | 245 | ||
246 | void MediaPlayerState::setVideoGamma( int v ){ | ||
247 | if ( videoGamma == v ) { | ||
248 | return; | ||
249 | } | ||
250 | videoGamma = v; | ||
251 | emit videoGammaChanged( v ); | ||
252 | } | ||
253 | |||
212 | void MediaPlayerState::setLength( long l ) { | 254 | void MediaPlayerState::setLength( long l ) { |
213 | if ( curLength == l ) { | 255 | if ( curLength == l ) { |
214 | return; | 256 | return; |
215 | } | 257 | } |
216 | curLength = l; | 258 | curLength = l; |
217 | emit lengthChanged(l); | 259 | emit lengthChanged(l); |
218 | } | 260 | } |
219 | 261 | ||
220 | void MediaPlayerState::setView( char v ) { | 262 | void MediaPlayerState::setView( char v ) { |
221 | if ( curView == v ) { | 263 | if ( curView == v ) { |
222 | return; | 264 | return; |
223 | } | 265 | } |
224 | curView = v; | 266 | curView = v; |
225 | emit viewChanged(v); | 267 | emit viewChanged(v); |
226 | } | 268 | } |
227 | 269 | ||
228 | void MediaPlayerState::setPrev(){ | 270 | void MediaPlayerState::setPrev(){ |
229 | emit prev(); | 271 | emit prev(); |
230 | } | 272 | } |
231 | 273 | ||
232 | void MediaPlayerState::setNext() { | 274 | void MediaPlayerState::setNext() { |
233 | emit next(); | 275 | emit next(); |
234 | } | 276 | } |
235 | 277 | ||
236 | void MediaPlayerState::setList() { | 278 | void MediaPlayerState::setList() { |
237 | setPlaying( FALSE ); | 279 | setPlaying( FALSE ); |
238 | setView('l'); | 280 | setView('l'); |
239 | } | 281 | } |
240 | 282 | ||
241 | void MediaPlayerState::setVideo() { | 283 | void MediaPlayerState::setVideo() { |
242 | setView('v'); | 284 | setView('v'); |
243 | } | 285 | } |
244 | 286 | ||
245 | void MediaPlayerState::setAudio() { | 287 | void MediaPlayerState::setAudio() { |
246 | setView('a'); | 288 | setView('a'); |
247 | } | 289 | } |
248 | 290 | ||
249 | void MediaPlayerState::toggleFullscreen() { | 291 | void MediaPlayerState::toggleFullscreen() { |
250 | setFullscreen( !isFullscreen ); | 292 | setFullscreen( !isFullscreen ); |
251 | } | 293 | } |
252 | 294 | ||
253 | void MediaPlayerState::toggleScaled() { | 295 | void MediaPlayerState::toggleScaled() { |
254 | setScaled( !isScaled); | 296 | setScaled( !isScaled); |
255 | } | 297 | } |
256 | 298 | ||
257 | void MediaPlayerState::toggleLooping() { | 299 | void MediaPlayerState::toggleLooping() { |
258 | setLooping( !isLooping); | 300 | setLooping( !isLooping); |
259 | } | 301 | } |
260 | 302 | ||
261 | void MediaPlayerState::toggleShuffled() { | 303 | void MediaPlayerState::toggleShuffled() { |
262 | setShuffled( !isShuffled); | 304 | setShuffled( !isShuffled); |
263 | } | 305 | } |
264 | 306 | ||
265 | void MediaPlayerState::togglePlaylist() { | 307 | void MediaPlayerState::togglePlaylist() { |
266 | setPlaylist( !usePlaylist); | 308 | setPlaylist( !usePlaylist); |
267 | } | 309 | } |
268 | 310 | ||
269 | void MediaPlayerState::togglePaused() { | 311 | void MediaPlayerState::togglePaused() { |
270 | setPaused( !isPaused); | 312 | setPaused( !isPaused); |
271 | } | 313 | } |
272 | 314 | ||
273 | void MediaPlayerState::togglePlaying() { | 315 | void MediaPlayerState::togglePlaying() { |
274 | setPlaying( !isPlaying); | 316 | setPlaying( !isPlaying); |
275 | } | 317 | } |
276 | 318 | ||
277 | void MediaPlayerState::toggleBlank() { | 319 | void MediaPlayerState::toggleBlank() { |
278 | setBlanked( !isBlanked); | 320 | setBlanked( !isBlanked); |
279 | } | 321 | } |
280 | 322 | ||
281 | 323 | ||
282 | 324 | ||
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | // this file is based on work by trolltech | ||
35 | |||
34 | #ifndef MEDIA_PLAYER_STATE_H | 36 | #ifndef MEDIA_PLAYER_STATE_H |
35 | #define MEDIA_PLAYER_STATE_H | 37 | #define MEDIA_PLAYER_STATE_H |
36 | 38 | ||
37 | 39 | ||
38 | #include <qobject.h> | 40 | #include <qobject.h> |
39 | 41 | ||
40 | 42 | ||
41 | class MediaPlayerDecoder; | 43 | class MediaPlayerDecoder; |
42 | class Config; | 44 | class Config; |
43 | 45 | ||
44 | 46 | ||
45 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
46 | Q_OBJECT | 48 | Q_OBJECT |
47 | public: | 49 | public: |
48 | MediaPlayerState( QObject *parent, const char *name ); | 50 | MediaPlayerState( QObject *parent, const char *name ); |
49 | ~MediaPlayerState(); | 51 | ~MediaPlayerState(); |
50 | 52 | ||
51 | bool isPaused; | 53 | bool isPaused; |
52 | bool isPlaying; | 54 | bool isPlaying; |
53 | bool isStoped; | 55 | bool isStoped; |
54 | bool streaming(); | 56 | bool streaming(); |
55 | bool fullscreen(); | 57 | bool fullscreen(); |
56 | bool scaled(); | 58 | bool scaled(); |
57 | bool looping(); | 59 | bool looping(); |
58 | bool shuffled(); | 60 | bool shuffled(); |
59 | bool playlist(); | 61 | bool playlist(); |
60 | bool paused(); | 62 | bool paused(); |
61 | bool playing(); | 63 | bool playing(); |
62 | bool stop(); | 64 | bool stop(); |
63 | long position(); | 65 | long position(); |
64 | long length(); | 66 | long length(); |
65 | char view(); | 67 | char view(); |
66 | 68 | ||
67 | public slots: | 69 | public slots: |
68 | void setIsStreaming( bool b ); | 70 | void setIsStreaming( bool b ); |
69 | void setFullscreen( bool b ); | 71 | void setFullscreen( bool b ); |
70 | void setScaled( bool b ); | 72 | void setScaled( bool b ); |
71 | void setLooping( bool b ); | 73 | void setLooping( bool b ); |
72 | void setShuffled( bool b ); | 74 | void setShuffled( bool b ); |
73 | void setPlaylist( bool b ); | 75 | void setPlaylist( bool b ); |
74 | void setPaused( bool b ); | 76 | void setPaused( bool b ); |
75 | void setPlaying( bool b ); | 77 | void setPlaying( bool b ); |
76 | void setStop( bool b ); | 78 | void setStop( bool b ); |
77 | void setPosition( long p ); | 79 | void setPosition( long p ); |
78 | void updatePosition( long p ); | 80 | void updatePosition( long p ); |
79 | void setLength( long l ); | 81 | void setLength( long l ); |
80 | void setView( char v ); | 82 | void setView( char v ); |
81 | void setBlanked( bool b ); | 83 | void setBlanked( bool b ); |
84 | void setVideoGamma( int v ); | ||
82 | 85 | ||
83 | void setPrev(); | 86 | void setPrev(); |
84 | void setNext(); | 87 | void setNext(); |
85 | void setList(); | 88 | void setList(); |
86 | void setVideo(); | 89 | void setVideo(); |
87 | void setAudio(); | 90 | void setAudio(); |
88 | 91 | ||
89 | void toggleFullscreen(); | 92 | void toggleFullscreen(); |
90 | void toggleScaled(); | 93 | void toggleScaled(); |
91 | void toggleLooping(); | 94 | void toggleLooping(); |
92 | void toggleShuffled(); | 95 | void toggleShuffled(); |
93 | void togglePlaylist(); | 96 | void togglePlaylist(); |
94 | void togglePaused(); | 97 | void togglePaused(); |
95 | void togglePlaying(); | 98 | void togglePlaying(); |
96 | void toggleBlank(); | 99 | void toggleBlank(); |
97 | void writeConfig( Config& cfg ) const; | 100 | void writeConfig( Config& cfg ) const; |
98 | 101 | ||
99 | 102 | ||
100 | signals: | 103 | signals: |
101 | void fullscreenToggled( bool ); | 104 | void fullscreenToggled( bool ); |
102 | void scaledToggled( bool ); | 105 | void scaledToggled( bool ); |
103 | void loopingToggled( bool ); | 106 | void loopingToggled( bool ); |
104 | void shuffledToggled( bool ); | 107 | void shuffledToggled( bool ); |
105 | void playlistToggled( bool ); | 108 | void playlistToggled( bool ); |
106 | void pausedToggled( bool ); | 109 | void pausedToggled( bool ); |
107 | void playingToggled( bool ); | 110 | void playingToggled( bool ); |
108 | void stopToggled( bool ); | 111 | void stopToggled( bool ); |
109 | void positionChanged( long ); // When the slider is moved | 112 | void positionChanged( long ); // When the slider is moved |
110 | void positionUpdated( long ); // When the media file progresses | 113 | void positionUpdated( long ); // When the media file progresses |
111 | void lengthChanged( long ); | 114 | void lengthChanged( long ); |
112 | void viewChanged( char ); | 115 | void viewChanged( char ); |
113 | void blankToggled( bool ); | 116 | void blankToggled( bool ); |
117 | void videoGammaChanged( int ); | ||
114 | void prev(); | 118 | void prev(); |
115 | void next(); | 119 | void next(); |
116 | 120 | ||
117 | private: | 121 | private: |
118 | bool isStreaming; | 122 | bool isStreaming; |
119 | bool isFullscreen; | 123 | bool isFullscreen; |
120 | bool isScaled; | 124 | bool isScaled; |
121 | bool isBlanked; | 125 | bool isBlanked; |
122 | bool isLooping; | 126 | bool isLooping; |
123 | bool isShuffled; | 127 | bool isShuffled; |
124 | bool usePlaylist; | 128 | bool usePlaylist; |
125 | long curPosition; | 129 | long curPosition; |
126 | long curLength; | 130 | long curLength; |
127 | char curView; | 131 | char curView; |
128 | 132 | int videoGamma; | |
129 | void readConfig( Config& cfg ); | 133 | void readConfig( Config& cfg ); |
130 | 134 | ||
131 | }; | 135 | }; |
132 | 136 | ||
133 | 137 | ||
134 | #endif // MEDIA_PLAYER_STATE_H | 138 | #endif // MEDIA_PLAYER_STATE_H |
135 | 139 | ||
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 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
1 | 33 | ||
2 | /*#include <xine.h>*/ | 34 | /*#include <xine.h>*/ |
3 | #include <stdlib.h> | 35 | #include <stdlib.h> |
4 | #include <stdio.h> | 36 | #include <stdio.h> |
5 | 37 | ||
6 | #include <math.h> | 38 | #include <math.h> |
7 | 39 | ||
8 | #include <xine/video_out.h> | 40 | #include <xine/video_out.h> |
9 | #include <xine/xine_internal.h> | 41 | #include <xine/xine_internal.h> |
10 | #include <xine/xineutils.h> | 42 | #include <xine/xineutils.h> |
11 | #include <xine/configfile.h> | 43 | #include <xine/configfile.h> |
12 | 44 | ||
13 | #include <pthread.h> | 45 | #include <pthread.h> |
14 | #include "alphablend.h" | 46 | #include "alphablend.h" |
15 | #include "yuv2rgb.h" | 47 | #include "yuv2rgb.h" |
16 | 48 | ||
17 | #define printf(x,...) | 49 | #define printf(x,...) |
18 | 50 | ||
19 | /* the caller for our event draw handler */ | 51 | /* the caller for our event draw handler */ |
20 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
21 | int width, int height,int bytes ); | 53 | int width, int height,int bytes ); |
22 | 54 | ||
23 | typedef struct null_driver_s null_driver_t; | 55 | typedef struct null_driver_s null_driver_t; |
24 | 56 | ||
25 | struct null_driver_s { | 57 | struct null_driver_s { |
26 | vo_driver_t vo_driver; | 58 | vo_driver_t vo_driver; |
27 | uint32_t m_capabilities; | 59 | uint32_t m_capabilities; |
28 | int m_show_video; | 60 | int m_show_video; |
29 | int m_video_fullscreen; | 61 | int m_video_fullscreen; |
30 | int m_is_scaling; | 62 | int m_is_scaling; |
31 | int depth, bpp, bytes_per_pixel; | 63 | int depth, bpp, bytes_per_pixel; |
32 | int yuv2rgb_mode; | 64 | int yuv2rgb_mode; |
33 | int yuv2rgb_swap; | 65 | int yuv2rgb_swap; |
34 | int zuv2rgb_gamma; | 66 | int yuv2rgb_gamma; |
35 | uint8_t *yuv2rgb_cmap; | 67 | uint8_t *yuv2rgb_cmap; |
36 | yuv2rgb_factory_t *yuv2rgb_factory; | 68 | yuv2rgb_factory_t *yuv2rgb_factory; |
37 | vo_overlay_t *overlay; | 69 | vo_overlay_t *overlay; |
38 | int user_ratio; | 70 | int user_ratio; |
39 | double output_scale_factor; | 71 | double output_scale_factor; |
40 | int last_frame_output_width; | 72 | int last_frame_output_width; |
41 | int last_frame_output_height; | 73 | int last_frame_output_height; |
42 | int gui_width; | 74 | int gui_width; |
43 | int gui_height; | 75 | int gui_height; |
44 | int gui_changed; | 76 | int gui_changed; |
45 | double display_ratio; | 77 | double display_ratio; |
46 | void* caller; | 78 | void* caller; |
47 | display_xine_frame_t frameDis; | 79 | display_xine_frame_t frameDis; |
48 | 80 | ||
49 | 81 | ||
50 | }; | 82 | }; |
51 | typedef struct opie_frame_s opie_frame_t; | 83 | typedef struct opie_frame_s opie_frame_t; |
52 | struct opie_frame_s { | 84 | struct opie_frame_s { |
53 | vo_frame_t frame; | 85 | vo_frame_t frame; |
54 | char* name; | 86 | char* name; |
55 | int version; | 87 | int version; |
56 | int width; | 88 | int width; |
57 | int height; | 89 | int height; |
58 | int ratio_code; | 90 | int ratio_code; |
59 | int format; | 91 | int format; |
60 | int flags; | 92 | int flags; |
61 | int user_ratio; | 93 | int user_ratio; |
62 | 94 | ||
63 | double ratio_factor; | 95 | double ratio_factor; |
64 | int ideal_width; | 96 | int ideal_width; |
65 | int ideal_height; | 97 | int ideal_height; |
66 | int output_width, output_height; | 98 | int output_width, output_height; |
67 | int gui_width, gui_height; | 99 | int gui_width, gui_height; |
68 | uint8_t *chunk[3]; | 100 | uint8_t *chunk[3]; |
69 | 101 | ||
70 | yuv2rgb_t *yuv2rgb; | 102 | yuv2rgb_t *yuv2rgb; |
71 | uint8_t *rgb_dst; | 103 | uint8_t *rgb_dst; |
72 | int yuv_stride; | 104 | int yuv_stride; |
73 | int stripe_height, stripe_inc; | 105 | int stripe_height, stripe_inc; |
74 | 106 | ||
75 | int bytes_per_line; | 107 | int bytes_per_line; |
76 | uint8_t *data; | 108 | uint8_t *data; |
77 | 109 | ||
78 | // int show_video; | 110 | // int show_video; |
79 | null_driver_t *output; | 111 | null_driver_t *output; |
80 | }; | 112 | }; |
81 | 113 | ||
82 | static uint32_t null_get_capabilities(vo_driver_t *self ){ | 114 | static uint32_t null_get_capabilities(vo_driver_t *self ){ |
83 | null_driver_t* this = (null_driver_t*)self; | 115 | null_driver_t* this = (null_driver_t*)self; |
84 | printf("capabilities\n"); | 116 | printf("capabilities\n"); |
85 | return this->m_capabilities; | 117 | return this->m_capabilities; |
86 | } | 118 | } |
87 | 119 | ||
88 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { | 120 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { |
89 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 121 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
90 | printf("frame copy\n"); | 122 | printf("frame copy\n"); |
91 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video | 123 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video |
92 | 124 | ||
93 | if (frame->format == IMGFMT_YV12) { | 125 | if (frame->format == IMGFMT_YV12) { |
94 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 126 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
95 | src[0], src[1], src[2]); | 127 | src[0], src[1], src[2]); |
96 | } else { | 128 | } else { |
97 | 129 | ||
98 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 130 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
99 | src[0]); | 131 | src[0]); |
100 | } | 132 | } |
101 | 133 | ||
102 | frame->rgb_dst += frame->stripe_inc; | 134 | frame->rgb_dst += frame->stripe_inc; |
103 | printf("returning\n"); | 135 | printf("returning\n"); |
104 | } | 136 | } |
105 | 137 | ||
106 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { | 138 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { |
107 | 139 | ||
108 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 140 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
109 | printf("field\n\n"); | 141 | printf("field\n\n"); |
110 | 142 | ||
111 | switch (which_field) { | 143 | switch (which_field) { |
112 | case VO_TOP_FIELD: | 144 | case VO_TOP_FIELD: |
113 | frame->rgb_dst = (uint8_t *)frame->data; | 145 | frame->rgb_dst = (uint8_t *)frame->data; |
114 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 146 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
115 | break; | 147 | break; |
116 | case VO_BOTTOM_FIELD: | 148 | case VO_BOTTOM_FIELD: |
117 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 149 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
118 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 150 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
119 | break; | 151 | break; |
120 | case VO_BOTH_FIELDS: | 152 | case VO_BOTH_FIELDS: |
121 | frame->rgb_dst = (uint8_t *)frame->data; | 153 | frame->rgb_dst = (uint8_t *)frame->data; |
122 | break; | 154 | break; |
123 | } | 155 | } |
124 | } | 156 | } |
125 | 157 | ||
126 | 158 | ||
127 | /* take care of the frame*/ | 159 | /* take care of the frame*/ |
128 | static void null_frame_dispose( vo_frame_t* vo_img){ | 160 | static void null_frame_dispose( vo_frame_t* vo_img){ |
129 | opie_frame_t* frame = (opie_frame_t*)vo_img; | 161 | opie_frame_t* frame = (opie_frame_t*)vo_img; |
130 | printf("frame_dispose\n"); | 162 | printf("frame_dispose\n"); |
131 | if( frame->data ) | 163 | if( frame->data ) |
132 | free( frame->data ); | 164 | free( frame->data ); |
133 | free (frame); | 165 | free (frame); |
134 | } | 166 | } |
135 | 167 | ||
136 | /* end take care of frames*/ | 168 | /* end take care of frames*/ |
137 | 169 | ||
138 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | 170 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ |
139 | null_driver_t* this = (null_driver_t*)self; | 171 | null_driver_t* this = (null_driver_t*)self; |
140 | opie_frame_t* frame; | 172 | opie_frame_t* frame; |
141 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); | 173 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); |
142 | 174 | ||
143 | memset( frame, 0, sizeof( opie_frame_t) ); | 175 | memset( frame, 0, sizeof( opie_frame_t) ); |
144 | pthread_mutex_init (&frame->frame.mutex, NULL); | 176 | pthread_mutex_init (&frame->frame.mutex, NULL); |
145 | 177 | ||
146 | printf("alloc_frame\n"); | 178 | printf("alloc_frame\n"); |
147 | frame->name = "opie\0"; | 179 | frame->name = "opie\0"; |
148 | frame->version = 1; | 180 | frame->version = 1; |
149 | frame->output = this; | 181 | frame->output = this; |
150 | // frame->show_video = this->m_show_video; | 182 | // frame->show_video = this->m_show_video; |
151 | /* initialize the frame*/ | 183 | /* initialize the frame*/ |
152 | frame->frame.driver = self; | 184 | frame->frame.driver = self; |
153 | /*frame.frame.free = null_frame_free;*/ | 185 | /*frame.frame.free = null_frame_free;*/ |
154 | frame->frame.copy = null_frame_copy; | 186 | frame->frame.copy = null_frame_copy; |
155 | frame->frame.field = null_frame_field; | 187 | frame->frame.field = null_frame_field; |
156 | frame->frame.dispose = null_frame_dispose; | 188 | frame->frame.dispose = null_frame_dispose; |
157 | frame->yuv2rgb = 0; | 189 | frame->yuv2rgb = 0; |
158 | /* | 190 | /* |
159 | * colorspace converter for this frame | 191 | * colorspace converter for this frame |
160 | */ | 192 | */ |
161 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | 193 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); |
162 | 194 | ||
163 | 195 | ||
164 | return (vo_frame_t*) frame; | 196 | return (vo_frame_t*) frame; |
165 | } | 197 | } |
166 | 198 | ||
167 | // size specific | 199 | // size specific |
168 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { | 200 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { |
169 | 201 | ||
170 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { | 202 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { |
171 | printf("Not scaling\n"); | 203 | printf("Not scaling\n"); |
172 | frame->ideal_width = frame->width; | 204 | frame->ideal_width = frame->width; |
173 | frame->ideal_height = frame->height; | 205 | frame->ideal_height = frame->height; |
174 | frame->ratio_factor = 1.0; | 206 | frame->ratio_factor = 1.0; |
175 | 207 | ||
176 | } else { | 208 | } else { |
177 | 209 | ||
178 | double image_ratio, desired_ratio, corr_factor; | 210 | double image_ratio, desired_ratio, corr_factor; |
179 | 211 | ||
180 | image_ratio = (double) frame->width / (double) frame->height; | 212 | image_ratio = (double) frame->width / (double) frame->height; |
181 | 213 | ||
182 | switch (frame->user_ratio) { | 214 | switch (frame->user_ratio) { |
183 | case ASPECT_AUTO: | 215 | case ASPECT_AUTO: |
184 | switch (frame->ratio_code) { | 216 | switch (frame->ratio_code) { |
185 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ | 217 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ |
186 | case XINE_ASPECT_RATIO_PAN_SCAN: | 218 | case XINE_ASPECT_RATIO_PAN_SCAN: |
187 | desired_ratio = 16.0 /9.0; | 219 | desired_ratio = 16.0 /9.0; |
188 | break; | 220 | break; |
189 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ | 221 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ |
190 | desired_ratio = 2.11/1.0; | 222 | desired_ratio = 2.11/1.0; |
191 | break; | 223 | break; |
192 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ | 224 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ |
193 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ | 225 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ |
194 | desired_ratio = image_ratio; | 226 | desired_ratio = image_ratio; |
195 | break; | 227 | break; |
196 | case 0: /* forbidden -> 4:3 */ | 228 | case 0: /* forbidden -> 4:3 */ |
197 | printf ("video_out_fb: invalid ratio, using 4:3\n"); | 229 | printf ("video_out_fb: invalid ratio, using 4:3\n"); |
198 | default: | 230 | default: |
199 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", | 231 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", |
200 | frame->ratio_code); | 232 | frame->ratio_code); |
201 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ | 233 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ |
202 | desired_ratio = 4.0 / 3.0; | 234 | desired_ratio = 4.0 / 3.0; |
203 | break; | 235 | break; |
204 | } | 236 | } |
205 | break; | 237 | break; |
206 | case ASPECT_ANAMORPHIC: | 238 | case ASPECT_ANAMORPHIC: |
207 | desired_ratio = 16.0 / 9.0; | 239 | desired_ratio = 16.0 / 9.0; |
208 | break; | 240 | break; |
209 | case ASPECT_DVB: | 241 | case ASPECT_DVB: |
210 | desired_ratio = 2.0 / 1.0; | 242 | desired_ratio = 2.0 / 1.0; |
211 | break; | 243 | break; |
212 | case ASPECT_SQUARE: | 244 | case ASPECT_SQUARE: |
213 | desired_ratio = image_ratio; | 245 | desired_ratio = image_ratio; |
214 | break; | 246 | break; |
215 | case ASPECT_FULL: | 247 | case ASPECT_FULL: |
216 | default: | 248 | default: |
217 | desired_ratio = 4.0 / 3.0; | 249 | desired_ratio = 4.0 / 3.0; |
218 | } | 250 | } |
219 | 251 | ||
220 | frame->ratio_factor = this->display_ratio * desired_ratio; | 252 | frame->ratio_factor = this->display_ratio * desired_ratio; |
221 | 253 | ||
222 | corr_factor = frame->ratio_factor / image_ratio ; | 254 | corr_factor = frame->ratio_factor / image_ratio ; |
223 | 255 | ||
224 | if (fabs(corr_factor - 1.0) < 0.005) { | 256 | if (fabs(corr_factor - 1.0) < 0.005) { |
225 | frame->ideal_width = frame->width; | 257 | frame->ideal_width = frame->width; |
226 | frame->ideal_height = frame->height; | 258 | frame->ideal_height = frame->height; |
227 | 259 | ||
228 | } else { | 260 | } else { |
229 | 261 | ||
230 | if (corr_factor >= 1.0) { | 262 | if (corr_factor >= 1.0) { |
231 | frame->ideal_width = frame->width * corr_factor + 0.5; | 263 | frame->ideal_width = frame->width * corr_factor + 0.5; |
232 | frame->ideal_height = frame->height; | 264 | frame->ideal_height = frame->height; |
233 | } else { | 265 | } else { |
234 | frame->ideal_width = frame->width; | 266 | frame->ideal_width = frame->width; |
235 | frame->ideal_height = frame->height / corr_factor + 0.5; | 267 | frame->ideal_height = frame->height / corr_factor + 0.5; |
236 | } | 268 | } |
237 | 269 | ||
238 | } | 270 | } |
239 | } | 271 | } |
240 | printf("return from helper\n"); | 272 | printf("return from helper\n"); |
241 | } | 273 | } |
242 | 274 | ||
243 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { | 275 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { |
244 | 276 | ||
245 | double x_factor, y_factor; | 277 | double x_factor, y_factor; |
246 | 278 | ||
247 | /* | 279 | /* |
248 | * make the frame fit into the given destination area | 280 | * make the frame fit into the given destination area |
249 | */ | 281 | */ |
250 | 282 | ||
251 | x_factor = (double) this->gui_width / (double) frame->ideal_width; | 283 | x_factor = (double) this->gui_width / (double) frame->ideal_width; |
252 | y_factor = (double) this->gui_height / (double) frame->ideal_height; | 284 | y_factor = (double) this->gui_height / (double) frame->ideal_height; |
253 | 285 | ||
254 | if ( x_factor < y_factor ) { | 286 | if ( x_factor < y_factor ) { |
255 | frame->output_width = (double) frame->ideal_width * x_factor ; | 287 | frame->output_width = (double) frame->ideal_width * x_factor ; |
256 | frame->output_height = (double) frame->ideal_height * x_factor ; | 288 | frame->output_height = (double) frame->ideal_height * x_factor ; |
257 | } else { | 289 | } else { |
258 | frame->output_width = (double) frame->ideal_width * y_factor ; | 290 | frame->output_width = (double) frame->ideal_width * y_factor ; |
259 | frame->output_height = (double) frame->ideal_height * y_factor ; | 291 | frame->output_height = (double) frame->ideal_height * y_factor ; |
260 | } | 292 | } |
261 | 293 | ||
262 | #define LOG 1 | 294 | #define LOG 1 |
263 | #ifdef LOG | 295 | #ifdef LOG |
264 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", | 296 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", |
265 | frame->width, frame->height, | 297 | frame->width, frame->height, |
266 | frame->output_width, frame->output_height, | 298 | frame->output_width, frame->output_height, |
267 | ( frame->width != frame->output_width | 299 | ( frame->width != frame->output_width |
268 | || frame->height != frame->output_height | 300 | || frame->height != frame->output_height |
269 | ? ", software scaling" | 301 | ? ", software scaling" |
270 | : "" ) | 302 | : "" ) |
271 | ); | 303 | ); |
272 | #endif | 304 | #endif |
273 | } | 305 | } |
274 | 306 | ||
275 | 307 | ||
276 | // size specific | 308 | // size specific |
277 | 309 | ||
278 | 310 | ||
279 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | 311 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, |
280 | uint32_t width, uint32_t height, | 312 | uint32_t width, uint32_t height, |
281 | int ratio_code, int format, int flags ){ | 313 | int ratio_code, int format, int flags ){ |
282 | null_driver_t* this = (null_driver_t*) self; | 314 | null_driver_t* this = (null_driver_t*) self; |
283 | opie_frame_t* frame = (opie_frame_t*)img; | 315 | opie_frame_t* frame = (opie_frame_t*)img; |
284 | /* not needed now */ | 316 | /* not needed now */ |
285 | printf("update_frame_format\n"); | 317 | printf("update_frame_format\n"); |
286 | printf("al crash aye?\n"); | 318 | printf("al crash aye?\n"); |
287 | 319 | ||
288 | flags &= VO_BOTH_FIELDS; | 320 | flags &= VO_BOTH_FIELDS; |
289 | 321 | ||
290 | /* find out if we need to adapt this frame */ | 322 | /* find out if we need to adapt this frame */ |
291 | 323 | ||
292 | if ((width != frame->width) | 324 | if ((width != frame->width) |
293 | || (height != frame->height) | 325 | || (height != frame->height) |
294 | || (ratio_code != frame->ratio_code) | 326 | || (ratio_code != frame->ratio_code) |
295 | || (flags != frame->flags) | 327 | || (flags != frame->flags) |
296 | || (format != frame->format) | 328 | || (format != frame->format) |
297 | || (this->user_ratio != frame->user_ratio) | 329 | || (this->user_ratio != frame->user_ratio) |
298 | || (this->gui_width != frame-> gui_width ) | 330 | || (this->gui_width != frame-> gui_width ) |
299 | || (this-> gui_height != frame-> gui_height)) { | 331 | || (this-> gui_height != frame-> gui_height)) { |
300 | 332 | ||
301 | frame->width = width; | 333 | frame->width = width; |
302 | frame->height = height; | 334 | frame->height = height; |
303 | frame->ratio_code = ratio_code; | 335 | frame->ratio_code = ratio_code; |
304 | frame->flags = flags; | 336 | frame->flags = flags; |
305 | frame->format = format; | 337 | frame->format = format; |
306 | frame->user_ratio = this->user_ratio; | 338 | frame->user_ratio = this->user_ratio; |
307 | this->gui_changed = 0; | 339 | this->gui_changed = 0; |
308 | //frame->show_video = this->m_show_video; | 340 | //frame->show_video = this->m_show_video; |
309 | frame->gui_width = this->gui_width; | 341 | frame->gui_width = this->gui_width; |
310 | frame->gui_height = this->gui_height; | 342 | frame->gui_height = this->gui_height; |
311 | 343 | ||
312 | null_compute_ideal_size (this, frame); | 344 | null_compute_ideal_size (this, frame); |
313 | null_compute_rgb_size (this, frame); | 345 | null_compute_rgb_size (this, frame); |
314 | 346 | ||
315 | /* | 347 | /* |
316 | * (re-) allocate | 348 | * (re-) allocate |
317 | */ | 349 | */ |
318 | if( frame->data ) { | 350 | if( frame->data ) { |
319 | if(frame->chunk[0] ){ | 351 | if(frame->chunk[0] ){ |
320 | free( frame->chunk[0] ); | 352 | free( frame->chunk[0] ); |
321 | frame->chunk[0] = NULL; | 353 | frame->chunk[0] = NULL; |
322 | } | 354 | } |
323 | if(frame->chunk[1] ){ | 355 | if(frame->chunk[1] ){ |
324 | free ( frame->chunk[1] ); | 356 | free ( frame->chunk[1] ); |
325 | frame->chunk[1] = NULL; | 357 | frame->chunk[1] = NULL; |
326 | } | 358 | } |
327 | if(frame->chunk[2] ){ | 359 | if(frame->chunk[2] ){ |
328 | free ( frame->chunk[2] ); | 360 | free ( frame->chunk[2] ); |
329 | frame->chunk[2] = NULL; | 361 | frame->chunk[2] = NULL; |
330 | } | 362 | } |
331 | free ( frame->data ); | 363 | free ( frame->data ); |
332 | } | 364 | } |
333 | printf("after freeing\n"); | 365 | printf("after freeing\n"); |
334 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * | 366 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * |
335 | this->bytes_per_pixel ); | 367 | this->bytes_per_pixel ); |
336 | 368 | ||
337 | if( format == IMGFMT_YV12 ) { | 369 | if( format == IMGFMT_YV12 ) { |
338 | frame->frame.pitches[0] = 8*((width + 7) / 8); | 370 | frame->frame.pitches[0] = 8*((width + 7) / 8); |
339 | frame->frame.pitches[1] = 8*((width + 15) / 16); | 371 | frame->frame.pitches[1] = 8*((width + 15) / 16); |
340 | frame->frame.pitches[2] = 8*((width + 15) / 16); | 372 | frame->frame.pitches[2] = 8*((width + 15) / 16); |
341 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); | 373 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height,(void **)&frame->chunk[0]); |
342 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); | 374 | frame->frame.base[1] = xine_xmalloc_aligned (16, frame->frame.pitches[1] * ((height+ 1)/2), (void **)&frame->chunk[1]); |
343 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); | 375 | frame->frame.base[2] = xine_xmalloc_aligned (16, frame->frame.pitches[2] * ((height+ 1)/2), (void **)&frame->chunk[2]); |
344 | 376 | ||
345 | }else{ | 377 | }else{ |
346 | frame->frame.pitches[0] = 8*((width + 3) / 4); | 378 | frame->frame.pitches[0] = 8*((width + 3) / 4); |
347 | 379 | ||
348 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, | 380 | frame->frame.base[0] = xine_xmalloc_aligned (16, frame->frame.pitches[0] * height, |
349 | (void **)&frame->chunk[0]); | 381 | (void **)&frame->chunk[0]); |
350 | frame->chunk[1] = NULL; | 382 | frame->chunk[1] = NULL; |
351 | frame->chunk[2] = NULL; | 383 | frame->chunk[2] = NULL; |
352 | } | 384 | } |
353 | 385 | ||
354 | frame->format = format; | 386 | frame->format = format; |
355 | frame->width = width; | 387 | frame->width = width; |
356 | frame->height = height; | 388 | frame->height = height; |
357 | 389 | ||
358 | frame->stripe_height = 16 * frame->output_height / frame->height; | 390 | frame->stripe_height = 16 * frame->output_height / frame->height; |
359 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; | 391 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; |
360 | 392 | ||
361 | /* | 393 | /* |
362 | * set up colorspace converter | 394 | * set up colorspace converter |
363 | */ | 395 | */ |
364 | if(1 /*this->m_show_video*/ ){ | 396 | if(1 /*this->m_show_video*/ ){ |
365 | printf("showing video\n"); | 397 | printf("showing video\n"); |
366 | 398 | ||
367 | switch (flags) { | 399 | switch (flags) { |
368 | case VO_TOP_FIELD: | 400 | case VO_TOP_FIELD: |
369 | case VO_BOTTOM_FIELD: | 401 | case VO_BOTTOM_FIELD: |
370 | frame->yuv2rgb->configure (frame->yuv2rgb, | 402 | frame->yuv2rgb->configure (frame->yuv2rgb, |
371 | frame->width, | 403 | frame->width, |
372 | 16, | 404 | 16, |
373 | 2*frame->frame.pitches[0], | 405 | 2*frame->frame.pitches[0], |
374 | 2*frame->frame.pitches[1], | 406 | 2*frame->frame.pitches[1], |
375 | frame->output_width, | 407 | frame->output_width, |
376 | frame->stripe_height, | 408 | frame->stripe_height, |
377 | frame->bytes_per_line*2); | 409 | frame->bytes_per_line*2); |
378 | frame->yuv_stride = frame->bytes_per_line*2; | 410 | frame->yuv_stride = frame->bytes_per_line*2; |
379 | break; | 411 | break; |
380 | case VO_BOTH_FIELDS: | 412 | case VO_BOTH_FIELDS: |
381 | frame->yuv2rgb->configure (frame->yuv2rgb, | 413 | frame->yuv2rgb->configure (frame->yuv2rgb, |
382 | frame->width, | 414 | frame->width, |
383 | 16, | 415 | 16, |
384 | frame->frame.pitches[0], | 416 | frame->frame.pitches[0], |
385 | frame->frame.pitches[1], | 417 | frame->frame.pitches[1], |
386 | frame->output_width, | 418 | frame->output_width, |
387 | frame->stripe_height, | 419 | frame->stripe_height, |
388 | frame->bytes_per_line); | 420 | frame->bytes_per_line); |
389 | frame->yuv_stride = frame->bytes_per_line; | 421 | frame->yuv_stride = frame->bytes_per_line; |
390 | break; | 422 | break; |
391 | } | 423 | } |
392 | } | 424 | } |
393 | } | 425 | } |
394 | printf("after gui changed\n"); | 426 | printf("after gui changed\n"); |
395 | /* | 427 | /* |
396 | * reset dest pointers | 428 | * reset dest pointers |
397 | */ | 429 | */ |
398 | 430 | ||
399 | if (frame->data) { | 431 | if (frame->data) { |
400 | switch (flags) { | 432 | switch (flags) { |
401 | case VO_TOP_FIELD: | 433 | case VO_TOP_FIELD: |
402 | frame->rgb_dst = (uint8_t *)frame->data; | 434 | frame->rgb_dst = (uint8_t *)frame->data; |
403 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 435 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
404 | break; | 436 | break; |
405 | case VO_BOTTOM_FIELD: | 437 | case VO_BOTTOM_FIELD: |
406 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 438 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
407 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 439 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
408 | break; | 440 | break; |
409 | case VO_BOTH_FIELDS: | 441 | case VO_BOTH_FIELDS: |
410 | frame->rgb_dst = (uint8_t *)frame->data; | 442 | frame->rgb_dst = (uint8_t *)frame->data; |
411 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; | 443 | frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; |
412 | break; | 444 | break; |
413 | } | 445 | } |
414 | } | 446 | } |
415 | printf("done\n"); | 447 | printf("done\n"); |
416 | } | 448 | } |
417 | static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ | 449 | static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){ |
418 | null_driver_t* this = (null_driver_t*) self; | 450 | null_driver_t* this = (null_driver_t*) self; |
419 | opie_frame_t* frame = (opie_frame_t*)frame_gen; | 451 | opie_frame_t* frame = (opie_frame_t*)frame_gen; |
420 | display_xine_frame_t display = this->frameDis; | 452 | display_xine_frame_t display = this->frameDis; |
421 | 453 | ||
422 | printf("display frame\n"); | 454 | printf("display frame\n"); |
423 | // if( this->m_show_video ) { // return if not displaying | 455 | // if( this->m_show_video ) { // return if not displaying |
424 | printf("calling home aye\n" ); | 456 | printf("calling home aye\n" ); |
425 | if( display != NULL ) { | 457 | if( display != NULL ) { |
426 | (*display)(this->caller, frame->data, | 458 | (*display)(this->caller, frame->data, |
427 | frame->output_width, frame->output_height, | 459 | frame->output_width, frame->output_height, |
428 | frame->bytes_per_line ); | 460 | frame->bytes_per_line ); |
429 | printf("display done hope you enyoyed the frame"); | 461 | printf("display done hope you enyoyed the frame"); |
430 | } | 462 | } |
431 | // } | 463 | // } |
432 | 464 | ||
433 | frame->frame.displayed (&frame->frame); | 465 | frame->frame.displayed (&frame->frame); |
434 | } | 466 | } |
435 | 467 | ||
436 | 468 | ||
437 | // blending related | 469 | // blending related |
438 | 470 | ||
439 | 471 | ||
440 | static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay, | 472 | static void null_overlay_clut_yuv2rgb(null_driver_t *this, vo_overlay_t *overlay, |
441 | opie_frame_t *frame) { | 473 | opie_frame_t *frame) { |
442 | int i; | 474 | int i; |
443 | clut_t* clut = (clut_t*) overlay->color; | 475 | clut_t* clut = (clut_t*) overlay->color; |
444 | if (!overlay->rgb_clut) { | 476 | if (!overlay->rgb_clut) { |
445 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 477 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
446 | *((uint32_t *)&clut[i]) = | 478 | *((uint32_t *)&clut[i]) = |
447 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, | 479 | frame->yuv2rgb->yuv2rgb_single_pixel_fun (frame->yuv2rgb, |
448 | clut[i].y, clut[i].cb, clut[i].cr); | 480 | clut[i].y, clut[i].cb, clut[i].cr); |
449 | } | 481 | } |
450 | overlay->rgb_clut++; | 482 | overlay->rgb_clut++; |
451 | } | 483 | } |
452 | if (!overlay->clip_rgb_clut) { | 484 | if (!overlay->clip_rgb_clut) { |
453 | clut = (clut_t*) overlay->clip_color; | 485 | clut = (clut_t*) overlay->clip_color; |
454 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { | 486 | for (i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) { |
455 | *((uint32_t *)&clut[i]) = | 487 | *((uint32_t *)&clut[i]) = |
456 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, | 488 | frame->yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, |
457 | clut[i].y, clut[i].cb, clut[i].cr); | 489 | clut[i].y, clut[i].cb, clut[i].cr); |
458 | } | 490 | } |
459 | overlay->clip_rgb_clut++; | 491 | overlay->clip_rgb_clut++; |
460 | } | 492 | } |
461 | } | 493 | } |
462 | 494 | ||
463 | static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { | 495 | static void null_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { |
464 | null_driver_t *this = (null_driver_t *) this_gen; | 496 | null_driver_t *this = (null_driver_t *) this_gen; |
465 | opie_frame_t *frame = (opie_frame_t *) frame_gen; | 497 | opie_frame_t *frame = (opie_frame_t *) frame_gen; |
466 | 498 | ||
467 | printf("overlay blend\n"); | 499 | printf("overlay blend\n"); |
468 | if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0) | 500 | if(!this->m_show_video || frame->output_width == 0 || frame->output_height== 0) |
469 | return; | 501 | return; |
470 | 502 | ||
471 | /* Alpha Blend here */ | 503 | /* Alpha Blend here */ |
472 | if (overlay->rle) { | 504 | if (overlay->rle) { |
473 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) | 505 | if( !overlay->rgb_clut || !overlay->clip_rgb_clut) |
474 | null_overlay_clut_yuv2rgb(this,overlay,frame); | 506 | null_overlay_clut_yuv2rgb(this,overlay,frame); |
475 | 507 | ||
476 | switch(this->bpp) { | 508 | switch(this->bpp) { |
477 | case 16: | 509 | case 16: |
478 | blend_rgb16( (uint8_t *)frame->data, overlay, | 510 | blend_rgb16( (uint8_t *)frame->data, overlay, |
479 | frame->output_width, frame->output_height, | 511 | frame->output_width, frame->output_height, |
480 | frame->width, frame->height); | 512 | frame->width, frame->height); |
481 | break; | 513 | break; |
482 | case 24: | 514 | case 24: |
483 | blend_rgb24( (uint8_t *)frame->data, overlay, | 515 | blend_rgb24( (uint8_t *)frame->data, overlay, |
484 | frame->output_width, frame->output_height, | 516 | frame->output_width, frame->output_height, |
485 | frame->width, frame->height); | 517 | frame->width, frame->height); |
486 | break; | 518 | break; |
487 | case 32: | 519 | case 32: |
488 | blend_rgb32( (uint8_t *)frame->data, overlay, | 520 | blend_rgb32( (uint8_t *)frame->data, overlay, |
489 | frame->output_width, frame->output_height, | 521 | frame->output_width, frame->output_height, |
490 | frame->width, frame->height); | 522 | frame->width, frame->height); |
491 | break; | 523 | break; |
492 | default: | 524 | default: |
493 | /* It should never get here */ | 525 | /* It should never get here */ |
494 | break; | 526 | break; |
495 | } | 527 | } |
496 | } | 528 | } |
497 | } | 529 | } |
498 | 530 | ||
499 | 531 | ||
500 | static int null_get_property( vo_driver_t* self, | 532 | static int null_get_property( vo_driver_t* self, |
501 | int property ){ | 533 | int property ){ |
502 | printf("property get\n"); | 534 | printf("property get\n"); |
503 | return 0; | 535 | return 0; |
504 | } | 536 | } |
505 | static int null_set_property( vo_driver_t* self, | 537 | static int null_set_property( vo_driver_t* self, |
506 | int property, | 538 | int property, |
507 | int value ){ | 539 | int value ){ |
508 | printf("set property\n"); | 540 | printf("set property\n"); |
509 | return value; | 541 | return value; |
510 | } | 542 | } |
511 | static void null_get_property_min_max( vo_driver_t* self, | 543 | static void null_get_property_min_max( vo_driver_t* self, |
512 | int property, int *min, | 544 | int property, int *min, |
513 | int *max ){ | 545 | int *max ){ |
514 | printf("min max\n"); | 546 | printf("min max\n"); |
515 | *max = 0; | 547 | *max = 0; |
516 | *min = 0; | 548 | *min = 0; |
517 | } | 549 | } |
518 | static int null_gui_data_exchange( vo_driver_t* self, | 550 | static int null_gui_data_exchange( vo_driver_t* self, |
519 | int data_type, | 551 | int data_type, |
520 | void *data ){ | 552 | void *data ){ |
521 | return 0; | 553 | return 0; |
522 | } | 554 | } |
523 | static void null_exit( vo_driver_t* self ){ | 555 | static void null_exit( vo_driver_t* self ){ |
524 | null_driver_t* this = (null_driver_t*)self; | 556 | null_driver_t* this = (null_driver_t*)self; |
525 | free ( this ); | 557 | free ( this ); |
526 | } | 558 | } |
527 | static int null_redraw_needed( vo_driver_t* self ){ | 559 | static int null_redraw_needed( vo_driver_t* self ){ |
528 | return 0; | 560 | return 0; |
529 | } | 561 | } |
530 | 562 | ||
531 | 563 | ||
532 | vo_driver_t* init_video_out_plugin( config_values_t* conf, | 564 | vo_driver_t* init_video_out_plugin( config_values_t* conf, |
533 | void* video ){ | 565 | void* video ){ |
534 | null_driver_t *vo; | 566 | null_driver_t *vo; |
535 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); | 567 | vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); |
536 | 568 | ||
537 | /* memset? */ | 569 | /* memset? */ |
538 | memset(vo,0, sizeof(null_driver_t ) ); | 570 | memset(vo,0, sizeof(null_driver_t ) ); |
539 | vo->m_show_video = 0; // false | 571 | vo->m_show_video = 0; // false |
540 | vo->m_video_fullscreen = 0; | 572 | vo->m_video_fullscreen = 0; |
541 | vo->m_is_scaling = 0; | 573 | vo->m_is_scaling = 0; |
542 | vo->user_ratio = ASPECT_AUTO; | 574 | vo->user_ratio = ASPECT_AUTO; |
543 | vo->display_ratio = 1.0; | 575 | vo->display_ratio = 1.0; |
544 | vo->gui_width = 16; | 576 | vo->gui_width = 16; |
545 | vo->gui_height = 8; | 577 | vo->gui_height = 8; |
546 | vo->frameDis = NULL; | 578 | vo->frameDis = NULL; |
547 | 579 | ||
548 | /* install callback handlers*/ | 580 | /* install callback handlers*/ |
549 | vo->vo_driver.get_capabilities = null_get_capabilities; | 581 | vo->vo_driver.get_capabilities = null_get_capabilities; |
550 | vo->vo_driver.alloc_frame = null_alloc_frame; | 582 | vo->vo_driver.alloc_frame = null_alloc_frame; |
551 | vo->vo_driver.update_frame_format = null_update_frame_format; | 583 | vo->vo_driver.update_frame_format = null_update_frame_format; |
552 | vo->vo_driver.display_frame = null_display_frame; | 584 | vo->vo_driver.display_frame = null_display_frame; |
553 | vo->vo_driver.overlay_blend = null_overlay_blend; | 585 | vo->vo_driver.overlay_blend = null_overlay_blend; |
554 | vo->vo_driver.get_property = null_get_property; | 586 | vo->vo_driver.get_property = null_get_property; |
555 | vo->vo_driver.set_property = null_set_property; | 587 | vo->vo_driver.set_property = null_set_property; |
556 | vo->vo_driver.get_property_min_max = null_get_property_min_max; | 588 | vo->vo_driver.get_property_min_max = null_get_property_min_max; |
557 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; | 589 | vo->vo_driver.gui_data_exchange = null_gui_data_exchange; |
558 | vo->vo_driver.exit = null_exit; | 590 | vo->vo_driver.exit = null_exit; |
559 | vo->vo_driver.redraw_needed = null_redraw_needed; | 591 | vo->vo_driver.redraw_needed = null_redraw_needed; |
560 | 592 | ||
561 | 593 | ||
562 | /* capabilities */ | 594 | /* capabilities */ |
563 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; | 595 | vo->m_capabilities = VO_CAP_COPIES_IMAGE | VO_CAP_YUY2 | VO_CAP_YV12; |
564 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, | 596 | vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, |
565 | vo->yuv2rgb_cmap); | 597 | vo->yuv2rgb_cmap); |
566 | printf("done initialisation\n"); | 598 | printf("done initialisation\n"); |
567 | return (vo_driver_t*) vo; | 599 | return (vo_driver_t*) vo; |
568 | } | 600 | } |
569 | 601 | ||
570 | static vo_info_t vo_info_null = { | 602 | static vo_info_t vo_info_null = { |
571 | 5, | 603 | 5, |
572 | "null plugin", | 604 | "null plugin", |
573 | NULL, | 605 | NULL, |
574 | VISUAL_TYPE_FB, | 606 | VISUAL_TYPE_FB, |
575 | 5 | 607 | 5 |
576 | }; | 608 | }; |
577 | 609 | ||
578 | vo_info_t *get_video_out_plugin_info(){ | 610 | vo_info_t *get_video_out_plugin_info(){ |
579 | vo_info_null.description = _("xine video output plugin using null device"); | 611 | vo_info_null.description = _("xine video output plugin using null device"); |
580 | return &vo_info_null; | 612 | return &vo_info_null; |
581 | } | 613 | } |
582 | 614 | ||
583 | /* this is special for this device */ | 615 | /* this is special for this device */ |
584 | /** | 616 | /** |
585 | * We know that we will be controled by the XINE LIB++ | 617 | * We know that we will be controled by the XINE LIB++ |
586 | */ | 618 | */ |
587 | 619 | ||
588 | /** | 620 | /** |
589 | * | 621 | * |
590 | */ | 622 | */ |
591 | int null_is_showing_video( vo_driver_t* self ){ | 623 | int null_is_showing_video( vo_driver_t* self ){ |
592 | null_driver_t* this = (null_driver_t*)self; | 624 | null_driver_t* this = (null_driver_t*)self; |
593 | return this->m_show_video; | 625 | return this->m_show_video; |
594 | } | 626 | } |
595 | void null_set_show_video( vo_driver_t* self, int show ) { | 627 | void null_set_show_video( vo_driver_t* self, int show ) { |
596 | ((null_driver_t*)self)->m_show_video = show; | 628 | ((null_driver_t*)self)->m_show_video = show; |
597 | } | 629 | } |
598 | 630 | ||
599 | int null_is_fullscreen( vo_driver_t* self ){ | 631 | int null_is_fullscreen( vo_driver_t* self ){ |
600 | return ((null_driver_t*)self)->m_video_fullscreen; | 632 | return ((null_driver_t*)self)->m_video_fullscreen; |
601 | } | 633 | } |
602 | void null_set_fullscreen( vo_driver_t* self, int screen ){ | 634 | void null_set_fullscreen( vo_driver_t* self, int screen ){ |
603 | ((null_driver_t*)self)->m_video_fullscreen = screen; | 635 | ((null_driver_t*)self)->m_video_fullscreen = screen; |
604 | } | 636 | } |
605 | int null_is_scaling( vo_driver_t* self ){ | 637 | int null_is_scaling( vo_driver_t* self ){ |
606 | return ((null_driver_t*)self)->m_is_scaling; | 638 | return ((null_driver_t*)self)->m_is_scaling; |
607 | } | 639 | } |
640 | |||
641 | void null_set_videoGamma( vo_driver_t* self , int value ) { | ||
642 | ((null_driver_t*) self) ->yuv2rgb_gamma = value; | ||
643 | ((null_driver_t*) self) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self) ->yuv2rgb_factory, value ); | ||
644 | } | ||
645 | |||
608 | void null_set_scaling( vo_driver_t* self, int scale ){ | 646 | void null_set_scaling( vo_driver_t* self, int scale ){ |
609 | ((null_driver_t*)self)->m_is_scaling = scale; | 647 | ((null_driver_t*)self)->m_is_scaling = scale; |
610 | } | 648 | } |
611 | 649 | ||
612 | void null_set_gui_width( vo_driver_t* self, int width ){ | 650 | void null_set_gui_width( vo_driver_t* self, int width ){ |
613 | ((null_driver_t*)self)->gui_width = width; | 651 | ((null_driver_t*)self)->gui_width = width; |
614 | } | 652 | } |
615 | void null_set_gui_height( vo_driver_t* self, int height ){ | 653 | void null_set_gui_height( vo_driver_t* self, int height ){ |
616 | ((null_driver_t*)self)->gui_height = height; | 654 | ((null_driver_t*)self)->gui_height = height; |
617 | } | 655 | } |
656 | |||
657 | |||
618 | void null_set_mode( vo_driver_t* self, int depth, int rgb ){ | 658 | void null_set_mode( vo_driver_t* self, int depth, int rgb ){ |
619 | null_driver_t* this = (null_driver_t*)self; | 659 | null_driver_t* this = (null_driver_t*)self; |
620 | 660 | ||
621 | this->bytes_per_pixel = (depth + 7 ) / 8; | 661 | this->bytes_per_pixel = (depth + 7 ) / 8; |
622 | this->bpp = this->bytes_per_pixel * 8; | 662 | this->bpp = this->bytes_per_pixel * 8; |
623 | this->depth = depth; | 663 | this->depth = depth; |
624 | printf("depth %d %d\n", depth, this->bpp); | 664 | printf("depth %d %d\n", depth, this->bpp); |
625 | printf("pixeltype %d\n", rgb ); | 665 | printf("pixeltype %d\n", rgb ); |
626 | switch ( this->depth ){ | 666 | switch ( this->depth ){ |
627 | case 32: | 667 | case 32: |
628 | if( rgb == 0 ) | 668 | if( rgb == 0 ) |
629 | this->yuv2rgb_mode = MODE_32_RGB; | 669 | this->yuv2rgb_mode = MODE_32_RGB; |
630 | else | 670 | else |
631 | this->yuv2rgb_mode = MODE_32_BGR; | 671 | this->yuv2rgb_mode = MODE_32_BGR; |
632 | case 24: | 672 | case 24: |
633 | if( this->bpp == 32 ) { | 673 | if( this->bpp == 32 ) { |
634 | if(rgb == 0 ) | 674 | if(rgb == 0 ) |
635 | this->yuv2rgb_mode = MODE_32_RGB; | 675 | this->yuv2rgb_mode = MODE_32_RGB; |
636 | else | 676 | else |
637 | this->yuv2rgb_mode = MODE_32_BGR; | 677 | this->yuv2rgb_mode = MODE_32_BGR; |
638 | }else{ | 678 | }else{ |
639 | if( rgb == 0 ) | 679 | if( rgb == 0 ) |
640 | this->yuv2rgb_mode = MODE_24_RGB; | 680 | this->yuv2rgb_mode = MODE_24_RGB; |
641 | else | 681 | else |
642 | this->yuv2rgb_mode = MODE_24_BGR; | 682 | this->yuv2rgb_mode = MODE_24_BGR; |
643 | }; | 683 | }; |
644 | break; | 684 | break; |
645 | case 16: | 685 | case 16: |
646 | if( rgb == 0 ) | 686 | if( rgb == 0 ) |
647 | this->yuv2rgb_mode = MODE_16_RGB; | 687 | this->yuv2rgb_mode = MODE_16_RGB; |
648 | else | 688 | else |
649 | this->yuv2rgb_mode = MODE_16_BGR; | 689 | this->yuv2rgb_mode = MODE_16_BGR; |
650 | break; | 690 | break; |
651 | case 15: | 691 | case 15: |
652 | if( rgb == 0 ) | 692 | if( rgb == 0 ) |
653 | this->yuv2rgb_mode = MODE_15_RGB; | 693 | this->yuv2rgb_mode = MODE_15_RGB; |
654 | else | 694 | else |
655 | this->yuv2rgb_mode = MODE_15_BGR; | 695 | this->yuv2rgb_mode = MODE_15_BGR; |
656 | break; | 696 | break; |
657 | case 8: | 697 | case 8: |
658 | if( rgb == 0 ) | 698 | if( rgb == 0 ) |
659 | this->yuv2rgb_mode = MODE_8_RGB; | 699 | this->yuv2rgb_mode = MODE_8_RGB; |
660 | else | 700 | else |
661 | this->yuv2rgb_mode = MODE_8_BGR; | 701 | this->yuv2rgb_mode = MODE_8_BGR; |
662 | break; | 702 | break; |
663 | }; | 703 | }; |
664 | //free(this->yuv2rgb_factory ); | 704 | //free(this->yuv2rgb_factory ); |
665 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, | 705 | // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap, |
666 | // this->yuv2rgb_cmap); | 706 | // this->yuv2rgb_cmap); |
667 | }; | 707 | }; |
668 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) { | 708 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data) { |
669 | null_driver_t* this = (null_driver_t*) self; | 709 | null_driver_t* this = (null_driver_t*) self; |
670 | this->caller = user_data; | 710 | this->caller = user_data; |
671 | this->frameDis = t; | 711 | this->frameDis = t; |
672 | } | 712 | } |
713 | |||
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
49 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
50 | 50 | ||
51 | //only needed for the random play | 51 | //only needed for the random play |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include "audiowidget.h" | 54 | #include "audiowidget.h" |
55 | #include "videowidget.h" | 55 | #include "videowidget.h" |
56 | 56 | ||
57 | extern MediaPlayerState *mediaPlayerState; | 57 | extern MediaPlayerState *mediaPlayerState; |
58 | 58 | ||
59 | 59 | ||
60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 60 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
61 | : PlayListWidgetGui( parent, name, fl ) { | 61 | : PlayListWidgetGui( parent, name, fl ) { |
62 | 62 | ||
63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", |
66 | this , SLOT(removeSelected() ) ); | 66 | this , SLOT(removeSelected() ) ); |
67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 67 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
68 | this , SLOT( btnPlay( bool) ), TRUE ); | 68 | this , SLOT( btnPlay( bool) ), TRUE ); |
69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 69 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
70 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 70 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 71 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
72 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 72 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
73 | 73 | ||
74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 74 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 76 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
78 | pmPlayList->insertSeparator(-1); | 78 | pmPlayList->insertSeparator(-1); |
79 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 79 | (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 80 | (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
81 | pmPlayList->insertSeparator(-1); | 81 | pmPlayList->insertSeparator(-1); |
82 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 82 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
83 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 84 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 85 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
86 | 86 | ||
87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 87 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
88 | 88 | ||
89 | Config cfg( "OpiePlayer" ); | 89 | Config cfg( "OpiePlayer" ); |
90 | bool b= cfg.readBoolEntry("FullScreen", 0); | 90 | bool b= cfg.readBoolEntry("FullScreen", 0); |
91 | mediaPlayerState->setFullscreen( b ); | 91 | mediaPlayerState->setFullscreen( b ); |
92 | pmView->setItemChecked( -16, b ); | 92 | pmView->setItemChecked( -16, b ); |
93 | 93 | ||
94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); | 94 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); |
95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); | 95 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); |
96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); | 96 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); |
97 | QVBox *stretch2 = new QVBox( vbox1 ); | 97 | QVBox *stretch2 = new QVBox( vbox1 ); |
98 | 98 | ||
99 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); | 99 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); |
100 | connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); | 100 | connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); |
101 | connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); | 101 | connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); |
102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 102 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
103 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 103 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 104 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 105 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 106 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
107 | this,SLOT( playIt( QListViewItem *) ) ); | 107 | this,SLOT( playIt( QListViewItem *) ) ); |
108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 108 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 109 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 110 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 111 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
112 | this,SLOT( playIt( QListViewItem *) ) ); | 112 | this,SLOT( playIt( QListViewItem *) ) ); |
113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 113 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 114 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); | 115 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); |
116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 116 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 117 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 118 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 119 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 120 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
121 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | ||
121 | 122 | ||
122 | readConfig( cfg ); | 123 | readConfig( cfg ); |
123 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); | 124 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); |
124 | loadList(DocLnk( currentPlaylist ) ); | 125 | loadList(DocLnk( currentPlaylist ) ); |
125 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); | 126 | setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); |
126 | 127 | ||
127 | // see which skins are installed | 128 | // see which skins are installed |
128 | videoScan=FALSE; | 129 | videoScan=FALSE; |
129 | audioScan=FALSE; | 130 | audioScan=FALSE; |
130 | populateSkinsMenu(); | 131 | populateSkinsMenu(); |
131 | initializeStates(); | 132 | initializeStates(); |
132 | } | 133 | } |
133 | 134 | ||
134 | 135 | ||
135 | PlayListWidget::~PlayListWidget() { | 136 | PlayListWidget::~PlayListWidget() { |
136 | // WTF?!@?! | 137 | // WTF?!@?! |
137 | 138 | ||
138 | if ( d->current ) { | 139 | if ( d->current ) { |
139 | delete d->current; | 140 | delete d->current; |
140 | } | 141 | } |
141 | delete d; | 142 | delete d; |
142 | } | 143 | } |
143 | 144 | ||
144 | 145 | ||
145 | void PlayListWidget::initializeStates() { | 146 | void PlayListWidget::initializeStates() { |
146 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 147 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
147 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 148 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
148 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 149 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
149 | setPlaylist( true ); | 150 | setPlaylist( true ); |
150 | } | 151 | } |
151 | 152 | ||
152 | 153 | ||
153 | void PlayListWidget::readConfig( Config& cfg ) { | 154 | void PlayListWidget::readConfig( Config& cfg ) { |
154 | cfg.setGroup( "PlayList" ); | 155 | cfg.setGroup( "PlayList" ); |
155 | QString currentString = cfg.readEntry( "current", "" ); | 156 | QString currentString = cfg.readEntry( "current", "" ); |
156 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); | 157 | int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); |
157 | for ( int i = 0; i < noOfFiles; i++ ) { | 158 | for ( int i = 0; i < noOfFiles; i++ ) { |
158 | QString entryName; | 159 | QString entryName; |
159 | entryName.sprintf( "File%i", i + 1 ); | 160 | entryName.sprintf( "File%i", i + 1 ); |
160 | QString linkFile = cfg.readEntry( entryName ); | 161 | QString linkFile = cfg.readEntry( entryName ); |
161 | if( QFileInfo( linkFile ).exists() ) { | 162 | if( QFileInfo( linkFile ).exists() ) { |
162 | DocLnk lnk( linkFile ); | 163 | DocLnk lnk( linkFile ); |
163 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { | 164 | if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { |
164 | d->selectedFiles->addToSelection( lnk ); | 165 | d->selectedFiles->addToSelection( lnk ); |
165 | } | 166 | } |
166 | } | 167 | } |
167 | } | 168 | } |
168 | d->selectedFiles->setSelectedItem( currentString ); | 169 | d->selectedFiles->setSelectedItem( currentString ); |
169 | } | 170 | } |
170 | 171 | ||
171 | 172 | ||
172 | void PlayListWidget::writeConfig( Config& cfg ) const { | 173 | void PlayListWidget::writeConfig( Config& cfg ) const { |
173 | d->selectedFiles->writeCurrent( cfg ); | 174 | d->selectedFiles->writeCurrent( cfg ); |
174 | cfg.setGroup( "PlayList" ); | 175 | cfg.setGroup( "PlayList" ); |
175 | int noOfFiles = 0; | 176 | int noOfFiles = 0; |
176 | d->selectedFiles->first(); | 177 | d->selectedFiles->first(); |
177 | do { | 178 | do { |
178 | const DocLnk *lnk = d->selectedFiles->current(); | 179 | const DocLnk *lnk = d->selectedFiles->current(); |
179 | if ( lnk ) { | 180 | if ( lnk ) { |
180 | QString entryName; | 181 | QString entryName; |
181 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 182 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
182 | cfg.writeEntry( entryName, lnk->linkFile() ); | 183 | cfg.writeEntry( entryName, lnk->linkFile() ); |
183 | // if this link does exist, add it so we have the file | 184 | // if this link does exist, add it so we have the file |
184 | // next time... | 185 | // next time... |
185 | if ( !QFile::exists( lnk->linkFile() ) ) { | 186 | if ( !QFile::exists( lnk->linkFile() ) ) { |
186 | // the way writing lnks doesn't really check for out | 187 | // the way writing lnks doesn't really check for out |
187 | // of disk space, but check it anyway. | 188 | // of disk space, but check it anyway. |
188 | if ( !lnk->writeLink() ) { | 189 | if ( !lnk->writeLink() ) { |
189 | QMessageBox::critical( 0, tr("Out of space"), | 190 | QMessageBox::critical( 0, tr("Out of space"), |
190 | tr( "There was a problem saving " | 191 | tr( "There was a problem saving " |
191 | "the playlist.\n" | 192 | "the playlist.\n" |
192 | "Your playlist " | 193 | "Your playlist " |
193 | "may be missing some entries\n" | 194 | "may be missing some entries\n" |
194 | "the next time you start it." ) | 195 | "the next time you start it." ) |
195 | ); | 196 | ); |
196 | } | 197 | } |
197 | } | 198 | } |
198 | noOfFiles++; | 199 | noOfFiles++; |
199 | } | 200 | } |
200 | } | 201 | } |
201 | while ( d->selectedFiles->next() ); | 202 | while ( d->selectedFiles->next() ); |
202 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 203 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
203 | } | 204 | } |
204 | 205 | ||
205 | 206 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 207 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 208 | d->setDocumentUsed = FALSE; |
208 | if ( mediaPlayerState->playlist() ) { | 209 | if ( mediaPlayerState->playlist() ) { |
209 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) | 210 | if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) |
210 | d->selectedFiles->addToSelection( lnk ); | 211 | d->selectedFiles->addToSelection( lnk ); |
211 | } | 212 | } |
212 | else | 213 | else |
213 | mediaPlayerState->setPlaying( TRUE ); | 214 | mediaPlayerState->setPlaying( TRUE ); |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | void PlayListWidget::clearList() { | 218 | void PlayListWidget::clearList() { |
218 | while ( first() ) { | 219 | while ( first() ) { |
219 | d->selectedFiles->removeSelected(); | 220 | d->selectedFiles->removeSelected(); |
220 | } | 221 | } |
221 | } | 222 | } |
222 | 223 | ||
223 | 224 | ||
224 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
225 | switch (mouse) { | 226 | switch (mouse) { |
226 | case 1: | 227 | case 1: |
227 | break; | 228 | break; |
228 | case 2: | 229 | case 2: |
229 | { | 230 | { |
230 | QPopupMenu m; | 231 | QPopupMenu m; |
231 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
232 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
233 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
234 | } | 235 | } |
235 | break; | 236 | break; |
236 | } | 237 | } |
237 | } | 238 | } |
238 | 239 | ||
239 | 240 | ||
240 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
241 | switch (mouse) { | 242 | switch (mouse) { |
242 | case 1: | 243 | case 1: |
243 | break; | 244 | break; |
244 | case 2: | 245 | case 2: |
245 | { | 246 | { |
246 | QPopupMenu m; | 247 | QPopupMenu m; |
247 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
248 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
249 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
250 | } | 251 | } |
251 | break; | 252 | break; |
252 | } | 253 | } |
253 | } | 254 | } |
254 | 255 | ||
255 | 256 | ||
256 | void PlayListWidget::addAllToList() { | 257 | void PlayListWidget::addAllToList() { |
257 | DocLnkSet filesAll; | 258 | DocLnkSet filesAll; |
258 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 259 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
259 | QListIterator<DocLnk> Adit( filesAll.children() ); | 260 | QListIterator<DocLnk> Adit( filesAll.children() ); |
260 | for ( ; Adit.current(); ++Adit ) { | 261 | for ( ; Adit.current(); ++Adit ) { |
261 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 262 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
262 | d->selectedFiles->addToSelection( **Adit ); | 263 | d->selectedFiles->addToSelection( **Adit ); |
263 | } | 264 | } |
264 | } | 265 | } |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | void PlayListWidget::addAllMusicToList() { | 269 | void PlayListWidget::addAllMusicToList() { |
269 | QListIterator<DocLnk> dit( files.children() ); | 270 | QListIterator<DocLnk> dit( files.children() ); |
270 | for ( ; dit.current(); ++dit ) { | 271 | for ( ; dit.current(); ++dit ) { |
271 | if( QFileInfo(dit.current()->file() ).exists() ) { | 272 | if( QFileInfo(dit.current()->file() ).exists() ) { |
272 | d->selectedFiles->addToSelection( **dit ); | 273 | d->selectedFiles->addToSelection( **dit ); |
273 | } | 274 | } |
274 | } | 275 | } |
275 | } | 276 | } |
276 | 277 | ||
277 | 278 | ||
278 | void PlayListWidget::addAllVideoToList() { | 279 | void PlayListWidget::addAllVideoToList() { |
279 | QListIterator<DocLnk> dit( vFiles.children() ); | 280 | QListIterator<DocLnk> dit( vFiles.children() ); |
280 | for ( ; dit.current(); ++dit ) { | 281 | for ( ; dit.current(); ++dit ) { |
281 | if( QFileInfo( dit.current()->file() ).exists() ) { | 282 | if( QFileInfo( dit.current()->file() ).exists() ) { |
282 | d->selectedFiles->addToSelection( **dit ); | 283 | d->selectedFiles->addToSelection( **dit ); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | } | 286 | } |
286 | 287 | ||
287 | 288 | ||
288 | void PlayListWidget::setDocument( const QString& fileref ) { | 289 | void PlayListWidget::setDocument( const QString& fileref ) { |
289 | //qDebug( fileref ); | 290 | //qDebug( fileref ); |
290 | fromSetDocument = TRUE; | 291 | fromSetDocument = TRUE; |
291 | if ( fileref.isNull() ) { | 292 | if ( fileref.isNull() ) { |
292 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 293 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
293 | return; | 294 | return; |
294 | } | 295 | } |
295 | 296 | ||
296 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 297 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
297 | readm3u( fileref ); | 298 | readm3u( fileref ); |
298 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 299 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
299 | readPls( fileref ); | 300 | readPls( fileref ); |
300 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist | 301 | } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist |
301 | clearList(); | 302 | clearList(); |
302 | loadList( DocLnk( fileref ) ); | 303 | loadList( DocLnk( fileref ) ); |
303 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
304 | } else { | 305 | } else { |
305 | clearList(); | 306 | clearList(); |
306 | addToSelection( DocLnk( fileref ) ); | 307 | addToSelection( DocLnk( fileref ) ); |
307 | d->setDocumentUsed = TRUE; | 308 | d->setDocumentUsed = TRUE; |
308 | mediaPlayerState->setPlaying( FALSE ); | 309 | mediaPlayerState->setPlaying( FALSE ); |
309 | qApp->processEvents(); | 310 | qApp->processEvents(); |
310 | mediaPlayerState->setPlaying( TRUE ); | 311 | mediaPlayerState->setPlaying( TRUE ); |
311 | qApp->processEvents(); | 312 | qApp->processEvents(); |
312 | setCaption( tr("OpiePlayer") ); | 313 | setCaption( tr("OpiePlayer") ); |
313 | } | 314 | } |
314 | } | 315 | } |
315 | 316 | ||
316 | 317 | ||
317 | void PlayListWidget::useSelectedDocument() { | 318 | void PlayListWidget::useSelectedDocument() { |
318 | d->setDocumentUsed = FALSE; | 319 | d->setDocumentUsed = FALSE; |
319 | } | 320 | } |
320 | 321 | ||
321 | 322 | ||
322 | const DocLnk *PlayListWidget::current() { // this is fugly | 323 | const DocLnk *PlayListWidget::current() { // this is fugly |
323 | switch ( tabWidget->currentPageIndex() ) { | 324 | switch ( tabWidget->currentPageIndex() ) { |
324 | case 0: //playlist | 325 | case 0: //playlist |
325 | { | 326 | { |
326 | // qDebug("playlist"); | 327 | // qDebug("playlist"); |
327 | if ( mediaPlayerState->playlist() ) { | 328 | if ( mediaPlayerState->playlist() ) { |
328 | return d->selectedFiles->current(); | 329 | return d->selectedFiles->current(); |
329 | } else if ( d->setDocumentUsed && d->current ) { | 330 | } else if ( d->setDocumentUsed && d->current ) { |
330 | return d->current; | 331 | return d->current; |
331 | } else { | 332 | } else { |
332 | return d->files->selected(); | 333 | return d->files->selected(); |
333 | } | 334 | } |
334 | } | 335 | } |
335 | break; | 336 | break; |
336 | case 1://audio | 337 | case 1://audio |
337 | { | 338 | { |
338 | // qDebug("audioView"); | 339 | // qDebug("audioView"); |
339 | QListIterator<DocLnk> dit( files.children() ); | 340 | QListIterator<DocLnk> dit( files.children() ); |
340 | for ( ; dit.current(); ++dit ) { | 341 | for ( ; dit.current(); ++dit ) { |
341 | if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { | 342 | if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { |
342 | insanityBool = TRUE; | 343 | insanityBool = TRUE; |
343 | return dit; | 344 | return dit; |
344 | } | 345 | } |
345 | } | 346 | } |
346 | } | 347 | } |
347 | break; | 348 | break; |
348 | case 2: // video | 349 | case 2: // video |
349 | { | 350 | { |
350 | // qDebug("videoView"); | 351 | // qDebug("videoView"); |
351 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 352 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
352 | for ( ; Vdit.current(); ++Vdit ) { | 353 | for ( ; Vdit.current(); ++Vdit ) { |
353 | if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { | 354 | if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { |
354 | insanityBool = TRUE; | 355 | insanityBool = TRUE; |
355 | return Vdit; | 356 | return Vdit; |
356 | } | 357 | } |
357 | } | 358 | } |
358 | } | 359 | } |
359 | break; | 360 | break; |
360 | }; | 361 | }; |
361 | return 0; | 362 | return 0; |
362 | } | 363 | } |
363 | 364 | ||
364 | 365 | ||
365 | bool PlayListWidget::prev() { | 366 | bool PlayListWidget::prev() { |
366 | if ( mediaPlayerState->playlist() ) { | 367 | if ( mediaPlayerState->playlist() ) { |
367 | if ( mediaPlayerState->shuffled() ) { | 368 | if ( mediaPlayerState->shuffled() ) { |
368 | const DocLnk *cur = current(); | 369 | const DocLnk *cur = current(); |
369 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 370 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
370 | for ( int i = 0; i < j; i++ ) { | 371 | for ( int i = 0; i < j; i++ ) { |
371 | if ( !d->selectedFiles->next() ) | 372 | if ( !d->selectedFiles->next() ) |
372 | d->selectedFiles->first(); | 373 | d->selectedFiles->first(); |
373 | } | 374 | } |
374 | if ( cur == current() ) | 375 | if ( cur == current() ) |
375 | if ( !d->selectedFiles->next() ) { | 376 | if ( !d->selectedFiles->next() ) { |
376 | d->selectedFiles->first(); | 377 | d->selectedFiles->first(); |
377 | } | 378 | } |
378 | return TRUE; | 379 | return TRUE; |
379 | } else { | 380 | } else { |
380 | if ( !d->selectedFiles->prev() ) { | 381 | if ( !d->selectedFiles->prev() ) { |
381 | if ( mediaPlayerState->looping() ) { | 382 | if ( mediaPlayerState->looping() ) { |
382 | return d->selectedFiles->last(); | 383 | return d->selectedFiles->last(); |
383 | } else { | 384 | } else { |
384 | return FALSE; | 385 | return FALSE; |
385 | } | 386 | } |
386 | } | 387 | } |
387 | return TRUE; | 388 | return TRUE; |
388 | } | 389 | } |
389 | } else { | 390 | } else { |
390 | return mediaPlayerState->looping(); | 391 | return mediaPlayerState->looping(); |
391 | } | 392 | } |
392 | } | 393 | } |
393 | 394 | ||
394 | 395 | ||
395 | bool PlayListWidget::next() { | 396 | bool PlayListWidget::next() { |
396 | if ( mediaPlayerState->playlist() ) { | 397 | if ( mediaPlayerState->playlist() ) { |
397 | if ( mediaPlayerState->shuffled() ) { | 398 | if ( mediaPlayerState->shuffled() ) { |
398 | return prev(); | 399 | return prev(); |
399 | } else { | 400 | } else { |
400 | if ( !d->selectedFiles->next() ) { | 401 | if ( !d->selectedFiles->next() ) { |
401 | if ( mediaPlayerState->looping() ) { | 402 | if ( mediaPlayerState->looping() ) { |
402 | return d->selectedFiles->first(); | 403 | return d->selectedFiles->first(); |
403 | } else { | 404 | } else { |
404 | return FALSE; | 405 | return FALSE; |
405 | } | 406 | } |
406 | } | 407 | } |
407 | return TRUE; | 408 | return TRUE; |
408 | } | 409 | } |
409 | } else { | 410 | } else { |
410 | return mediaPlayerState->looping(); | 411 | return mediaPlayerState->looping(); |
411 | } | 412 | } |
412 | } | 413 | } |
413 | 414 | ||
414 | 415 | ||
415 | bool PlayListWidget::first() { | 416 | bool PlayListWidget::first() { |
416 | if ( mediaPlayerState->playlist() ) | 417 | if ( mediaPlayerState->playlist() ) |
417 | return d->selectedFiles->first(); | 418 | return d->selectedFiles->first(); |
418 | else | 419 | else |
419 | return mediaPlayerState->looping(); | 420 | return mediaPlayerState->looping(); |
420 | } | 421 | } |
421 | 422 | ||
422 | 423 | ||
423 | bool PlayListWidget::last() { | 424 | bool PlayListWidget::last() { |
424 | if ( mediaPlayerState->playlist() ) | 425 | if ( mediaPlayerState->playlist() ) |
425 | return d->selectedFiles->last(); | 426 | return d->selectedFiles->last(); |
426 | else | 427 | else |
427 | return mediaPlayerState->looping(); | 428 | return mediaPlayerState->looping(); |
428 | } | 429 | } |
429 | 430 | ||
430 | 431 | ||
431 | void PlayListWidget::saveList() { | 432 | void PlayListWidget::saveList() { |
432 | 433 | ||
433 | QString filename; | 434 | QString filename; |
434 | InputDialog *fileDlg = 0l; | 435 | InputDialog *fileDlg = 0l; |
435 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 436 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
436 | fileDlg->exec(); | 437 | fileDlg->exec(); |
437 | if( fileDlg->result() == 1 ) { | 438 | if( fileDlg->result() == 1 ) { |
438 | if ( d->current ) | 439 | if ( d->current ) |
439 | delete d->current; | 440 | delete d->current; |
440 | filename = fileDlg->text();//+".playlist"; | 441 | filename = fileDlg->text();//+".playlist"; |
441 | // qDebug("saving playlist "+filename+".playlist"); | 442 | // qDebug("saving playlist "+filename+".playlist"); |
442 | Config cfg( filename +".playlist"); | 443 | Config cfg( filename +".playlist"); |
443 | writeConfig( cfg ); | 444 | writeConfig( cfg ); |
444 | 445 | ||
445 | DocLnk lnk; | 446 | DocLnk lnk; |
446 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 447 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
447 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 448 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
448 | lnk.setIcon("opieplayer2/playlist2"); | 449 | lnk.setIcon("opieplayer2/playlist2"); |
449 | lnk.setName( filename); //sets file name | 450 | lnk.setName( filename); //sets file name |
450 | // qDebug(filename); | 451 | // qDebug(filename); |
451 | if(!lnk.writeLink()) { | 452 | if(!lnk.writeLink()) { |
452 | qDebug("Writing doclink did not work"); | 453 | qDebug("Writing doclink did not work"); |
453 | } | 454 | } |
454 | } | 455 | } |
455 | Config config( "OpiePlayer" ); | 456 | Config config( "OpiePlayer" ); |
456 | config.writeEntry("CurrentPlaylist",filename); | 457 | config.writeEntry("CurrentPlaylist",filename); |
457 | setCaption(tr("OpiePlayer: ")+filename); | 458 | setCaption(tr("OpiePlayer: ")+filename); |
458 | d->selectedFiles->first(); | 459 | d->selectedFiles->first(); |
459 | if(fileDlg) { | 460 | if(fileDlg) { |
460 | delete fileDlg; | 461 | delete fileDlg; |
461 | } | 462 | } |
462 | } | 463 | } |
463 | 464 | ||
464 | void PlayListWidget::loadList( const DocLnk & lnk) { | 465 | void PlayListWidget::loadList( const DocLnk & lnk) { |
465 | QString name= lnk.name(); | 466 | QString name= lnk.name(); |
466 | // qDebug("currentList is "+name); | 467 | // qDebug("currentList is "+name); |
467 | if( name.length()>1) { | 468 | if( name.length()>1) { |
468 | setCaption("OpiePlayer: "+name); | 469 | setCaption("OpiePlayer: "+name); |
469 | // qDebug("load list "+ name+".playlist"); | 470 | // qDebug("load list "+ name+".playlist"); |
470 | clearList(); | 471 | clearList(); |
471 | Config cfg( name+".playlist"); | 472 | Config cfg( name+".playlist"); |
472 | readConfig(cfg); | 473 | readConfig(cfg); |
473 | 474 | ||
474 | tabWidget->setCurrentPage(0); | 475 | tabWidget->setCurrentPage(0); |
475 | 476 | ||
476 | Config config( "OpiePlayer" ); | 477 | Config config( "OpiePlayer" ); |
477 | config.writeEntry("CurrentPlaylist", name); | 478 | config.writeEntry("CurrentPlaylist", name); |
478 | // d->selectedFiles->first(); | 479 | // d->selectedFiles->first(); |
479 | } | 480 | } |
480 | } | 481 | } |
481 | 482 | ||
482 | 483 | ||
483 | void PlayListWidget::setPlaylist( bool shown ) { | 484 | void PlayListWidget::setPlaylist( bool shown ) { |
484 | if ( shown ) { | 485 | if ( shown ) { |
485 | d->playListFrame->show(); | 486 | d->playListFrame->show(); |
486 | } else { | 487 | } else { |
487 | d->playListFrame->hide(); | 488 | d->playListFrame->hide(); |
488 | } | 489 | } |
489 | } | 490 | } |
490 | 491 | ||
491 | 492 | ||
492 | void PlayListWidget::addSelected() { | 493 | void PlayListWidget::addSelected() { |
493 | 494 | ||
494 | Config cfg( "OpiePlayer" ); | 495 | Config cfg( "OpiePlayer" ); |
495 | cfg.setGroup("PlayList"); | 496 | cfg.setGroup("PlayList"); |
496 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 497 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
497 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 498 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
498 | 499 | ||
499 | switch (tabWidget->currentPageIndex()) { | 500 | switch (tabWidget->currentPageIndex()) { |
500 | case 0: //playlist | 501 | case 0: //playlist |
501 | break; | 502 | break; |
502 | case 1: { //audio | 503 | case 1: { //audio |
503 | QListViewItemIterator it( audioView ); | 504 | QListViewItemIterator it( audioView ); |
504 | // iterate through all items of the listview | 505 | // iterate through all items of the listview |
505 | for ( ; it.current(); ++it ) { | 506 | for ( ; it.current(); ++it ) { |
506 | if ( it.current()->isSelected() ) { | 507 | if ( it.current()->isSelected() ) { |
507 | QListIterator<DocLnk> dit( files.children() ); | 508 | QListIterator<DocLnk> dit( files.children() ); |
508 | for ( ; dit.current(); ++dit ) { | 509 | for ( ; dit.current(); ++dit ) { |
509 | if( dit.current()->name() == it.current()->text(0) ) { | 510 | if( dit.current()->name() == it.current()->text(0) ) { |
510 | if(QFileInfo( dit.current()->file()).exists()) | 511 | if(QFileInfo( dit.current()->file()).exists()) |
511 | d->selectedFiles->addToSelection( **dit ); | 512 | d->selectedFiles->addToSelection( **dit ); |
512 | } | 513 | } |
513 | } | 514 | } |
514 | audioView->setSelected( it.current(),FALSE); | 515 | audioView->setSelected( it.current(),FALSE); |
515 | } | 516 | } |
516 | } | 517 | } |
517 | tabWidget->setCurrentPage(0); | 518 | tabWidget->setCurrentPage(0); |
518 | } | 519 | } |
519 | break; | 520 | break; |
520 | case 2: { // video | 521 | case 2: { // video |
521 | QListViewItemIterator it( videoView ); | 522 | QListViewItemIterator it( videoView ); |
522 | // iterate through all items of the listview | 523 | // iterate through all items of the listview |
523 | for ( ; it.current(); ++it ) { | 524 | for ( ; it.current(); ++it ) { |
524 | if ( it.current()->isSelected() ) { | 525 | if ( it.current()->isSelected() ) { |
525 | QListIterator<DocLnk> dit( vFiles.children() ); | 526 | QListIterator<DocLnk> dit( vFiles.children() ); |
526 | for ( ; dit.current(); ++dit ) { | 527 | for ( ; dit.current(); ++dit ) { |
527 | if( dit.current()->name() == it.current()->text(0) ) { | 528 | if( dit.current()->name() == it.current()->text(0) ) { |
528 | if(QFileInfo( dit.current()->file()).exists()) | 529 | if(QFileInfo( dit.current()->file()).exists()) |
529 | d->selectedFiles->addToSelection( **dit ); | 530 | d->selectedFiles->addToSelection( **dit ); |
530 | } | 531 | } |
531 | } | 532 | } |
532 | videoView->setSelected( it.current(),FALSE); | 533 | videoView->setSelected( it.current(),FALSE); |
533 | } | 534 | } |
534 | } | 535 | } |
535 | tabWidget->setCurrentPage(0); | 536 | tabWidget->setCurrentPage(0); |
536 | } | 537 | } |
537 | break; | 538 | break; |
538 | }; | 539 | }; |
539 | } | 540 | } |
540 | 541 | ||
541 | 542 | ||
542 | void PlayListWidget::removeSelected() { | 543 | void PlayListWidget::removeSelected() { |
543 | d->selectedFiles->removeSelected( ); | 544 | d->selectedFiles->removeSelected( ); |
544 | } | 545 | } |
545 | 546 | ||
546 | 547 | ||
547 | void PlayListWidget::playIt( QListViewItem *it) { | 548 | void PlayListWidget::playIt( QListViewItem *it) { |
548 | if(!it) return; | 549 | if(!it) return; |
549 | mediaPlayerState->setPlaying(FALSE); | 550 | mediaPlayerState->setPlaying(FALSE); |
550 | mediaPlayerState->setPlaying(TRUE); | 551 | mediaPlayerState->setPlaying(TRUE); |
551 | d->selectedFiles->unSelect(); | 552 | d->selectedFiles->unSelect(); |
552 | } | 553 | } |
553 | 554 | ||
554 | 555 | ||
555 | void PlayListWidget::addToSelection( QListViewItem *it) { | 556 | void PlayListWidget::addToSelection( QListViewItem *it) { |
556 | d->setDocumentUsed = FALSE; | 557 | d->setDocumentUsed = FALSE; |
557 | 558 | ||
558 | if(it) { | 559 | if(it) { |
559 | switch (tabWidget->currentPageIndex()) { | 560 | switch (tabWidget->currentPageIndex()) { |
560 | case 1: { | 561 | case 1: { |
561 | QListIterator<DocLnk> dit( files.children() ); | 562 | QListIterator<DocLnk> dit( files.children() ); |
562 | for ( ; dit.current(); ++dit ) { | 563 | for ( ; dit.current(); ++dit ) { |
563 | if( dit.current()->name() == it->text(0)) { | 564 | if( dit.current()->name() == it->text(0)) { |
564 | if(QFileInfo( dit.current()->file()).exists()) | 565 | if(QFileInfo( dit.current()->file()).exists()) |
565 | d->selectedFiles->addToSelection( **dit ); | 566 | d->selectedFiles->addToSelection( **dit ); |
566 | } | 567 | } |
567 | } | 568 | } |
568 | } | 569 | } |
569 | break; | 570 | break; |
570 | case 2: { | 571 | case 2: { |
571 | QListIterator<DocLnk> dit( vFiles.children() ); | 572 | QListIterator<DocLnk> dit( vFiles.children() ); |
572 | for ( ; dit.current(); ++dit ) { | 573 | for ( ; dit.current(); ++dit ) { |
573 | if( dit.current()->name() == it->text(0)) { | 574 | if( dit.current()->name() == it->text(0)) { |
574 | if(QFileInfo( dit.current()->file()).exists()) | 575 | if(QFileInfo( dit.current()->file()).exists()) |
575 | d->selectedFiles->addToSelection( **dit ); | 576 | d->selectedFiles->addToSelection( **dit ); |
576 | } | 577 | } |
577 | } | 578 | } |
578 | } | 579 | } |
579 | break; | 580 | break; |
580 | case 0: | 581 | case 0: |
581 | break; | 582 | break; |
582 | }; | 583 | }; |
583 | tabWidget->setCurrentPage(0); | 584 | tabWidget->setCurrentPage(0); |
584 | } | 585 | } |
585 | } | 586 | } |
586 | 587 | ||
587 | 588 | ||
588 | void PlayListWidget::tabChanged(QWidget *) { | 589 | void PlayListWidget::tabChanged(QWidget *) { |
589 | 590 | ||
590 | switch ( tabWidget->currentPageIndex()) { | 591 | switch ( tabWidget->currentPageIndex()) { |
591 | case 0: | 592 | case 0: |
592 | { | 593 | { |
593 | if( !tbDeletePlaylist->isHidden() ) { | 594 | if( !tbDeletePlaylist->isHidden() ) { |
594 | tbDeletePlaylist->hide(); | 595 | tbDeletePlaylist->hide(); |
595 | } | 596 | } |
596 | d->tbRemoveFromList->setEnabled(TRUE); | 597 | d->tbRemoveFromList->setEnabled(TRUE); |
597 | d->tbAddToList->setEnabled(FALSE); | 598 | d->tbAddToList->setEnabled(FALSE); |
598 | } | 599 | } |
599 | break; | 600 | break; |
600 | case 1: | 601 | case 1: |
601 | { | 602 | { |
602 | audioView->clear(); | 603 | audioView->clear(); |
603 | populateAudioView(); | 604 | populateAudioView(); |
604 | 605 | ||
605 | if( !tbDeletePlaylist->isHidden() ) { | 606 | if( !tbDeletePlaylist->isHidden() ) { |
606 | tbDeletePlaylist->hide(); | 607 | tbDeletePlaylist->hide(); |
607 | } | 608 | } |
608 | d->tbRemoveFromList->setEnabled(FALSE); | 609 | d->tbRemoveFromList->setEnabled(FALSE); |
609 | d->tbAddToList->setEnabled(TRUE); | 610 | d->tbAddToList->setEnabled(TRUE); |
610 | } | 611 | } |
611 | break; | 612 | break; |
612 | case 2: | 613 | case 2: |
613 | { | 614 | { |
614 | videoView->clear(); | 615 | videoView->clear(); |
615 | populateVideoView(); | 616 | populateVideoView(); |
616 | if( !tbDeletePlaylist->isHidden() ) { | 617 | if( !tbDeletePlaylist->isHidden() ) { |
617 | tbDeletePlaylist->hide(); | 618 | tbDeletePlaylist->hide(); |
618 | } | 619 | } |
619 | d->tbRemoveFromList->setEnabled(FALSE); | 620 | d->tbRemoveFromList->setEnabled(FALSE); |
620 | d->tbAddToList->setEnabled(TRUE); | 621 | d->tbAddToList->setEnabled(TRUE); |
621 | } | 622 | } |
622 | break; | 623 | break; |
623 | case 3: | 624 | case 3: |
624 | { | 625 | { |
625 | if( tbDeletePlaylist->isHidden() ) { | 626 | if( tbDeletePlaylist->isHidden() ) { |
626 | tbDeletePlaylist->show(); | 627 | tbDeletePlaylist->show(); |
627 | } | 628 | } |
628 | playLists->reread(); | 629 | playLists->reread(); |
629 | } | 630 | } |
630 | break; | 631 | break; |
631 | }; | 632 | }; |
632 | } | 633 | } |
633 | 634 | ||
634 | 635 | ||
635 | void PlayListWidget::btnPlay(bool b) { | 636 | void PlayListWidget::btnPlay(bool b) { |
636 | // mediaPlayerState->setPlaying(b); | 637 | // mediaPlayerState->setPlaying(b); |
637 | switch ( tabWidget->currentPageIndex()) { | 638 | switch ( tabWidget->currentPageIndex()) { |
638 | case 0: | 639 | case 0: |
639 | { | 640 | { |
640 | mediaPlayerState->setPlaying(b); | 641 | mediaPlayerState->setPlaying(b); |
641 | } | 642 | } |
642 | break; | 643 | break; |
643 | case 1: | 644 | case 1: |
644 | { | 645 | { |
645 | addToSelection( audioView->currentItem() ); | 646 | addToSelection( audioView->currentItem() ); |
646 | mediaPlayerState->setPlaying(b); | 647 | mediaPlayerState->setPlaying(b); |
647 | d->selectedFiles->removeSelected( ); | 648 | d->selectedFiles->removeSelected( ); |
648 | tabWidget->setCurrentPage(1); | 649 | tabWidget->setCurrentPage(1); |
649 | d->selectedFiles->unSelect(); | 650 | d->selectedFiles->unSelect(); |
650 | insanityBool=FALSE; | 651 | insanityBool=FALSE; |
651 | }// audioView->clearSelection(); | 652 | }// audioView->clearSelection(); |
652 | break; | 653 | break; |
653 | case 2: | 654 | case 2: |
654 | { | 655 | { |
655 | addToSelection( videoView->currentItem() ); | 656 | addToSelection( videoView->currentItem() ); |
656 | mediaPlayerState->setPlaying(b); | 657 | mediaPlayerState->setPlaying(b); |
657 | qApp->processEvents(); | 658 | qApp->processEvents(); |
658 | d->selectedFiles->removeSelected( ); | 659 | d->selectedFiles->removeSelected( ); |
659 | tabWidget->setCurrentPage(2); | 660 | tabWidget->setCurrentPage(2); |
660 | d->selectedFiles->unSelect(); | 661 | d->selectedFiles->unSelect(); |
661 | insanityBool=FALSE; | 662 | insanityBool=FALSE; |
662 | }// videoView->clearSelection(); | 663 | }// videoView->clearSelection(); |
663 | break; | 664 | break; |
664 | }; | 665 | }; |
665 | 666 | ||
666 | } | 667 | } |
667 | 668 | ||
668 | void PlayListWidget::deletePlaylist() { | 669 | void PlayListWidget::deletePlaylist() { |
669 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 670 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
670 | (tr("You really want to delete\nthis playlist?")), | 671 | (tr("You really want to delete\nthis playlist?")), |
671 | (tr("Yes")), (tr("No")), 0 )){ | 672 | (tr("Yes")), (tr("No")), 0 )){ |
672 | case 0: // Yes clicked, | 673 | case 0: // Yes clicked, |
673 | QFile().remove(playLists->selected()->file()); | 674 | QFile().remove(playLists->selected()->file()); |
674 | QFile().remove(playLists->selected()->linkFile()); | 675 | QFile().remove(playLists->selected()->linkFile()); |
675 | playLists->reread(); | 676 | playLists->reread(); |
676 | break; | 677 | break; |
677 | case 1: // Cancel | 678 | case 1: // Cancel |
678 | break; | 679 | break; |
679 | }; | 680 | }; |
680 | } | 681 | } |
681 | 682 | ||
682 | 683 | ||
683 | void PlayListWidget::playSelected() { | 684 | void PlayListWidget::playSelected() { |
684 | btnPlay( TRUE); | 685 | btnPlay( TRUE); |
685 | } | 686 | } |
686 | 687 | ||
687 | 688 | ||
688 | void PlayListWidget::scanForAudio() { | 689 | void PlayListWidget::scanForAudio() { |
689 | // qDebug("scan for audio"); | 690 | // qDebug("scan for audio"); |
690 | files.detachChildren(); | 691 | files.detachChildren(); |
691 | QListIterator<DocLnk> sdit( files.children() ); | 692 | QListIterator<DocLnk> sdit( files.children() ); |
692 | for ( ; sdit.current(); ++sdit ) { | 693 | for ( ; sdit.current(); ++sdit ) { |
693 | delete sdit.current(); | 694 | delete sdit.current(); |
694 | } | 695 | } |
695 | Global::findDocuments(&files, "audio/*"); | 696 | Global::findDocuments(&files, "audio/*"); |
696 | audioScan = TRUE; | 697 | audioScan = TRUE; |
697 | } | 698 | } |
698 | 699 | ||
699 | void PlayListWidget::scanForVideo() { | 700 | void PlayListWidget::scanForVideo() { |
700 | // qDebug("scan for video"); | 701 | // qDebug("scan for video"); |
701 | vFiles.detachChildren(); | 702 | vFiles.detachChildren(); |
702 | QListIterator<DocLnk> sdit( vFiles.children() ); | 703 | QListIterator<DocLnk> sdit( vFiles.children() ); |
703 | for ( ; sdit.current(); ++sdit ) { | 704 | for ( ; sdit.current(); ++sdit ) { |
704 | delete sdit.current(); | 705 | delete sdit.current(); |
705 | } | 706 | } |
706 | Global::findDocuments(&vFiles, "video/*"); | 707 | Global::findDocuments(&vFiles, "video/*"); |
707 | videoScan = TRUE; | 708 | videoScan = TRUE; |
708 | } | 709 | } |
709 | 710 | ||
710 | void PlayListWidget::populateAudioView() { | 711 | void PlayListWidget::populateAudioView() { |
711 | audioView->clear(); | 712 | audioView->clear(); |
712 | StorageInfo storageInfo; | 713 | StorageInfo storageInfo; |
713 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 714 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
714 | if(!audioScan) { | 715 | if(!audioScan) { |
715 | scanForAudio(); | 716 | scanForAudio(); |
716 | } | 717 | } |
717 | 718 | ||
718 | QListIterator<DocLnk> dit( files.children() ); | 719 | QListIterator<DocLnk> dit( files.children() ); |
719 | QListIterator<FileSystem> it ( fs ); | 720 | QListIterator<FileSystem> it ( fs ); |
720 | 721 | ||
721 | QString storage; | 722 | QString storage; |
722 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
723 | for( ; it.current(); ++it ){ | 724 | for( ; it.current(); ++it ){ |
724 | const QString name = (*it)->name(); | 725 | const QString name = (*it)->name(); |
725 | const QString path = (*it)->path(); | 726 | const QString path = (*it)->path(); |
726 | if(dit.current()->file().find(path) != -1 ) { | 727 | if(dit.current()->file().find(path) != -1 ) { |
727 | storage = name; | 728 | storage = name; |
728 | } | 729 | } |
729 | } | 730 | } |
730 | 731 | ||
731 | QListViewItem * newItem; | 732 | QListViewItem * newItem; |
732 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 733 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
733 | long size; | 734 | long size; |
734 | if( dit.current()->file().left(4) == "http" ) | 735 | if( dit.current()->file().left(4) == "http" ) |
735 | size=0; | 736 | size=0; |
736 | else | 737 | else |
737 | size = QFile( dit.current()->file() ).size(); | 738 | size = QFile( dit.current()->file() ).size(); |
738 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage); | 739 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage); |
739 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 740 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
740 | } | 741 | } |
741 | } | 742 | } |
742 | } | 743 | } |
743 | 744 | ||
744 | 745 | ||
745 | void PlayListWidget::populateVideoView() { | 746 | void PlayListWidget::populateVideoView() { |
746 | videoView->clear(); | 747 | videoView->clear(); |
747 | StorageInfo storageInfo; | 748 | StorageInfo storageInfo; |
748 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 749 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
749 | 750 | ||
750 | if(!videoScan ) { | 751 | if(!videoScan ) { |
751 | scanForVideo(); | 752 | scanForVideo(); |
752 | } | 753 | } |
753 | 754 | ||
754 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 755 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
755 | QListIterator<FileSystem> it ( fs ); | 756 | QListIterator<FileSystem> it ( fs ); |
756 | videoView->clear(); | 757 | videoView->clear(); |
757 | QString storage; | 758 | QString storage; |
758 | for ( ; Vdit.current(); ++Vdit ) { | 759 | for ( ; Vdit.current(); ++Vdit ) { |
759 | for( ; it.current(); ++it ) { | 760 | for( ; it.current(); ++it ) { |
760 | const QString name = (*it)->name(); | 761 | const QString name = (*it)->name(); |
761 | const QString path = (*it)->path(); | 762 | const QString path = (*it)->path(); |
762 | if( Vdit.current()->file().find(path) != -1 ) { | 763 | if( Vdit.current()->file().find(path) != -1 ) { |
763 | storage=name; | 764 | storage=name; |
764 | } | 765 | } |
765 | } | 766 | } |
766 | 767 | ||
767 | QListViewItem * newItem; | 768 | QListViewItem * newItem; |
768 | if ( QFile( Vdit.current()->file() ).exists() ) { | 769 | if ( QFile( Vdit.current()->file() ).exists() ) { |
769 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 770 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
770 | QString::number( QFile( Vdit.current()->file() ).size() ), storage ); | 771 | QString::number( QFile( Vdit.current()->file() ).size() ), storage ); |
771 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 772 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
772 | } | 773 | } |
773 | } | 774 | } |
774 | } | 775 | } |
775 | 776 | ||
776 | 777 | ||
777 | void PlayListWidget::openFile() { | 778 | void PlayListWidget::openFile() { |
778 | QString filename, name; | 779 | QString filename, name; |
779 | InputDialog *fileDlg; | 780 | InputDialog *fileDlg; |
780 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 781 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
781 | fileDlg->exec(); | 782 | fileDlg->exec(); |
782 | if( fileDlg->result() == 1 ) { | 783 | if( fileDlg->result() == 1 ) { |
783 | filename = fileDlg->text(); | 784 | filename = fileDlg->text(); |
784 | 785 | ||
785 | qDebug( "Selected filename is " + filename ); | 786 | qDebug( "Selected filename is " + filename ); |
786 | if( filename.right( 3 ) == "m3u" ) { | 787 | if( filename.right( 3 ) == "m3u" ) { |
787 | readm3u( filename ); | 788 | readm3u( filename ); |
788 | } else if( filename.right(3) == "pls" ) { | 789 | } else if( filename.right(3) == "pls" ) { |
789 | readPls( filename ); | 790 | readPls( filename ); |
790 | } else { | 791 | } else { |
791 | // this doesnt need fixing | 792 | // this doesnt need fixing |
792 | DocLnk lnk; | 793 | DocLnk lnk; |
793 | lnk.setName( filename ); //sets file name | 794 | lnk.setName( filename ); //sets file name |
794 | lnk.setFile( filename ); //sets File property | 795 | lnk.setFile( filename ); //sets File property |
795 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); | 796 | //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); |
796 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); | 797 | lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); |
797 | lnk.setExec( "opieplayer" ); | 798 | lnk.setExec( "opieplayer" ); |
798 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); | 799 | lnk.setIcon( "opieplayer2/MPEGPlayer" ); |
799 | 800 | ||
800 | if( !lnk.writeLink() ) { | 801 | if( !lnk.writeLink() ) { |
801 | qDebug( "Writing doclink did not work" ); | 802 | qDebug( "Writing doclink did not work" ); |
802 | } | 803 | } |
803 | d->selectedFiles->addToSelection( lnk ); | 804 | d->selectedFiles->addToSelection( lnk ); |
804 | } | 805 | } |
805 | } | 806 | } |
806 | if( fileDlg ) { | 807 | if( fileDlg ) { |
807 | delete fileDlg; | 808 | delete fileDlg; |
808 | } | 809 | } |
809 | } | 810 | } |
810 | 811 | ||
811 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 812 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
812 | switch ( e->key() ) { | 813 | switch ( e->key() ) { |
813 | ////////////////////////////// Zaurus keys | 814 | ////////////////////////////// Zaurus keys |
814 | case Key_F9: //activity | 815 | case Key_F9: //activity |
815 | // if(audioUI->isHidden()) | 816 | // if(audioUI->isHidden()) |
816 | // audioUI->showMaximized(); | 817 | // audioUI->showMaximized(); |
817 | break; | 818 | break; |
818 | case Key_F10: //contacts | 819 | case Key_F10: //contacts |
819 | // if( videoUI->isHidden()) | 820 | // if( videoUI->isHidden()) |
820 | // videoUI->showMaximized(); | 821 | // videoUI->showMaximized(); |
821 | break; | 822 | break; |
822 | case Key_F11: //menu | 823 | case Key_F11: //menu |
823 | break; | 824 | break; |
824 | case Key_F12: //home | 825 | case Key_F12: //home |
825 | // doBlank(); | 826 | // doBlank(); |
826 | break; | 827 | break; |
827 | case Key_F13: //mail | 828 | case Key_F13: //mail |
828 | // doUnblank(); | 829 | // doUnblank(); |
829 | break; | 830 | break; |
830 | case Key_Q: //add to playlist | 831 | case Key_Q: //add to playlist |
831 | addSelected(); | 832 | addSelected(); |
832 | break; | 833 | break; |
833 | case Key_R: //remove from playlist | 834 | case Key_R: //remove from playlist |
834 | removeSelected(); | 835 | removeSelected(); |
835 | break; | 836 | break; |
836 | // case Key_P: //play | 837 | // case Key_P: //play |
837 | // qDebug("Play"); | 838 | // qDebug("Play"); |
838 | // playSelected(); | 839 | // playSelected(); |
839 | // break; | 840 | // break; |
840 | case Key_Space: | 841 | case Key_Space: |
841 | // playSelected(); puh | 842 | // playSelected(); puh |
842 | break; | 843 | break; |
843 | case Key_1: | 844 | case Key_1: |
844 | tabWidget->setCurrentPage( 0 ); | 845 | tabWidget->setCurrentPage( 0 ); |
845 | break; | 846 | break; |
846 | case Key_2: | 847 | case Key_2: |
847 | tabWidget->setCurrentPage( 1 ); | 848 | tabWidget->setCurrentPage( 1 ); |
848 | break; | 849 | break; |
849 | case Key_3: | 850 | case Key_3: |
850 | tabWidget->setCurrentPage( 2 ); | 851 | tabWidget->setCurrentPage( 2 ); |
851 | break; | 852 | break; |
852 | case Key_4: | 853 | case Key_4: |
853 | tabWidget->setCurrentPage( 3 ); | 854 | tabWidget->setCurrentPage( 3 ); |
854 | break; | 855 | break; |
855 | case Key_Down: | 856 | case Key_Down: |
856 | if ( !d->selectedFiles->next() ) | 857 | if ( !d->selectedFiles->next() ) |
857 | d->selectedFiles->first(); | 858 | d->selectedFiles->first(); |
858 | 859 | ||
859 | break; | 860 | break; |
860 | case Key_Up: | 861 | case Key_Up: |
861 | if ( !d->selectedFiles->prev() ) | 862 | if ( !d->selectedFiles->prev() ) |
862 | // d->selectedFiles->last(); | 863 | // d->selectedFiles->last(); |
863 | 864 | ||
864 | break; | 865 | break; |
865 | 866 | ||
866 | } | 867 | } |
867 | } | 868 | } |
868 | 869 | ||
869 | void PlayListWidget::readm3u( const QString &filename ) { | 870 | void PlayListWidget::readm3u( const QString &filename ) { |
870 | qDebug( "m3u filename is " + filename ); | 871 | qDebug( "m3u filename is " + filename ); |
871 | QFile f( filename ); | 872 | QFile f( filename ); |
872 | 873 | ||
873 | if( f.open( IO_ReadOnly ) ) { | 874 | if( f.open( IO_ReadOnly ) ) { |
874 | QTextStream t(&f); | 875 | QTextStream t(&f); |
875 | QString s;//, first, second; | 876 | QString s;//, first, second; |
876 | int i=0; | 877 | int i=0; |
877 | while ( !t.atEnd() ) { | 878 | while ( !t.atEnd() ) { |
878 | s=t.readLine(); | 879 | s=t.readLine(); |
879 | 880 | ||
880 | if( s.find( "#", 0, TRUE) == -1 ) { | 881 | if( s.find( "#", 0, TRUE) == -1 ) { |
881 | if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat | 882 | if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat |
882 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 883 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
883 | s = s.right( s.length() -2 ); | 884 | s = s.right( s.length() -2 ); |
884 | DocLnk lnk( s ); | 885 | DocLnk lnk( s ); |
885 | QFileInfo f( s ); | 886 | QFileInfo f( s ); |
886 | QString name = f.baseName(); | 887 | QString name = f.baseName(); |
887 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 888 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
888 | lnk.setName( name ); | 889 | lnk.setName( name ); |
889 | s=s.replace( QRegExp( "\\" ), "/" ); | 890 | s=s.replace( QRegExp( "\\" ), "/" ); |
890 | lnk.setFile( s ); | 891 | lnk.setFile( s ); |
891 | lnk.writeLink(); | 892 | lnk.writeLink(); |
892 | qDebug( "add " + name); | 893 | qDebug( "add " + name); |
893 | d->selectedFiles->addToSelection( lnk ); | 894 | d->selectedFiles->addToSelection( lnk ); |
894 | } else { // is url | 895 | } else { // is url |
895 | s.replace( QRegExp( "%20" )," " ); | 896 | s.replace( QRegExp( "%20" )," " ); |
896 | DocLnk lnk( s ); | 897 | DocLnk lnk( s ); |
897 | QString name; | 898 | QString name; |
898 | if( name.left( 4 ) == "http" ) { | 899 | if( name.left( 4 ) == "http" ) { |
899 | name = s.right( s.length() - 7 ); | 900 | name = s.right( s.length() - 7 ); |
900 | } else { | 901 | } else { |
901 | name = s; | 902 | name = s; |
902 | } | 903 | } |
903 | lnk.setName( name ); | 904 | lnk.setName( name ); |
904 | if( s.at( s.length() - 4) == '.' ) { | 905 | if( s.at( s.length() - 4) == '.' ) { |
905 | lnk.setFile( s ); | 906 | lnk.setFile( s ); |
906 | } else { | 907 | } else { |
907 | lnk.setFile( s + "/" ); | 908 | lnk.setFile( s + "/" ); |
908 | } | 909 | } |
909 | lnk.setType( "audio/x-mpegurl" ); | 910 | lnk.setType( "audio/x-mpegurl" ); |
910 | lnk.writeLink(); | 911 | lnk.writeLink(); |
911 | d->selectedFiles->addToSelection( lnk ); | 912 | d->selectedFiles->addToSelection( lnk ); |
912 | } | 913 | } |
913 | i++; | 914 | i++; |
914 | } | 915 | } |
915 | } | 916 | } |
916 | } | 917 | } |
917 | } | 918 | } |
918 | f.close(); | 919 | f.close(); |
919 | } | 920 | } |
920 | 921 | ||
921 | void PlayListWidget::writem3u() { | 922 | void PlayListWidget::writem3u() { |
922 | InputDialog *fileDlg; | 923 | InputDialog *fileDlg; |
923 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 924 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
924 | fileDlg->exec(); | 925 | fileDlg->exec(); |
925 | QString filename, list; | 926 | QString filename, list; |
926 | if( fileDlg->result() == 1 ) { | 927 | if( fileDlg->result() == 1 ) { |
927 | filename = fileDlg->text(); | 928 | filename = fileDlg->text(); |
928 | qDebug( filename ); | 929 | qDebug( filename ); |
929 | int noOfFiles = 0; | 930 | int noOfFiles = 0; |
930 | d->selectedFiles->first(); | 931 | d->selectedFiles->first(); |
931 | do { | 932 | do { |
932 | // we dont check for existance because of url's | 933 | // we dont check for existance because of url's |
933 | // qDebug(d->selectedFiles->current()->file()); | 934 | // qDebug(d->selectedFiles->current()->file()); |
934 | 935 | ||
935 | // so maybe we should do some net checking to ,-) | 936 | // so maybe we should do some net checking to ,-) |
936 | // no, cause it takes to long... | 937 | // no, cause it takes to long... |
937 | 938 | ||
938 | list += d->selectedFiles->current()->file() + "\n"; | 939 | list += d->selectedFiles->current()->file() + "\n"; |
939 | noOfFiles++; | 940 | noOfFiles++; |
940 | } | 941 | } |
941 | while ( d->selectedFiles->next() ); | 942 | while ( d->selectedFiles->next() ); |
942 | qDebug( list ); | 943 | qDebug( list ); |
943 | if( filename.left( 1) != "/" ) { | 944 | if( filename.left( 1) != "/" ) { |
944 | filename=QPEApplication::documentDir() + "/" + filename; | 945 | filename=QPEApplication::documentDir() + "/" + filename; |
945 | } | 946 | } |
946 | if( filename.right( 3 ) != "m3u" ) { | 947 | if( filename.right( 3 ) != "m3u" ) { |
947 | filename=filename+".m3u"; | 948 | filename=filename+".m3u"; |
948 | } | 949 | } |
949 | QFile f( filename ); | 950 | QFile f( filename ); |
950 | f.open( IO_WriteOnly ); | 951 | f.open( IO_WriteOnly ); |
951 | f.writeBlock( list, list.length() ); | 952 | f.writeBlock( list, list.length() ); |
952 | f.close(); | 953 | f.close(); |
953 | } | 954 | } |
954 | if( fileDlg ) { | 955 | if( fileDlg ) { |
955 | delete fileDlg; | 956 | delete fileDlg; |
956 | } | 957 | } |
957 | } | 958 | } |
958 | 959 | ||
959 | void PlayListWidget::readPls( const QString &filename ) { | 960 | void PlayListWidget::readPls( const QString &filename ) { |
960 | 961 | ||
961 | qDebug( "pls filename is " + filename ); | 962 | qDebug( "pls filename is " + filename ); |
962 | QFile f( filename ); | 963 | QFile f( filename ); |
963 | 964 | ||
964 | if( f.open( IO_ReadOnly ) ) { | 965 | if( f.open( IO_ReadOnly ) ) { |
965 | QTextStream t( &f ); | 966 | QTextStream t( &f ); |
966 | QString s;//, first, second; | 967 | QString s;//, first, second; |
967 | int i = 0; | 968 | int i = 0; |
968 | while ( !t.atEnd() ) { | 969 | while ( !t.atEnd() ) { |
969 | s = t.readLine(); | 970 | s = t.readLine(); |
970 | if( s.left(4) == "File" ) { | 971 | if( s.left(4) == "File" ) { |
971 | s = s.right( s.length() - 6 ); | 972 | s = s.right( s.length() - 6 ); |
972 | s.replace( QRegExp( "%20" )," "); | 973 | s.replace( QRegExp( "%20" )," "); |
973 | qDebug( "adding " + s + " to playlist" ); | 974 | qDebug( "adding " + s + " to playlist" ); |
974 | // numberofentries=2 | 975 | // numberofentries=2 |
975 | // File1=http | 976 | // File1=http |
976 | // Title | 977 | // Title |
977 | // Length | 978 | // Length |
978 | // Version | 979 | // Version |
979 | // File2=http | 980 | // File2=http |
980 | s = s.replace( QRegExp( "\\" ), "/" ); | 981 | s = s.replace( QRegExp( "\\" ), "/" ); |
981 | DocLnk lnk( s ); | 982 | DocLnk lnk( s ); |
982 | QFileInfo f( s ); | 983 | QFileInfo f( s ); |
983 | QString name = f.baseName(); | 984 | QString name = f.baseName(); |
984 | if( name.left( 4 ) == "http" ) { | 985 | if( name.left( 4 ) == "http" ) { |
985 | name = s.right( s.length() - 7); | 986 | name = s.right( s.length() - 7); |
986 | } else { | 987 | } else { |
987 | name = s; | 988 | name = s; |
988 | } | 989 | } |
989 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 990 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
990 | lnk.setName( name ); | 991 | lnk.setName( name ); |
991 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 992 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
992 | lnk.setFile( s ); | 993 | lnk.setFile( s ); |
993 | else { //if its a url | 994 | else { //if its a url |
994 | if( name.right( 1 ).find( '/' ) == -1) { | 995 | if( name.right( 1 ).find( '/' ) == -1) { |
995 | s += "/"; | 996 | s += "/"; |
996 | } | 997 | } |
997 | lnk.setFile( s ); | 998 | lnk.setFile( s ); |
998 | } | 999 | } |
999 | lnk.setType( "audio/x-mpegurl" ); | 1000 | lnk.setType( "audio/x-mpegurl" ); |
1000 | 1001 | ||
1001 | //qDebug("DocLnk add "+name); | 1002 | //qDebug("DocLnk add "+name); |
1002 | d->selectedFiles->addToSelection( lnk ); | 1003 | d->selectedFiles->addToSelection( lnk ); |
1003 | } | 1004 | } |
1004 | } | 1005 | } |
1005 | i++; | 1006 | i++; |
1006 | } | 1007 | } |
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | void PlayListWidget::pmViewActivated(int index) { | 1010 | void PlayListWidget::pmViewActivated(int index) { |
1010 | // qDebug("%d", index); | 1011 | // qDebug("%d", index); |
1011 | switch(index) { | 1012 | switch(index) { |
1012 | case -16: | 1013 | case -16: |
1013 | { | 1014 | { |
1014 | mediaPlayerState->toggleFullscreen(); | 1015 | mediaPlayerState->toggleFullscreen(); |
1015 | bool b=mediaPlayerState->fullscreen(); | 1016 | bool b=mediaPlayerState->fullscreen(); |
1016 | pmView->setItemChecked( index, b); | 1017 | pmView->setItemChecked( index, b); |
1017 | Config cfg( "OpiePlayer" ); | 1018 | Config cfg( "OpiePlayer" ); |
1018 | cfg.writeEntry( "FullScreen", b ); | 1019 | cfg.writeEntry( "FullScreen", b ); |
1019 | } | 1020 | } |
1020 | break; | 1021 | break; |
1021 | }; | 1022 | }; |
1022 | } | 1023 | } |
1023 | 1024 | ||
1024 | void PlayListWidget::populateSkinsMenu() { | 1025 | void PlayListWidget::populateSkinsMenu() { |
1025 | int item = 0; | 1026 | int item = 0; |
1026 | defaultSkinIndex = 0; | 1027 | defaultSkinIndex = 0; |
1027 | QString skinName; | 1028 | QString skinName; |
1028 | Config cfg( "OpiePlayer" ); | 1029 | Config cfg( "OpiePlayer" ); |
1029 | cfg.setGroup("Options" ); | 1030 | cfg.setGroup("Options" ); |
1030 | QString skin = cfg.readEntry( "Skin", "default" ); | 1031 | QString skin = cfg.readEntry( "Skin", "default" ); |
1031 | 1032 | ||
1032 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1033 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1033 | skinsDir.setFilter( QDir::Dirs ); | 1034 | skinsDir.setFilter( QDir::Dirs ); |
1034 | skinsDir.setSorting(QDir::Name ); | 1035 | skinsDir.setSorting(QDir::Name ); |
1035 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1036 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1036 | QFileInfoListIterator it( *skinslist ); | 1037 | QFileInfoListIterator it( *skinslist ); |
1037 | QFileInfo *fi; | 1038 | QFileInfo *fi; |
1038 | while ( ( fi = it.current() ) ) { | 1039 | while ( ( fi = it.current() ) ) { |
1039 | skinName = fi->fileName(); | 1040 | skinName = fi->fileName(); |
1040 | qDebug( fi->fileName() ); | 1041 | qDebug( fi->fileName() ); |
1041 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1042 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1042 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1043 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1043 | } | 1044 | } |
1044 | if( skinName == "default" ) { | 1045 | if( skinName == "default" ) { |
1045 | defaultSkinIndex = item; | 1046 | defaultSkinIndex = item; |
1046 | } | 1047 | } |
1047 | if( skinName == skin ) { | 1048 | if( skinName == skin ) { |
1048 | skinsMenu->setItemChecked( item, TRUE ); | 1049 | skinsMenu->setItemChecked( item, TRUE ); |
1049 | } | 1050 | } |
1050 | ++it; | 1051 | ++it; |
1051 | } | 1052 | } |
1052 | } | 1053 | } |
1053 | 1054 | ||
1054 | void PlayListWidget::skinsMenuActivated( int item ) { | 1055 | void PlayListWidget::skinsMenuActivated( int item ) { |
1055 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1056 | for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1056 | skinsMenu->setItemChecked( i, FALSE ); | 1057 | skinsMenu->setItemChecked( i, FALSE ); |
1057 | } | 1058 | } |
1058 | skinsMenu->setItemChecked( item, TRUE ); | 1059 | skinsMenu->setItemChecked( item, TRUE ); |
1059 | 1060 | ||
1060 | Config cfg( "OpiePlayer" ); | 1061 | Config cfg( "OpiePlayer" ); |
1061 | cfg.setGroup("Options"); | 1062 | cfg.setGroup("Options"); |
1062 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1063 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1063 | } | 1064 | } |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef PLAY_LIST_WIDGET_H | 34 | #ifndef PLAY_LIST_WIDGET_H |
35 | #define PLAY_LIST_WIDGET_H | 35 | #define PLAY_LIST_WIDGET_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qpe/fileselector.h> | 40 | #include <qpe/fileselector.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qpopupmenu.h> | 42 | #include <qpopupmenu.h> |
43 | 43 | ||
44 | #include "playlistwidgetgui.h" | 44 | #include "playlistwidgetgui.h" |
45 | 45 | ||
46 | 46 | ||
47 | //class PlayListWidgetPrivate; | 47 | //class PlayListWidgetPrivate; |
48 | class Config; | 48 | class Config; |
49 | class QListViewItem; | 49 | class QListViewItem; |
50 | class QListView; | 50 | class QListView; |
51 | class QPoint; | 51 | class QPoint; |
52 | class QAction; | 52 | class QAction; |
53 | class QLabel; | 53 | class QLabel; |
54 | 54 | ||
55 | class PlayListWidget : public PlayListWidgetGui { | 55 | class PlayListWidget : public PlayListWidgetGui { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 58 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
59 | ~PlayListWidget(); | 59 | ~PlayListWidget(); |
60 | DocLnkSet files; | 60 | DocLnkSet files; |
61 | DocLnkSet vFiles; | 61 | DocLnkSet vFiles; |
62 | bool fromSetDocument; | 62 | bool fromSetDocument; |
63 | bool insanityBool; | 63 | bool insanityBool; |
64 | QString setDocFileRef; | 64 | QString setDocFileRef; |
65 | // retrieve the current playlist entry (media file link) | 65 | // retrieve the current playlist entry (media file link) |
66 | const DocLnk *current(); | 66 | const DocLnk *current(); |
67 | void useSelectedDocument(); | 67 | void useSelectedDocument(); |
68 | int selected; | 68 | int selected; |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | bool first(); | 71 | bool first(); |
72 | bool last(); | 72 | bool last(); |
73 | bool next(); | 73 | bool next(); |
74 | bool prev(); | 74 | bool prev(); |
75 | void writeConfig( Config& cfg ) const; | 75 | void writeConfig( Config& cfg ) const; |
76 | 76 | ||
77 | protected: | 77 | protected: |
78 | void keyReleaseEvent( QKeyEvent *e); | 78 | void keyReleaseEvent( QKeyEvent *e); |
79 | 79 | ||
80 | private: | 80 | private: |
81 | int defaultSkinIndex; | 81 | int defaultSkinIndex; |
82 | bool audioScan, videoScan; | 82 | bool audioScan, videoScan; |
83 | void readm3u(const QString &); | 83 | void readm3u(const QString &); |
84 | void readPls(const QString &); | 84 | void readPls(const QString &); |
85 | void initializeStates(); | 85 | void initializeStates(); |
86 | void readConfig( Config& cfg ); | 86 | void readConfig( Config& cfg ); |
87 | void populateAudioView(); | 87 | void populateAudioView(); |
88 | void populateVideoView(); | 88 | void populateVideoView(); |
89 | 89 | ||
90 | private slots: | 90 | private slots: |
91 | void populateSkinsMenu(); | 91 | void populateSkinsMenu(); |
92 | void skinsMenuActivated(int); | 92 | void skinsMenuActivated(int); |
93 | void pmViewActivated(int); | 93 | void pmViewActivated(int); |
94 | void writem3u(); | 94 | void writem3u(); |
95 | void scanForAudio(); | 95 | void scanForAudio(); |
96 | void scanForVideo(); | 96 | void scanForVideo(); |
97 | void openFile(); | 97 | void openFile(); |
98 | void setDocument( const QString& fileref ); | 98 | void setDocument( const QString& fileref ); |
99 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 99 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
100 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 100 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
101 | void setPlaylist( bool ); // Show/Hide the playlist | 101 | void setPlaylist( bool ); // Show/Hide the playlist |
102 | void clearList(); | 102 | void clearList(); |
103 | void addAllToList(); | 103 | void addAllToList(); |
104 | void addAllMusicToList(); | 104 | void addAllMusicToList(); |
105 | void addAllVideoToList(); | 105 | void addAllVideoToList(); |
106 | void saveList(); // Save the playlist | 106 | void saveList(); // Save the playlist |
107 | void loadList( const DocLnk &); // Load a playlist | 107 | void loadList( const DocLnk &); // Load a playlist |
108 | void playIt( QListViewItem *); | 108 | void playIt( QListViewItem *); |
109 | void btnPlay(bool); | 109 | void btnPlay(bool); |
110 | void deletePlaylist(); | 110 | void deletePlaylist(); |
111 | void addSelected(); | 111 | void addSelected(); |
112 | void removeSelected(); | 112 | void removeSelected(); |
113 | void tabChanged(QWidget*); | 113 | void tabChanged(QWidget*); |
114 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 114 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
115 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 115 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
116 | void playSelected(); | 116 | void playSelected(); |
117 | }; | 117 | }; |
118 | 118 | ||
119 | #endif // PLAY_LIST_WIDGET_H | 119 | #endif // PLAY_LIST_WIDGET_H |
120 | 120 | ||
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
39 | #include <qpe/mimetype.h> | 39 | #include <qpe/mimetype.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qcursor.h> | 46 | #include <qcursor.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | 49 | ||
50 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
54 | 54 | ||
55 | //only needed for the random play | 55 | //only needed for the random play |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
59 | #include "videowidget.h" | 59 | #include "videowidget.h" |
60 | #include "mediaplayerstate.h" | 60 | #include "mediaplayerstate.h" |
61 | 61 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
63 | 63 | ||
64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) | 64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) |
65 | : QMainWindow( parent, name, fl ) { | 65 | : QMainWindow( parent, name, fl ) { |
66 | 66 | ||
67 | d = new PlayListWidgetPrivate; | 67 | d = new PlayListWidgetPrivate; |
68 | d->setDocumentUsed = FALSE; | 68 | d->setDocumentUsed = FALSE; |
69 | d->current = NULL; | 69 | d->current = NULL; |
70 | 70 | ||
71 | setBackgroundMode( PaletteButton ); | 71 | setBackgroundMode( PaletteButton ); |
72 | setToolBarsMovable( FALSE ); | 72 | setToolBarsMovable( FALSE ); |
73 | 73 | ||
74 | // Create Toolbar | 74 | // Create Toolbar |
75 | QPEToolBar *toolbar = new QPEToolBar( this ); | 75 | QPEToolBar *toolbar = new QPEToolBar( this ); |
76 | toolbar->setHorizontalStretchable( TRUE ); | 76 | toolbar->setHorizontalStretchable( TRUE ); |
77 | 77 | ||
78 | // Create Menubar | 78 | // Create Menubar |
79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 79 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
80 | menu->setMargin( 0 ); | 80 | menu->setMargin( 0 ); |
81 | 81 | ||
82 | bar = new QPEToolBar( this ); | 82 | bar = new QPEToolBar( this ); |
83 | bar->setLabel( tr( "Play Operations" ) ); | 83 | bar->setLabel( tr( "Play Operations" ) ); |
84 | 84 | ||
85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 85 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
86 | tbDeletePlaylist->setFlat( TRUE ); | 86 | tbDeletePlaylist->setFlat( TRUE ); |
87 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 87 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
88 | 88 | ||
89 | tbDeletePlaylist->hide(); | 89 | tbDeletePlaylist->hide(); |
90 | 90 | ||
91 | pmPlayList = new QPopupMenu( this ); | 91 | pmPlayList = new QPopupMenu( this ); |
92 | menu->insertItem( tr( "File" ), pmPlayList ); | 92 | menu->insertItem( tr( "File" ), pmPlayList ); |
93 | 93 | ||
94 | pmView = new QPopupMenu( this ); | 94 | pmView = new QPopupMenu( this ); |
95 | menu->insertItem( tr( "View" ), pmView ); | 95 | menu->insertItem( tr( "View" ), pmView ); |
96 | pmView->isCheckable(); | 96 | pmView->isCheckable(); |
97 | 97 | ||
98 | skinsMenu = new QPopupMenu( this ); | 98 | skinsMenu = new QPopupMenu( this ); |
99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 99 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
100 | skinsMenu->isCheckable(); | 100 | skinsMenu->isCheckable(); |
101 | 101 | ||
102 | gammaMenu = new QPopupMenu( this ); | ||
103 | pmView->insertItem( tr( "Gamma" ), gammaMenu ); | ||
104 | gammaMenu->setMinimumHeight( 50 ); | ||
105 | |||
106 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | ||
107 | gammaSlider->setRange( -100, 100 ); | ||
108 | gammaSlider->setTickmarks( QSlider::Left ); | ||
109 | gammaSlider->setTickInterval( 20 ); | ||
110 | gammaSlider->setFocusPolicy( QWidget::NoFocus ); | ||
111 | gammaSlider->setValue( 0 ); | ||
112 | gammaSlider->setMinimumHeight( 50 ); | ||
113 | |||
114 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | ||
115 | |||
116 | gammaMenu->insertItem( gammaSlider ); | ||
117 | gammaMenu->insertItem( gammaLCD ); | ||
118 | |||
119 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | ||
120 | |||
102 | vbox5 = new QVBox( this ); | 121 | vbox5 = new QVBox( this ); |
103 | QVBox *vbox4 = new QVBox( vbox5 ); | 122 | QVBox *vbox4 = new QVBox( vbox5 ); |
104 | QHBox *hbox6 = new QHBox( vbox4 ); | 123 | QHBox *hbox6 = new QHBox( vbox4 ); |
105 | 124 | ||
106 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 125 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
107 | 126 | ||
108 | QWidget *pTab; | 127 | QWidget *pTab; |
109 | pTab = new QWidget( tabWidget, "pTab" ); | 128 | pTab = new QWidget( tabWidget, "pTab" ); |
110 | tabWidget->insertTab( pTab,"Playlist"); | 129 | tabWidget->insertTab( pTab, "Playlist"); |
111 | 130 | ||
112 | QGridLayout *Playout = new QGridLayout( pTab ); | 131 | QGridLayout *Playout = new QGridLayout( pTab ); |
113 | Playout->setSpacing( 2); | 132 | Playout->setSpacing( 2); |
114 | Playout->setMargin( 2); | 133 | Playout->setMargin( 2); |
115 | 134 | ||
116 | // Add the playlist area | 135 | // Add the playlist area |
117 | QVBox *vbox3 = new QVBox( pTab ); | 136 | QVBox *vbox3 = new QVBox( pTab ); |
118 | d->playListFrame = vbox3; | 137 | d->playListFrame = vbox3; |
119 | 138 | ||
120 | QHBox *hbox2 = new QHBox( vbox3 ); | 139 | QHBox *hbox2 = new QHBox( vbox3 ); |
121 | d->selectedFiles = new PlayListSelection( hbox2 ); | 140 | d->selectedFiles = new PlayListSelection( hbox2 ); |
122 | 141 | ||
123 | vbox1 = new QVBox( hbox2 ); | 142 | vbox1 = new QVBox( hbox2 ); |
124 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 143 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
125 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 144 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
126 | 145 | ||
127 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 146 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
128 | 147 | ||
129 | QWidget *aTab; | 148 | QWidget *aTab; |
130 | aTab = new QWidget( tabWidget, "aTab" ); | 149 | aTab = new QWidget( tabWidget, "aTab" ); |
131 | 150 | ||
132 | QGridLayout *Alayout = new QGridLayout( aTab ); | 151 | QGridLayout *Alayout = new QGridLayout( aTab ); |
133 | Alayout->setSpacing( 2 ); | 152 | Alayout->setSpacing( 2 ); |
134 | Alayout->setMargin( 2 ); | 153 | Alayout->setMargin( 2 ); |
135 | audioView = new QListView( aTab, "Audioview" ); | 154 | audioView = new QListView( aTab, "Audioview" ); |
136 | audioView->addColumn( tr( "Title" ), 140 ); | 155 | audioView->addColumn( tr( "Title" ), 140 ); |
137 | audioView->addColumn( tr( "Size" ), -1 ); | 156 | audioView->addColumn( tr( "Size" ), -1 ); |
138 | audioView->addColumn( tr( "Media" ), -1 ); | 157 | audioView->addColumn( tr( "Media" ), -1 ); |
139 | audioView->setColumnAlignment( 1, Qt::AlignRight ); | 158 | audioView->setColumnAlignment( 1, Qt::AlignRight ); |
140 | audioView->setColumnAlignment( 2, Qt::AlignRight ); | 159 | audioView->setColumnAlignment( 2, Qt::AlignRight ); |
141 | audioView->setAllColumnsShowFocus( TRUE ); | 160 | audioView->setAllColumnsShowFocus( TRUE ); |
142 | audioView->setSorting( 0, TRUE ); | 161 | audioView->setSorting( 0, TRUE ); |
143 | audioView->setMultiSelection( TRUE ); | 162 | audioView->setMultiSelection( TRUE ); |
144 | audioView->setSelectionMode( QListView::Extended ); | 163 | audioView->setSelectionMode( QListView::Extended ); |
145 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 164 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
146 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 165 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
147 | 166 | ||
148 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 167 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
149 | 168 | ||
150 | QWidget *vTab; | 169 | QWidget *vTab; |
151 | vTab = new QWidget( tabWidget, "vTab" ); | 170 | vTab = new QWidget( tabWidget, "vTab" ); |
152 | 171 | ||
153 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 172 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
154 | Vlayout->setSpacing( 2 ); | 173 | Vlayout->setSpacing( 2 ); |
155 | Vlayout->setMargin( 2 ); | 174 | Vlayout->setMargin( 2 ); |
156 | videoView = new QListView( vTab, "Videoview" ); | 175 | videoView = new QListView( vTab, "Videoview" ); |
157 | videoView->addColumn( tr( "Title" ), 140); | 176 | videoView->addColumn( tr( "Title" ), 140); |
158 | videoView->addColumn( tr( "Size" ), -1 ); | 177 | videoView->addColumn( tr( "Size" ), -1 ); |
159 | videoView->addColumn(tr( "Media" ), -1 ); | 178 | videoView->addColumn(tr( "Media" ), -1 ); |
160 | videoView->setColumnAlignment( 1, Qt::AlignRight ); | 179 | videoView->setColumnAlignment( 1, Qt::AlignRight ); |
161 | videoView->setColumnAlignment( 2, Qt::AlignRight ); | 180 | videoView->setColumnAlignment( 2, Qt::AlignRight ); |
162 | videoView->setAllColumnsShowFocus( TRUE ); | 181 | videoView->setAllColumnsShowFocus( TRUE ); |
163 | videoView->setSorting( 0, TRUE ); | 182 | videoView->setSorting( 0, TRUE ); |
164 | videoView->setMultiSelection( TRUE ); | 183 | videoView->setMultiSelection( TRUE ); |
165 | videoView->setSelectionMode( QListView::Extended ); | 184 | videoView->setSelectionMode( QListView::Extended ); |
166 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 185 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
167 | 186 | ||
168 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 187 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
169 | 188 | ||
170 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 189 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
171 | 190 | ||
172 | //playlists list | 191 | //playlists list |
173 | QWidget *LTab; | 192 | QWidget *LTab; |
174 | LTab = new QWidget( tabWidget, "LTab" ); | 193 | LTab = new QWidget( tabWidget, "LTab" ); |
175 | QGridLayout *Llayout = new QGridLayout( LTab ); | 194 | QGridLayout *Llayout = new QGridLayout( LTab ); |
176 | Llayout->setSpacing( 2 ); | 195 | Llayout->setSpacing( 2 ); |
177 | Llayout->setMargin( 2 ); | 196 | Llayout->setMargin( 2 ); |
178 | 197 | ||
179 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy | 198 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy |
180 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 199 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
181 | 200 | ||
182 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 201 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
183 | 202 | ||
184 | setCentralWidget( vbox5 ); | 203 | setCentralWidget( vbox5 ); |
185 | } | 204 | } |
186 | 205 | ||
187 | 206 | ||
188 | 207 | ||
189 | PlayListWidgetGui::~PlayListWidgetGui() { | 208 | PlayListWidgetGui::~PlayListWidgetGui() { |
190 | } | 209 | } |
191 | 210 | ||
192 | void PlayListWidgetGui::setView( char view ) { | 211 | void PlayListWidgetGui::setView( char view ) { |
193 | if ( view == 'l' ) | 212 | if ( view == 'l' ) |
194 | showMaximized(); | 213 | showMaximized(); |
195 | else | 214 | else |
196 | hide(); | 215 | hide(); |
197 | } | 216 | } |
198 | 217 | ||
199 | 218 | ||
200 | void PlayListWidgetGui::setActiveWindow() { | 219 | void PlayListWidgetGui::setActiveWindow() { |
201 | // qDebug("SETTING active window"); | 220 | // qDebug("SETTING active window"); |
202 | // When we get raised we need to ensure that it switches views | 221 | // When we get raised we need to ensure that it switches views |
203 | char origView = mediaPlayerState->view(); | 222 | char origView = mediaPlayerState->view(); |
204 | mediaPlayerState->setView( 'l' ); // invalidate | 223 | mediaPlayerState->setView( 'l' ); // invalidate |
205 | mediaPlayerState->setView( origView ); // now switch back | 224 | mediaPlayerState->setView( origView ); // now switch back |
206 | } | 225 | } |
207 | 226 | ||
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef PLAY_LIST_WIDGET_GUI_H | 34 | #ifndef PLAY_LIST_WIDGET_GUI_H |
35 | #define PLAY_LIST_WIDGET_GUI_H | 35 | #define PLAY_LIST_WIDGET_GUI_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
41 | 41 | ||
42 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
43 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | 47 | #include <qslider.h> | |
48 | #include <qlcdnumber.h> | ||
48 | 49 | ||
49 | class PlayListWidgetPrivate; | 50 | class PlayListWidgetPrivate; |
50 | class PlayListSelection; | 51 | class PlayListSelection; |
51 | 52 | ||
52 | class Config; | 53 | class Config; |
53 | class QPEToolBar; | 54 | class QPEToolBar; |
54 | class QListViewItem; | 55 | class QListViewItem; |
55 | class QListView; | 56 | class QListView; |
56 | class QPoint; | 57 | class QPoint; |
57 | class QAction; | 58 | class QAction; |
58 | class QLabel; | 59 | class QLabel; |
59 | 60 | ||
60 | class PlayListWidgetPrivate { | 61 | class PlayListWidgetPrivate { |
61 | public: | 62 | public: |
62 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 63 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
63 | QFrame *playListFrame; | 64 | QFrame *playListFrame; |
64 | FileSelector *files; | 65 | FileSelector *files; |
65 | PlayListSelection *selectedFiles; | 66 | PlayListSelection *selectedFiles; |
66 | bool setDocumentUsed; | 67 | bool setDocumentUsed; |
67 | DocLnk *current; | 68 | DocLnk *current; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | 71 | ||
71 | class ToolButton : public QToolButton { | 72 | class ToolButton : public QToolButton { |
72 | public: | 73 | public: |
73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 74 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
74 | : QToolButton( parent, name ) { | 75 | : QToolButton( parent, name ) { |
75 | setTextLabel( name ); | 76 | setTextLabel( name ); |
76 | setPixmap( Resource::loadPixmap( icon ) ); | 77 | setPixmap( Resource::loadPixmap( icon ) ); |
77 | setAutoRaise( TRUE ); | 78 | setAutoRaise( TRUE ); |
78 | setFocusPolicy( QWidget::NoFocus ); | 79 | setFocusPolicy( QWidget::NoFocus ); |
79 | setToggleButton( t ); | 80 | setToggleButton( t ); |
80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 81 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
81 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 82 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
82 | } | 83 | } |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | class MenuItem : public QAction { | 87 | class MenuItem : public QAction { |
87 | 88 | ||
88 | public: | 89 | public: |
89 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 90 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
90 | : QAction( text, QString::null, 0, 0 ) { | 91 | : QAction( text, QString::null, 0, 0 ) { |
91 | connect( this, SIGNAL( activated() ), handler, slot ); | 92 | connect( this, SIGNAL( activated() ), handler, slot ); |
92 | addTo( parent ); | 93 | addTo( parent ); |
93 | } | 94 | } |
94 | }; | 95 | }; |
95 | 96 | ||
96 | class PlayListWidgetGui : public QMainWindow { | 97 | class PlayListWidgetGui : public QMainWindow { |
97 | Q_OBJECT | 98 | Q_OBJECT |
98 | public: | 99 | public: |
99 | PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 100 | PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
100 | ~PlayListWidgetGui(); | 101 | ~PlayListWidgetGui(); |
101 | 102 | ||
102 | protected: | 103 | protected: |
103 | QTabWidget * tabWidget; | 104 | QTabWidget * tabWidget; |
104 | QListView *audioView, *videoView, *playlistView; | 105 | QListView *audioView, *videoView, *playlistView; |
105 | QLabel *libString; | 106 | QLabel *libString; |
106 | QPopupMenu *pmView ; | 107 | QPopupMenu *pmView ; |
108 | QPopupMenu *gammaMenu; | ||
109 | QSlider *gammaSlider; | ||
110 | QLCDNumber *gammaLCD; | ||
107 | bool fromSetDocument; | 111 | bool fromSetDocument; |
108 | bool insanityBool; | 112 | bool insanityBool; |
109 | QString setDocFileRef; | 113 | QString setDocFileRef; |
110 | // retrieve the current playlist entry (media file link) | 114 | // retrieve the current playlist entry (media file link) |
111 | QPushButton *tbDeletePlaylist; | 115 | QPushButton *tbDeletePlaylist; |
112 | int selected; | 116 | int selected; |
113 | QPopupMenu *pmPlayList; | 117 | QPopupMenu *pmPlayList; |
114 | FileSelector* playLists; | 118 | FileSelector* playLists; |
115 | QPopupMenu *skinsMenu; | 119 | QPopupMenu *skinsMenu; |
116 | PlayListWidgetPrivate *d; // Private implementation data | 120 | PlayListWidgetPrivate *d; // Private implementation data |
117 | QVBox *vbox1; | 121 | QVBox *vbox1; |
118 | QVBox *vbox5; | 122 | QVBox *vbox5; |
119 | QPEToolBar *bar; | 123 | QPEToolBar *bar; |
120 | void setActiveWindow(); // need to handle this to show the right view | 124 | void setActiveWindow(); // need to handle this to show the right view |
121 | void setView( char ); | 125 | void setView( char ); |
122 | 126 | ||
123 | }; | 127 | }; |
124 | 128 | ||
125 | #endif | 129 | #endif |
126 | 130 | ||
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include "xinecontrol.h" | 38 | #include "xinecontrol.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | #include "videowidget.h" | 40 | #include "videowidget.h" |
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
44 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( QObject *parent, const char *name ) |
45 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
46 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 46 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
47 | 47 | ||
48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
54 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | ||
54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 55 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
55 | 56 | ||
56 | disabledSuspendScreenSaver = FALSE; | 57 | disabledSuspendScreenSaver = FALSE; |
57 | } | 58 | } |
58 | 59 | ||
59 | XineControl::~XineControl() { | 60 | XineControl::~XineControl() { |
60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 61 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
61 | if ( disabledSuspendScreenSaver ) { | 62 | if ( disabledSuspendScreenSaver ) { |
62 | disabledSuspendScreenSaver = FALSE; | 63 | disabledSuspendScreenSaver = FALSE; |
63 | // Re-enable the suspend mode | 64 | // Re-enable the suspend mode |
64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 65 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
65 | } | 66 | } |
66 | #endif | 67 | #endif |
67 | delete libXine; | 68 | delete libXine; |
68 | } | 69 | } |
69 | 70 | ||
70 | void XineControl::play( const QString& fileName ) { | 71 | void XineControl::play( const QString& fileName ) { |
71 | hasVideoChannel=FALSE; | 72 | hasVideoChannel=FALSE; |
72 | hasAudioChannel=FALSE; | 73 | hasAudioChannel=FALSE; |
73 | m_fileName = fileName; | 74 | m_fileName = fileName; |
74 | 75 | ||
75 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 76 | //qDebug("<<FILENAME: " + fileName + ">>>>"); |
76 | 77 | ||
77 | libXine->play( fileName ); | 78 | libXine->play( fileName ); |
78 | mediaPlayerState->setPlaying( true ); | 79 | mediaPlayerState->setPlaying( true ); |
79 | // default to audio view until we know how to handle video | 80 | // default to audio view until we know how to handle video |
80 | // MediaDetect mdetect; | 81 | // MediaDetect mdetect; |
81 | char whichGui = mdetect.videoOrAudio( fileName ); | 82 | char whichGui = mdetect.videoOrAudio( fileName ); |
82 | if (whichGui == 'f') { | 83 | if (whichGui == 'f') { |
83 | qDebug("Nicht erkannter Dateityp"); | 84 | qDebug("Nicht erkannter Dateityp"); |
84 | return; | 85 | return; |
85 | } | 86 | } |
86 | 87 | ||
87 | if (whichGui == 'a') { | 88 | if (whichGui == 'a') { |
88 | libXine->setShowVideo( false ); | 89 | libXine->setShowVideo( false ); |
89 | hasAudioChannel=TRUE; | 90 | hasAudioChannel=TRUE; |
90 | } else { | 91 | } else { |
91 | libXine->setShowVideo( true ); | 92 | libXine->setShowVideo( true ); |
92 | hasVideoChannel=TRUE; | 93 | hasVideoChannel=TRUE; |
93 | } | 94 | } |
94 | 95 | ||
95 | // determine if slider is shown | 96 | // determine if slider is shown |
96 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 97 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
97 | // which gui (video / audio) | 98 | // which gui (video / audio) |
98 | mediaPlayerState->setView( whichGui ); | 99 | mediaPlayerState->setView( whichGui ); |
99 | 100 | ||
100 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 101 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
101 | if ( !disabledSuspendScreenSaver ) { | 102 | if ( !disabledSuspendScreenSaver ) { |
102 | disabledSuspendScreenSaver = TRUE; | 103 | disabledSuspendScreenSaver = TRUE; |
103 | // Stop the screen from blanking and power saving state | 104 | // Stop the screen from blanking and power saving state |
104 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 105 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
105 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 106 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
106 | } | 107 | } |
107 | #endif | 108 | #endif |
108 | 109 | ||
109 | length(); | 110 | length(); |
110 | position(); | 111 | position(); |
111 | } | 112 | } |
112 | 113 | ||
113 | void XineControl::nextMedia() { | 114 | void XineControl::nextMedia() { |
114 | mediaPlayerState->setNext(); | 115 | mediaPlayerState->setNext(); |
115 | } | 116 | } |
116 | 117 | ||
118 | void XineControl::setGamma( int value ) { | ||
119 | libXine->setGamma( value ); | ||
120 | } | ||
121 | |||
117 | void XineControl::stop( bool isSet ) { | 122 | void XineControl::stop( bool isSet ) { |
118 | if ( !isSet) { | 123 | if ( !isSet) { |
119 | libXine->stop( ); | 124 | libXine->stop( ); |
120 | mediaPlayerState->setList(); | 125 | mediaPlayerState->setList(); |
121 | // mediaPlayerState->setPlaying( false ); | 126 | // mediaPlayerState->setPlaying( false ); |
122 | 127 | ||
123 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 128 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
124 | if ( disabledSuspendScreenSaver ) { | 129 | if ( disabledSuspendScreenSaver ) { |
125 | disabledSuspendScreenSaver = FALSE; | 130 | disabledSuspendScreenSaver = FALSE; |
126 | // Re-enable the suspend mode | 131 | // Re-enable the suspend mode |
127 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 132 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
128 | } | 133 | } |
129 | #endif | 134 | #endif |
130 | 135 | ||
131 | } else { | 136 | } else { |
132 | // play again | 137 | // play again |
133 | } | 138 | } |
134 | } | 139 | } |
135 | 140 | ||
136 | /** | 141 | /** |
137 | * Pause playback | 142 | * Pause playback |
138 | * @isSet | 143 | * @isSet |
139 | */ | 144 | */ |
140 | void XineControl::pause( bool isSet) { | 145 | void XineControl::pause( bool isSet) { |
141 | if (isSet) { | 146 | if (isSet) { |
142 | libXine->pause(); | 147 | libXine->pause(); |
143 | } else { | 148 | } else { |
144 | libXine->play( m_fileName, 0, m_currentTime); | 149 | libXine->play( m_fileName, 0, m_currentTime); |
145 | } | 150 | } |
146 | } | 151 | } |
147 | 152 | ||
148 | 153 | ||
149 | /** | 154 | /** |
150 | * get current time in playback | 155 | * get current time in playback |
151 | */ | 156 | */ |
152 | long XineControl::currentTime() { | 157 | long XineControl::currentTime() { |
153 | // todo: jede sekunde überprüfen | 158 | // todo: jede sekunde überprüfen |
154 | m_currentTime = libXine->currentTime(); | 159 | m_currentTime = libXine->currentTime(); |
155 | return m_currentTime; | 160 | return m_currentTime; |
156 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 161 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
157 | } | 162 | } |
158 | 163 | ||
159 | /** | 164 | /** |
160 | * Set the length of the media file | 165 | * Set the length of the media file |
161 | */ | 166 | */ |
162 | void XineControl::length() { | 167 | void XineControl::length() { |
163 | m_length = libXine->length(); | 168 | m_length = libXine->length(); |
164 | mediaPlayerState->setLength( m_length ); | 169 | mediaPlayerState->setLength( m_length ); |
165 | } | 170 | } |
166 | 171 | ||
167 | 172 | ||
168 | /** | 173 | /** |
169 | * Reports the position the xine backend is at right now | 174 | * Reports the position the xine backend is at right now |
170 | * @return long the postion in seconds | 175 | * @return long the postion in seconds |
171 | */ | 176 | */ |
172 | long XineControl::position() { | 177 | long XineControl::position() { |
173 | m_position = ( currentTime() ); | 178 | m_position = ( currentTime() ); |
174 | mediaPlayerState->updatePosition( m_position ); | 179 | mediaPlayerState->updatePosition( m_position ); |
175 | long emitPos = (long)m_position; | 180 | long emitPos = (long)m_position; |
176 | emit positionChanged( emitPos ); | 181 | emit positionChanged( emitPos ); |
177 | if(mediaPlayerState->isPlaying) | 182 | if(mediaPlayerState->isPlaying) |
178 | // needs to be stopped the media is stopped | 183 | // needs to be stopped the media is stopped |
179 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 184 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
180 | // qDebug("POSITION : %d", m_position); | 185 | // qDebug("POSITION : %d", m_position); |
181 | return m_position; | 186 | return m_position; |
182 | } | 187 | } |
183 | 188 | ||
184 | /** | 189 | /** |
185 | * Set videoplayback to fullscreen | 190 | * Set videoplayback to fullscreen |
186 | * @param isSet | 191 | * @param isSet |
187 | */ | 192 | */ |
188 | void XineControl::setFullscreen( bool isSet ) { | 193 | void XineControl::setFullscreen( bool isSet ) { |
189 | libXine->showVideoFullScreen( isSet); | 194 | libXine->showVideoFullScreen( isSet); |
190 | } | 195 | } |
191 | 196 | ||
192 | /** | 197 | /** |
193 | * Seek to a position in the track | 198 | * Seek to a position in the track |
194 | * @param second the second to jump to | 199 | * @param second the second to jump to |
195 | */ | 200 | */ |
196 | void XineControl::seekTo( long second ) { | 201 | void XineControl::seekTo( long second ) { |
197 | libXine->play( m_fileName , 0, (int)second ); | 202 | libXine->play( m_fileName , 0, (int)second ); |
198 | } | 203 | } |
199 | 204 | ||
200 | void XineControl::videoResized ( const QSize &s ) { | 205 | void XineControl::videoResized ( const QSize &s ) { |
201 | libXine-> resize ( s ); | 206 | libXine-> resize ( s ); |
202 | } | 207 | } |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include "mediadetect.h" | 38 | #include "mediadetect.h" |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | class XineControl : public QObject { | 41 | class XineControl : public QObject { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | XineControl( QObject *parent = 0, const char *name =0 ); | 44 | XineControl( QObject *parent = 0, const char *name =0 ); |
45 | ~XineControl(); | 45 | ~XineControl(); |
46 | 46 | ||
47 | bool hasVideo() const { return hasVideoChannel; } | 47 | bool hasVideo() const { return hasVideoChannel; } |
48 | bool hasAudio() const { return hasAudioChannel; } | 48 | bool hasAudio() const { return hasAudioChannel; } |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void play( const QString& fileName ); | 51 | void play( const QString& fileName ); |
52 | void stop( bool ); | 52 | void stop( bool ); |
53 | |||
54 | /** | ||
55 | * Pause the media stream | ||
56 | * @param if pause or not | ||
57 | */ | ||
53 | void pause( bool ); | 58 | void pause( bool ); |
59 | |||
60 | /** | ||
61 | * Set videos fullscreen | ||
62 | * @param yes or no | ||
63 | */ | ||
54 | void setFullscreen( bool ); | 64 | void setFullscreen( bool ); |
65 | |||
66 | /** | ||
67 | * | ||
68 | */ | ||
55 | long currentTime(); | 69 | long currentTime(); |
56 | void seekTo( long ); | 70 | void seekTo( long ); |
57 | // get length of media file and set it | 71 | // get length of media file and set it |
58 | void length(); | 72 | void length(); |
59 | long position(); | 73 | long position(); |
74 | |||
75 | /** | ||
76 | * Proceed to the next media file in playlist | ||
77 | */ | ||
60 | void nextMedia(); | 78 | void nextMedia(); |
79 | |||
61 | void videoResized ( const QSize &s ); | 80 | void videoResized ( const QSize &s ); |
62 | 81 | ||
82 | /** | ||
83 | * Set the gamma value of the video output | ||
84 | * @param int value between -100 and 100, 0 is original | ||
85 | */ | ||
86 | void setGamma( int ); | ||
87 | |||
88 | |||
63 | private: | 89 | private: |
64 | XINE::Lib *libXine; | 90 | XINE::Lib *libXine; |
65 | MediaDetect mdetect; | 91 | MediaDetect mdetect; |
66 | long m_currentTime; | 92 | long m_currentTime; |
67 | long m_position; | 93 | long m_position; |
68 | int m_length; | 94 | int m_length; |
69 | QString m_fileName; | 95 | QString m_fileName; |
70 | bool disabledSuspendScreenSaver : 1; | 96 | bool disabledSuspendScreenSaver : 1; |
71 | bool hasVideoChannel : 1; | 97 | bool hasVideoChannel : 1; |
72 | bool hasAudioChannel : 1; | 98 | bool hasAudioChannel : 1; |
99 | |||
73 | signals: | 100 | signals: |
74 | void positionChanged( long ); | 101 | void positionChanged( long ); |
75 | 102 | ||
76 | }; | 103 | }; |
77 | 104 | ||
78 | 105 | ||
79 | #endif | 106 | #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 | |||
@@ -1,273 +1,273 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 5 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
6 | Copyright (c) 2002 LJP <> | 6 | Copyright (c) 2002 LJP <> |
7 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 7 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
8 | =. | 8 | =. |
9 | .=l. | 9 | .=l. |
10 | .>+-= | 10 | .>+-= |
11 | _;:, .> :=|. This program is free software; you can | 11 | _;:, .> :=|. This program is free software; you can |
12 | .> <`_, > . <= redistribute it and/or modify it under | 12 | .> <`_, > . <= redistribute it and/or modify it under |
13 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 13 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
14 | .="- .-=="i, .._ License as published by the Free Software | 14 | .="- .-=="i, .._ License as published by the Free Software |
15 | - . .-<_> .<> Foundation; either version 2 of the License, | 15 | - . .-<_> .<> Foundation; either version 2 of the License, |
16 | ._= =} : or (at your option) any later version. | 16 | ._= =} : or (at your option) any later version. |
17 | .%`+i> _;_. | 17 | .%`+i> _;_. |
18 | .i_,=:_. -<s. This program is distributed in the hope that | 18 | .i_,=:_. -<s. This program is distributed in the hope that |
19 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 19 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
20 | : .. .:, . . . without even the implied warranty of | 20 | : .. .:, . . . without even the implied warranty of |
21 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 21 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
22 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 22 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
23 | ..}^=.= = ; Library General Public License for more | 23 | ..}^=.= = ; Library General Public License for more |
24 | ++= -. .` .: details. | 24 | ++= -. .` .: details. |
25 | : = ...= . :.=- | 25 | : = ...= . :.=- |
26 | -. .:....=;==+<; You should have received a copy of the GNU | 26 | -. .:....=;==+<; You should have received a copy of the GNU |
27 | -_. . . )=. = Library General Public License along with | 27 | -_. . . )=. = Library General Public License along with |
28 | -- :-=` this library; see the file COPYING.LIB. | 28 | -- :-=` this library; see the file COPYING.LIB. |
29 | If not, write to the Free Software Foundation, | 29 | If not, write to the Free Software Foundation, |
30 | Inc., 59 Temple Place - Suite 330, | 30 | Inc., 59 Temple Place - Suite 330, |
31 | Boston, MA 02111-1307, USA. | 31 | Boston, MA 02111-1307, USA. |
32 | 32 | ||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <qimage.h> | 35 | #include <qimage.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qgfx_qws.h> | 37 | #include <qgfx_qws.h> |
38 | #include <qdirectpainter_qws.h> | 38 | #include <qdirectpainter_qws.h> |
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | #include <qsize.h> | 40 | #include <qsize.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | 43 | ||
44 | #include <qpe/resource.h> | 44 | #include <qpe/resource.h> |
45 | 45 | ||
46 | #include "xinevideowidget.h" | 46 | #include "xinevideowidget.h" |
47 | 47 | ||
48 | 48 | ||
49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
50 | { | 50 | { |
51 | ((char *) src ) += len; | 51 | ((char *) src ) += len; |
52 | 52 | ||
53 | len >>= 1; | 53 | len >>= 1; |
54 | while ( len-- ) | 54 | while ( len-- ) |
55 | *((short int *) dst )++ = *--((short int *) src ); | 55 | *((short int *) dst )++ = *--((short int *) src ); |
56 | } | 56 | } |
57 | 57 | ||
58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
59 | { | 59 | { |
60 | len >>= 1; | 60 | len >>= 1; |
61 | while ( len-- ) { | 61 | while ( len-- ) { |
62 | *((short int *) dst )++ = *((short int *) src ); | 62 | *((short int *) dst )++ = *((short int *) src ); |
63 | ((char *) src ) += step; | 63 | ((char *) src ) += step; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
68 | { | 68 | { |
69 | len >>= 1; | 69 | len >>= 1; |
70 | 70 | ||
71 | ((char *) src ) += ( len * step ); | 71 | ((char *) src ) += ( len * step ); |
72 | 72 | ||
73 | while ( len-- ) { | 73 | while ( len-- ) { |
74 | ((char *) src ) -= step; | 74 | ((char *) src ) -= step; |
75 | *((short int *) dst )++ = *((short int *) src ); | 75 | *((short int *) dst )++ = *((short int *) src ); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 80 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 81 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
82 | { | 82 | { |
83 | setBackgroundMode ( NoBackground ); | 83 | setBackgroundMode ( NoBackground ); |
84 | 84 | ||
85 | m_image = 0; | 85 | m_image = 0; |
86 | m_buff = 0; | 86 | m_buff = 0; |
87 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 87 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
88 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 88 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
89 | m_rotation = 0; | 89 | m_rotation = 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | XineVideoWidget::~XineVideoWidget ( ) | 93 | XineVideoWidget::~XineVideoWidget ( ) |
94 | { | 94 | { |
95 | delete m_image; | 95 | delete m_image; |
96 | } | 96 | } |
97 | 97 | ||
98 | void XineVideoWidget::clear ( ) | 98 | void XineVideoWidget::clear ( ) |
99 | { | 99 | { |
100 | m_buff = 0; | 100 | m_buff = 0; |
101 | repaint ( false ); | 101 | repaint ( false ); |
102 | } | 102 | } |
103 | 103 | ||
104 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 104 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
105 | { | 105 | { |
106 | //qWarning( "painting <<<" ); | 106 | //qWarning( "painting <<<" ); |
107 | if ( m_buff == 0 ) { | 107 | if ( m_buff == 0 ) { |
108 | QPainter p ( this ); | 108 | QPainter p ( this ); |
109 | p. fillRect ( rect ( ), black ); | 109 | p. fillRect ( rect ( ), black ); |
110 | if ( m_image ) | 110 | if ( m_image ) |
111 | p. drawImage ( 0, 0, *m_image ); | 111 | p. drawImage ( 0, 0, *m_image ); |
112 | //qWarning ( "logo\n" ); | 112 | //qWarning ( "logo\n" ); |
113 | } | 113 | } |
114 | else { | 114 | else { |
115 | // qWarning ( "paintevent\n" ); | 115 | // qWarning ( "paintevent\n" ); |
116 | 116 | ||
117 | QArray <QRect> qt_bug_workaround_clip_rects; | 117 | QArray <QRect> qt_bug_workaround_clip_rects; |
118 | 118 | ||
119 | { | 119 | { |
120 | QDirectPainter dp ( this ); | 120 | QDirectPainter dp ( this ); |
121 | 121 | ||
122 | int rot = dp. transformOrientation ( ) + m_rotation; | 122 | int rot = dp. transformOrientation ( ) + m_rotation; |
123 | 123 | ||
124 | uchar *fb = dp. frameBuffer ( ); | 124 | uchar *fb = dp. frameBuffer ( ); |
125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
126 | 126 | ||
127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
128 | 128 | ||
129 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 129 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
130 | 130 | ||
131 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 131 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
132 | const QRect &clip = dp. rect ( i ); | 132 | const QRect &clip = dp. rect ( i ); |
133 | 133 | ||
134 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 134 | qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
135 | 135 | ||
136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); |
137 | uchar *src = frame; | 137 | uchar *src = frame; |
138 | 138 | ||
139 | switch ( rot ) { | 139 | switch ( rot ) { |
140 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; | 140 | case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; |
141 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; | 141 | case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; |
142 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; | 142 | case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; |
143 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; | 143 | case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; |
144 | default: break; | 144 | default: break; |
145 | } | 145 | } |
146 | 146 | ||
147 | uint leftfill = 0; | 147 | uint leftfill = 0; |
148 | uint framefill = 0; | 148 | uint framefill = 0; |
149 | uint rightfill = 0; | 149 | uint rightfill = 0; |
150 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 150 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; |
151 | 151 | ||
152 | if ( clip. left ( ) < framerect. left ( )) | 152 | if ( clip. left ( ) < framerect. left ( )) |
153 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 153 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
154 | if ( clip. right ( ) > framerect. right ( )) | 154 | if ( clip. right ( ) > framerect. right ( )) |
155 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 155 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
156 | 156 | ||
157 | framefill = clipwidth - ( leftfill + rightfill ); | 157 | framefill = clipwidth - ( leftfill + rightfill ); |
158 | 158 | ||
159 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 159 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
160 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 160 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
161 | memset ( dst, 0, clipwidth ); | 161 | memset ( dst, 0, clipwidth ); |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | if ( leftfill ) | 164 | if ( leftfill ) |
165 | memset ( dst, 0, leftfill ); | 165 | memset ( dst, 0, leftfill ); |
166 | 166 | ||
167 | if ( framefill ) { | 167 | if ( framefill ) { |
168 | switch ( rot ) { | 168 | switch ( rot ) { |
169 | case 0: memcpy ( dst + leftfill, src, framefill ); break; | 169 | case 0: memcpy ( dst + leftfill, src, framefill ); break; |
170 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 170 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
171 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 171 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
172 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 172 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
173 | default: break; | 173 | default: break; |
174 | } | ||
174 | } | 175 | } |
175 | } | ||
176 | if ( rightfill ) | 176 | if ( rightfill ) |
177 | memset ( dst + leftfill + framefill, 0, rightfill ); | 177 | memset ( dst + leftfill + framefill, 0, rightfill ); |
178 | } | 178 | } |
179 | 179 | ||
180 | dst += m_bytes_per_line_fb; | 180 | dst += m_bytes_per_line_fb; |
181 | 181 | ||
182 | switch ( rot ) { | 182 | switch ( rot ) { |
183 | case 0: src += m_bytes_per_line_frame; break; | 183 | case 0: src += m_bytes_per_line_frame; break; |
184 | case 1: src -= m_bytes_per_pixel; break; | 184 | case 1: src -= m_bytes_per_pixel; break; |
185 | case 2: src -= m_bytes_per_line_frame; break; | 185 | case 2: src -= m_bytes_per_line_frame; break; |
186 | case 3: src += m_bytes_per_pixel; break; | 186 | case 3: src += m_bytes_per_pixel; break; |
187 | default: break; | 187 | default: break; |
188 | } | ||
188 | } | 189 | } |
189 | } | ||
190 | } | 190 | } |
191 | } | 191 | } |
192 | //qWarning ( " ||| painting |||" ); | 192 | //qWarning ( " ||| painting |||" ); |
193 | { | 193 | { |
194 | // QVFB hack by MArtin Jones | 194 | // QVFB hack by MArtin Jones |
195 | QPainter p ( this ); | 195 | QPainter p ( this ); |
196 | 196 | ||
197 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 197 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
198 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 198 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | //qWarning( "painting >>>" ); | 202 | //qWarning( "painting >>>" ); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void XineVideoWidget::setImage ( QImage* image ) | 206 | void XineVideoWidget::setImage ( QImage* image ) |
207 | { | 207 | { |
208 | delete m_image; | 208 | delete m_image; |
209 | m_image = image; | 209 | m_image = image; |
210 | } | 210 | } |
211 | 211 | ||
212 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | 212 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) |
213 | { | 213 | { |
214 | bool rot90 = (( -m_rotation ) & 1 ); | 214 | bool rot90 = (( -m_rotation ) & 1 ); |
215 | 215 | ||
216 | if ( rot90 ) { | 216 | if ( rot90 ) { |
217 | int d = w; | 217 | int d = w; |
218 | w = h; | 218 | w = h; |
219 | h = d; | 219 | h = d; |
220 | } | 220 | } |
221 | 221 | ||
222 | m_lastframe = m_thisframe; | 222 | m_lastframe = m_thisframe; |
223 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 223 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
224 | 224 | ||
225 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 225 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
226 | 226 | ||
227 | m_buff = img; | 227 | m_buff = img; |
228 | m_bytes_per_line_frame = bpl; | 228 | m_bytes_per_line_frame = bpl; |
229 | 229 | ||
230 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 230 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
231 | } | 231 | } |
232 | 232 | ||
233 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 233 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
234 | { | 234 | { |
235 | QSize s = size ( ); | 235 | QSize s = size ( ); |
236 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | 236 | bool fs = ( s == qApp-> desktop ( )-> size ( )); |
237 | 237 | ||
238 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 238 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; |
239 | 239 | ||
240 | if ( fs && qt_screen-> isTransformed ( )) { | 240 | if ( fs && qt_screen-> isTransformed ( )) { |
241 | s = qt_screen-> mapToDevice ( s ); | 241 | s = qt_screen-> mapToDevice ( s ); |
242 | } | 242 | } |
243 | 243 | ||
244 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | 244 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); |
245 | 245 | ||
246 | emit videoResized ( s ); | 246 | emit videoResized ( s ); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void XineVideoWidget::mousePressEvent ( QMouseEvent * /*me*/ ) | 250 | void XineVideoWidget::mousePressEvent ( QMouseEvent * /*me*/ ) |
251 | { | 251 | { |
252 | QWidget *p = parentWidget ( ); | 252 | QWidget *p = parentWidget ( ); |
253 | 253 | ||
254 | if ( p ) { | 254 | if ( p ) { |
255 | // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 255 | // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
256 | 256 | ||
257 | // QApplication::sendEvent ( p, &pme ); | 257 | // QApplication::sendEvent ( p, &pme ); |
258 | // emit clicked(); | 258 | // emit clicked(); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 262 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
263 | { | 263 | { |
264 | QWidget *p = parentWidget ( ); | 264 | QWidget *p = parentWidget ( ); |
265 | 265 | ||
266 | if ( p ) { | 266 | if ( p ) { |
267 | // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | 267 | // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); |
268 | 268 | ||
269 | // QApplication::sendEvent ( p, &pme ); | 269 | // QApplication::sendEvent ( p, &pme ); |
270 | emit clicked(); | 270 | emit clicked(); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
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 | |||
@@ -1530,1639 +1530,1638 @@ static void yuv2rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, | |||
1530 | this->dest_width, this->step_dx); | 1530 | this->dest_width, this->step_dx); |
1531 | 1531 | ||
1532 | if (height & 1) { | 1532 | if (height & 1) { |
1533 | _pu += this->uv_stride; | 1533 | _pu += this->uv_stride; |
1534 | _pv += this->uv_stride; | 1534 | _pv += this->uv_stride; |
1535 | 1535 | ||
1536 | scale_line (_pu, this->u_buffer, | 1536 | scale_line (_pu, this->u_buffer, |
1537 | this->dest_width >> 1, this->step_dx); | 1537 | this->dest_width >> 1, this->step_dx); |
1538 | scale_line (_pv, this->v_buffer, | 1538 | scale_line (_pv, this->v_buffer, |
1539 | this->dest_width >> 1, this->step_dx); | 1539 | this->dest_width >> 1, this->step_dx); |
1540 | 1540 | ||
1541 | } | 1541 | } |
1542 | height++; | 1542 | height++; |
1543 | } while (dy>=32768); | 1543 | } while (dy>=32768); |
1544 | } | 1544 | } |
1545 | } else { | 1545 | } else { |
1546 | height = this->source_height >> 1; | 1546 | height = this->source_height >> 1; |
1547 | do { | 1547 | do { |
1548 | dst_1 = _dst; | 1548 | dst_1 = _dst; |
1549 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); | 1549 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); |
1550 | py_1 = _py; | 1550 | py_1 = _py; |
1551 | py_2 = _py + this->y_stride; | 1551 | py_2 = _py + this->y_stride; |
1552 | pu = _pu; | 1552 | pu = _pu; |
1553 | pv = _pv; | 1553 | pv = _pv; |
1554 | 1554 | ||
1555 | width = this->source_width >> 3; | 1555 | width = this->source_width >> 3; |
1556 | do { | 1556 | do { |
1557 | RGB(0); | 1557 | RGB(0); |
1558 | DST1RGB(0); | 1558 | DST1RGB(0); |
1559 | DST2RGB(0); | 1559 | DST2RGB(0); |
1560 | 1560 | ||
1561 | RGB(1); | 1561 | RGB(1); |
1562 | DST2RGB(1); | 1562 | DST2RGB(1); |
1563 | DST1RGB(1); | 1563 | DST1RGB(1); |
1564 | 1564 | ||
1565 | RGB(2); | 1565 | RGB(2); |
1566 | DST1RGB(2); | 1566 | DST1RGB(2); |
1567 | DST2RGB(2); | 1567 | DST2RGB(2); |
1568 | 1568 | ||
1569 | RGB(3); | 1569 | RGB(3); |
1570 | DST2RGB(3); | 1570 | DST2RGB(3); |
1571 | DST1RGB(3); | 1571 | DST1RGB(3); |
1572 | 1572 | ||
1573 | pu += 4; | 1573 | pu += 4; |
1574 | pv += 4; | 1574 | pv += 4; |
1575 | py_1 += 8; | 1575 | py_1 += 8; |
1576 | py_2 += 8; | 1576 | py_2 += 8; |
1577 | dst_1 += 24; | 1577 | dst_1 += 24; |
1578 | dst_2 += 24; | 1578 | dst_2 += 24; |
1579 | } while (--width); | 1579 | } while (--width); |
1580 | 1580 | ||
1581 | _dst += 2 * this->rgb_stride; | 1581 | _dst += 2 * this->rgb_stride; |
1582 | _py += 2 * this->y_stride; | 1582 | _py += 2 * this->y_stride; |
1583 | _pu += this->uv_stride; | 1583 | _pu += this->uv_stride; |
1584 | _pv += this->uv_stride; | 1584 | _pv += this->uv_stride; |
1585 | 1585 | ||
1586 | } while (--height); | 1586 | } while (--height); |
1587 | } | 1587 | } |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | /* only trivial mods from yuv2rgb_c_24_rgb */ | 1590 | /* only trivial mods from yuv2rgb_c_24_rgb */ |
1591 | static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, | 1591 | static void yuv2rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, |
1592 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 1592 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
1593 | { | 1593 | { |
1594 | int U, V, Y; | 1594 | int U, V, Y; |
1595 | uint8_t * py_1, * py_2, * pu, * pv; | 1595 | uint8_t * py_1, * py_2, * pu, * pv; |
1596 | uint8_t * r, * g, * b; | 1596 | uint8_t * r, * g, * b; |
1597 | uint8_t * dst_1, * dst_2; | 1597 | uint8_t * dst_1, * dst_2; |
1598 | int width, height, dst_height; | 1598 | int width, height, dst_height; |
1599 | int dy; | 1599 | int dy; |
1600 | 1600 | ||
1601 | if (this->do_scale) { | 1601 | if (this->do_scale) { |
1602 | 1602 | ||
1603 | scale_line_func_t scale_line = this->scale_line; | 1603 | scale_line_func_t scale_line = this->scale_line; |
1604 | 1604 | ||
1605 | scale_line (_pu, this->u_buffer, | 1605 | scale_line (_pu, this->u_buffer, |
1606 | this->dest_width >> 1, this->step_dx); | 1606 | this->dest_width >> 1, this->step_dx); |
1607 | scale_line (_pv, this->v_buffer, | 1607 | scale_line (_pv, this->v_buffer, |
1608 | this->dest_width >> 1, this->step_dx); | 1608 | this->dest_width >> 1, this->step_dx); |
1609 | scale_line (_py, this->y_buffer, | 1609 | scale_line (_py, this->y_buffer, |
1610 | this->dest_width, this->step_dx); | 1610 | this->dest_width, this->step_dx); |
1611 | 1611 | ||
1612 | dy = 0; | 1612 | dy = 0; |
1613 | dst_height = this->dest_height; | 1613 | dst_height = this->dest_height; |
1614 | 1614 | ||
1615 | for (height = 0;; ) { | 1615 | for (height = 0;; ) { |
1616 | dst_1 = _dst; | 1616 | dst_1 = _dst; |
1617 | py_1 = this->y_buffer; | 1617 | py_1 = this->y_buffer; |
1618 | pu = this->u_buffer; | 1618 | pu = this->u_buffer; |
1619 | pv = this->v_buffer; | 1619 | pv = this->v_buffer; |
1620 | 1620 | ||
1621 | width = this->dest_width >> 3; | 1621 | width = this->dest_width >> 3; |
1622 | 1622 | ||
1623 | do { | 1623 | do { |
1624 | RGB(0); | 1624 | RGB(0); |
1625 | DST1BGR(0); | 1625 | DST1BGR(0); |
1626 | 1626 | ||
1627 | RGB(1); | 1627 | RGB(1); |
1628 | DST1BGR(1); | 1628 | DST1BGR(1); |
1629 | 1629 | ||
1630 | RGB(2); | 1630 | RGB(2); |
1631 | DST1BGR(2); | 1631 | DST1BGR(2); |
1632 | 1632 | ||
1633 | RGB(3); | 1633 | RGB(3); |
1634 | DST1BGR(3); | 1634 | DST1BGR(3); |
1635 | 1635 | ||
1636 | pu += 4; | 1636 | pu += 4; |
1637 | pv += 4; | 1637 | pv += 4; |
1638 | py_1 += 8; | 1638 | py_1 += 8; |
1639 | dst_1 += 24; | 1639 | dst_1 += 24; |
1640 | } while (--width); | 1640 | } while (--width); |
1641 | 1641 | ||
1642 | dy += this->step_dy; | 1642 | dy += this->step_dy; |
1643 | _dst += this->rgb_stride; | 1643 | _dst += this->rgb_stride; |
1644 | 1644 | ||
1645 | while (--dst_height > 0 && dy < 32768) { | 1645 | while (--dst_height > 0 && dy < 32768) { |
1646 | 1646 | ||
1647 | xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); | 1647 | xine_fast_memcpy (_dst, _dst-this->rgb_stride, this->dest_width*3); |
1648 | 1648 | ||
1649 | dy += this->step_dy; | 1649 | dy += this->step_dy; |
1650 | _dst += this->rgb_stride; | 1650 | _dst += this->rgb_stride; |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | if (dst_height <= 0) | 1653 | if (dst_height <= 0) |
1654 | break; | 1654 | break; |
1655 | 1655 | ||
1656 | do { | 1656 | do { |
1657 | dy -= 32768; | 1657 | dy -= 32768; |
1658 | _py += this->y_stride; | 1658 | _py += this->y_stride; |
1659 | 1659 | ||
1660 | scale_line (_py, this->y_buffer, | 1660 | scale_line (_py, this->y_buffer, |
1661 | this->dest_width, this->step_dx); | 1661 | this->dest_width, this->step_dx); |
1662 | 1662 | ||
1663 | if (height & 1) { | 1663 | if (height & 1) { |
1664 | _pu += this->uv_stride; | 1664 | _pu += this->uv_stride; |
1665 | _pv += this->uv_stride; | 1665 | _pv += this->uv_stride; |
1666 | 1666 | ||
1667 | scale_line (_pu, this->u_buffer, | 1667 | scale_line (_pu, this->u_buffer, |
1668 | this->dest_width >> 1, this->step_dx); | 1668 | this->dest_width >> 1, this->step_dx); |
1669 | scale_line (_pv, this->v_buffer, | 1669 | scale_line (_pv, this->v_buffer, |
1670 | this->dest_width >> 1, this->step_dx); | 1670 | this->dest_width >> 1, this->step_dx); |
1671 | 1671 | ||
1672 | } | 1672 | } |
1673 | height++; | 1673 | height++; |
1674 | } while( dy>=32768 ); | 1674 | } while( dy>=32768 ); |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | } else { | 1677 | } else { |
1678 | height = this->source_height >> 1; | 1678 | height = this->source_height >> 1; |
1679 | do { | 1679 | do { |
1680 | dst_1 = _dst; | 1680 | dst_1 = _dst; |
1681 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); | 1681 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); |
1682 | py_1 = _py; | 1682 | py_1 = _py; |
1683 | py_2 = _py + this->y_stride; | 1683 | py_2 = _py + this->y_stride; |
1684 | pu = _pu; | 1684 | pu = _pu; |
1685 | pv = _pv; | 1685 | pv = _pv; |
1686 | width = this->source_width >> 3; | 1686 | width = this->source_width >> 3; |
1687 | do { | 1687 | do { |
1688 | RGB(0); | 1688 | RGB(0); |
1689 | DST1BGR(0); | 1689 | DST1BGR(0); |
1690 | DST2BGR(0); | 1690 | DST2BGR(0); |
1691 | 1691 | ||
1692 | RGB(1); | 1692 | RGB(1); |
1693 | DST2BGR(1); | 1693 | DST2BGR(1); |
1694 | DST1BGR(1); | 1694 | DST1BGR(1); |
1695 | 1695 | ||
1696 | RGB(2); | 1696 | RGB(2); |
1697 | DST1BGR(2); | 1697 | DST1BGR(2); |
1698 | DST2BGR(2); | 1698 | DST2BGR(2); |
1699 | 1699 | ||
1700 | RGB(3); | 1700 | RGB(3); |
1701 | DST2BGR(3); | 1701 | DST2BGR(3); |
1702 | DST1BGR(3); | 1702 | DST1BGR(3); |
1703 | 1703 | ||
1704 | pu += 4; | 1704 | pu += 4; |
1705 | pv += 4; | 1705 | pv += 4; |
1706 | py_1 += 8; | 1706 | py_1 += 8; |
1707 | py_2 += 8; | 1707 | py_2 += 8; |
1708 | dst_1 += 24; | 1708 | dst_1 += 24; |
1709 | dst_2 += 24; | 1709 | dst_2 += 24; |
1710 | } while (--width); | 1710 | } while (--width); |
1711 | 1711 | ||
1712 | _dst += 2 * this->rgb_stride; | 1712 | _dst += 2 * this->rgb_stride; |
1713 | _py += 2 * this->y_stride; | 1713 | _py += 2 * this->y_stride; |
1714 | _pu += this->uv_stride; | 1714 | _pu += this->uv_stride; |
1715 | _pv += this->uv_stride; | 1715 | _pv += this->uv_stride; |
1716 | 1716 | ||
1717 | } while (--height); | 1717 | } while (--height); |
1718 | } | 1718 | } |
1719 | } | 1719 | } |
1720 | 1720 | ||
1721 | /* This is exactly the same code as yuv2rgb_c_32 except for the types of */ | 1721 | /* This is exactly the same code as yuv2rgb_c_32 except for the types of */ |
1722 | /* r, g, b, dst_1, dst_2 */ | 1722 | /* r, g, b, dst_1, dst_2 */ |
1723 | static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, | 1723 | static void yuv2rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, |
1724 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 1724 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
1725 | { | 1725 | { |
1726 | int U, V, Y; | 1726 | int U, V, Y; |
1727 | uint8_t * py_1, * py_2, * pu, * pv; | 1727 | uint8_t * py_1, * py_2, * pu, * pv; |
1728 | uint16_t * r, * g, * b; | 1728 | uint16_t * r, * g, * b; |
1729 | uint16_t * dst_1, * dst_2; | 1729 | uint16_t * dst_1, * dst_2; |
1730 | int width, height, dst_height; | 1730 | int width, height, dst_height; |
1731 | int dy; | 1731 | int dy; |
1732 | 1732 | ||
1733 | if (this->do_scale) { | 1733 | if (this->do_scale) { |
1734 | scale_line_func_t scale_line = this->scale_line; | 1734 | scale_line_func_t scale_line = this->scale_line; |
1735 | 1735 | ||
1736 | scale_line (_pu, this->u_buffer, | 1736 | scale_line (_pu, this->u_buffer, |
1737 | this->dest_width >> 1, this->step_dx); | 1737 | this->dest_width >> 1, this->step_dx); |
1738 | scale_line (_pv, this->v_buffer, | 1738 | scale_line (_pv, this->v_buffer, |
1739 | this->dest_width >> 1, this->step_dx); | 1739 | this->dest_width >> 1, this->step_dx); |
1740 | scale_line (_py, this->y_buffer, | 1740 | scale_line (_py, this->y_buffer, |
1741 | this->dest_width, this->step_dx); | 1741 | this->dest_width, this->step_dx); |
1742 | 1742 | ||
1743 | dy = 0; | 1743 | dy = 0; |
1744 | dst_height = this->dest_height; | 1744 | dst_height = this->dest_height; |
1745 | 1745 | ||
1746 | for (height = 0;; ) { | 1746 | for (height = 0;; ) { |
1747 | dst_1 = (uint16_t*)_dst; | 1747 | dst_1 = (uint16_t*)_dst; |
1748 | py_1 = this->y_buffer; | 1748 | py_1 = this->y_buffer; |
1749 | pu = this->u_buffer; | 1749 | pu = this->u_buffer; |
1750 | pv = this->v_buffer; | 1750 | pv = this->v_buffer; |
1751 | 1751 | ||
1752 | width = this->dest_width >> 3; | 1752 | width = this->dest_width >> 3; |
1753 | 1753 | ||
1754 | do { | 1754 | do { |
1755 | RGB(0); | 1755 | RGB(0); |
1756 | DST1(0); | 1756 | DST1(0); |
1757 | 1757 | ||
1758 | RGB(1); | 1758 | RGB(1); |
1759 | DST1(1); | 1759 | DST1(1); |
1760 | 1760 | ||
1761 | RGB(2); | 1761 | RGB(2); |
1762 | DST1(2); | 1762 | DST1(2); |
1763 | 1763 | ||
1764 | RGB(3); | 1764 | RGB(3); |
1765 | DST1(3); | 1765 | DST1(3); |
1766 | 1766 | ||
1767 | pu += 4; | 1767 | pu += 4; |
1768 | pv += 4; | 1768 | pv += 4; |
1769 | py_1 += 8; | 1769 | py_1 += 8; |
1770 | dst_1 += 8; | 1770 | dst_1 += 8; |
1771 | } while (--width); | 1771 | } while (--width); |
1772 | 1772 | ||
1773 | dy += this->step_dy; | 1773 | dy += this->step_dy; |
1774 | _dst += this->rgb_stride; | 1774 | _dst += this->rgb_stride; |
1775 | 1775 | ||
1776 | while (--dst_height > 0 && dy < 32768) { | 1776 | while (--dst_height > 0 && dy < 32768) { |
1777 | 1777 | ||
1778 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); | 1778 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); |
1779 | 1779 | ||
1780 | dy += this->step_dy; | 1780 | dy += this->step_dy; |
1781 | _dst += this->rgb_stride; | 1781 | _dst += this->rgb_stride; |
1782 | } | 1782 | } |
1783 | 1783 | ||
1784 | if (dst_height <= 0) | 1784 | if (dst_height <= 0) |
1785 | break; | 1785 | break; |
1786 | 1786 | ||
1787 | do { | 1787 | do { |
1788 | dy -= 32768; | 1788 | dy -= 32768; |
1789 | _py += this->y_stride; | 1789 | _py += this->y_stride; |
1790 | 1790 | ||
1791 | scale_line (_py, this->y_buffer, | 1791 | scale_line (_py, this->y_buffer, |
1792 | this->dest_width, this->step_dx); | 1792 | this->dest_width, this->step_dx); |
1793 | 1793 | ||
1794 | if (height & 1) { | 1794 | if (height & 1) { |
1795 | _pu += this->uv_stride; | 1795 | _pu += this->uv_stride; |
1796 | _pv += this->uv_stride; | 1796 | _pv += this->uv_stride; |
1797 | 1797 | ||
1798 | scale_line (_pu, this->u_buffer, | 1798 | scale_line (_pu, this->u_buffer, |
1799 | this->dest_width >> 1, this->step_dx); | 1799 | this->dest_width >> 1, this->step_dx); |
1800 | scale_line (_pv, this->v_buffer, | 1800 | scale_line (_pv, this->v_buffer, |
1801 | this->dest_width >> 1, this->step_dx); | 1801 | this->dest_width >> 1, this->step_dx); |
1802 | 1802 | ||
1803 | } | 1803 | } |
1804 | height++; | 1804 | height++; |
1805 | } while( dy>=32768); | 1805 | } while( dy>=32768); |
1806 | } | 1806 | } |
1807 | } else { | 1807 | } else { |
1808 | height = this->source_height >> 1; | 1808 | height = this->source_height >> 1; |
1809 | do { | 1809 | do { |
1810 | dst_1 = (uint16_t*)_dst; | 1810 | dst_1 = (uint16_t*)_dst; |
1811 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); | 1811 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); |
1812 | py_1 = _py; | 1812 | py_1 = _py; |
1813 | py_2 = _py + this->y_stride; | 1813 | py_2 = _py + this->y_stride; |
1814 | pu = _pu; | 1814 | pu = _pu; |
1815 | pv = _pv; | 1815 | pv = _pv; |
1816 | width = this->source_width >> 3; | 1816 | width = this->source_width >> 3; |
1817 | do { | 1817 | do { |
1818 | RGB(0); | 1818 | RGB(0); |
1819 | DST1(0); | 1819 | DST1(0); |
1820 | DST2(0); | 1820 | DST2(0); |
1821 | 1821 | ||
1822 | RGB(1); | 1822 | RGB(1); |
1823 | DST2(1); | 1823 | DST2(1); |
1824 | DST1(1); | 1824 | DST1(1); |
1825 | 1825 | ||
1826 | RGB(2); | 1826 | RGB(2); |
1827 | DST1(2); | 1827 | DST1(2); |
1828 | DST2(2); | 1828 | DST2(2); |
1829 | 1829 | ||
1830 | RGB(3); | 1830 | RGB(3); |
1831 | DST2(3); | 1831 | DST2(3); |
1832 | DST1(3); | 1832 | DST1(3); |
1833 | 1833 | ||
1834 | pu += 4; | 1834 | pu += 4; |
1835 | pv += 4; | 1835 | pv += 4; |
1836 | py_1 += 8; | 1836 | py_1 += 8; |
1837 | py_2 += 8; | 1837 | py_2 += 8; |
1838 | dst_1 += 8; | 1838 | dst_1 += 8; |
1839 | dst_2 += 8; | 1839 | dst_2 += 8; |
1840 | } while (--width); | 1840 | } while (--width); |
1841 | 1841 | ||
1842 | _dst += 2 * this->rgb_stride; | 1842 | _dst += 2 * this->rgb_stride; |
1843 | _py += 2 * this->y_stride; | 1843 | _py += 2 * this->y_stride; |
1844 | _pu += this->uv_stride; | 1844 | _pu += this->uv_stride; |
1845 | _pv += this->uv_stride; | 1845 | _pv += this->uv_stride; |
1846 | 1846 | ||
1847 | } while (--height); | 1847 | } while (--height); |
1848 | } | 1848 | } |
1849 | } | 1849 | } |
1850 | 1850 | ||
1851 | /* This is exactly the same code as yuv2rgb_c_32 except for the types of */ | 1851 | /* This is exactly the same code as yuv2rgb_c_32 except for the types of */ |
1852 | /* r, g, b, dst_1, dst_2 */ | 1852 | /* r, g, b, dst_1, dst_2 */ |
1853 | static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, | 1853 | static void yuv2rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, |
1854 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 1854 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
1855 | { | 1855 | { |
1856 | int U, V, Y; | 1856 | int U, V, Y; |
1857 | uint8_t * py_1, * py_2, * pu, * pv; | 1857 | uint8_t * py_1, * py_2, * pu, * pv; |
1858 | uint8_t * r, * g, * b; | 1858 | uint8_t * r, * g, * b; |
1859 | uint8_t * dst_1, * dst_2; | 1859 | uint8_t * dst_1, * dst_2; |
1860 | int width, height, dst_height; | 1860 | int width, height, dst_height; |
1861 | int dy; | 1861 | int dy; |
1862 | 1862 | ||
1863 | if (this->do_scale) { | 1863 | if (this->do_scale) { |
1864 | scale_line_func_t scale_line = this->scale_line; | 1864 | scale_line_func_t scale_line = this->scale_line; |
1865 | 1865 | ||
1866 | scale_line (_pu, this->u_buffer, | 1866 | scale_line (_pu, this->u_buffer, |
1867 | this->dest_width >> 1, this->step_dx); | 1867 | this->dest_width >> 1, this->step_dx); |
1868 | scale_line (_pv, this->v_buffer, | 1868 | scale_line (_pv, this->v_buffer, |
1869 | this->dest_width >> 1, this->step_dx); | 1869 | this->dest_width >> 1, this->step_dx); |
1870 | scale_line (_py, this->y_buffer, | 1870 | scale_line (_py, this->y_buffer, |
1871 | this->dest_width, this->step_dx); | 1871 | this->dest_width, this->step_dx); |
1872 | 1872 | ||
1873 | dy = 0; | 1873 | dy = 0; |
1874 | dst_height = this->dest_height; | 1874 | dst_height = this->dest_height; |
1875 | 1875 | ||
1876 | for (height = 0;; ) { | 1876 | for (height = 0;; ) { |
1877 | dst_1 = (uint8_t*)_dst; | 1877 | dst_1 = (uint8_t*)_dst; |
1878 | py_1 = this->y_buffer; | 1878 | py_1 = this->y_buffer; |
1879 | pu = this->u_buffer; | 1879 | pu = this->u_buffer; |
1880 | pv = this->v_buffer; | 1880 | pv = this->v_buffer; |
1881 | 1881 | ||
1882 | width = this->dest_width >> 3; | 1882 | width = this->dest_width >> 3; |
1883 | 1883 | ||
1884 | do { | 1884 | do { |
1885 | RGB(0); | 1885 | RGB(0); |
1886 | DST1(0); | 1886 | DST1(0); |
1887 | 1887 | ||
1888 | RGB(1); | 1888 | RGB(1); |
1889 | DST1(1); | 1889 | DST1(1); |
1890 | 1890 | ||
1891 | RGB(2); | 1891 | RGB(2); |
1892 | DST1(2); | 1892 | DST1(2); |
1893 | 1893 | ||
1894 | RGB(3); | 1894 | RGB(3); |
1895 | DST1(3); | 1895 | DST1(3); |
1896 | 1896 | ||
1897 | pu += 4; | 1897 | pu += 4; |
1898 | pv += 4; | 1898 | pv += 4; |
1899 | py_1 += 8; | 1899 | py_1 += 8; |
1900 | dst_1 += 8; | 1900 | dst_1 += 8; |
1901 | } while (--width); | 1901 | } while (--width); |
1902 | 1902 | ||
1903 | dy += this->step_dy; | 1903 | dy += this->step_dy; |
1904 | _dst += this->rgb_stride; | 1904 | _dst += this->rgb_stride; |
1905 | 1905 | ||
1906 | while (--dst_height > 0 && dy < 32768) { | 1906 | while (--dst_height > 0 && dy < 32768) { |
1907 | 1907 | ||
1908 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 1908 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
1909 | 1909 | ||
1910 | dy += this->step_dy; | 1910 | dy += this->step_dy; |
1911 | _dst += this->rgb_stride; | 1911 | _dst += this->rgb_stride; |
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | if (dst_height <= 0) | 1914 | if (dst_height <= 0) |
1915 | break; | 1915 | break; |
1916 | 1916 | ||
1917 | do { | 1917 | do { |
1918 | dy -= 32768; | 1918 | dy -= 32768; |
1919 | _py += this->y_stride; | 1919 | _py += this->y_stride; |
1920 | 1920 | ||
1921 | scale_line (_py, this->y_buffer, | 1921 | scale_line (_py, this->y_buffer, |
1922 | this->dest_width, this->step_dx); | 1922 | this->dest_width, this->step_dx); |
1923 | 1923 | ||
1924 | if (height & 1) { | 1924 | if (height & 1) { |
1925 | _pu += this->uv_stride; | 1925 | _pu += this->uv_stride; |
1926 | _pv += this->uv_stride; | 1926 | _pv += this->uv_stride; |
1927 | 1927 | ||
1928 | scale_line (_pu, this->u_buffer, | 1928 | scale_line (_pu, this->u_buffer, |
1929 | this->dest_width >> 1, this->step_dx); | 1929 | this->dest_width >> 1, this->step_dx); |
1930 | scale_line (_pv, this->v_buffer, | 1930 | scale_line (_pv, this->v_buffer, |
1931 | this->dest_width >> 1, this->step_dx); | 1931 | this->dest_width >> 1, this->step_dx); |
1932 | 1932 | ||
1933 | } | 1933 | } |
1934 | height++; | 1934 | height++; |
1935 | } while( dy>=32768 ); | 1935 | } while( dy>=32768 ); |
1936 | } | 1936 | } |
1937 | } else { | 1937 | } else { |
1938 | height = this->source_height >> 1; | 1938 | height = this->source_height >> 1; |
1939 | do { | 1939 | do { |
1940 | dst_1 = (uint8_t*)_dst; | 1940 | dst_1 = (uint8_t*)_dst; |
1941 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); | 1941 | dst_2 = (void*)( (uint8_t *)_dst + this->rgb_stride ); |
1942 | py_1 = _py; | 1942 | py_1 = _py; |
1943 | py_2 = _py + this->y_stride; | 1943 | py_2 = _py + this->y_stride; |
1944 | pu = _pu; | 1944 | pu = _pu; |
1945 | pv = _pv; | 1945 | pv = _pv; |
1946 | 1946 | ||
1947 | width = this->source_width >> 3; | 1947 | width = this->source_width >> 3; |
1948 | do { | 1948 | do { |
1949 | RGB(0); | 1949 | RGB(0); |
1950 | DST1(0); | 1950 | DST1(0); |
1951 | DST2(0); | 1951 | DST2(0); |
1952 | 1952 | ||
1953 | RGB(1); | 1953 | RGB(1); |
1954 | DST2(1); | 1954 | DST2(1); |
1955 | DST1(1); | 1955 | DST1(1); |
1956 | 1956 | ||
1957 | RGB(2); | 1957 | RGB(2); |
1958 | DST1(2); | 1958 | DST1(2); |
1959 | DST2(2); | 1959 | DST2(2); |
1960 | 1960 | ||
1961 | RGB(3); | 1961 | RGB(3); |
1962 | DST2(3); | 1962 | DST2(3); |
1963 | DST1(3); | 1963 | DST1(3); |
1964 | 1964 | ||
1965 | pu += 4; | 1965 | pu += 4; |
1966 | pv += 4; | 1966 | pv += 4; |
1967 | py_1 += 8; | 1967 | py_1 += 8; |
1968 | py_2 += 8; | 1968 | py_2 += 8; |
1969 | dst_1 += 8; | 1969 | dst_1 += 8; |
1970 | dst_2 += 8; | 1970 | dst_2 += 8; |
1971 | } while (--width); | 1971 | } while (--width); |
1972 | 1972 | ||
1973 | _dst += 2 * this->rgb_stride; | 1973 | _dst += 2 * this->rgb_stride; |
1974 | _py += 2 * this->y_stride; | 1974 | _py += 2 * this->y_stride; |
1975 | _pu += this->uv_stride; | 1975 | _pu += this->uv_stride; |
1976 | _pv += this->uv_stride; | 1976 | _pv += this->uv_stride; |
1977 | 1977 | ||
1978 | } while (--height); | 1978 | } while (--height); |
1979 | } | 1979 | } |
1980 | } | 1980 | } |
1981 | 1981 | ||
1982 | /* now for something different: 256 grayscale mode */ | 1982 | /* now for something different: 256 grayscale mode */ |
1983 | static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, | 1983 | static void yuv2rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, |
1984 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 1984 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
1985 | { | 1985 | { |
1986 | int height, dst_height; | 1986 | int height, dst_height; |
1987 | int dy; | 1987 | int dy; |
1988 | 1988 | ||
1989 | if (this->do_scale) { | 1989 | if (this->do_scale) { |
1990 | scale_line_func_t scale_line = this->scale_line; | 1990 | scale_line_func_t scale_line = this->scale_line; |
1991 | 1991 | ||
1992 | dy = 0; | 1992 | dy = 0; |
1993 | dst_height = this->dest_height; | 1993 | dst_height = this->dest_height; |
1994 | 1994 | ||
1995 | for (;;) { | 1995 | for (;;) { |
1996 | scale_line (_py, _dst, this->dest_width, this->step_dx); | 1996 | scale_line (_py, _dst, this->dest_width, this->step_dx); |
1997 | 1997 | ||
1998 | dy += this->step_dy; | 1998 | dy += this->step_dy; |
1999 | _dst += this->rgb_stride; | 1999 | _dst += this->rgb_stride; |
2000 | 2000 | ||
2001 | while (--dst_height > 0 && dy < 32768) { | 2001 | while (--dst_height > 0 && dy < 32768) { |
2002 | 2002 | ||
2003 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2003 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2004 | 2004 | ||
2005 | dy += this->step_dy; | 2005 | dy += this->step_dy; |
2006 | _dst += this->rgb_stride; | 2006 | _dst += this->rgb_stride; |
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | if (dst_height <= 0) | 2009 | if (dst_height <= 0) |
2010 | break; | 2010 | break; |
2011 | 2011 | ||
2012 | _py += this->y_stride*(dy>>15); | 2012 | _py += this->y_stride*(dy>>15); |
2013 | dy &= 32767; | 2013 | dy &= 32767; |
2014 | /* dy -= 32768; | 2014 | /* dy -= 32768; |
2015 | _py += this->y_stride; | 2015 | _py += this->y_stride; |
2016 | */ | 2016 | */ |
2017 | } | 2017 | } |
2018 | } else { | 2018 | } else { |
2019 | for (height = this->source_height; --height >= 0; ) { | 2019 | for (height = this->source_height; --height >= 0; ) { |
2020 | xine_fast_memcpy(_dst, _py, this->dest_width); | 2020 | xine_fast_memcpy(_dst, _py, this->dest_width); |
2021 | _dst += this->rgb_stride; | 2021 | _dst += this->rgb_stride; |
2022 | _py += this->y_stride; | 2022 | _py += this->y_stride; |
2023 | } | 2023 | } |
2024 | } | 2024 | } |
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | /* now for something different: 256 color mode */ | 2027 | /* now for something different: 256 color mode */ |
2028 | static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, | 2028 | static void yuv2rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, |
2029 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) | 2029 | uint8_t * _py, uint8_t * _pu, uint8_t * _pv) |
2030 | { | 2030 | { |
2031 | int U, V, Y; | 2031 | int U, V, Y; |
2032 | uint8_t * py_1, * py_2, * pu, * pv; | 2032 | uint8_t * py_1, * py_2, * pu, * pv; |
2033 | uint16_t * r, * g, * b; | 2033 | uint16_t * r, * g, * b; |
2034 | uint8_t * dst_1, * dst_2; | 2034 | uint8_t * dst_1, * dst_2; |
2035 | int width, height, dst_height; | 2035 | int width, height, dst_height; |
2036 | int dy; | 2036 | int dy; |
2037 | 2037 | ||
2038 | if (this->do_scale) { | 2038 | if (this->do_scale) { |
2039 | scale_line_func_t scale_line = this->scale_line; | 2039 | scale_line_func_t scale_line = this->scale_line; |
2040 | 2040 | ||
2041 | scale_line (_pu, this->u_buffer, | 2041 | scale_line (_pu, this->u_buffer, |
2042 | this->dest_width >> 1, this->step_dx); | 2042 | this->dest_width >> 1, this->step_dx); |
2043 | scale_line (_pv, this->v_buffer, | 2043 | scale_line (_pv, this->v_buffer, |
2044 | this->dest_width >> 1, this->step_dx); | 2044 | this->dest_width >> 1, this->step_dx); |
2045 | scale_line (_py, this->y_buffer, | 2045 | scale_line (_py, this->y_buffer, |
2046 | this->dest_width, this->step_dx); | 2046 | this->dest_width, this->step_dx); |
2047 | 2047 | ||
2048 | dy = 0; | 2048 | dy = 0; |
2049 | dst_height = this->dest_height; | 2049 | dst_height = this->dest_height; |
2050 | 2050 | ||
2051 | for (height = 0;; ) { | 2051 | for (height = 0;; ) { |
2052 | dst_1 = _dst; | 2052 | dst_1 = _dst; |
2053 | py_1 = this->y_buffer; | 2053 | py_1 = this->y_buffer; |
2054 | pu = this->u_buffer; | 2054 | pu = this->u_buffer; |
2055 | pv = this->v_buffer; | 2055 | pv = this->v_buffer; |
2056 | 2056 | ||
2057 | width = this->dest_width >> 3; | 2057 | width = this->dest_width >> 3; |
2058 | 2058 | ||
2059 | do { | 2059 | do { |
2060 | RGB(0); | 2060 | RGB(0); |
2061 | DST1CMAP(0); | 2061 | DST1CMAP(0); |
2062 | 2062 | ||
2063 | RGB(1); | 2063 | RGB(1); |
2064 | DST1CMAP(1); | 2064 | DST1CMAP(1); |
2065 | 2065 | ||
2066 | RGB(2); | 2066 | RGB(2); |
2067 | DST1CMAP(2); | 2067 | DST1CMAP(2); |
2068 | 2068 | ||
2069 | RGB(3); | 2069 | RGB(3); |
2070 | DST1CMAP(3); | 2070 | DST1CMAP(3); |
2071 | 2071 | ||
2072 | pu += 4; | 2072 | pu += 4; |
2073 | pv += 4; | 2073 | pv += 4; |
2074 | py_1 += 8; | 2074 | py_1 += 8; |
2075 | dst_1 += 8; | 2075 | dst_1 += 8; |
2076 | } while (--width); | 2076 | } while (--width); |
2077 | 2077 | ||
2078 | dy += this->step_dy; | 2078 | dy += this->step_dy; |
2079 | _dst += this->rgb_stride; | 2079 | _dst += this->rgb_stride; |
2080 | 2080 | ||
2081 | while (--dst_height > 0 && dy < 32768) { | 2081 | while (--dst_height > 0 && dy < 32768) { |
2082 | 2082 | ||
2083 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2083 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2084 | 2084 | ||
2085 | dy += this->step_dy; | 2085 | dy += this->step_dy; |
2086 | _dst += this->rgb_stride; | 2086 | _dst += this->rgb_stride; |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | if (dst_height <= 0) | 2089 | if (dst_height <= 0) |
2090 | break; | 2090 | break; |
2091 | 2091 | ||
2092 | do { | 2092 | do { |
2093 | dy -= 32768; | 2093 | dy -= 32768; |
2094 | _py += this->y_stride; | 2094 | _py += this->y_stride; |
2095 | 2095 | ||
2096 | scale_line (_py, this->y_buffer, | 2096 | scale_line (_py, this->y_buffer, |
2097 | this->dest_width, this->step_dx); | 2097 | this->dest_width, this->step_dx); |
2098 | 2098 | ||
2099 | if (height & 1) { | 2099 | if (height & 1) { |
2100 | _pu += this->uv_stride; | 2100 | _pu += this->uv_stride; |
2101 | _pv += this->uv_stride; | 2101 | _pv += this->uv_stride; |
2102 | 2102 | ||
2103 | scale_line (_pu, this->u_buffer, | 2103 | scale_line (_pu, this->u_buffer, |
2104 | this->dest_width >> 1, this->step_dx); | 2104 | this->dest_width >> 1, this->step_dx); |
2105 | scale_line (_pv, this->v_buffer, | 2105 | scale_line (_pv, this->v_buffer, |
2106 | this->dest_width >> 1, this->step_dx); | 2106 | this->dest_width >> 1, this->step_dx); |
2107 | 2107 | ||
2108 | } | 2108 | } |
2109 | height++; | 2109 | height++; |
2110 | } while( dy>=32768 ); | 2110 | } while( dy>=32768 ); |
2111 | } | 2111 | } |
2112 | } else { | 2112 | } else { |
2113 | height = this->source_height >> 1; | 2113 | height = this->source_height >> 1; |
2114 | do { | 2114 | do { |
2115 | dst_1 = _dst; | 2115 | dst_1 = _dst; |
2116 | dst_2 = _dst + this->rgb_stride; | 2116 | dst_2 = _dst + this->rgb_stride; |
2117 | py_1 = _py; | 2117 | py_1 = _py; |
2118 | py_2 = _py + this->y_stride; | 2118 | py_2 = _py + this->y_stride; |
2119 | pu = _pu; | 2119 | pu = _pu; |
2120 | pv = _pv; | 2120 | pv = _pv; |
2121 | width = this->source_width >> 3; | 2121 | width = this->source_width >> 3; |
2122 | do { | 2122 | do { |
2123 | RGB(0); | 2123 | RGB(0); |
2124 | DST1CMAP(0); | 2124 | DST1CMAP(0); |
2125 | DST2CMAP(0); | 2125 | DST2CMAP(0); |
2126 | 2126 | ||
2127 | RGB(1); | 2127 | RGB(1); |
2128 | DST2CMAP(1); | 2128 | DST2CMAP(1); |
2129 | DST1CMAP(1); | 2129 | DST1CMAP(1); |
2130 | 2130 | ||
2131 | RGB(2); | 2131 | RGB(2); |
2132 | DST1CMAP(2); | 2132 | DST1CMAP(2); |
2133 | DST2CMAP(2); | 2133 | DST2CMAP(2); |
2134 | 2134 | ||
2135 | RGB(3); | 2135 | RGB(3); |
2136 | DST2CMAP(3); | 2136 | DST2CMAP(3); |
2137 | DST1CMAP(3); | 2137 | DST1CMAP(3); |
2138 | 2138 | ||
2139 | pu += 4; | 2139 | pu += 4; |
2140 | pv += 4; | 2140 | pv += 4; |
2141 | py_1 += 8; | 2141 | py_1 += 8; |
2142 | py_2 += 8; | 2142 | py_2 += 8; |
2143 | dst_1 += 8; | 2143 | dst_1 += 8; |
2144 | dst_2 += 8; | 2144 | dst_2 += 8; |
2145 | } while (--width); | 2145 | } while (--width); |
2146 | 2146 | ||
2147 | _dst += 2 * this->rgb_stride; | 2147 | _dst += 2 * this->rgb_stride; |
2148 | _py += 2 * this->y_stride; | 2148 | _py += 2 * this->y_stride; |
2149 | _pu += this->uv_stride; | 2149 | _pu += this->uv_stride; |
2150 | _pv += this->uv_stride; | 2150 | _pv += this->uv_stride; |
2151 | 2151 | ||
2152 | } while (--height); | 2152 | } while (--height); |
2153 | } | 2153 | } |
2154 | } | 2154 | } |
2155 | 2155 | ||
2156 | static int div_round (int dividend, int divisor) | 2156 | static int div_round (int dividend, int divisor) |
2157 | { | 2157 | { |
2158 | if (dividend > 0) | 2158 | if (dividend > 0) |
2159 | return (dividend + (divisor>>1)) / divisor; | 2159 | return (dividend + (divisor>>1)) / divisor; |
2160 | else | 2160 | else |
2161 | return -((-dividend + (divisor>>1)) / divisor); | 2161 | return -((-dividend + (divisor>>1)) / divisor); |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) | 2164 | static void yuv2rgb_setup_tables (yuv2rgb_factory_t *this, int mode, int swapped) |
2165 | { | 2165 | { |
2166 | int i; | 2166 | int i; |
2167 | uint8_t table_Y[1024]; | 2167 | uint8_t table_Y[1024]; |
2168 | uint32_t * table_32 = 0; | 2168 | uint32_t * table_32 = 0; |
2169 | uint16_t * table_16 = 0; | 2169 | uint16_t * table_16 = 0; |
2170 | uint8_t * table_8 = 0; | 2170 | uint8_t * table_8 = 0; |
2171 | int entry_size = 0; | 2171 | int entry_size = 0; |
2172 | void *table_r = 0, *table_g = 0, *table_b = 0; | 2172 | void *table_r = 0, *table_g = 0, *table_b = 0; |
2173 | int shift_r = 0, shift_g = 0, shift_b = 0; | 2173 | int shift_r = 0, shift_g = 0, shift_b = 0; |
2174 | 2174 | ||
2175 | int crv = Inverse_Table_6_9[this->matrix_coefficients][0]; | 2175 | int crv = Inverse_Table_6_9[this->matrix_coefficients][0]; |
2176 | int cbu = Inverse_Table_6_9[this->matrix_coefficients][1]; | 2176 | int cbu = Inverse_Table_6_9[this->matrix_coefficients][1]; |
2177 | int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2]; | 2177 | int cgu = -Inverse_Table_6_9[this->matrix_coefficients][2]; |
2178 | int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3]; | 2178 | int cgv = -Inverse_Table_6_9[this->matrix_coefficients][3]; |
2179 | 2179 | ||
2180 | for (i = 0; i < 1024; i++) { | 2180 | for (i = 0; i < 1024; i++) { |
2181 | int j; | 2181 | int j; |
2182 | 2182 | ||
2183 | j = (76309 * (i - 384 - 16) + 32768) >> 16; | 2183 | j = (76309 * (i - 384 - 16) + 32768) >> 16; |
2184 | j = (j < 0) ? 0 : ((j > 255) ? 255 : j); | 2184 | j = (j < 0) ? 0 : ((j > 255) ? 255 : j); |
2185 | table_Y[i] = j; | 2185 | table_Y[i] = j; |
2186 | } | 2186 | } |
2187 | 2187 | ||
2188 | switch (mode) { | 2188 | switch (mode) { |
2189 | case MODE_32_RGB: | 2189 | case MODE_32_RGB: |
2190 | case MODE_32_BGR: | 2190 | case MODE_32_BGR: |
2191 | table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); | 2191 | table_32 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint32_t)); |
2192 | 2192 | ||
2193 | entry_size = sizeof (uint32_t); | 2193 | entry_size = sizeof (uint32_t); |
2194 | table_r = table_32 + 197; | 2194 | table_r = table_32 + 197; |
2195 | table_b = table_32 + 197 + 685; | 2195 | table_b = table_32 + 197 + 685; |
2196 | table_g = table_32 + 197 + 2*682; | 2196 | table_g = table_32 + 197 + 2*682; |
2197 | 2197 | ||
2198 | if (swapped) { | 2198 | if (swapped) { |
2199 | switch (mode) { | 2199 | switch (mode) { |
2200 | case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break; | 2200 | case MODE_32_RGB: shift_r = 8; shift_g = 16; shift_b = 24; break; |
2201 | case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break; | 2201 | case MODE_32_BGR:shift_r = 24; shift_g = 16; shift_b = 8; break; |
2202 | } | 2202 | } |
2203 | } else { | 2203 | } else { |
2204 | switch (mode) { | 2204 | switch (mode) { |
2205 | case MODE_32_RGB:shift_r = 16; shift_g = 8; shift_b = 0; break; | 2205 | case MODE_32_RGB:shift_r = 16; shift_g = 8; shift_b = 0; break; |
2206 | case MODE_32_BGR:shift_r = 0; shift_g = 8; shift_b = 16; break; | 2206 | case MODE_32_BGR:shift_r = 0; shift_g = 8; shift_b = 16; break; |
2207 | } | 2207 | } |
2208 | } | 2208 | } |
2209 | 2209 | ||
2210 | for (i = -197; i < 256+197; i++) | 2210 | for (i = -197; i < 256+197; i++) |
2211 | ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r; | 2211 | ((uint32_t *) table_r)[i] = table_Y[i+384] << shift_r; |
2212 | for (i = -132; i < 256+132; i++) | 2212 | for (i = -132; i < 256+132; i++) |
2213 | ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g; | 2213 | ((uint32_t *) table_g)[i] = table_Y[i+384] << shift_g; |
2214 | for (i = -232; i < 256+232; i++) | 2214 | for (i = -232; i < 256+232; i++) |
2215 | ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b; | 2215 | ((uint32_t *) table_b)[i] = table_Y[i+384] << shift_b; |
2216 | break; | 2216 | break; |
2217 | 2217 | ||
2218 | case MODE_24_RGB: | 2218 | case MODE_24_RGB: |
2219 | case MODE_24_BGR: | 2219 | case MODE_24_BGR: |
2220 | table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); | 2220 | table_8 = malloc ((256 + 2*232) * sizeof (uint8_t)); |
2221 | 2221 | ||
2222 | entry_size = sizeof (uint8_t); | 2222 | entry_size = sizeof (uint8_t); |
2223 | table_r = table_g = table_b = table_8 + 232; | 2223 | table_r = table_g = table_b = table_8 + 232; |
2224 | 2224 | ||
2225 | for (i = -232; i < 256+232; i++) | 2225 | for (i = -232; i < 256+232; i++) |
2226 | ((uint8_t * )table_b)[i] = table_Y[i+384]; | 2226 | ((uint8_t * )table_b)[i] = table_Y[i+384]; |
2227 | break; | 2227 | break; |
2228 | 2228 | ||
2229 | case MODE_15_BGR: | 2229 | case MODE_15_BGR: |
2230 | case MODE_16_BGR: | 2230 | case MODE_16_BGR: |
2231 | case MODE_15_RGB: | 2231 | case MODE_15_RGB: |
2232 | case MODE_16_RGB: | 2232 | case MODE_16_RGB: |
2233 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | 2233 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); |
2234 | 2234 | ||
2235 | entry_size = sizeof (uint16_t); | 2235 | entry_size = sizeof (uint16_t); |
2236 | table_r = table_16 + 197; | 2236 | table_r = table_16 + 197; |
2237 | table_b = table_16 + 197 + 685; | 2237 | table_b = table_16 + 197 + 685; |
2238 | table_g = table_16 + 197 + 2*682; | 2238 | table_g = table_16 + 197 + 2*682; |
2239 | 2239 | ||
2240 | if (swapped) { | 2240 | if (swapped) { |
2241 | switch (mode) { | 2241 | switch (mode) { |
2242 | case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break; | 2242 | case MODE_15_BGR: shift_r = 8; shift_g = 5; shift_b = 2; break; |
2243 | case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break; | 2243 | case MODE_16_BGR:shift_r = 8; shift_g = 5; shift_b = 3; break; |
2244 | case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break; | 2244 | case MODE_15_RGB:shift_r = 2; shift_g = 5; shift_b = 8; break; |
2245 | case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break; | 2245 | case MODE_16_RGB:shift_r = 3; shift_g = 5; shift_b = 8; break; |
2246 | } | 2246 | } |
2247 | } else { | 2247 | } else { |
2248 | switch (mode) { | 2248 | switch (mode) { |
2249 | case MODE_15_BGR:shift_r = 0; shift_g = 5; shift_b = 10; break; | 2249 | case MODE_15_BGR:shift_r = 0; shift_g = 5; shift_b = 10; break; |
2250 | case MODE_16_BGR:shift_r = 0; shift_g = 5; shift_b = 11; break; | 2250 | case MODE_16_BGR:shift_r = 0; shift_g = 5; shift_b = 11; break; |
2251 | case MODE_15_RGB:shift_r = 10; shift_g = 5; shift_b = 0; break; | 2251 | case MODE_15_RGB:shift_r = 10; shift_g = 5; shift_b = 0; break; |
2252 | case MODE_16_RGB:shift_r = 11; shift_g = 5; shift_b = 0; break; | 2252 | case MODE_16_RGB:shift_r = 11; shift_g = 5; shift_b = 0; break; |
2253 | } | 2253 | } |
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | for (i = -197; i < 256+197; i++) | 2256 | for (i = -197; i < 256+197; i++) |
2257 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << shift_r; | 2257 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << shift_r; |
2258 | 2258 | ||
2259 | for (i = -132; i < 256+132; i++) { | 2259 | for (i = -132; i < 256+132; i++) { |
2260 | int j = table_Y[i+384] >> (((mode==MODE_16_RGB) || (mode==MODE_16_BGR)) ? 2 : 3); | 2260 | int j = table_Y[i+384] >> (((mode==MODE_16_RGB) || (mode==MODE_16_BGR)) ? 2 : 3); |
2261 | if (swapped) | 2261 | if (swapped) |
2262 | ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3); | 2262 | ((uint16_t *)table_g)[i] = (j&7) << 13 | (j>>3); |
2263 | else | 2263 | else |
2264 | ((uint16_t *)table_g)[i] = j << 5; | 2264 | ((uint16_t *)table_g)[i] = j << 5; |
2265 | } | 2265 | } |
2266 | for (i = -232; i < 256+232; i++) | 2266 | for (i = -232; i < 256+232; i++) |
2267 | ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b; | 2267 | ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << shift_b; |
2268 | 2268 | ||
2269 | break; | 2269 | break; |
2270 | 2270 | ||
2271 | case MODE_8_RGB: | 2271 | case MODE_8_RGB: |
2272 | case MODE_8_BGR: | 2272 | case MODE_8_BGR: |
2273 | table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); | 2273 | table_8 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint8_t)); |
2274 | 2274 | ||
2275 | entry_size = sizeof (uint8_t); | 2275 | entry_size = sizeof (uint8_t); |
2276 | table_r = table_8 + 197; | 2276 | table_r = table_8 + 197; |
2277 | table_b = table_8 + 197 + 685; | 2277 | table_b = table_8 + 197 + 685; |
2278 | table_g = table_8 + 197 + 2*682; | 2278 | table_g = table_8 + 197 + 2*682; |
2279 | 2279 | ||
2280 | switch (mode) { | 2280 | switch (mode) { |
2281 | case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break; | 2281 | case MODE_8_RGB: shift_r = 5; shift_g = 2; shift_b = 0; break; |
2282 | case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break; | 2282 | case MODE_8_BGR: shift_r = 0; shift_g = 3; shift_b = 6; break; |
2283 | } | 2283 | } |
2284 | 2284 | ||
2285 | for (i = -197; i < 256+197; i++) | 2285 | for (i = -197; i < 256+197; i++) |
2286 | ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r; | 2286 | ((uint8_t *) table_r)[i] = (table_Y[i+384] >> 5) << shift_r; |
2287 | for (i = -132; i < 256+132; i++) | 2287 | for (i = -132; i < 256+132; i++) |
2288 | ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g; | 2288 | ((uint8_t *) table_g)[i] = (table_Y[i+384] >> 5) << shift_g; |
2289 | for (i = -232; i < 256+232; i++) | 2289 | for (i = -232; i < 256+232; i++) |
2290 | ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b; | 2290 | ((uint8_t *) table_b)[i] = (table_Y[i+384] >> 6) << shift_b; |
2291 | break; | 2291 | break; |
2292 | 2292 | ||
2293 | case MODE_8_GRAY: | 2293 | case MODE_8_GRAY: |
2294 | return; | 2294 | return; |
2295 | 2295 | ||
2296 | case MODE_PALETTE: | 2296 | case MODE_PALETTE: |
2297 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); | 2297 | table_16 = malloc ((197 + 2*682 + 256 + 132) * sizeof (uint16_t)); |
2298 | 2298 | ||
2299 | entry_size = sizeof (uint16_t); | 2299 | entry_size = sizeof (uint16_t); |
2300 | table_r = table_16 + 197; | 2300 | table_r = table_16 + 197; |
2301 | table_b = table_16 + 197 + 685; | 2301 | table_b = table_16 + 197 + 685; |
2302 | table_g = table_16 + 197 + 2*682; | 2302 | table_g = table_16 + 197 + 2*682; |
2303 | 2303 | ||
2304 | shift_r = 10; | 2304 | shift_r = 10; |
2305 | shift_g = 5; | 2305 | shift_g = 5; |
2306 | shift_b = 0; | 2306 | shift_b = 0; |
2307 | 2307 | ||
2308 | for (i = -197; i < 256+197; i++) | 2308 | for (i = -197; i < 256+197; i++) |
2309 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10; | 2309 | ((uint16_t *)table_r)[i] = (table_Y[i+384] >> 3) << 10; |
2310 | 2310 | ||
2311 | for (i = -132; i < 256+132; i++) | 2311 | for (i = -132; i < 256+132; i++) |
2312 | ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5; | 2312 | ((uint16_t *)table_g)[i] = (table_Y[i+384] >> 3) << 5; |
2313 | 2313 | ||
2314 | for (i = -232; i < 256+232; i++) | 2314 | for (i = -232; i < 256+232; i++) |
2315 | ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0; | 2315 | ((uint16_t *)table_b)[i] = (table_Y[i+384] >> 3) << 0; |
2316 | 2316 | ||
2317 | break; | 2317 | break; |
2318 | 2318 | ||
2319 | 2319 | ||
2320 | default: | 2320 | default: |
2321 | fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode); | 2321 | fprintf (stderr, "mode %d not supported by yuv2rgb\n", mode); |
2322 | abort(); | 2322 | abort(); |
2323 | } | 2323 | } |
2324 | 2324 | ||
2325 | for (i = 0; i < 256; i++) { | 2325 | for (i = 0; i < 256; i++) { |
2326 | this->table_rV[i] = (((uint8_t *) table_r) + | 2326 | this->table_rV[i] = (((uint8_t *) table_r) + |
2327 | entry_size * div_round (crv * (i-128), 76309)); | 2327 | entry_size * div_round (crv * (i-128), 76309)); |
2328 | this->table_gU[i] = (((uint8_t *) table_g) + | 2328 | this->table_gU[i] = (((uint8_t *) table_g) + |
2329 | entry_size * div_round (cgu * (i-128), 76309)); | 2329 | entry_size * div_round (cgu * (i-128), 76309)); |
2330 | this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); | 2330 | this->table_gV[i] = entry_size * div_round (cgv * (i-128), 76309); |
2331 | this->table_bU[i] = (((uint8_t *)table_b) + | 2331 | this->table_bU[i] = (((uint8_t *)table_b) + |
2332 | entry_size * div_round (cbu * (i-128), 76309)); | 2332 | entry_size * div_round (cbu * (i-128), 76309)); |
2333 | } | 2333 | } |
2334 | this->gamma = 0; | 2334 | this->gamma = 0; |
2335 | this->entry_size = entry_size; | 2335 | this->entry_size = entry_size; |
2336 | } | 2336 | } |
2337 | 2337 | ||
2338 | static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2338 | static uint32_t yuv2rgb_single_pixel_32 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2339 | { | 2339 | { |
2340 | uint32_t * r, * g, * b; | 2340 | uint32_t * r, * g, * b; |
2341 | 2341 | ||
2342 | r = this->table_rV[v]; | 2342 | r = this->table_rV[v]; |
2343 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2343 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2344 | b = this->table_bU[u]; | 2344 | b = this->table_bU[u]; |
2345 | 2345 | ||
2346 | return r[y] + g[y] + b[y]; | 2346 | return r[y] + g[y] + b[y]; |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2349 | static uint32_t yuv2rgb_single_pixel_24_rgb (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2350 | { | 2350 | { |
2351 | uint8_t * r, * g, * b; | 2351 | uint8_t * r, * g, * b; |
2352 | 2352 | ||
2353 | r = this->table_rV[v]; | 2353 | r = this->table_rV[v]; |
2354 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2354 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2355 | b = this->table_bU[u]; | 2355 | b = this->table_bU[u]; |
2356 | 2356 | ||
2357 | return (uint32_t) r[y] + | 2357 | return (uint32_t) r[y] + |
2358 | ((uint32_t) g[y] << 8) + | 2358 | ((uint32_t) g[y] << 8) + |
2359 | ((uint32_t) b[y] << 16); | 2359 | ((uint32_t) b[y] << 16); |
2360 | } | 2360 | } |
2361 | 2361 | ||
2362 | static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2362 | static uint32_t yuv2rgb_single_pixel_24_bgr (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2363 | { | 2363 | { |
2364 | uint8_t * r, * g, * b; | 2364 | uint8_t * r, * g, * b; |
2365 | 2365 | ||
2366 | r = this->table_rV[v]; | 2366 | r = this->table_rV[v]; |
2367 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2367 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2368 | b = this->table_bU[u]; | 2368 | b = this->table_bU[u]; |
2369 | 2369 | ||
2370 | return (uint32_t) b[y] + | 2370 | return (uint32_t) b[y] + |
2371 | ((uint32_t) g[y] << 8) + | 2371 | ((uint32_t) g[y] << 8) + |
2372 | ((uint32_t) r[y] << 16); | 2372 | ((uint32_t) r[y] << 16); |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2375 | static uint32_t yuv2rgb_single_pixel_16 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2376 | { | 2376 | { |
2377 | uint16_t * r, * g, * b; | 2377 | uint16_t * r, * g, * b; |
2378 | 2378 | ||
2379 | r = this->table_rV[v]; | 2379 | r = this->table_rV[v]; |
2380 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2380 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2381 | b = this->table_bU[u]; | 2381 | b = this->table_bU[u]; |
2382 | 2382 | ||
2383 | return r[y] + g[y] + b[y]; | 2383 | return r[y] + g[y] + b[y]; |
2384 | } | 2384 | } |
2385 | 2385 | ||
2386 | static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2386 | static uint32_t yuv2rgb_single_pixel_8 (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2387 | { | 2387 | { |
2388 | uint8_t * r, * g, * b; | 2388 | uint8_t * r, * g, * b; |
2389 | 2389 | ||
2390 | r = this->table_rV[v]; | 2390 | r = this->table_rV[v]; |
2391 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2391 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2392 | b = this->table_bU[u]; | 2392 | b = this->table_bU[u]; |
2393 | 2393 | ||
2394 | return r[y] + g[y] + b[y]; | 2394 | return r[y] + g[y] + b[y]; |
2395 | } | 2395 | } |
2396 | 2396 | ||
2397 | static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2397 | static uint32_t yuv2rgb_single_pixel_gray (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2398 | { | 2398 | { |
2399 | return y; | 2399 | return y; |
2400 | } | 2400 | } |
2401 | 2401 | ||
2402 | static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) | 2402 | static uint32_t yuv2rgb_single_pixel_palette (yuv2rgb_t *this, uint8_t y, uint8_t u, uint8_t v) |
2403 | { | 2403 | { |
2404 | uint16_t * r, * g, * b; | 2404 | uint16_t * r, * g, * b; |
2405 | 2405 | ||
2406 | r = this->table_rV[v]; | 2406 | r = this->table_rV[v]; |
2407 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); | 2407 | g = (void *) (((uint8_t *)this->table_gU[u]) + this->table_gV[v]); |
2408 | b = this->table_bU[u]; | 2408 | b = this->table_bU[u]; |
2409 | 2409 | ||
2410 | return this->cmap[r[y] + g[y] + b[y]]; | 2410 | return this->cmap[r[y] + g[y] + b[y]]; |
2411 | } | 2411 | } |
2412 | 2412 | ||
2413 | 2413 | ||
2414 | static void yuv2rgb_c_init (yuv2rgb_factory_t *this) | 2414 | static void yuv2rgb_c_init (yuv2rgb_factory_t *this) |
2415 | { | 2415 | { |
2416 | switch (this->mode) { | 2416 | switch (this->mode) { |
2417 | case MODE_32_RGB: | 2417 | case MODE_32_RGB: |
2418 | case MODE_32_BGR: | 2418 | case MODE_32_BGR: |
2419 | this->yuv2rgb_fun = yuv2rgb_c_32; | 2419 | this->yuv2rgb_fun = yuv2rgb_c_32; |
2420 | break; | 2420 | break; |
2421 | 2421 | ||
2422 | case MODE_24_RGB: | 2422 | case MODE_24_RGB: |
2423 | case MODE_24_BGR: | 2423 | case MODE_24_BGR: |
2424 | this->yuv2rgb_fun = | 2424 | this->yuv2rgb_fun = |
2425 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) | 2425 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) |
2426 | ? yuv2rgb_c_24_rgb | 2426 | ? yuv2rgb_c_24_rgb |
2427 | : yuv2rgb_c_24_bgr; | 2427 | : yuv2rgb_c_24_bgr; |
2428 | break; | 2428 | break; |
2429 | 2429 | ||
2430 | case MODE_15_BGR: | 2430 | case MODE_15_BGR: |
2431 | case MODE_16_BGR: | 2431 | case MODE_16_BGR: |
2432 | case MODE_15_RGB: | 2432 | case MODE_15_RGB: |
2433 | case MODE_16_RGB: | 2433 | case MODE_16_RGB: |
2434 | this->yuv2rgb_fun = yuv2rgb_c_16; | 2434 | this->yuv2rgb_fun = yuv2rgb_c_16; |
2435 | break; | 2435 | break; |
2436 | 2436 | ||
2437 | case MODE_8_RGB: | 2437 | case MODE_8_RGB: |
2438 | case MODE_8_BGR: | 2438 | case MODE_8_BGR: |
2439 | this->yuv2rgb_fun = yuv2rgb_c_8; | 2439 | this->yuv2rgb_fun = yuv2rgb_c_8; |
2440 | break; | 2440 | break; |
2441 | 2441 | ||
2442 | case MODE_8_GRAY: | 2442 | case MODE_8_GRAY: |
2443 | this->yuv2rgb_fun = yuv2rgb_c_gray; | 2443 | this->yuv2rgb_fun = yuv2rgb_c_gray; |
2444 | break; | 2444 | break; |
2445 | 2445 | ||
2446 | case MODE_PALETTE: | 2446 | case MODE_PALETTE: |
2447 | this->yuv2rgb_fun = yuv2rgb_c_palette; | 2447 | this->yuv2rgb_fun = yuv2rgb_c_palette; |
2448 | break; | 2448 | break; |
2449 | 2449 | ||
2450 | default: | 2450 | default: |
2451 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); | 2451 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); |
2452 | abort(); | 2452 | abort(); |
2453 | } | 2453 | } |
2454 | 2454 | ||
2455 | } | 2455 | } |
2456 | 2456 | ||
2457 | static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { | 2457 | static void yuv2rgb_single_pixel_init (yuv2rgb_factory_t *this) { |
2458 | 2458 | ||
2459 | switch (this->mode) { | 2459 | switch (this->mode) { |
2460 | case MODE_32_RGB: | 2460 | case MODE_32_RGB: |
2461 | case MODE_32_BGR: | 2461 | case MODE_32_BGR: |
2462 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32; | 2462 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_32; |
2463 | break; | 2463 | break; |
2464 | 2464 | ||
2465 | case MODE_24_RGB: | 2465 | case MODE_24_RGB: |
2466 | case MODE_24_BGR: | 2466 | case MODE_24_BGR: |
2467 | this->yuv2rgb_single_pixel_fun = | 2467 | this->yuv2rgb_single_pixel_fun = |
2468 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) | 2468 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) |
2469 | ? yuv2rgb_single_pixel_24_rgb | 2469 | ? yuv2rgb_single_pixel_24_rgb |
2470 | : yuv2rgb_single_pixel_24_bgr; | 2470 | : yuv2rgb_single_pixel_24_bgr; |
2471 | break; | 2471 | break; |
2472 | 2472 | ||
2473 | case MODE_15_BGR: | 2473 | case MODE_15_BGR: |
2474 | case MODE_16_BGR: | 2474 | case MODE_16_BGR: |
2475 | case MODE_15_RGB: | 2475 | case MODE_15_RGB: |
2476 | case MODE_16_RGB: | 2476 | case MODE_16_RGB: |
2477 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_16; | 2477 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_16; |
2478 | break; | 2478 | break; |
2479 | 2479 | ||
2480 | case MODE_8_RGB: | 2480 | case MODE_8_RGB: |
2481 | case MODE_8_BGR: | 2481 | case MODE_8_BGR: |
2482 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8; | 2482 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_8; |
2483 | break; | 2483 | break; |
2484 | 2484 | ||
2485 | case MODE_8_GRAY: | 2485 | case MODE_8_GRAY: |
2486 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray; | 2486 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_gray; |
2487 | break; | 2487 | break; |
2488 | 2488 | ||
2489 | case MODE_PALETTE: | 2489 | case MODE_PALETTE: |
2490 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette; | 2490 | this->yuv2rgb_single_pixel_fun = yuv2rgb_single_pixel_palette; |
2491 | break; | 2491 | break; |
2492 | 2492 | ||
2493 | default: | 2493 | default: |
2494 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); | 2494 | printf ("yuv2rgb: mode %d not supported by yuv2rgb\n", this->mode); |
2495 | abort(); | 2495 | abort(); |
2496 | } | 2496 | } |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | 2499 | ||
2500 | /* | 2500 | /* |
2501 | * yuy2 stuff | 2501 | * yuy2 stuff |
2502 | */ | 2502 | */ |
2503 | 2503 | ||
2504 | static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2504 | static void yuy22rgb_c_32 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2505 | { | 2505 | { |
2506 | int U, V, Y; | 2506 | int U, V, Y; |
2507 | uint8_t * py_1, * pu, * pv; | 2507 | uint8_t * py_1, * pu, * pv; |
2508 | uint32_t * r, * g, * b; | 2508 | uint32_t * r, * g, * b; |
2509 | uint32_t * dst_1; | 2509 | uint32_t * dst_1; |
2510 | int width, height; | 2510 | int width, height; |
2511 | int dy; | 2511 | int dy; |
2512 | 2512 | ||
2513 | /* FIXME: implement unscaled version */ | 2513 | /* FIXME: implement unscaled version */ |
2514 | 2514 | ||
2515 | scale_line_4 (_p+1, this->u_buffer, | 2515 | scale_line_4 (_p+1, this->u_buffer, |
2516 | this->dest_width >> 1, this->step_dx); | 2516 | this->dest_width >> 1, this->step_dx); |
2517 | scale_line_4 (_p+3, this->v_buffer, | 2517 | scale_line_4 (_p+3, this->v_buffer, |
2518 | this->dest_width >> 1, this->step_dx); | 2518 | this->dest_width >> 1, this->step_dx); |
2519 | scale_line_2 (_p, this->y_buffer, | 2519 | scale_line_2 (_p, this->y_buffer, |
2520 | this->dest_width, this->step_dx); | 2520 | this->dest_width, this->step_dx); |
2521 | 2521 | ||
2522 | dy = 0; | 2522 | dy = 0; |
2523 | height = this->dest_height; | 2523 | height = this->dest_height; |
2524 | 2524 | ||
2525 | for (;;) { | 2525 | for (;;) { |
2526 | dst_1 = (uint32_t*)_dst; | 2526 | dst_1 = (uint32_t*)_dst; |
2527 | py_1 = this->y_buffer; | 2527 | py_1 = this->y_buffer; |
2528 | pu = this->u_buffer; | 2528 | pu = this->u_buffer; |
2529 | pv = this->v_buffer; | 2529 | pv = this->v_buffer; |
2530 | 2530 | ||
2531 | width = this->dest_width >> 3; | 2531 | width = this->dest_width >> 3; |
2532 | 2532 | ||
2533 | do { | 2533 | do { |
2534 | 2534 | ||
2535 | RGB(0); | 2535 | RGB(0); |
2536 | DST1(0); | 2536 | DST1(0); |
2537 | 2537 | ||
2538 | RGB(1); | 2538 | RGB(1); |
2539 | DST1(1); | 2539 | DST1(1); |
2540 | 2540 | ||
2541 | RGB(2); | 2541 | RGB(2); |
2542 | DST1(2); | 2542 | DST1(2); |
2543 | 2543 | ||
2544 | RGB(3); | 2544 | RGB(3); |
2545 | DST1(3); | 2545 | DST1(3); |
2546 | 2546 | ||
2547 | pu += 4; | 2547 | pu += 4; |
2548 | pv += 4; | 2548 | pv += 4; |
2549 | py_1 += 8; | 2549 | py_1 += 8; |
2550 | dst_1 += 8; | 2550 | dst_1 += 8; |
2551 | } while (--width); | 2551 | } while (--width); |
2552 | 2552 | ||
2553 | dy += this->step_dy; | 2553 | dy += this->step_dy; |
2554 | _dst += this->rgb_stride; | 2554 | _dst += this->rgb_stride; |
2555 | 2555 | ||
2556 | while (--height > 0 && dy < 32768) { | 2556 | while (--height > 0 && dy < 32768) { |
2557 | 2557 | ||
2558 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); | 2558 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*4); |
2559 | 2559 | ||
2560 | dy += this->step_dy; | 2560 | dy += this->step_dy; |
2561 | _dst += this->rgb_stride; | 2561 | _dst += this->rgb_stride; |
2562 | } | 2562 | } |
2563 | 2563 | ||
2564 | if (height <= 0) | 2564 | if (height <= 0) |
2565 | break; | 2565 | break; |
2566 | 2566 | ||
2567 | _p += this->y_stride*2*(dy>>15); | 2567 | _p += this->y_stride*2*(dy>>15); |
2568 | dy &= 32767; | 2568 | dy &= 32767; |
2569 | /* | 2569 | /* |
2570 | dy -= 32768; | 2570 | dy -= 32768; |
2571 | _p += this->y_stride*2; | 2571 | _p += this->y_stride*2; |
2572 | */ | 2572 | */ |
2573 | 2573 | ||
2574 | scale_line_4 (_p+1, this->u_buffer, | 2574 | scale_line_4 (_p+1, this->u_buffer, |
2575 | this->dest_width >> 1, this->step_dx); | 2575 | this->dest_width >> 1, this->step_dx); |
2576 | scale_line_4 (_p+3, this->v_buffer, | 2576 | scale_line_4 (_p+3, this->v_buffer, |
2577 | this->dest_width >> 1, this->step_dx); | 2577 | this->dest_width >> 1, this->step_dx); |
2578 | scale_line_2 (_p, this->y_buffer, | 2578 | scale_line_2 (_p, this->y_buffer, |
2579 | this->dest_width, this->step_dx); | 2579 | this->dest_width, this->step_dx); |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | 2582 | ||
2583 | static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2583 | static void yuy22rgb_c_24_rgb (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2584 | { | 2584 | { |
2585 | int U, V, Y; | 2585 | int U, V, Y; |
2586 | uint8_t * py_1, * pu, * pv; | 2586 | uint8_t * py_1, * pu, * pv; |
2587 | uint8_t * r, * g, * b; | 2587 | uint8_t * r, * g, * b; |
2588 | uint8_t * dst_1; | 2588 | uint8_t * dst_1; |
2589 | int width, height; | 2589 | int width, height; |
2590 | int dy; | 2590 | int dy; |
2591 | 2591 | ||
2592 | /* FIXME: implement unscaled version */ | 2592 | /* FIXME: implement unscaled version */ |
2593 | 2593 | ||
2594 | scale_line_4 (_p+1, this->u_buffer, | 2594 | scale_line_4 (_p+1, this->u_buffer, |
2595 | this->dest_width >> 1, this->step_dx); | 2595 | this->dest_width >> 1, this->step_dx); |
2596 | scale_line_4 (_p+3, this->v_buffer, | 2596 | scale_line_4 (_p+3, this->v_buffer, |
2597 | this->dest_width >> 1, this->step_dx); | 2597 | this->dest_width >> 1, this->step_dx); |
2598 | scale_line_2 (_p, this->y_buffer, | 2598 | scale_line_2 (_p, this->y_buffer, |
2599 | this->dest_width, this->step_dx); | 2599 | this->dest_width, this->step_dx); |
2600 | 2600 | ||
2601 | dy = 0; | 2601 | dy = 0; |
2602 | height = this->dest_height; | 2602 | height = this->dest_height; |
2603 | 2603 | ||
2604 | for (;;) { | 2604 | for (;;) { |
2605 | dst_1 = _dst; | 2605 | dst_1 = _dst; |
2606 | py_1 = this->y_buffer; | 2606 | py_1 = this->y_buffer; |
2607 | pu = this->u_buffer; | 2607 | pu = this->u_buffer; |
2608 | pv = this->v_buffer; | 2608 | pv = this->v_buffer; |
2609 | 2609 | ||
2610 | width = this->dest_width >> 3; | 2610 | width = this->dest_width >> 3; |
2611 | 2611 | ||
2612 | do { | 2612 | do { |
2613 | RGB(0); | 2613 | RGB(0); |
2614 | DST1RGB(0); | 2614 | DST1RGB(0); |
2615 | 2615 | ||
2616 | RGB(1); | 2616 | RGB(1); |
2617 | DST1RGB(1); | 2617 | DST1RGB(1); |
2618 | 2618 | ||
2619 | RGB(2); | 2619 | RGB(2); |
2620 | DST1RGB(2); | 2620 | DST1RGB(2); |
2621 | 2621 | ||
2622 | RGB(3); | 2622 | RGB(3); |
2623 | DST1RGB(3); | 2623 | DST1RGB(3); |
2624 | 2624 | ||
2625 | pu += 4; | 2625 | pu += 4; |
2626 | pv += 4; | 2626 | pv += 4; |
2627 | py_1 += 8; | 2627 | py_1 += 8; |
2628 | dst_1 += 24; | 2628 | dst_1 += 24; |
2629 | } while (--width); | 2629 | } while (--width); |
2630 | 2630 | ||
2631 | dy += this->step_dy; | 2631 | dy += this->step_dy; |
2632 | _dst += this->rgb_stride; | 2632 | _dst += this->rgb_stride; |
2633 | 2633 | ||
2634 | while (--height > 0 && dy < 32768) { | 2634 | while (--height > 0 && dy < 32768) { |
2635 | 2635 | ||
2636 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); | 2636 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); |
2637 | 2637 | ||
2638 | dy += this->step_dy; | 2638 | dy += this->step_dy; |
2639 | _dst += this->rgb_stride; | 2639 | _dst += this->rgb_stride; |
2640 | } | 2640 | } |
2641 | 2641 | ||
2642 | if (height <= 0) | 2642 | if (height <= 0) |
2643 | break; | 2643 | break; |
2644 | 2644 | ||
2645 | _p += this->y_stride*2*(dy>>15); | 2645 | _p += this->y_stride*2*(dy>>15); |
2646 | dy &= 32767; | 2646 | dy &= 32767; |
2647 | /* | 2647 | /* |
2648 | dy -= 32768; | 2648 | dy -= 32768; |
2649 | _p += this->y_stride*2; | 2649 | _p += this->y_stride*2; |
2650 | */ | 2650 | */ |
2651 | 2651 | ||
2652 | scale_line_4 (_p+1, this->u_buffer, | 2652 | scale_line_4 (_p+1, this->u_buffer, |
2653 | this->dest_width >> 1, this->step_dx); | 2653 | this->dest_width >> 1, this->step_dx); |
2654 | scale_line_4 (_p+3, this->v_buffer, | 2654 | scale_line_4 (_p+3, this->v_buffer, |
2655 | this->dest_width >> 1, this->step_dx); | 2655 | this->dest_width >> 1, this->step_dx); |
2656 | scale_line_2 (_p, this->y_buffer, | 2656 | scale_line_2 (_p, this->y_buffer, |
2657 | this->dest_width, this->step_dx); | 2657 | this->dest_width, this->step_dx); |
2658 | } | 2658 | } |
2659 | } | 2659 | } |
2660 | 2660 | ||
2661 | static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2661 | static void yuy22rgb_c_24_bgr (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2662 | { | 2662 | { |
2663 | int U, V, Y; | 2663 | int U, V, Y; |
2664 | uint8_t * py_1, * pu, * pv; | 2664 | uint8_t * py_1, * pu, * pv; |
2665 | uint8_t * r, * g, * b; | 2665 | uint8_t * r, * g, * b; |
2666 | uint8_t * dst_1; | 2666 | uint8_t * dst_1; |
2667 | int width, height; | 2667 | int width, height; |
2668 | int dy; | 2668 | int dy; |
2669 | 2669 | ||
2670 | /* FIXME: implement unscaled version */ | 2670 | /* FIXME: implement unscaled version */ |
2671 | 2671 | ||
2672 | scale_line_4 (_p+1, this->u_buffer, | 2672 | scale_line_4 (_p+1, this->u_buffer, |
2673 | this->dest_width >> 1, this->step_dx); | 2673 | this->dest_width >> 1, this->step_dx); |
2674 | scale_line_4 (_p+3, this->v_buffer, | 2674 | scale_line_4 (_p+3, this->v_buffer, |
2675 | this->dest_width >> 1, this->step_dx); | 2675 | this->dest_width >> 1, this->step_dx); |
2676 | scale_line_2 (_p, this->y_buffer, | 2676 | scale_line_2 (_p, this->y_buffer, |
2677 | this->dest_width, this->step_dx); | 2677 | this->dest_width, this->step_dx); |
2678 | 2678 | ||
2679 | dy = 0; | 2679 | dy = 0; |
2680 | height = this->dest_height; | 2680 | height = this->dest_height; |
2681 | 2681 | ||
2682 | for (;;) { | 2682 | for (;;) { |
2683 | dst_1 = _dst; | 2683 | dst_1 = _dst; |
2684 | py_1 = this->y_buffer; | 2684 | py_1 = this->y_buffer; |
2685 | pu = this->u_buffer; | 2685 | pu = this->u_buffer; |
2686 | pv = this->v_buffer; | 2686 | pv = this->v_buffer; |
2687 | 2687 | ||
2688 | width = this->dest_width >> 3; | 2688 | width = this->dest_width >> 3; |
2689 | 2689 | ||
2690 | do { | 2690 | do { |
2691 | RGB(0); | 2691 | RGB(0); |
2692 | DST1BGR(0); | 2692 | DST1BGR(0); |
2693 | 2693 | ||
2694 | RGB(1); | 2694 | RGB(1); |
2695 | DST1BGR(1); | 2695 | DST1BGR(1); |
2696 | 2696 | ||
2697 | RGB(2); | 2697 | RGB(2); |
2698 | DST1BGR(2); | 2698 | DST1BGR(2); |
2699 | 2699 | ||
2700 | RGB(3); | 2700 | RGB(3); |
2701 | DST1BGR(3); | 2701 | DST1BGR(3); |
2702 | 2702 | ||
2703 | pu += 4; | 2703 | pu += 4; |
2704 | pv += 4; | 2704 | pv += 4; |
2705 | py_1 += 8; | 2705 | py_1 += 8; |
2706 | dst_1 += 24; | 2706 | dst_1 += 24; |
2707 | } while (--width); | 2707 | } while (--width); |
2708 | 2708 | ||
2709 | dy += this->step_dy; | 2709 | dy += this->step_dy; |
2710 | _dst += this->rgb_stride; | 2710 | _dst += this->rgb_stride; |
2711 | 2711 | ||
2712 | while (--height > 0 && dy < 32768) { | 2712 | while (--height > 0 && dy < 32768) { |
2713 | 2713 | ||
2714 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); | 2714 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*3); |
2715 | 2715 | ||
2716 | dy += this->step_dy; | 2716 | dy += this->step_dy; |
2717 | _dst += this->rgb_stride; | 2717 | _dst += this->rgb_stride; |
2718 | } | 2718 | } |
2719 | 2719 | ||
2720 | if (height <= 0) | 2720 | if (height <= 0) |
2721 | break; | 2721 | break; |
2722 | 2722 | ||
2723 | _p += this->y_stride*2*(dy>>15); | 2723 | _p += this->y_stride*2*(dy>>15); |
2724 | dy &= 32767; | 2724 | dy &= 32767; |
2725 | 2725 | ||
2726 | scale_line_4 (_p+1, this->u_buffer, | 2726 | scale_line_4 (_p+1, this->u_buffer, |
2727 | this->dest_width >> 1, this->step_dx); | 2727 | this->dest_width >> 1, this->step_dx); |
2728 | scale_line_4 (_p+3, this->v_buffer, | 2728 | scale_line_4 (_p+3, this->v_buffer, |
2729 | this->dest_width >> 1, this->step_dx); | 2729 | this->dest_width >> 1, this->step_dx); |
2730 | scale_line_2 (_p, this->y_buffer, | 2730 | scale_line_2 (_p, this->y_buffer, |
2731 | this->dest_width, this->step_dx); | 2731 | this->dest_width, this->step_dx); |
2732 | } | 2732 | } |
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2735 | static void yuy22rgb_c_16 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2736 | { | 2736 | { |
2737 | int U, V, Y; | 2737 | int U, V, Y; |
2738 | uint8_t * py_1, * pu, * pv; | 2738 | uint8_t * py_1, * pu, * pv; |
2739 | uint16_t * r, * g, * b; | 2739 | uint16_t * r, * g, * b; |
2740 | uint16_t * dst_1; | 2740 | uint16_t * dst_1; |
2741 | int width, height; | 2741 | int width, height; |
2742 | int dy; | 2742 | int dy; |
2743 | 2743 | ||
2744 | /* FIXME: implement unscaled version */ | 2744 | /* FIXME: implement unscaled version */ |
2745 | 2745 | ||
2746 | scale_line_4 (_p+1, this->u_buffer, | 2746 | scale_line_4 (_p+1, this->u_buffer, |
2747 | this->dest_width >> 1, this->step_dx); | 2747 | this->dest_width >> 1, this->step_dx); |
2748 | scale_line_4 (_p+3, this->v_buffer, | 2748 | scale_line_4 (_p+3, this->v_buffer, |
2749 | this->dest_width >> 1, this->step_dx); | 2749 | this->dest_width >> 1, this->step_dx); |
2750 | scale_line_2 (_p, this->y_buffer, | 2750 | scale_line_2 (_p, this->y_buffer, |
2751 | this->dest_width, this->step_dx); | 2751 | this->dest_width, this->step_dx); |
2752 | 2752 | ||
2753 | dy = 0; | 2753 | dy = 0; |
2754 | height = this->dest_height; | 2754 | height = this->dest_height; |
2755 | 2755 | ||
2756 | for (;;) { | 2756 | for (;;) { |
2757 | dst_1 = (uint16_t*)_dst; | 2757 | dst_1 = (uint16_t*)_dst; |
2758 | py_1 = this->y_buffer; | 2758 | py_1 = this->y_buffer; |
2759 | pu = this->u_buffer; | 2759 | pu = this->u_buffer; |
2760 | pv = this->v_buffer; | 2760 | pv = this->v_buffer; |
2761 | 2761 | ||
2762 | width = this->dest_width >> 3; | 2762 | width = this->dest_width >> 3; |
2763 | 2763 | ||
2764 | do { | 2764 | do { |
2765 | RGB(0); | 2765 | RGB(0); |
2766 | DST1(0); | 2766 | DST1(0); |
2767 | 2767 | ||
2768 | RGB(1); | 2768 | RGB(1); |
2769 | DST1(1); | 2769 | DST1(1); |
2770 | 2770 | ||
2771 | RGB(2); | 2771 | RGB(2); |
2772 | DST1(2); | 2772 | DST1(2); |
2773 | 2773 | ||
2774 | RGB(3); | 2774 | RGB(3); |
2775 | DST1(3); | 2775 | DST1(3); |
2776 | 2776 | ||
2777 | pu += 4; | 2777 | pu += 4; |
2778 | pv += 4; | 2778 | pv += 4; |
2779 | py_1 += 8; | 2779 | py_1 += 8; |
2780 | dst_1 += 8; | 2780 | dst_1 += 8; |
2781 | } while (--width); | 2781 | } while (--width); |
2782 | 2782 | ||
2783 | dy += this->step_dy; | 2783 | dy += this->step_dy; |
2784 | _dst += this->rgb_stride; | 2784 | _dst += this->rgb_stride; |
2785 | 2785 | ||
2786 | while (--height > 0 && dy < 32768) { | 2786 | while (--height > 0 && dy < 32768) { |
2787 | 2787 | ||
2788 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); | 2788 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width*2); |
2789 | 2789 | ||
2790 | dy += this->step_dy; | 2790 | dy += this->step_dy; |
2791 | _dst += this->rgb_stride; | 2791 | _dst += this->rgb_stride; |
2792 | } | 2792 | } |
2793 | 2793 | ||
2794 | if (height <= 0) | 2794 | if (height <= 0) |
2795 | break; | 2795 | break; |
2796 | 2796 | ||
2797 | _p += this->y_stride*2*(dy>>15); | 2797 | _p += this->y_stride*2*(dy>>15); |
2798 | dy &= 32767; | 2798 | dy &= 32767; |
2799 | 2799 | ||
2800 | scale_line_4 (_p+1, this->u_buffer, | 2800 | scale_line_4 (_p+1, this->u_buffer, |
2801 | this->dest_width >> 1, this->step_dx); | 2801 | this->dest_width >> 1, this->step_dx); |
2802 | scale_line_4 (_p+3, this->v_buffer, | 2802 | scale_line_4 (_p+3, this->v_buffer, |
2803 | this->dest_width >> 1, this->step_dx); | 2803 | this->dest_width >> 1, this->step_dx); |
2804 | scale_line_2 (_p, this->y_buffer, | 2804 | scale_line_2 (_p, this->y_buffer, |
2805 | this->dest_width, this->step_dx); | 2805 | this->dest_width, this->step_dx); |
2806 | } | 2806 | } |
2807 | } | 2807 | } |
2808 | 2808 | ||
2809 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2809 | static void yuy22rgb_c_8 (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2810 | { | 2810 | { |
2811 | int U, V, Y; | 2811 | int U, V, Y; |
2812 | uint8_t * py_1, * pu, * pv; | 2812 | uint8_t * py_1, * pu, * pv; |
2813 | uint8_t * r, * g, * b; | 2813 | uint8_t * r, * g, * b; |
2814 | uint8_t * dst_1; | 2814 | uint8_t * dst_1; |
2815 | int width, height; | 2815 | int width, height; |
2816 | int dy; | 2816 | int dy; |
2817 | 2817 | ||
2818 | /* FIXME: implement unscaled version */ | 2818 | /* FIXME: implement unscaled version */ |
2819 | 2819 | ||
2820 | scale_line_4 (_p+1, this->u_buffer, | 2820 | scale_line_4 (_p+1, this->u_buffer, |
2821 | this->dest_width >> 1, this->step_dx); | 2821 | this->dest_width >> 1, this->step_dx); |
2822 | scale_line_4 (_p+3, this->v_buffer, | 2822 | scale_line_4 (_p+3, this->v_buffer, |
2823 | this->dest_width >> 1, this->step_dx); | 2823 | this->dest_width >> 1, this->step_dx); |
2824 | scale_line_2 (_p, this->y_buffer, | 2824 | scale_line_2 (_p, this->y_buffer, |
2825 | this->dest_width, this->step_dx); | 2825 | this->dest_width, this->step_dx); |
2826 | 2826 | ||
2827 | dy = 0; | 2827 | dy = 0; |
2828 | height = this->dest_height; | 2828 | height = this->dest_height; |
2829 | 2829 | ||
2830 | for (;;) { | 2830 | for (;;) { |
2831 | dst_1 = _dst; | 2831 | dst_1 = _dst; |
2832 | py_1 = this->y_buffer; | 2832 | py_1 = this->y_buffer; |
2833 | pu = this->u_buffer; | 2833 | pu = this->u_buffer; |
2834 | pv = this->v_buffer; | 2834 | pv = this->v_buffer; |
2835 | 2835 | ||
2836 | width = this->dest_width >> 3; | 2836 | width = this->dest_width >> 3; |
2837 | 2837 | ||
2838 | do { | 2838 | do { |
2839 | RGB(0); | 2839 | RGB(0); |
2840 | DST1(0); | 2840 | DST1(0); |
2841 | 2841 | ||
2842 | RGB(1); | 2842 | RGB(1); |
2843 | DST1(1); | 2843 | DST1(1); |
2844 | 2844 | ||
2845 | RGB(2); | 2845 | RGB(2); |
2846 | DST1(2); | 2846 | DST1(2); |
2847 | 2847 | ||
2848 | RGB(3); | 2848 | RGB(3); |
2849 | DST1(3); | 2849 | DST1(3); |
2850 | 2850 | ||
2851 | pu += 4; | 2851 | pu += 4; |
2852 | pv += 4; | 2852 | pv += 4; |
2853 | py_1 += 8; | 2853 | py_1 += 8; |
2854 | dst_1 += 8; | 2854 | dst_1 += 8; |
2855 | } while (--width); | 2855 | } while (--width); |
2856 | 2856 | ||
2857 | dy += this->step_dy; | 2857 | dy += this->step_dy; |
2858 | _dst += this->rgb_stride; | 2858 | _dst += this->rgb_stride; |
2859 | 2859 | ||
2860 | while (--height > 0 && dy < 32768) { | 2860 | while (--height > 0 && dy < 32768) { |
2861 | 2861 | ||
2862 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2862 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2863 | 2863 | ||
2864 | dy += this->step_dy; | 2864 | dy += this->step_dy; |
2865 | _dst += this->rgb_stride; | 2865 | _dst += this->rgb_stride; |
2866 | } | 2866 | } |
2867 | 2867 | ||
2868 | if (height <= 0) | 2868 | if (height <= 0) |
2869 | break; | 2869 | break; |
2870 | 2870 | ||
2871 | _p += this->y_stride*2*(dy>>15); | 2871 | _p += this->y_stride*2*(dy>>15); |
2872 | dy &= 32767; | 2872 | dy &= 32767; |
2873 | 2873 | ||
2874 | scale_line_4 (_p+1, this->u_buffer, | 2874 | scale_line_4 (_p+1, this->u_buffer, |
2875 | this->dest_width >> 1, this->step_dx); | 2875 | this->dest_width >> 1, this->step_dx); |
2876 | scale_line_4 (_p+3, this->v_buffer, | 2876 | scale_line_4 (_p+3, this->v_buffer, |
2877 | this->dest_width >> 1, this->step_dx); | 2877 | this->dest_width >> 1, this->step_dx); |
2878 | scale_line_2 (_p, this->y_buffer, | 2878 | scale_line_2 (_p, this->y_buffer, |
2879 | this->dest_width, this->step_dx); | 2879 | this->dest_width, this->step_dx); |
2880 | } | 2880 | } |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2883 | static void yuy22rgb_c_gray (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2884 | { | 2884 | { |
2885 | int width, height; | 2885 | int width, height; |
2886 | int dy; | 2886 | int dy; |
2887 | uint8_t * dst; | 2887 | uint8_t * dst; |
2888 | uint8_t * y; | 2888 | uint8_t * y; |
2889 | 2889 | ||
2890 | if (this->do_scale) { | 2890 | if (this->do_scale) { |
2891 | dy = 0; | 2891 | dy = 0; |
2892 | height = this->dest_height; | 2892 | height = this->dest_height; |
2893 | 2893 | ||
2894 | for (;;) { | 2894 | for (;;) { |
2895 | scale_line_2 (_p, _dst, this->dest_width, this->step_dx); | 2895 | scale_line_2 (_p, _dst, this->dest_width, this->step_dx); |
2896 | 2896 | ||
2897 | dy += this->step_dy; | 2897 | dy += this->step_dy; |
2898 | _dst += this->rgb_stride; | 2898 | _dst += this->rgb_stride; |
2899 | 2899 | ||
2900 | while (--height > 0 && dy < 32768) { | 2900 | while (--height > 0 && dy < 32768) { |
2901 | 2901 | ||
2902 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2902 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2903 | 2903 | ||
2904 | dy += this->step_dy; | 2904 | dy += this->step_dy; |
2905 | _dst += this->rgb_stride; | 2905 | _dst += this->rgb_stride; |
2906 | } | 2906 | } |
2907 | 2907 | ||
2908 | if (height <= 0) | 2908 | if (height <= 0) |
2909 | break; | 2909 | break; |
2910 | 2910 | ||
2911 | _p += this->y_stride*2*(dy>>15); | 2911 | _p += this->y_stride*2*(dy>>15); |
2912 | dy &= 32767; | 2912 | dy &= 32767; |
2913 | } | 2913 | } |
2914 | } else { | 2914 | } else { |
2915 | for (height = this->source_height; --height >= 0; ) { | 2915 | for (height = this->source_height; --height >= 0; ) { |
2916 | dst = _dst; | 2916 | dst = _dst; |
2917 | y = _p; | 2917 | y = _p; |
2918 | for (width = this->source_width; --width >= 0; ) { | 2918 | for (width = this->source_width; --width >= 0; ) { |
2919 | *dst++ = *y; | 2919 | *dst++ = *y; |
2920 | y += 2; | 2920 | y += 2; |
2921 | } | 2921 | } |
2922 | _dst += this->rgb_stride; | 2922 | _dst += this->rgb_stride; |
2923 | _p += this->y_stride*2; | 2923 | _p += this->y_stride*2; |
2924 | } | 2924 | } |
2925 | } | 2925 | } |
2926 | } | 2926 | } |
2927 | 2927 | ||
2928 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) | 2928 | static void yuy22rgb_c_palette (yuv2rgb_t *this, uint8_t * _dst, uint8_t * _p) |
2929 | { | 2929 | { |
2930 | int U, V, Y; | 2930 | int U, V, Y; |
2931 | uint8_t * py_1, * pu, * pv; | 2931 | uint8_t * py_1, * pu, * pv; |
2932 | uint16_t * r, * g, * b; | 2932 | uint16_t * r, * g, * b; |
2933 | uint8_t * dst_1; | 2933 | uint8_t * dst_1; |
2934 | int width, height; | 2934 | int width, height; |
2935 | int dy; | 2935 | int dy; |
2936 | 2936 | ||
2937 | scale_line_4 (_p+1, this->u_buffer, | 2937 | scale_line_4 (_p+1, this->u_buffer, |
2938 | this->dest_width >> 1, this->step_dx); | 2938 | this->dest_width >> 1, this->step_dx); |
2939 | scale_line_4 (_p+3, this->v_buffer, | 2939 | scale_line_4 (_p+3, this->v_buffer, |
2940 | this->dest_width >> 1, this->step_dx); | 2940 | this->dest_width >> 1, this->step_dx); |
2941 | scale_line_2 (_p, this->y_buffer, | 2941 | scale_line_2 (_p, this->y_buffer, |
2942 | this->dest_width, this->step_dx); | 2942 | this->dest_width, this->step_dx); |
2943 | 2943 | ||
2944 | dy = 0; | 2944 | dy = 0; |
2945 | height = this->dest_height; | 2945 | height = this->dest_height; |
2946 | 2946 | ||
2947 | for (;;) { | 2947 | for (;;) { |
2948 | dst_1 = _dst; | 2948 | dst_1 = _dst; |
2949 | py_1 = this->y_buffer; | 2949 | py_1 = this->y_buffer; |
2950 | pu = this->u_buffer; | 2950 | pu = this->u_buffer; |
2951 | pv = this->v_buffer; | 2951 | pv = this->v_buffer; |
2952 | 2952 | ||
2953 | width = this->dest_width >> 3; | 2953 | width = this->dest_width >> 3; |
2954 | 2954 | ||
2955 | do { | 2955 | do { |
2956 | RGB(0); | 2956 | RGB(0); |
2957 | DST1CMAP(0); | 2957 | DST1CMAP(0); |
2958 | 2958 | ||
2959 | RGB(1); | 2959 | RGB(1); |
2960 | DST1CMAP(1); | 2960 | DST1CMAP(1); |
2961 | 2961 | ||
2962 | RGB(2); | 2962 | RGB(2); |
2963 | DST1CMAP(2); | 2963 | DST1CMAP(2); |
2964 | 2964 | ||
2965 | RGB(3); | 2965 | RGB(3); |
2966 | DST1CMAP(3); | 2966 | DST1CMAP(3); |
2967 | 2967 | ||
2968 | pu += 4; | 2968 | pu += 4; |
2969 | pv += 4; | 2969 | pv += 4; |
2970 | py_1 += 8; | 2970 | py_1 += 8; |
2971 | dst_1 += 8; | 2971 | dst_1 += 8; |
2972 | } while (--width); | 2972 | } while (--width); |
2973 | 2973 | ||
2974 | dy += this->step_dy; | 2974 | dy += this->step_dy; |
2975 | _dst += this->rgb_stride; | 2975 | _dst += this->rgb_stride; |
2976 | 2976 | ||
2977 | while (--height > 0 && dy < 32768) { | 2977 | while (--height > 0 && dy < 32768) { |
2978 | 2978 | ||
2979 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); | 2979 | xine_fast_memcpy (_dst, (uint8_t*)_dst-this->rgb_stride, this->dest_width); |
2980 | 2980 | ||
2981 | dy += this->step_dy; | 2981 | dy += this->step_dy; |
2982 | _dst += this->rgb_stride; | 2982 | _dst += this->rgb_stride; |
2983 | } | 2983 | } |
2984 | 2984 | ||
2985 | if (height <= 0) | 2985 | if (height <= 0) |
2986 | break; | 2986 | break; |
2987 | 2987 | ||
2988 | _p += this->y_stride*2*(dy>>15); | 2988 | _p += this->y_stride*2*(dy>>15); |
2989 | dy &= 32767; | 2989 | dy &= 32767; |
2990 | 2990 | ||
2991 | scale_line_4 (_p+1, this->u_buffer, | 2991 | scale_line_4 (_p+1, this->u_buffer, |
2992 | this->dest_width >> 1, this->step_dx); | 2992 | this->dest_width >> 1, this->step_dx); |
2993 | scale_line_4 (_p+3, this->v_buffer, | 2993 | scale_line_4 (_p+3, this->v_buffer, |
2994 | this->dest_width >> 1, this->step_dx); | 2994 | this->dest_width >> 1, this->step_dx); |
2995 | scale_line_2 (_p, this->y_buffer, | 2995 | scale_line_2 (_p, this->y_buffer, |
2996 | this->dest_width, this->step_dx); | 2996 | this->dest_width, this->step_dx); |
2997 | } | 2997 | } |
2998 | } | 2998 | } |
2999 | 2999 | ||
3000 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) | 3000 | static void yuy22rgb_c_init (yuv2rgb_factory_t *this) |
3001 | { | 3001 | { |
3002 | switch (this->mode) { | 3002 | switch (this->mode) { |
3003 | case MODE_32_RGB: | 3003 | case MODE_32_RGB: |
3004 | case MODE_32_BGR: | 3004 | case MODE_32_BGR: |
3005 | this->yuy22rgb_fun = yuy22rgb_c_32; | 3005 | this->yuy22rgb_fun = yuy22rgb_c_32; |
3006 | break; | 3006 | break; |
3007 | 3007 | ||
3008 | case MODE_24_RGB: | 3008 | case MODE_24_RGB: |
3009 | case MODE_24_BGR: | 3009 | case MODE_24_BGR: |
3010 | this->yuy22rgb_fun = | 3010 | this->yuy22rgb_fun = |
3011 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) | 3011 | (this->mode==MODE_24_RGB && !this->swapped) || (this->mode==MODE_24_BGR && this->swapped) |
3012 | ? yuy22rgb_c_24_rgb | 3012 | ? yuy22rgb_c_24_rgb |
3013 | : yuy22rgb_c_24_bgr; | 3013 | : yuy22rgb_c_24_bgr; |
3014 | break; | 3014 | break; |
3015 | case MODE_15_BGR: | 3015 | case MODE_15_BGR: |
3016 | case MODE_16_BGR: | 3016 | case MODE_16_BGR: |
3017 | case MODE_15_RGB: | 3017 | case MODE_15_RGB: |
3018 | case MODE_16_RGB: | 3018 | case MODE_16_RGB: |
3019 | this->yuy22rgb_fun = yuy22rgb_c_16; | 3019 | this->yuy22rgb_fun = yuy22rgb_c_16; |
3020 | break; | 3020 | break; |
3021 | 3021 | ||
3022 | case MODE_8_RGB: | 3022 | case MODE_8_RGB: |
3023 | case MODE_8_BGR: | 3023 | case MODE_8_BGR: |
3024 | this->yuy22rgb_fun = yuy22rgb_c_8; | 3024 | this->yuy22rgb_fun = yuy22rgb_c_8; |
3025 | break; | 3025 | break; |
3026 | 3026 | ||
3027 | case MODE_8_GRAY: | 3027 | case MODE_8_GRAY: |
3028 | this->yuy22rgb_fun = yuy22rgb_c_gray; | 3028 | this->yuy22rgb_fun = yuy22rgb_c_gray; |
3029 | break; | 3029 | break; |
3030 | 3030 | ||
3031 | case MODE_PALETTE: | 3031 | case MODE_PALETTE: |
3032 | this->yuy22rgb_fun = yuy22rgb_c_palette; | 3032 | this->yuy22rgb_fun = yuy22rgb_c_palette; |
3033 | break; | 3033 | break; |
3034 | 3034 | ||
3035 | default: | 3035 | default: |
3036 | printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); | 3036 | printf ("yuv2rgb: mode %d not supported for yuy2\n", this->mode); |
3037 | } | 3037 | } |
3038 | } | 3038 | } |
3039 | 3039 | ||
3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { | 3040 | yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) { |
3041 | 3041 | ||
3042 | yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t)); | 3042 | yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t)); |
3043 | 3043 | ||
3044 | this->cmap = factory->cmap; | 3044 | this->cmap = factory->cmap; |
3045 | 3045 | ||
3046 | this->y_chunk = this->y_buffer = NULL; | 3046 | this->y_chunk = this->y_buffer = NULL; |
3047 | this->u_chunk = this->u_buffer = NULL; | 3047 | this->u_chunk = this->u_buffer = NULL; |
3048 | this->v_chunk = this->v_buffer = NULL; | 3048 | this->v_chunk = this->v_buffer = NULL; |
3049 | 3049 | ||
3050 | this->table_rV = factory->table_rV; | 3050 | this->table_rV = factory->table_rV; |
3051 | this->table_gU = factory->table_gU; | 3051 | this->table_gU = factory->table_gU; |
3052 | this->table_gV = factory->table_gV; | 3052 | this->table_gV = factory->table_gV; |
3053 | this->table_bU = factory->table_bU; | 3053 | this->table_bU = factory->table_bU; |
3054 | 3054 | ||
3055 | this->yuv2rgb_fun = factory->yuv2rgb_fun; | 3055 | this->yuv2rgb_fun = factory->yuv2rgb_fun; |
3056 | this->yuy22rgb_fun = factory->yuy22rgb_fun; | 3056 | this->yuy22rgb_fun = factory->yuy22rgb_fun; |
3057 | this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun; | 3057 | this->yuv2rgb_single_pixel_fun = factory->yuv2rgb_single_pixel_fun; |
3058 | 3058 | ||
3059 | this->configure = yuv2rgb_configure; | 3059 | this->configure = yuv2rgb_configure; |
3060 | return this; | 3060 | return this; |
3061 | } | 3061 | } |
3062 | 3062 | ||
3063 | /* | 3063 | /* |
3064 | * factory functions | 3064 | * factory functions |
3065 | */ | 3065 | */ |
3066 | |||
3067 | void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) { | 3066 | void yuv2rgb_set_gamma (yuv2rgb_factory_t *this, int gamma) { |
3068 | 3067 | ||
3069 | int i; | 3068 | int i; |
3070 | 3069 | ||
3071 | for (i = 0; i < 256; i++) { | 3070 | for (i = 0; i < 256; i++) { |
3072 | (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma); | 3071 | (uint8_t *)this->table_rV[i] += this->entry_size*(gamma - this->gamma); |
3073 | (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma); | 3072 | (uint8_t *)this->table_gU[i] += this->entry_size*(gamma - this->gamma); |
3074 | (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma); | 3073 | (uint8_t *)this->table_bU[i] += this->entry_size*(gamma - this->gamma); |
3075 | } | 3074 | } |
3076 | #ifdef ARCH_X86 | 3075 | #ifdef ARCH_X86 |
3077 | mmx_yuv2rgb_set_gamma(gamma); | 3076 | mmx_yuv2rgb_set_gamma(gamma); |
3078 | #endif | 3077 | #endif |
3079 | this->gamma = gamma; | 3078 | this->gamma = gamma; |
3080 | } | 3079 | } |
3081 | 3080 | ||
3082 | int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { | 3081 | int yuv2rgb_get_gamma (yuv2rgb_factory_t *this) { |
3083 | 3082 | ||
3084 | return this->gamma; | 3083 | return this->gamma; |
3085 | } | 3084 | } |
3086 | 3085 | ||
3087 | yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, | 3086 | yuv2rgb_factory_t* yuv2rgb_factory_init (int mode, int swapped, |
3088 | uint8_t *cmap) { | 3087 | uint8_t *cmap) { |
3089 | 3088 | ||
3090 | yuv2rgb_factory_t *this; | 3089 | yuv2rgb_factory_t *this; |
3091 | 3090 | ||
3092 | #ifdef ARCH_X86 | 3091 | #ifdef ARCH_X86 |
3093 | uint32_t mm = xine_mm_accel(); | 3092 | uint32_t mm = xine_mm_accel(); |
3094 | #endif | 3093 | #endif |
3095 | 3094 | ||
3096 | this = malloc (sizeof (yuv2rgb_factory_t)); | 3095 | this = malloc (sizeof (yuv2rgb_factory_t)); |
3097 | 3096 | ||
3098 | this->mode = mode; | 3097 | this->mode = mode; |
3099 | this->swapped = swapped; | 3098 | this->swapped = swapped; |
3100 | this->cmap = cmap; | 3099 | this->cmap = cmap; |
3101 | this->create_converter = yuv2rgb_create_converter; | 3100 | this->create_converter = yuv2rgb_create_converter; |
3102 | this->set_gamma = yuv2rgb_set_gamma; | 3101 | this->set_gamma = yuv2rgb_set_gamma; |
3103 | this->get_gamma = yuv2rgb_get_gamma; | 3102 | this->get_gamma = yuv2rgb_get_gamma; |
3104 | this->matrix_coefficients = 6; | 3103 | this->matrix_coefficients = 6; |
3105 | 3104 | ||
3106 | 3105 | ||
3107 | yuv2rgb_setup_tables (this, mode, swapped); | 3106 | yuv2rgb_setup_tables (this, mode, swapped); |
3108 | 3107 | ||
3109 | /* | 3108 | /* |
3110 | * auto-probe for the best yuv2rgb function | 3109 | * auto-probe for the best yuv2rgb function |
3111 | */ | 3110 | */ |
3112 | 3111 | ||
3113 | this->yuv2rgb_fun = NULL; | 3112 | this->yuv2rgb_fun = NULL; |
3114 | #ifdef ARCH_X86 | 3113 | #ifdef ARCH_X86 |
3115 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { | 3114 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMXEXT)) { |
3116 | 3115 | ||
3117 | yuv2rgb_init_mmxext (this); | 3116 | yuv2rgb_init_mmxext (this); |
3118 | 3117 | ||
3119 | if (this->yuv2rgb_fun != NULL) | 3118 | if (this->yuv2rgb_fun != NULL) |
3120 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); | 3119 | printf ("yuv2rgb: using MMXEXT for colorspace transform\n"); |
3121 | } | 3120 | } |
3122 | 3121 | ||
3123 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) { | 3122 | if ((this->yuv2rgb_fun == NULL) && (mm & MM_ACCEL_X86_MMX)) { |
3124 | 3123 | ||
3125 | yuv2rgb_init_mmx (this); | 3124 | yuv2rgb_init_mmx (this); |
3126 | 3125 | ||
3127 | if (this->yuv2rgb_fun != NULL) | 3126 | if (this->yuv2rgb_fun != NULL) |
3128 | printf ("yuv2rgb: using MMX for colorspace transform\n"); | 3127 | printf ("yuv2rgb: using MMX for colorspace transform\n"); |
3129 | } | 3128 | } |
3130 | #endif | 3129 | #endif |
3131 | #if HAVE_MLIB | 3130 | #if HAVE_MLIB |
3132 | if (this->yuv2rgb_fun == NULL) { | 3131 | if (this->yuv2rgb_fun == NULL) { |
3133 | 3132 | ||
3134 | yuv2rgb_init_mlib (this); | 3133 | yuv2rgb_init_mlib (this); |
3135 | 3134 | ||
3136 | if (this->yuv2rgb_fun != NULL) | 3135 | if (this->yuv2rgb_fun != NULL) |
3137 | printf ("yuv2rgb: using medialib for colorspace transform\n"); | 3136 | printf ("yuv2rgb: using medialib for colorspace transform\n"); |
3138 | } | 3137 | } |
3139 | #endif | 3138 | #endif |
3140 | #ifdef __arm__ | 3139 | #ifdef __arm__ |
3141 | if (this->yuv2rgb_fun == NULL) { | 3140 | if (this->yuv2rgb_fun == NULL) { |
3142 | yuv2rgb_init_arm ( this ); | 3141 | yuv2rgb_init_arm ( this ); |
3143 | 3142 | ||
3144 | if(this->yuv2rgb_fun != NULL) | 3143 | if(this->yuv2rgb_fun != NULL) |
3145 | printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); | 3144 | printf("yuv2rgb: using arm4l assembler for colorspace transform\n" ); |
3146 | } | 3145 | } |
3147 | #endif | 3146 | #endif |
3148 | if (this->yuv2rgb_fun == NULL) { | 3147 | if (this->yuv2rgb_fun == NULL) { |
3149 | printf ("yuv2rgb: no accelerated colorspace conversion found\n"); | 3148 | printf ("yuv2rgb: no accelerated colorspace conversion found\n"); |
3150 | yuv2rgb_c_init (this); | 3149 | yuv2rgb_c_init (this); |
3151 | } | 3150 | } |
3152 | 3151 | ||
3153 | /* | 3152 | /* |
3154 | * auto-probe for the best yuy22rgb function | 3153 | * auto-probe for the best yuy22rgb function |
3155 | */ | 3154 | */ |
3156 | 3155 | ||
3157 | /* FIXME: implement mmx/mlib functions */ | 3156 | /* FIXME: implement mmx/mlib functions */ |
3158 | yuy22rgb_c_init (this); | 3157 | yuy22rgb_c_init (this); |
3159 | 3158 | ||
3160 | /* | 3159 | /* |
3161 | * set up single pixel function | 3160 | * set up single pixel function |
3162 | */ | 3161 | */ |
3163 | 3162 | ||
3164 | yuv2rgb_single_pixel_init (this); | 3163 | yuv2rgb_single_pixel_init (this); |
3165 | 3164 | ||
3166 | return this; | 3165 | return this; |
3167 | } | 3166 | } |
3168 | 3167 | ||