summaryrefslogtreecommitdiff
authorsandman <sandman>2002-08-01 01:33:23 (UTC)
committer sandman <sandman>2002-08-01 01:33:23 (UTC)
commit32b7fdb0e9e5ec6cb6f791962efe68c40564b178 (patch) (unidiff)
tree86044a8b3884536f65d38b32d3e0552c30f13a81
parentba034bf4cb91b83654056945fc27313a28528015 (diff)
downloadopie-32b7fdb0e9e5ec6cb6f791962efe68c40564b178.zip
opie-32b7fdb0e9e5ec6cb6f791962efe68c40564b178.tar.gz
opie-32b7fdb0e9e5ec6cb6f791962efe68c40564b178.tar.bz2
Fixed video output (frames allocated before video was enabled via
show_video flag have never been displayes thereafter) Also optimized the video widget
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/nullvideo.c13
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp61
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h3
4 files changed, 38 insertions, 41 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index aa37cd7..ac5cdd5 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -195,15 +195,15 @@ 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(); 207// m_wid->repaint(false);
208 208
209} 209}
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c
index f356e76..63d5752 100644
--- a/noncore/multimedia/opieplayer2/nullvideo.c
+++ b/noncore/multimedia/opieplayer2/nullvideo.c
@@ -63,47 +63,46 @@ struct opie_frame_s {
63 int ideal_height; 63 int ideal_height;
64 int output_width, output_height; 64 int output_width, output_height;
65 uint8_t *chunk[3]; 65 uint8_t *chunk[3];
66 66
67 yuv2rgb_t *yuv2rgb; 67 yuv2rgb_t *yuv2rgb;
68 uint8_t *rgb_dst; 68 uint8_t *rgb_dst;
69 int yuv_stride; 69 int yuv_stride;
70 int stripe_height, stripe_inc; 70 int stripe_height, stripe_inc;
71 71
72 int bytes_per_line; 72 int bytes_per_line;
73 uint8_t *data; 73 uint8_t *data;
74 74
75 int show_video; 75// int show_video;
76 null_driver_t *output; 76 null_driver_t *output;
77}; 77};
78 78
79static uint32_t null_get_capabilities(vo_driver_t *self ){ 79static uint32_t null_get_capabilities(vo_driver_t *self ){
80 null_driver_t* this = (null_driver_t*)self; 80 null_driver_t* this = (null_driver_t*)self;
81 printf("capabilities\n"); 81 printf("capabilities\n");
82 return this->m_capabilities; 82 return this->m_capabilities;
83} 83}
84 84
85static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) { 85static void null_frame_copy (vo_frame_t *vo_img, uint8_t **src) {
86 opie_frame_t *frame = (opie_frame_t *) vo_img ; 86 opie_frame_t *frame = (opie_frame_t *) vo_img ;
87 printf("frame copy\n"); 87 printf("frame copy\n");
88 if(!frame->show_video ){ printf("no video\n"); return; } // no video 88 if(!frame->output->m_show_video ){ printf("no video\n"); return; } // no video
89 89
90 if (frame->format == IMGFMT_YV12) { 90 if (frame->format == IMGFMT_YV12) {
91 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, 91 frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst,
92 src[0], src[1], src[2]); 92 src[0], src[1], src[2]);
93 } else { 93 } else {
94 94
95 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, 95 frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
96 src[0]); 96 src[0]);
97
98 } 97 }
99 98
100 frame->rgb_dst += frame->stripe_inc; 99 frame->rgb_dst += frame->stripe_inc;
101 printf("returning\n"); 100 printf("returning\n");
102} 101}
103 102
104static void null_frame_field (vo_frame_t *vo_img, int which_field) { 103static void null_frame_field (vo_frame_t *vo_img, int which_field) {
105 104
106 opie_frame_t *frame = (opie_frame_t *) vo_img ; 105 opie_frame_t *frame = (opie_frame_t *) vo_img ;
107 printf("field\n\n"); 106 printf("field\n\n");
108 107
109 switch (which_field) { 108 switch (which_field) {
@@ -136,45 +135,45 @@ static void null_frame_dispose( vo_frame_t* vo_img){
136static vo_frame_t* null_alloc_frame( vo_driver_t* self ){ 135static vo_frame_t* null_alloc_frame( vo_driver_t* self ){
137 null_driver_t* this = (null_driver_t*)self; 136 null_driver_t* this = (null_driver_t*)self;
138 opie_frame_t* frame; 137 opie_frame_t* frame;
139 frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) ); 138 frame = (opie_frame_t*)malloc ( sizeof(opie_frame_t) );
140 139
141 memset( frame, 0, sizeof( opie_frame_t) ); 140 memset( frame, 0, sizeof( opie_frame_t) );
142 pthread_mutex_init (&frame->frame.mutex, NULL); 141 pthread_mutex_init (&frame->frame.mutex, NULL);
143 142
144 printf("alloc_frame\n"); 143 printf("alloc_frame\n");
145 frame->name = "opie\0"; 144 frame->name = "opie\0";
146 frame->version = 1; 145 frame->version = 1;
147 frame->output = this; 146 frame->output = this;
148 frame->show_video = this->m_show_video; 147// frame->show_video = this->m_show_video;
149 /* initialize the frame*/ 148 /* initialize the frame*/
150 frame->frame.driver = self; 149 frame->frame.driver = self;
151 /*frame.frame.free = null_frame_free;*/ 150 /*frame.frame.free = null_frame_free;*/
152 frame->frame.copy = null_frame_copy; 151 frame->frame.copy = null_frame_copy;
153 frame->frame.field = null_frame_field; 152 frame->frame.field = null_frame_field;
154 frame->frame.dispose = null_frame_dispose; 153 frame->frame.dispose = null_frame_dispose;
155 frame->yuv2rgb = 0; 154 frame->yuv2rgb = 0;
156 /* 155 /*
157 * colorspace converter for this frame 156 * colorspace converter for this frame
158 */ 157 */
159 frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory); 158 frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory);
160 159
161 160
162 return (vo_frame_t*) frame; 161 return (vo_frame_t*) frame;
163} 162}
164 163
165// size specific 164// size specific
166static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) { 165static void null_compute_ideal_size (null_driver_t *this, opie_frame_t *frame) {
167 166
168 if (!this->m_is_scaling || !this->m_show_video) { 167 if (!this->m_is_scaling /*|| !this->m_show_video*/) {
169 printf("Not scaling\n"); 168 printf("Not scaling\n");
170 frame->ideal_width = frame->width; 169 frame->ideal_width = frame->width;
171 frame->ideal_height = frame->height; 170 frame->ideal_height = frame->height;
172 frame->ratio_factor = 1.0; 171 frame->ratio_factor = 1.0;
173 172
174 } else { 173 } else {
175 174
176 double image_ratio, desired_ratio, corr_factor; 175 double image_ratio, desired_ratio, corr_factor;
177 176
178 image_ratio = (double) frame->width / (double) frame->height; 177 image_ratio = (double) frame->width / (double) frame->height;
179 178
180 switch (frame->user_ratio) { 179 switch (frame->user_ratio) {
@@ -292,25 +291,25 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
292 || (flags != frame->flags) 291 || (flags != frame->flags)
293 || (format != frame->format) 292 || (format != frame->format)
294 || (this->user_ratio != frame->user_ratio) 293 || (this->user_ratio != frame->user_ratio)
295 || this->gui_changed ) { 294 || this->gui_changed ) {
296 295
297 frame->width = width; 296 frame->width = width;
298 frame->height = height; 297 frame->height = height;
299 frame->ratio_code = ratio_code; 298 frame->ratio_code = ratio_code;
300 frame->flags = flags; 299 frame->flags = flags;
301 frame->format = format; 300 frame->format = format;
302 frame->user_ratio = this->user_ratio; 301 frame->user_ratio = this->user_ratio;
303 this->gui_changed = 0; 302 this->gui_changed = 0;
304 frame->show_video = this->m_show_video; 303 //frame->show_video = this->m_show_video;
305 304
306 305
307 null_compute_ideal_size (this, frame); 306 null_compute_ideal_size (this, frame);
308 null_compute_rgb_size (this, frame); 307 null_compute_rgb_size (this, frame);
309 308
310 /* 309 /*
311 * (re-) allocate 310 * (re-) allocate
312 */ 311 */
313 if( frame->data ) { 312 if( frame->data ) {
314 if(frame->chunk[0] ){ 313 if(frame->chunk[0] ){
315 free( frame->chunk[0] ); 314 free( frame->chunk[0] );
316 frame->chunk[0] = NULL; 315 frame->chunk[0] = NULL;
@@ -346,25 +345,25 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
346 } 345 }
347 346
348 frame->format = format; 347 frame->format = format;
349 frame->width = width; 348 frame->width = width;
350 frame->height = height; 349 frame->height = height;
351 350
352 frame->stripe_height = 16 * frame->output_height / frame->height; 351 frame->stripe_height = 16 * frame->output_height / frame->height;
353 frame->bytes_per_line = frame->output_width * this->bytes_per_pixel; 352 frame->bytes_per_line = frame->output_width * this->bytes_per_pixel;
354 353
355 /* 354 /*
356 * set up colorspace converter 355 * set up colorspace converter
357 */ 356 */
358 if(this->m_show_video ){ 357 if(1 /*this->m_show_video*/ ){
359 printf("showing video\n"); 358 printf("showing video\n");
360 359
361 switch (flags) { 360 switch (flags) {
362 case VO_TOP_FIELD: 361 case VO_TOP_FIELD:
363 case VO_BOTTOM_FIELD: 362 case VO_BOTTOM_FIELD:
364 frame->yuv2rgb->configure (frame->yuv2rgb, 363 frame->yuv2rgb->configure (frame->yuv2rgb,
365 frame->width, 364 frame->width,
366 16, 365 16,
367 frame->width*2, 366 frame->width*2,
368 frame->width, 367 frame->width,
369 frame->output_width, 368 frame->output_width,
370 frame->stripe_height, 369 frame->stripe_height,
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index d665f16..b5a714e 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -37,94 +37,89 @@
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
45XineVideoWidget::XineVideoWidget( int width, 45XineVideoWidget::XineVideoWidget( int width,
46 int height, 46 int height,
47 QWidget* parent, 47 QWidget* parent,
48 const char* name ) 48 const char* name )
49 : QWidget( parent, name ) 49 : QWidget( parent, name, WRepaintNoErase | WResizeNoErase )
50{ 50{
51 m_image = new QImage( width, height, qt_screen->depth() ); 51 m_image = new QImage( width, height, qt_screen->depth() );
52 m_buff = 0; 52 m_buff = 0;
53 setBackgroundMode( NoBackground); 53 setBackgroundMode( NoBackground);
54/* QImage image = Resource::loadImage("SoundPlayer"); 54/* QImage image = Resource::loadImage("SoundPlayer");
55 image = image.smoothScale( width, height ); 55 image = image.smoothScale( width, height );
56 56
57 m_image = new QImage( image );*/ 57 m_image = new QImage( image );*/
58} 58}
59XineVideoWidget::~XineVideoWidget() { 59XineVideoWidget::~XineVideoWidget() {
60 delete m_image; 60 delete m_image;
61} 61}
62void XineVideoWidget::clear() { 62void XineVideoWidget::clear() {
63 m_buff = 0; 63 m_buff = 0;
64 repaint(); 64 repaint(false);
65} 65}
66void XineVideoWidget::paintEvent( QPaintEvent* e ) { 66void XineVideoWidget::paintEvent( QPaintEvent* e ) {
67 qWarning("painting"); 67 qWarning("painting");
68 if (m_buff == 0 ) {
68 QPainter p(this ); 69 QPainter p(this );
69 p.setBrush( QBrush( Qt::black ) ); 70 p.fillRect( rect(), black );
70 p.drawRect( rect() );
71 if (m_buff == 0 )
72 p.drawImage( 0, 0, *m_image ); 71 p.drawImage( 0, 0, *m_image );
72 qWarning ( "logo\n" );
73 }
73 else { 74 else {
74 qWarning("paitnevent\n"); 75 qWarning("paitnevent\n");
76 {
75 77
78 if (( m_thisframe & m_lastframe ) != m_lastframe ) {
79 QPainter p ( this );
80 p. fillRect ( m_lastframe, black );
81 }
82 }
83 {
76 QDirectPainter dp( this ); 84 QDirectPainter dp( this );
77 uchar* dst = dp.frameBuffer() + (m_yOff + dp.yOffset() ) * linestep + 85
78 (m_xOff + dp.xOffset() ) * m_bytes_per_pixel; 86 uchar* dst = dp.frameBuffer() + (m_thisframe. y ( ) + dp.yOffset() ) * linestep +
87 (m_thisframe. x ( ) + dp.xOffset() ) * m_bytes_per_pixel;
79 uchar* frame = m_buff; 88 uchar* frame = m_buff;
80 for(int y = 0; y < m_Height; y++ ) { 89 for(int y = 0; y < m_thisframe. height ( ); y++ ) {
81 memcpy( dst, frame, m_bytes ); 90 memcpy( dst, frame, m_bytes );
82 frame += m_bytes; 91 frame += m_bytes;
83 dst += linestep; 92 dst += linestep;
84 } 93 }
94 }
95 {
85 // QVFB hack by MArtin Jones 96 // QVFB hack by MArtin Jones
86// QPainter dp2(this); 97 QPainter p ( this );
87 // dp2.fillRect( rect(), QBrush( NoBrush ) ); 98 p. fillRect ( m_thisframe, QBrush ( NoBrush ));
99 }
88 } 100 }
89// QWidget::paintEvent( e );
90} 101}
91int XineVideoWidget::height() const{ 102int XineVideoWidget::height() const{
92 return m_image->height(); 103 return m_image->height();
93} 104}
94int XineVideoWidget::width() const{ 105int XineVideoWidget::width() const{
95 return m_image->width(); 106 return m_image->width();
96} 107}
97void XineVideoWidget::setImage( QImage* image ) { 108void XineVideoWidget::setImage( QImage* image ) {
98 delete m_image; 109 delete m_image;
99 m_image = image; 110 m_image = image;
100} 111}
101void XineVideoWidget::setImage( uchar* image, int yoffsetXLine, 112void XineVideoWidget::setImage( uchar* image, int yoffsetXLine,
102 int xoffsetXBytes, int width, 113 int xoffsetXBytes, int width,
103 int height, int linestep, int bytes, int bpp ) { 114 int height, int linestep, int bytes, int bpp ) {
104/* if (m_buff != 0 ) 115
105 free(m_buff ); 116 m_lastframe = m_thisframe;
106*/ 117 m_thisframe. setRect ( xoffsetXBytes, yoffsetXLine, width, height );
118
107 m_buff = image; 119 m_buff = image;
108 m_yOff = yoffsetXLine;
109 m_xOff = xoffsetXBytes;
110 m_Width = width;
111 m_Height = height;
112 this->linestep = linestep; 120 this->linestep = linestep;
113 m_bytes = bytes; 121 m_bytes = bytes;
114 m_bytes_per_pixel = bpp; 122 m_bytes_per_pixel = bpp;
115 //// 123
116 qWarning("width %d %d", width, height ); 124 repaint ( false );
117/* QDirectPainter dp( this );
118 uchar* dst = dp.frameBuffer() + (m_yOff + dp.yOffset() ) * linestep +
119 (m_xOff + dp.xOffset() ) * m_bytes_per_pixel;
120 uchar* frame = m_buff;
121 for(int y = 0; y < m_Height; y++ ) {
122 memcpy( dst, frame, m_bytes );
123 frame += m_bytes;
124 dst += linestep;
125 }
126 // QVFB hack
127 QPainter dp2(this);
128 dp2.fillRect( rect(), QBrush( NoBrush ) );
129*/
130} 125}
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index b670fa0..5656194 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -42,23 +42,26 @@ public:
42 XineVideoWidget( int width, int height, QWidget* parent, const char* name ); 42 XineVideoWidget( int width, int height, QWidget* parent, const char* name );
43 ~XineVideoWidget(); 43 ~XineVideoWidget();
44 QImage *image() { return m_image; }; 44 QImage *image() { return m_image; };
45 void setImage( QImage* image ); 45 void setImage( QImage* image );
46 void setImage( uchar* image, int yoffsetXLine, int xoffsetXBytes, 46 void setImage( uchar* image, int yoffsetXLine, int xoffsetXBytes,
47 int width, int height, int linestep, int bytes, int bpp); 47 int width, int height, int linestep, int bytes, int bpp);
48 int width() const; 48 int width() const;
49 int height() const; 49 int height() const;
50 void clear() ; 50 void clear() ;
51protected: 51protected:
52 void paintEvent( QPaintEvent* p ); 52 void paintEvent( QPaintEvent* p );
53private: 53private:
54 QRect m_lastframe;
55 QRect m_thisframe;
56
54 int m_wid; 57 int m_wid;
55 int m_height; 58 int m_height;
56 int m_yOff, m_xOff; 59 int m_yOff, m_xOff;
57 uchar* m_buff; 60 uchar* m_buff;
58 int m_Width, m_Height, linestep; 61 int m_Width, m_Height, linestep;
59 int m_bytes; 62 int m_bytes;
60 int m_bytes_per_pixel; 63 int m_bytes_per_pixel;
61 QImage* m_image; 64 QImage* m_image;
62 65
63}; 66};
64 67