author | sandman <sandman> | 2002-08-01 21:18:11 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-01 21:18:11 (UTC) |
commit | 54eb82d90a4ee254c0abb6d33937e76aeb32ddf1 (patch) (unidiff) | |
tree | e9628916c721262232efc3314a8ccd29613a7189 | |
parent | c80b2060a6f051f16690db4b8f0ccbc7dde84ec5 (diff) | |
download | opie-54eb82d90a4ee254c0abb6d33937e76aeb32ddf1.zip opie-54eb82d90a4ee254c0abb6d33937e76aeb32ddf1.tar.gz opie-54eb82d90a4ee254c0abb6d33937e76aeb32ddf1.tar.bz2 |
video in qvfb works now with 0/90/180/270° rotation
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/nullvideo.c | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 25 |
3 files changed, 22 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index ac5cdd5..5ae6c21 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,209 +1,209 @@ | |||
1 | 1 | ||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | //#include <qpe/qpeapplication.h> | 4 | //#include <qpe/qpeapplication.h> |
5 | #include <qimage.h> | 5 | #include <qimage.h> |
6 | #include <qpe/resource.h> | 6 | #include <qpe/resource.h> |
7 | 7 | ||
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | 9 | ||
10 | #include <qgfx_qws.h> | 10 | #include <qgfx_qws.h> |
11 | #include <qdirectpainter_qws.h> | 11 | #include <qdirectpainter_qws.h> |
12 | 12 | ||
13 | #include "xinevideowidget.h" | 13 | #include "xinevideowidget.h" |
14 | #include "frame.h" | 14 | #include "frame.h" |
15 | #include "lib.h" | 15 | #include "lib.h" |
16 | 16 | ||
17 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 17 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
18 | int width, int height,int bytes ); | 18 | int width, int height,int bytes ); |
19 | 19 | ||
20 | extern "C" { | 20 | extern "C" { |
21 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); | 21 | vo_driver_t* init_video_out_plugin( config_values_t* conf, void* video); |
22 | int null_is_showing_video( vo_driver_t* self ); | 22 | int null_is_showing_video( vo_driver_t* self ); |
23 | void null_set_show_video( vo_driver_t* self, int show ); | 23 | void null_set_show_video( vo_driver_t* self, int show ); |
24 | int null_is_fullscreen( vo_driver_t* self ); | 24 | int null_is_fullscreen( vo_driver_t* self ); |
25 | void null_set_fullscreen( vo_driver_t* self, int screen ); | 25 | void null_set_fullscreen( vo_driver_t* self, int screen ); |
26 | int null_is_scaling( vo_driver_t* self ); | 26 | int null_is_scaling( vo_driver_t* self ); |
27 | void null_set_scaling( vo_driver_t* self, int scale ); | 27 | void null_set_scaling( vo_driver_t* self, int scale ); |
28 | void null_set_gui_width( vo_driver_t* self, int width ); | 28 | void null_set_gui_width( vo_driver_t* self, int width ); |
29 | void null_set_gui_height( vo_driver_t* self, int height ); | 29 | void null_set_gui_height( vo_driver_t* self, int height ); |
30 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); | 30 | void null_set_mode( vo_driver_t* self, int depth, int rgb ); |
31 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); | 31 | void null_display_handler(vo_driver_t* self, display_xine_frame_t t, void* user_data); |
32 | } | 32 | } |
33 | 33 | ||
34 | using namespace XINE; | 34 | using namespace XINE; |
35 | 35 | ||
36 | Lib::Lib(XineVideoWidget* widget) { | 36 | Lib::Lib(XineVideoWidget* widget) { |
37 | m_video = false; | 37 | m_video = false; |
38 | m_wid = widget; | 38 | m_wid = widget; |
39 | printf("Lib"); | 39 | printf("Lib"); |
40 | QCString str( getenv("HOME") ); | 40 | QCString str( getenv("HOME") ); |
41 | str += "/Settings/opiexine.cf"; | 41 | str += "/Settings/opiexine.cf"; |
42 | // get the configuration | 42 | // get the configuration |
43 | m_config = xine_config_file_init( str.data() ); | 43 | m_config = xine_config_file_init( str.data() ); |
44 | 44 | ||
45 | // allocate oss for sound | 45 | // allocate oss for sound |
46 | // and fb for framebuffer | 46 | // and fb for framebuffer |
47 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; | 47 | m_audioOutput= xine_load_audio_output_plugin( m_config, "oss") ; |
48 | if (m_audioOutput == NULL ) | 48 | if (m_audioOutput == NULL ) |
49 | printf("Failure\n"); | 49 | printf("Failure\n"); |
50 | else | 50 | else |
51 | printf("Success\n"); | 51 | printf("Success\n"); |
52 | 52 | ||
53 | 53 | ||
54 | // test code | 54 | // test code |
55 | /* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", | 55 | /* m_videoOutput = xine_load_video_output_plugin(m_config, "fb", |
56 | VISUAL_TYPE_FB, | 56 | VISUAL_TYPE_FB, |
57 | 0 ); | 57 | 0 ); |
58 | */ | 58 | */ |
59 | 59 | ||
60 | char** files = xine_list_video_output_plugins(3); | 60 | char** files = xine_list_video_output_plugins(3); |
61 | char* out; | 61 | char* out; |
62 | int i = 0; | 62 | int i = 0; |
63 | while ( ( out = files[i] ) != 0 ) { | 63 | while ( ( out = files[i] ) != 0 ) { |
64 | printf("Video %s\n", out ); | 64 | printf("Video %s\n", out ); |
65 | i++; | 65 | i++; |
66 | } | 66 | } |
67 | // m_xine = xine_init( m_videoOutput, | 67 | // m_xine = xine_init( m_videoOutput, |
68 | // m_audioOutput, | 68 | // m_audioOutput, |
69 | // m_config ); | 69 | // m_config ); |
70 | // test loading | 70 | // test loading |
71 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); | 71 | m_videoOutput = ::init_video_out_plugin( m_config, NULL ); |
72 | if (m_wid != 0 ) { | 72 | if (m_wid != 0 ) { |
73 | printf("!0\n" ); | 73 | printf("!0\n" ); |
74 | ::null_set_gui_width( m_videoOutput, m_wid->image()->width() ); | 74 | ::null_set_gui_width( m_videoOutput, m_wid->image()->width() ); |
75 | ::null_set_gui_height(m_videoOutput, m_wid->image()->height() ); | 75 | ::null_set_gui_height(m_videoOutput, m_wid->image()->height() ); |
76 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 76 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
77 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 77 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
78 | QImage image = Resource::loadImage("SoundPlayer"); | 78 | QImage image = Resource::loadImage("SoundPlayer"); |
79 | image = image.smoothScale( m_wid->width(), m_wid->height() ); | 79 | image = image.smoothScale( m_wid->width(), m_wid->height() ); |
80 | QImage* img = new QImage( image ); | 80 | QImage* img = new QImage( image ); |
81 | m_wid->setImage( img ); | 81 | m_wid->setImage( img ); |
82 | m_wid->repaint(); | 82 | m_wid->repaint(); |
83 | } | 83 | } |
84 | null_display_handler( m_videoOutput, | 84 | null_display_handler( m_videoOutput, |
85 | xine_display_frame, | 85 | xine_display_frame, |
86 | this ); | 86 | this ); |
87 | 87 | ||
88 | m_xine = xine_init( m_videoOutput, | 88 | m_xine = xine_init( m_videoOutput, |
89 | m_audioOutput, m_config ); | 89 | m_audioOutput, m_config ); |
90 | // install the event handler | 90 | // install the event handler |
91 | xine_register_event_listener( m_xine, xine_event_handler, this ); | 91 | xine_register_event_listener( m_xine, xine_event_handler, this ); |
92 | } | 92 | } |
93 | 93 | ||
94 | Lib::~Lib() { | 94 | Lib::~Lib() { |
95 | delete m_config; | 95 | delete m_config; |
96 | xine_remove_event_listener( m_xine, xine_event_handler ); | 96 | xine_remove_event_listener( m_xine, xine_event_handler ); |
97 | xine_exit( m_xine ); | 97 | xine_exit( m_xine ); |
98 | delete m_videoOutput; | 98 | delete m_videoOutput; |
99 | //delete m_audioOutput; | 99 | //delete m_audioOutput; |
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | QCString Lib::version() { | 103 | QCString Lib::version() { |
104 | QCString str( xine_get_str_version() ); | 104 | QCString str( xine_get_str_version() ); |
105 | return str; | 105 | return str; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | int Lib::majorVersion() { | 108 | int Lib::majorVersion() { |
109 | return xine_get_major_version(); | 109 | return xine_get_major_version(); |
110 | } | 110 | } |
111 | int Lib::minorVersion() { | 111 | int Lib::minorVersion() { |
112 | return xine_get_minor_version(); | 112 | return xine_get_minor_version(); |
113 | }; | 113 | }; |
114 | 114 | ||
115 | int Lib::subVersion() { | 115 | int Lib::subVersion() { |
116 | return xine_get_sub_version(); | 116 | return xine_get_sub_version(); |
117 | } | 117 | } |
118 | int Lib::play( const QString& fileName, | 118 | int Lib::play( const QString& fileName, |
119 | int startPos, | 119 | int startPos, |
120 | int start_time ) { | 120 | int start_time ) { |
121 | QString str = fileName.stripWhiteSpace(); | 121 | QString str = fileName.stripWhiteSpace(); |
122 | //workaround OpiePlayer bug | 122 | //workaround OpiePlayer bug |
123 | if (str.right(1) == QString::fromLatin1("/") ) | 123 | if (str.right(1) == QString::fromLatin1("/") ) |
124 | str = str.mid( str.length() -1 ); | 124 | str = str.mid( str.length() -1 ); |
125 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), | 125 | return xine_play( m_xine, QFile::encodeName(str.utf8() ).data(), |
126 | startPos, start_time); | 126 | startPos, start_time); |
127 | } | 127 | } |
128 | void Lib::stop() { | 128 | void Lib::stop() { |
129 | xine_stop(m_xine ); | 129 | xine_stop(m_xine ); |
130 | } | 130 | } |
131 | void Lib::pause(){ | 131 | void Lib::pause(){ |
132 | xine_set_speed( m_xine, SPEED_PAUSE ); | 132 | xine_set_speed( m_xine, SPEED_PAUSE ); |
133 | } | 133 | } |
134 | int Lib::speed() { | 134 | int Lib::speed() { |
135 | return xine_get_speed( m_xine ); | 135 | return xine_get_speed( m_xine ); |
136 | } | 136 | } |
137 | void Lib::setSpeed( int speed ) { | 137 | void Lib::setSpeed( int speed ) { |
138 | xine_set_speed( m_xine, speed ); | 138 | xine_set_speed( m_xine, speed ); |
139 | } | 139 | } |
140 | int Lib::status(){ | 140 | int Lib::status(){ |
141 | return xine_get_status( m_xine ); | 141 | return xine_get_status( m_xine ); |
142 | } | 142 | } |
143 | int Lib::currentPosition(){ | 143 | int Lib::currentPosition(){ |
144 | return xine_get_current_position( m_xine ); | 144 | return xine_get_current_position( m_xine ); |
145 | } | 145 | } |
146 | int Lib::currentTime() { | 146 | int Lib::currentTime() { |
147 | return xine_get_current_time( m_xine ); | 147 | return xine_get_current_time( m_xine ); |
148 | }; | 148 | }; |
149 | int Lib::length() { | 149 | int Lib::length() { |
150 | return xine_get_stream_length( m_xine ); | 150 | return xine_get_stream_length( m_xine ); |
151 | } | 151 | } |
152 | bool Lib::isSeekable() { | 152 | bool Lib::isSeekable() { |
153 | return xine_is_stream_seekable(m_xine); | 153 | return xine_is_stream_seekable(m_xine); |
154 | } | 154 | } |
155 | Frame Lib::currentFrame() { | 155 | Frame Lib::currentFrame() { |
156 | Frame frame; | 156 | Frame frame; |
157 | return frame; | 157 | return frame; |
158 | }; | 158 | }; |
159 | int Lib::error() { | 159 | int Lib::error() { |
160 | return xine_get_error( m_xine ); | 160 | return xine_get_error( m_xine ); |
161 | }; | 161 | }; |
162 | void Lib::handleXineEvent( xine_event_t* t ) { | 162 | void Lib::handleXineEvent( xine_event_t* t ) { |
163 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) | 163 | if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) |
164 | emit stopped(); | 164 | emit stopped(); |
165 | } | 165 | } |
166 | void Lib::setShowVideo( bool video ) { | 166 | void Lib::setShowVideo( bool video ) { |
167 | m_video = video; | 167 | m_video = video; |
168 | ::null_set_show_video( m_videoOutput, video ); | 168 | ::null_set_show_video( m_videoOutput, video ); |
169 | } | 169 | } |
170 | bool Lib::isShowingVideo() { | 170 | bool Lib::isShowingVideo() { |
171 | return ::null_is_showing_video( m_videoOutput ); | 171 | return ::null_is_showing_video( m_videoOutput ); |
172 | } | 172 | } |
173 | void Lib::showVideoFullScreen( bool fullScreen ) { | 173 | void Lib::showVideoFullScreen( bool fullScreen ) { |
174 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 174 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
175 | } | 175 | } |
176 | bool Lib::isVideoFullScreen() { | 176 | bool Lib::isVideoFullScreen() { |
177 | return ::null_is_fullscreen( m_videoOutput ); | 177 | return ::null_is_fullscreen( m_videoOutput ); |
178 | } | 178 | } |
179 | void Lib::setScaling( bool scale ) { | 179 | void Lib::setScaling( bool scale ) { |
180 | ::null_set_scaling( m_videoOutput, scale ); | 180 | ::null_set_scaling( m_videoOutput, scale ); |
181 | } | 181 | } |
182 | bool Lib::isScaling() { | 182 | bool Lib::isScaling() { |
183 | return ::null_is_scaling( m_videoOutput ); | 183 | return ::null_is_scaling( m_videoOutput ); |
184 | } | 184 | } |
185 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { | 185 | void Lib::xine_event_handler( void* user_data, xine_event_t* t ) { |
186 | ((Lib*)user_data)->handleXineEvent( t ); | 186 | ((Lib*)user_data)->handleXineEvent( t ); |
187 | } | 187 | } |
188 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 188 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
189 | int width, int height, int bytes ) { | 189 | int width, int height, int bytes ) { |
190 | printf("display x frame"); | 190 | // printf("display x frame"); |
191 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 191 | ((Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
192 | printf("displayed x frame\n"); | 192 | // printf("displayed x frame\n"); |
193 | } | 193 | } |
194 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 194 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
195 | if (!m_video ) { | 195 | if (!m_video ) { |
196 | qWarning("not showing video now"); | 196 | qWarning("not showing video now"); |
197 | return; | 197 | return; |
198 | } | 198 | } |
199 | qWarning("called draw frame %d %d", width, height); | 199 | // qWarning("called draw frame %d %d", width, height); |
200 | 200 | ||
201 | QSize size = m_wid->size(); | 201 | QSize size = m_wid->size(); |
202 | int xoffset = (size.width() - width) / 2; | 202 | int xoffset = (size.width() - width) / 2; |
203 | int yoffset = (size.height() - height) / 2; | 203 | int yoffset = (size.height() - height) / 2; |
204 | int linestep = qt_screen->linestep(); | 204 | int linestep = qt_screen->linestep(); |
205 | 205 | ||
206 | m_wid->setImage( frame, yoffset, xoffset, width, height, linestep, bytes, m_bytes_per_pixel ); | 206 | m_wid->setImage( frame, yoffset, xoffset, width, height, linestep, bytes, m_bytes_per_pixel ); |
207 | // m_wid->repaint(false); | 207 | // m_wid->repaint(false); |
208 | 208 | ||
209 | } | 209 | } |
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c index 63d5752..3a18a40 100644 --- a/noncore/multimedia/opieplayer2/nullvideo.c +++ b/noncore/multimedia/opieplayer2/nullvideo.c | |||
@@ -1,400 +1,402 @@ | |||
1 | 1 | ||
2 | /*#include <xine.h>*/ | 2 | /*#include <xine.h>*/ |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | 5 | ||
6 | #include <math.h> | 6 | #include <math.h> |
7 | 7 | ||
8 | #include <xine/video_out.h> | 8 | #include <xine/video_out.h> |
9 | #include <xine/xine_internal.h> | 9 | #include <xine/xine_internal.h> |
10 | #include <xine/xineutils.h> | 10 | #include <xine/xineutils.h> |
11 | #include <xine/configfile.h> | 11 | #include <xine/configfile.h> |
12 | 12 | ||
13 | #include <pthread.h> | 13 | #include <pthread.h> |
14 | #include "alphablend.h" | 14 | #include "alphablend.h" |
15 | #include "yuv2rgb.h" | 15 | #include "yuv2rgb.h" |
16 | 16 | ||
17 | #define printf(x,...) | ||
18 | |||
17 | /* the caller for our event draw handler */ | 19 | /* the caller for our event draw handler */ |
18 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 20 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
19 | int width, int height,int bytes ); | 21 | int width, int height,int bytes ); |
20 | 22 | ||
21 | typedef struct null_driver_s null_driver_t; | 23 | typedef struct null_driver_s null_driver_t; |
22 | 24 | ||
23 | struct null_driver_s { | 25 | struct null_driver_s { |
24 | vo_driver_t vo_driver; | 26 | vo_driver_t vo_driver; |
25 | uint32_t m_capabilities; | 27 | uint32_t m_capabilities; |
26 | int m_show_video; | 28 | int m_show_video; |
27 | int m_video_fullscreen; | 29 | int m_video_fullscreen; |
28 | int m_is_scaling; | 30 | int m_is_scaling; |
29 | int depth, bpp, bytes_per_pixel; | 31 | int depth, bpp, bytes_per_pixel; |
30 | int yuv2rgb_mode; | 32 | int yuv2rgb_mode; |
31 | int yuv2rgb_swap; | 33 | int yuv2rgb_swap; |
32 | int zuv2rgb_gamma; | 34 | int zuv2rgb_gamma; |
33 | uint8_t *yuv2rgb_cmap; | 35 | uint8_t *yuv2rgb_cmap; |
34 | yuv2rgb_factory_t *yuv2rgb_factory; | 36 | yuv2rgb_factory_t *yuv2rgb_factory; |
35 | vo_overlay_t *overlay; | 37 | vo_overlay_t *overlay; |
36 | int user_ratio; | 38 | int user_ratio; |
37 | double output_scale_factor; | 39 | double output_scale_factor; |
38 | int last_frame_output_width; | 40 | int last_frame_output_width; |
39 | int last_frame_output_height; | 41 | int last_frame_output_height; |
40 | int gui_width; | 42 | int gui_width; |
41 | int gui_height; | 43 | int gui_height; |
42 | int gui_changed; | 44 | int gui_changed; |
43 | double display_ratio; | 45 | double display_ratio; |
44 | void* caller; | 46 | void* caller; |
45 | display_xine_frame_t frameDis; | 47 | display_xine_frame_t frameDis; |
46 | 48 | ||
47 | 49 | ||
48 | }; | 50 | }; |
49 | typedef struct opie_frame_s opie_frame_t; | 51 | typedef struct opie_frame_s opie_frame_t; |
50 | struct opie_frame_s { | 52 | struct opie_frame_s { |
51 | vo_frame_t frame; | 53 | vo_frame_t frame; |
52 | char* name; | 54 | char* name; |
53 | int version; | 55 | int version; |
54 | int width; | 56 | int width; |
55 | int height; | 57 | int height; |
56 | int ratio_code; | 58 | int ratio_code; |
57 | int format; | 59 | int format; |
58 | int flags; | 60 | int flags; |
59 | int user_ratio; | 61 | int user_ratio; |
60 | 62 | ||
61 | double ratio_factor; | 63 | double ratio_factor; |
62 | int ideal_width; | 64 | int ideal_width; |
63 | int ideal_height; | 65 | int ideal_height; |
64 | int output_width, output_height; | 66 | int output_width, output_height; |
65 | uint8_t *chunk[3]; | 67 | uint8_t *chunk[3]; |
66 | 68 | ||
67 | yuv2rgb_t *yuv2rgb; | 69 | yuv2rgb_t *yuv2rgb; |
68 | uint8_t *rgb_dst; | 70 | uint8_t *rgb_dst; |
69 | int yuv_stride; | 71 | int yuv_stride; |
70 | int stripe_height, stripe_inc; | 72 | int stripe_height, stripe_inc; |
71 | 73 | ||
72 | int bytes_per_line; | 74 | int bytes_per_line; |
73 | uint8_t *data; | 75 | uint8_t *data; |
74 | 76 | ||
75 | // int show_video; | 77 | // int show_video; |
76 | null_driver_t *output; | 78 | null_driver_t *output; |
77 | }; | 79 | }; |
78 | 80 | ||
79 | static uint32_t null_get_capabilities(vo_driver_t *self ){ | 81 | static uint32_t null_get_capabilities(vo_driver_t *self ){ |
80 | null_driver_t* this = (null_driver_t*)self; | 82 | null_driver_t* this = (null_driver_t*)self; |
81 | printf("capabilities\n"); | 83 | printf("capabilities\n"); |
82 | return this->m_capabilities; | 84 | return this->m_capabilities; |
83 | } | 85 | } |
84 | 86 | ||
85 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { | 87 | static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { |
86 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 88 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
87 | printf("frame copy\n"); | 89 | printf("frame copy\n"); |
88 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video | 90 | if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video |
89 | 91 | ||
90 | if (frame->format == IMGFMT_YV12) { | 92 | if (frame->format == IMGFMT_YV12) { |
91 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 93 | frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
92 | src[0], src[1], src[2]); | 94 | src[0], src[1], src[2]); |
93 | } else { | 95 | } else { |
94 | 96 | ||
95 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, | 97 | frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, |
96 | src[0]); | 98 | src[0]); |
97 | } | 99 | } |
98 | 100 | ||
99 | frame->rgb_dst += frame->stripe_inc; | 101 | frame->rgb_dst += frame->stripe_inc; |
100 | printf("returning\n"); | 102 | printf("returning\n"); |
101 | } | 103 | } |
102 | 104 | ||
103 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { | 105 | static void null_frame_field (vo_frame_t *vo_img, int which_field) { |
104 | 106 | ||
105 | opie_frame_t *frame = (opie_frame_t *) vo_img ; | 107 | opie_frame_t *frame = (opie_frame_t *) vo_img ; |
106 | printf("field\n\n"); | 108 | printf("field\n\n"); |
107 | 109 | ||
108 | switch (which_field) { | 110 | switch (which_field) { |
109 | case VO_TOP_FIELD: | 111 | case VO_TOP_FIELD: |
110 | frame->rgb_dst = (uint8_t *)frame->data; | 112 | frame->rgb_dst = (uint8_t *)frame->data; |
111 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 113 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
112 | break; | 114 | break; |
113 | case VO_BOTTOM_FIELD: | 115 | case VO_BOTTOM_FIELD: |
114 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 116 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
115 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; | 117 | frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; |
116 | break; | 118 | break; |
117 | case VO_BOTH_FIELDS: | 119 | case VO_BOTH_FIELDS: |
118 | frame->rgb_dst = (uint8_t *)frame->data; | 120 | frame->rgb_dst = (uint8_t *)frame->data; |
119 | break; | 121 | break; |
120 | } | 122 | } |
121 | } | 123 | } |
122 | 124 | ||
123 | 125 | ||
124 | /* take care of the frame*/ | 126 | /* take care of the frame*/ |
125 | static void null_frame_dispose( vo_frame_t* vo_img){ | 127 | static void null_frame_dispose( vo_frame_t* vo_img){ |
126 | opie_frame_t* frame = (opie_frame_t*)vo_img; | 128 | opie_frame_t* frame = (opie_frame_t*)vo_img; |
127 | printf("frame_dispose\n"); | 129 | printf("frame_dispose\n"); |
128 | if( frame->data ) | 130 | if( frame->data ) |
129 | free( frame->data ); | 131 | free( frame->data ); |
130 | free (frame); | 132 | free (frame); |
131 | } | 133 | } |
132 | 134 | ||
133 | /* end take care of frames*/ | 135 | /* end take care of frames*/ |
134 | 136 | ||
135 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ | 137 | static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ |
136 | null_driver_t* this = (null_driver_t*)self; | 138 | null_driver_t* this = (null_driver_t*)self; |
137 | opie_frame_t* frame; | 139 | opie_frame_t* frame; |
138 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); | 140 | frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); |
139 | 141 | ||
140 | memset( frame, 0, sizeof( opie_frame_t) ); | 142 | memset( frame, 0, sizeof( opie_frame_t) ); |
141 | pthread_mutex_init (&frame->frame.mutex, NULL); | 143 | pthread_mutex_init (&frame->frame.mutex, NULL); |
142 | 144 | ||
143 | printf("alloc_frame\n"); | 145 | printf("alloc_frame\n"); |
144 | frame->name = "opie\0"; | 146 | frame->name = "opie\0"; |
145 | frame->version = 1; | 147 | frame->version = 1; |
146 | frame->output = this; | 148 | frame->output = this; |
147 | // frame->show_video = this->m_show_video; | 149 | // frame->show_video = this->m_show_video; |
148 | /* initialize the frame*/ | 150 | /* initialize the frame*/ |
149 | frame->frame.driver = self; | 151 | frame->frame.driver = self; |
150 | /*frame.frame.free = null_frame_free;*/ | 152 | /*frame.frame.free = null_frame_free;*/ |
151 | frame->frame.copy = null_frame_copy; | 153 | frame->frame.copy = null_frame_copy; |
152 | frame->frame.field = null_frame_field; | 154 | frame->frame.field = null_frame_field; |
153 | frame->frame.dispose = null_frame_dispose; | 155 | frame->frame.dispose = null_frame_dispose; |
154 | frame->yuv2rgb = 0; | 156 | frame->yuv2rgb = 0; |
155 | /* | 157 | /* |
156 | * colorspace converter for this frame | 158 | * colorspace converter for this frame |
157 | */ | 159 | */ |
158 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); | 160 | frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); |
159 | 161 | ||
160 | 162 | ||
161 | return (vo_frame_t*) frame; | 163 | return (vo_frame_t*) frame; |
162 | } | 164 | } |
163 | 165 | ||
164 | // size specific | 166 | // size specific |
165 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { | 167 | static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { |
166 | 168 | ||
167 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { | 169 | if (!this->m_is_scaling /*|| !this->m_show_video*/) { |
168 | printf("Not scaling\n"); | 170 | printf("Not scaling\n"); |
169 | frame->ideal_width = frame->width; | 171 | frame->ideal_width = frame->width; |
170 | frame->ideal_height = frame->height; | 172 | frame->ideal_height = frame->height; |
171 | frame->ratio_factor = 1.0; | 173 | frame->ratio_factor = 1.0; |
172 | 174 | ||
173 | } else { | 175 | } else { |
174 | 176 | ||
175 | double image_ratio, desired_ratio, corr_factor; | 177 | double image_ratio, desired_ratio, corr_factor; |
176 | 178 | ||
177 | image_ratio = (double) frame->width / (double) frame->height; | 179 | image_ratio = (double) frame->width / (double) frame->height; |
178 | 180 | ||
179 | switch (frame->user_ratio) { | 181 | switch (frame->user_ratio) { |
180 | case ASPECT_AUTO: | 182 | case ASPECT_AUTO: |
181 | switch (frame->ratio_code) { | 183 | switch (frame->ratio_code) { |
182 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ | 184 | case XINE_ASPECT_RATIO_ANAMORPHIC: /* anamorphic */ |
183 | desired_ratio = 16.0 /9.0; | 185 | desired_ratio = 16.0 /9.0; |
184 | break; | 186 | break; |
185 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ | 187 | case XINE_ASPECT_RATIO_211_1: /* 2.11:1 */ |
186 | desired_ratio = 2.11/1.0; | 188 | desired_ratio = 2.11/1.0; |
187 | break; | 189 | break; |
188 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ | 190 | case XINE_ASPECT_RATIO_SQUARE: /* square pels */ |
189 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ | 191 | case XINE_ASPECT_RATIO_DONT_TOUCH: /* probably non-mpeg stream => don't touch aspect ratio */ |
190 | desired_ratio = image_ratio; | 192 | desired_ratio = image_ratio; |
191 | break; | 193 | break; |
192 | case 0: /* forbidden -> 4:3 */ | 194 | case 0: /* forbidden -> 4:3 */ |
193 | printf ("video_out_fb: invalid ratio, using 4:3\n"); | 195 | printf ("video_out_fb: invalid ratio, using 4:3\n"); |
194 | default: | 196 | default: |
195 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", | 197 | printf ("video_out_fb: unknown aspect ratio (%d) in stream => using 4:3\n", |
196 | frame->ratio_code); | 198 | frame->ratio_code); |
197 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ | 199 | case XINE_ASPECT_RATIO_4_3: /* 4:3 */ |
198 | desired_ratio = 4.0 / 3.0; | 200 | desired_ratio = 4.0 / 3.0; |
199 | break; | 201 | break; |
200 | } | 202 | } |
201 | break; | 203 | break; |
202 | case ASPECT_ANAMORPHIC: | 204 | case ASPECT_ANAMORPHIC: |
203 | desired_ratio = 16.0 / 9.0; | 205 | desired_ratio = 16.0 / 9.0; |
204 | break; | 206 | break; |
205 | case ASPECT_DVB: | 207 | case ASPECT_DVB: |
206 | desired_ratio = 2.0 / 1.0; | 208 | desired_ratio = 2.0 / 1.0; |
207 | break; | 209 | break; |
208 | case ASPECT_SQUARE: | 210 | case ASPECT_SQUARE: |
209 | desired_ratio = image_ratio; | 211 | desired_ratio = image_ratio; |
210 | break; | 212 | break; |
211 | case ASPECT_FULL: | 213 | case ASPECT_FULL: |
212 | default: | 214 | default: |
213 | desired_ratio = 4.0 / 3.0; | 215 | desired_ratio = 4.0 / 3.0; |
214 | } | 216 | } |
215 | 217 | ||
216 | frame->ratio_factor = this->display_ratio * desired_ratio; | 218 | frame->ratio_factor = this->display_ratio * desired_ratio; |
217 | 219 | ||
218 | corr_factor = frame->ratio_factor / image_ratio ; | 220 | corr_factor = frame->ratio_factor / image_ratio ; |
219 | 221 | ||
220 | if (fabs(corr_factor - 1.0) < 0.005) { | 222 | if (fabs(corr_factor - 1.0) < 0.005) { |
221 | frame->ideal_width = frame->width; | 223 | frame->ideal_width = frame->width; |
222 | frame->ideal_height = frame->height; | 224 | frame->ideal_height = frame->height; |
223 | 225 | ||
224 | } else { | 226 | } else { |
225 | 227 | ||
226 | if (corr_factor >= 1.0) { | 228 | if (corr_factor >= 1.0) { |
227 | frame->ideal_width = frame->width * corr_factor + 0.5; | 229 | frame->ideal_width = frame->width * corr_factor + 0.5; |
228 | frame->ideal_height = frame->height; | 230 | frame->ideal_height = frame->height; |
229 | } else { | 231 | } else { |
230 | frame->ideal_width = frame->width; | 232 | frame->ideal_width = frame->width; |
231 | frame->ideal_height = frame->height / corr_factor + 0.5; | 233 | frame->ideal_height = frame->height / corr_factor + 0.5; |
232 | } | 234 | } |
233 | 235 | ||
234 | } | 236 | } |
235 | } | 237 | } |
236 | printf("return from helper\n"); | 238 | printf("return from helper\n"); |
237 | } | 239 | } |
238 | 240 | ||
239 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { | 241 | static void null_compute_rgb_size (null_driver_t *this, opie_frame_t *frame) { |
240 | 242 | ||
241 | double x_factor, y_factor; | 243 | double x_factor, y_factor; |
242 | 244 | ||
243 | /* | 245 | /* |
244 | * make the frame fit into the given destination area | 246 | * make the frame fit into the given destination area |
245 | */ | 247 | */ |
246 | 248 | ||
247 | x_factor = (double) this->gui_width / (double) frame->ideal_width; | 249 | x_factor = (double) this->gui_width / (double) frame->ideal_width; |
248 | y_factor = (double) this->gui_height / (double) frame->ideal_height; | 250 | y_factor = (double) this->gui_height / (double) frame->ideal_height; |
249 | 251 | ||
250 | if ( x_factor < y_factor ) { | 252 | if ( x_factor < y_factor ) { |
251 | frame->output_width = (double) frame->ideal_width * x_factor ; | 253 | frame->output_width = (double) frame->ideal_width * x_factor ; |
252 | frame->output_height = (double) frame->ideal_height * x_factor ; | 254 | frame->output_height = (double) frame->ideal_height * x_factor ; |
253 | } else { | 255 | } else { |
254 | frame->output_width = (double) frame->ideal_width * y_factor ; | 256 | frame->output_width = (double) frame->ideal_width * y_factor ; |
255 | frame->output_height = (double) frame->ideal_height * y_factor ; | 257 | frame->output_height = (double) frame->ideal_height * y_factor ; |
256 | } | 258 | } |
257 | 259 | ||
258 | #define LOG 1 | 260 | #define LOG 1 |
259 | #ifdef LOG | 261 | #ifdef LOG |
260 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", | 262 | printf("video_out_fb: frame source %d x %d => screen output %d x %d%s\n", |
261 | frame->width, frame->height, | 263 | frame->width, frame->height, |
262 | frame->output_width, frame->output_height, | 264 | frame->output_width, frame->output_height, |
263 | ( frame->width != frame->output_width | 265 | ( frame->width != frame->output_width |
264 | || frame->height != frame->output_height | 266 | || frame->height != frame->output_height |
265 | ? ", software scaling" | 267 | ? ", software scaling" |
266 | : "" ) | 268 | : "" ) |
267 | ); | 269 | ); |
268 | #endif | 270 | #endif |
269 | } | 271 | } |
270 | 272 | ||
271 | 273 | ||
272 | // size specific | 274 | // size specific |
273 | 275 | ||
274 | 276 | ||
275 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, | 277 | static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img, |
276 | uint32_t width, uint32_t height, | 278 | uint32_t width, uint32_t height, |
277 | int ratio_code, int format, int flags ){ | 279 | int ratio_code, int format, int flags ){ |
278 | null_driver_t* this = (null_driver_t*) self; | 280 | null_driver_t* this = (null_driver_t*) self; |
279 | opie_frame_t* frame = (opie_frame_t*)img; | 281 | opie_frame_t* frame = (opie_frame_t*)img; |
280 | /* not needed now */ | 282 | /* not needed now */ |
281 | printf("update_frame_format\n"); | 283 | printf("update_frame_format\n"); |
282 | printf("al crash aye?\n"); | 284 | printf("al crash aye?\n"); |
283 | 285 | ||
284 | flags &= VO_BOTH_FIELDS; | 286 | flags &= VO_BOTH_FIELDS; |
285 | 287 | ||
286 | /* find out if we need to adapt this frame */ | 288 | /* find out if we need to adapt this frame */ |
287 | 289 | ||
288 | if ((width != frame->width) | 290 | if ((width != frame->width) |
289 | || (height != frame->height) | 291 | || (height != frame->height) |
290 | || (ratio_code != frame->ratio_code) | 292 | || (ratio_code != frame->ratio_code) |
291 | || (flags != frame->flags) | 293 | || (flags != frame->flags) |
292 | || (format != frame->format) | 294 | || (format != frame->format) |
293 | || (this->user_ratio != frame->user_ratio) | 295 | || (this->user_ratio != frame->user_ratio) |
294 | || this->gui_changed ) { | 296 | || this->gui_changed ) { |
295 | 297 | ||
296 | frame->width = width; | 298 | frame->width = width; |
297 | frame->height = height; | 299 | frame->height = height; |
298 | frame->ratio_code = ratio_code; | 300 | frame->ratio_code = ratio_code; |
299 | frame->flags = flags; | 301 | frame->flags = flags; |
300 | frame->format = format; | 302 | frame->format = format; |
301 | frame->user_ratio = this->user_ratio; | 303 | frame->user_ratio = this->user_ratio; |
302 | this->gui_changed = 0; | 304 | this->gui_changed = 0; |
303 | //frame->show_video = this->m_show_video; | 305 | //frame->show_video = this->m_show_video; |
304 | 306 | ||
305 | 307 | ||
306 | null_compute_ideal_size (this, frame); | 308 | null_compute_ideal_size (this, frame); |
307 | null_compute_rgb_size (this, frame); | 309 | null_compute_rgb_size (this, frame); |
308 | 310 | ||
309 | /* | 311 | /* |
310 | * (re-) allocate | 312 | * (re-) allocate |
311 | */ | 313 | */ |
312 | if( frame->data ) { | 314 | if( frame->data ) { |
313 | if(frame->chunk[0] ){ | 315 | if(frame->chunk[0] ){ |
314 | free( frame->chunk[0] ); | 316 | free( frame->chunk[0] ); |
315 | frame->chunk[0] = NULL; | 317 | frame->chunk[0] = NULL; |
316 | } | 318 | } |
317 | if(frame->chunk[1] ){ | 319 | if(frame->chunk[1] ){ |
318 | free ( frame->chunk[1] ); | 320 | free ( frame->chunk[1] ); |
319 | frame->chunk[1] = NULL; | 321 | frame->chunk[1] = NULL; |
320 | } | 322 | } |
321 | if(frame->chunk[2] ){ | 323 | if(frame->chunk[2] ){ |
322 | free ( frame->chunk[2] ); | 324 | free ( frame->chunk[2] ); |
323 | frame->chunk[2] = NULL; | 325 | frame->chunk[2] = NULL; |
324 | } | 326 | } |
325 | free ( frame->data ); | 327 | free ( frame->data ); |
326 | } | 328 | } |
327 | printf("after freeing\n"); | 329 | printf("after freeing\n"); |
328 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * | 330 | frame->data = xine_xmalloc (frame->output_width * frame->output_height * |
329 | this->bytes_per_pixel ); | 331 | this->bytes_per_pixel ); |
330 | 332 | ||
331 | if( format == IMGFMT_YV12 ) { | 333 | if( format == IMGFMT_YV12 ) { |
332 | int image_size = width * height; /* cast ouch*/ | 334 | int image_size = width * height; /* cast ouch*/ |
333 | frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, | 335 | frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, |
334 | (void **)&frame->chunk[0] ); | 336 | (void **)&frame->chunk[0] ); |
335 | frame->frame.base[1] = xine_xmalloc_aligned(16, image_size, | 337 | frame->frame.base[1] = xine_xmalloc_aligned(16, image_size, |
336 | (void **)&frame->chunk[1] ); | 338 | (void **)&frame->chunk[1] ); |
337 | frame->frame.base[2] = xine_xmalloc_aligned(16, image_size, | 339 | frame->frame.base[2] = xine_xmalloc_aligned(16, image_size, |
338 | (void **)&frame->chunk[2] ); | 340 | (void **)&frame->chunk[2] ); |
339 | }else{ | 341 | }else{ |
340 | int image_size = width * height; /* cast ouch*/ | 342 | int image_size = width * height; /* cast ouch*/ |
341 | frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, | 343 | frame->frame.base[0] = xine_xmalloc_aligned(16, image_size, |
342 | (void **)&frame->chunk[0] ); | 344 | (void **)&frame->chunk[0] ); |
343 | frame->chunk[1] = NULL; | 345 | frame->chunk[1] = NULL; |
344 | frame->chunk[2] = NULL; | 346 | frame->chunk[2] = NULL; |
345 | } | 347 | } |
346 | 348 | ||
347 | frame->format = format; | 349 | frame->format = format; |
348 | frame->width = width; | 350 | frame->width = width; |
349 | frame->height = height; | 351 | frame->height = height; |
350 | 352 | ||
351 | frame->stripe_height = 16 * frame->output_height / frame->height; | 353 | frame->stripe_height = 16 * frame->output_height / frame->height; |
352 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; | 354 | frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; |
353 | 355 | ||
354 | /* | 356 | /* |
355 | * set up colorspace converter | 357 | * set up colorspace converter |
356 | */ | 358 | */ |
357 | if(1 /*this->m_show_video*/ ){ | 359 | if(1 /*this->m_show_video*/ ){ |
358 | printf("showing video\n"); | 360 | printf("showing video\n"); |
359 | 361 | ||
360 | switch (flags) { | 362 | switch (flags) { |
361 | case VO_TOP_FIELD: | 363 | case VO_TOP_FIELD: |
362 | case VO_BOTTOM_FIELD: | 364 | case VO_BOTTOM_FIELD: |
363 | frame->yuv2rgb->configure (frame->yuv2rgb, | 365 | frame->yuv2rgb->configure (frame->yuv2rgb, |
364 | frame->width, | 366 | frame->width, |
365 | 16, | 367 | 16, |
366 | frame->width*2, | 368 | frame->width*2, |
367 | frame->width, | 369 | frame->width, |
368 | frame->output_width, | 370 | frame->output_width, |
369 | frame->stripe_height, | 371 | frame->stripe_height, |
370 | frame->bytes_per_line*2); | 372 | frame->bytes_per_line*2); |
371 | frame->yuv_stride = frame->bytes_per_line*2; | 373 | frame->yuv_stride = frame->bytes_per_line*2; |
372 | break; | 374 | break; |
373 | case VO_BOTH_FIELDS: | 375 | case VO_BOTH_FIELDS: |
374 | frame->yuv2rgb->configure (frame->yuv2rgb, | 376 | frame->yuv2rgb->configure (frame->yuv2rgb, |
375 | frame->width, | 377 | frame->width, |
376 | 16, | 378 | 16, |
377 | frame->width, | 379 | frame->width, |
378 | frame->width/2, | 380 | frame->width/2, |
379 | frame->output_width, | 381 | frame->output_width, |
380 | frame->stripe_height, | 382 | frame->stripe_height, |
381 | frame->bytes_per_line); | 383 | frame->bytes_per_line); |
382 | frame->yuv_stride = frame->bytes_per_line; | 384 | frame->yuv_stride = frame->bytes_per_line; |
383 | break; | 385 | break; |
384 | } | 386 | } |
385 | } | 387 | } |
386 | } | 388 | } |
387 | printf("after gui changed\n"); | 389 | printf("after gui changed\n"); |
388 | /* | 390 | /* |
389 | * reset dest pointers | 391 | * reset dest pointers |
390 | */ | 392 | */ |
391 | 393 | ||
392 | if (frame->data) { | 394 | if (frame->data) { |
393 | switch (flags) { | 395 | switch (flags) { |
394 | case VO_TOP_FIELD: | 396 | case VO_TOP_FIELD: |
395 | frame->rgb_dst = (uint8_t *)frame->data; | 397 | frame->rgb_dst = (uint8_t *)frame->data; |
396 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 398 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
397 | break; | 399 | break; |
398 | case VO_BOTTOM_FIELD: | 400 | case VO_BOTTOM_FIELD: |
399 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; | 401 | frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; |
400 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; | 402 | frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index e46c4df..8e8f139 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -1,258 +1,267 @@ | |||
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 <qsize.h> | 39 | #include <qsize.h> |
40 | 40 | ||
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | 42 | ||
43 | #include "xinevideowidget.h" | 43 | #include "xinevideowidget.h" |
44 | 44 | ||
45 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 45 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
46 | { | 46 | { |
47 | ((char *) src ) += len; | 47 | ((char *) src ) += len; |
48 | 48 | ||
49 | len >>= 1; | 49 | len >>= 1; |
50 | while ( len-- ) | 50 | while ( len-- ) |
51 | *((short int *) dst )++ = *--((short int *) src ); | 51 | *((short int *) dst )++ = *--((short int *) src ); |
52 | } | 52 | } |
53 | 53 | ||
54 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 54 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
55 | { | 55 | { |
56 | len >>= 1; | 56 | len >>= 1; |
57 | while ( len-- ) { | 57 | while ( len-- ) { |
58 | // *((char *) dst ) = *((char *) src + 1); | ||
59 | // *((char *) dst + 1) = *((char *) src ); | ||
60 | // ((char *) dst ) += 2; | ||
61 | |||
58 | *((short int *) dst )++ = *((short int *) src ); | 62 | *((short int *) dst )++ = *((short int *) src ); |
59 | ((char *) src ) += step; | 63 | ((char *) src ) += step; |
60 | } | 64 | } |
61 | } | 65 | } |
62 | 66 | ||
63 | 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 ) |
64 | { | 68 | { |
65 | len >>= 1; | 69 | len >>= 1; |
66 | 70 | ||
67 | ((char *) src ) += ( len * step ); | 71 | ((char *) src ) += ( len * step ); |
68 | 72 | ||
69 | while ( len-- ) { | 73 | while ( len-- ) { |
70 | ((char *) src ) -= step; | 74 | ((char *) src ) -= step; |
71 | *((short int *) dst )++ = *((short int *) src ); | 75 | *((short int *) dst )++ = *((short int *) src ); |
76 | |||
77 | // *((char *) dst ) = *((char *) src + 1); | ||
78 | // *((char *) dst + 1) = *((char *) src ); | ||
79 | // ((char *) dst ) += 2; | ||
72 | } | 80 | } |
73 | } | 81 | } |
74 | 82 | ||
75 | 83 | ||
76 | XineVideoWidget::XineVideoWidget( int width, | 84 | XineVideoWidget::XineVideoWidget( int width, |
77 | int height, | 85 | int height, |
78 | QWidget* parent, | 86 | QWidget* parent, |
79 | const char* name ) | 87 | const char* name ) |
80 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
81 | { | 89 | { |
82 | m_image = new QImage ( width, height, qt_screen-> depth ( )); | 90 | m_image = new QImage ( width, height, qt_screen-> depth ( )); |
83 | m_buff = 0; | 91 | m_buff = 0; |
84 | setBackgroundMode ( NoBackground ); | 92 | setBackgroundMode ( NoBackground ); |
85 | /* QImage image = Resource::loadImage("SoundPlayer"); | 93 | /* QImage image = Resource::loadImage("SoundPlayer"); |
86 | image = image.smoothScale( width, height ); | 94 | image = image.smoothScale( width, height ); |
87 | 95 | ||
88 | m_image = new QImage( image );*/ | 96 | m_image = new QImage( image );*/ |
89 | } | 97 | } |
90 | 98 | ||
91 | XineVideoWidget::~XineVideoWidget ( ) | 99 | XineVideoWidget::~XineVideoWidget ( ) |
92 | { | 100 | { |
93 | delete m_image; | 101 | delete m_image; |
94 | } | 102 | } |
95 | 103 | ||
96 | void XineVideoWidget::clear ( ) | 104 | void XineVideoWidget::clear ( ) |
97 | { | 105 | { |
98 | m_buff = 0; | 106 | m_buff = 0; |
99 | repaint ( false ); | 107 | repaint ( false ); |
100 | } | 108 | } |
101 | 109 | ||
102 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 110 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
103 | { | 111 | { |
104 | qWarning( "painting" ); | 112 | qWarning( "painting <<<" ); |
105 | if ( m_buff == 0 ) { | 113 | if ( m_buff == 0 ) { |
106 | QPainter p ( this ); | 114 | QPainter p ( this ); |
107 | p. fillRect ( rect ( ), black ); | 115 | p. fillRect ( rect ( ), black ); |
108 | p. drawImage ( 0, 0, *m_image ); | 116 | p. drawImage ( 0, 0, *m_image ); |
109 | qWarning ( "logo\n" ); | 117 | qWarning ( "logo\n" ); |
110 | } | 118 | } |
111 | else { | 119 | else { |
112 | qWarning ( "paintevent\n" ); | 120 | // qWarning ( "paintevent\n" ); |
113 | 121 | ||
114 | QArray <QRect> qt_bug_workaround_clip_rects; | 122 | QArray <QRect> qt_bug_workaround_clip_rects; |
115 | 123 | ||
116 | { | 124 | { |
117 | QDirectPainter dp ( this ); | 125 | QDirectPainter dp ( this ); |
118 | 126 | ||
127 | int rot = dp. transformOrientation ( ); | ||
128 | |||
119 | uchar *fb = dp. frameBuffer ( ); | 129 | uchar *fb = dp. frameBuffer ( ); |
120 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 130 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; |
121 | 131 | ||
122 | QRect framerect = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )); | 132 | QRect framerect = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )); |
123 | 133 | ||
124 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 134 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
125 | 135 | ||
126 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 136 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
127 | const QRect &clip = dp. rect ( i ); | 137 | const QRect &clip = dp. rect ( i ); |
128 | 138 | ||
129 | qt_bug_workaround_clip_rects [i] = clip; | 139 | qt_bug_workaround_clip_rects [i] = clip; |
130 | 140 | ||
131 | int rot = dp. transformOrientation ( ); | ||
132 | |||
133 | if ( rot == 0 || rot == 180 ) { | 141 | if ( rot == 0 || rot == 180 ) { |
134 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 142 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); |
135 | uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); | 143 | uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); |
136 | 144 | ||
137 | if ( rot == 180 ) | 145 | if ( rot == 180 ) |
138 | src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ); | 146 | src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ); |
139 | 147 | ||
140 | uint leftfill = 0; | 148 | uint leftfill = 0; |
141 | uint framefill = 0; | 149 | uint framefill = 0; |
142 | uint rightfill = 0; | 150 | uint rightfill = 0; |
143 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 151 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; |
144 | 152 | ||
145 | if ( clip. left ( ) < framerect. left ( )) | 153 | if ( clip. left ( ) < framerect. left ( )) |
146 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 154 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
147 | if ( clip. right ( ) > framerect. right ( )) | 155 | if ( clip. right ( ) > framerect. right ( )) |
148 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 156 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
149 | 157 | ||
150 | framefill = clipwidth - ( leftfill + rightfill ); | 158 | framefill = clipwidth - ( leftfill + rightfill ); |
151 | 159 | ||
152 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 160 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
153 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 161 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
154 | memset ( dst, 0, clipwidth ); | 162 | memset ( dst, 0, clipwidth ); |
155 | } | 163 | } |
156 | else { | 164 | else { |
157 | if ( leftfill ) | 165 | if ( leftfill ) |
158 | memset ( dst, 0, leftfill ); | 166 | memset ( dst, 0, leftfill ); |
159 | 167 | ||
160 | if ( framefill ) { | 168 | if ( framefill ) { |
161 | if ( rot == 0 ) | 169 | if ( rot == 0 ) |
162 | memcpy ( dst + leftfill, src, framefill ); | 170 | memcpy ( dst + leftfill, src, framefill ); |
163 | else | 171 | else |
164 | memcpy_rev ( dst + leftfill, src, framefill ); | 172 | memcpy_rev ( dst + leftfill, src, framefill ); |
165 | } | 173 | } |
166 | if ( rightfill ) | 174 | if ( rightfill ) |
167 | memset ( dst + leftfill + framefill, 0, rightfill ); | 175 | memset ( dst + leftfill + framefill, 0, rightfill ); |
168 | } | 176 | } |
169 | 177 | ||
170 | dst += m_bytes_per_line_fb; | 178 | dst += m_bytes_per_line_fb; |
171 | src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame ); | 179 | src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame ); |
172 | } | 180 | } |
173 | } | 181 | } |
174 | else { // rot == 90 || rot == 270 | 182 | else { // rot == 90 || rot == 270 |
175 | uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb ); | 183 | uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb ); |
176 | uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); | 184 | uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); |
177 | 185 | ||
178 | if ( rot == 270 ) | 186 | if ( rot == 270 ) |
179 | src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ); | 187 | src += (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ); |
180 | 188 | ||
181 | uint leftfill = 0; | 189 | uint leftfill = 0; |
182 | uint framefill = 0; | 190 | uint framefill = 0; |
183 | uint rightfill = 0; | 191 | uint rightfill = 0; |
184 | uint clipwidth = clip. height ( ) * m_bytes_per_pixel; | 192 | uint clipwidth = clip. height ( ) * m_bytes_per_pixel; |
185 | 193 | ||
186 | if ( clip. bottom ( ) > framerect. bottom ( )) | 194 | if ( clip. bottom ( ) > framerect. bottom ( )) |
187 | leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth; | 195 | leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth; |
188 | if ( clip. top ( ) < framerect. top ( )) | 196 | if ( clip. top ( ) < framerect. top ( )) |
189 | rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth; | 197 | rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth; |
190 | 198 | ||
191 | framefill = clipwidth - ( leftfill + rightfill ); | 199 | framefill = clipwidth - ( leftfill + rightfill ); |
192 | 200 | ||
193 | for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) { | 201 | for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) { |
194 | if (( y < framerect. left ( )) || ( y > framerect. right ( ))) { | 202 | if (( y < framerect. left ( )) || ( y > framerect. right ( ))) { |
195 | memset ( dst, 0, clipwidth ); | 203 | memset ( dst, 0, clipwidth ); |
196 | } | 204 | } |
197 | else { | 205 | else { |
198 | if ( leftfill ) | 206 | if ( leftfill ) |
199 | memset ( dst, 0, leftfill ); | 207 | memset ( dst, 0, leftfill ); |
200 | 208 | ||
201 | if ( framefill ) { | 209 | if ( framefill ) { |
202 | if ( rot == 90 ) | 210 | if ( rot == 90 ) |
203 | memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); | ||
204 | else | ||
205 | memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); | 211 | memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); |
212 | else | ||
213 | memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); | ||
206 | } | 214 | } |
207 | if ( rightfill ) | 215 | if ( rightfill ) |
208 | memset ( dst + leftfill + framefill, 0, rightfill ); | 216 | memset ( dst + leftfill + framefill, 0, rightfill ); |
209 | } | 217 | } |
210 | 218 | ||
211 | dst += m_bytes_per_line_fb; | 219 | dst += m_bytes_per_line_fb; |
212 | src += ( rot == 90 ? +1 : -1 ); // m_bytes_per_line_frame : -m_bytes_per_line_frame ); | 220 | src += ( rot == 270 ? -m_bytes_per_pixel : m_bytes_per_pixel ); |
213 | } | 221 | } |
214 | } | 222 | } |
215 | } | 223 | } |
216 | } | 224 | } |
217 | { | 225 | { |
218 | // QVFB hack by MArtin Jones | 226 | // QVFB hack by MArtin Jones |
219 | QPainter p ( this ); | 227 | QPainter p ( this ); |
220 | 228 | ||
221 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 229 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
222 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); | 230 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); |
223 | } | 231 | } |
224 | } | 232 | } |
225 | } | 233 | } |
234 | qWarning( "painting >>>" ); | ||
226 | } | 235 | } |
227 | 236 | ||
228 | int XineVideoWidget::height ( ) const | 237 | int XineVideoWidget::height ( ) const |
229 | { | 238 | { |
230 | return m_image-> height ( ); | 239 | return m_image-> height ( ); |
231 | } | 240 | } |
232 | 241 | ||
233 | int XineVideoWidget::width ( ) const | 242 | int XineVideoWidget::width ( ) const |
234 | { | 243 | { |
235 | return m_image-> width ( ); | 244 | return m_image-> width ( ); |
236 | } | 245 | } |
237 | 246 | ||
238 | void XineVideoWidget::setImage ( QImage* image ) | 247 | void XineVideoWidget::setImage ( QImage* image ) |
239 | { | 248 | { |
240 | delete m_image; | 249 | delete m_image; |
241 | m_image = image; | 250 | m_image = image; |
242 | } | 251 | } |
243 | 252 | ||
244 | void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, | 253 | void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, |
245 | int xoffsetXBytes, int width, | 254 | int xoffsetXBytes, int width, |
246 | int height, int linestep, int bytes, int bpp ) | 255 | int height, int linestep, int bytes, int bpp ) |
247 | { | 256 | { |
248 | 257 | ||
249 | m_lastframe = m_thisframe; | 258 | m_lastframe = m_thisframe; |
250 | m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height ); | 259 | m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height ); |
251 | 260 | ||
252 | m_buff = image; | 261 | m_buff = image; |
253 | m_bytes_per_line_fb = linestep; | 262 | m_bytes_per_line_fb = linestep; |
254 | m_bytes_per_line_frame = bytes; | 263 | m_bytes_per_line_frame = bytes; |
255 | m_bytes_per_pixel = bpp; | 264 | m_bytes_per_pixel = bpp; |
256 | 265 | ||
257 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 266 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
258 | } | 267 | } |