summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/nullvideo.c
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/nullvideo.c') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/nullvideo.c220
1 files changed, 90 insertions, 130 deletions
diff --git a/noncore/multimedia/opieplayer2/nullvideo.c b/noncore/multimedia/opieplayer2/nullvideo.c
index 6769a37..99fa329 100644
--- a/noncore/multimedia/opieplayer2/nullvideo.c
+++ b/noncore/multimedia/opieplayer2/nullvideo.c
@@ -3,5 +3,4 @@
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 <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 5 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 Copyright (c) 2002-2003 Miguel Freitas of xine 6 Copyright (c) 2002-2003 Miguel Freitas of xine
@@ -41,5 +40,4 @@
41#include <xine/video_out.h> 40#include <xine/video_out.h>
42#include <xine/xine_internal.h> 41#include <xine/xine_internal.h>
43//#include <xine/xineutils.h>
44#include <xine/vo_scale.h> 42#include <xine/vo_scale.h>
45#include <xine/buffer.h> 43#include <xine/buffer.h>
@@ -52,5 +50,5 @@
52 50
53/* 51/*
54#define LOG 52 * #define LOG
55*/ 53*/
56 54
@@ -58,4 +56,8 @@
58typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 56typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
59 int width, int height,int bytes ); 57 int width, int height,int bytes );
58typedef void (*vo_scale_cb) (void*, int, int, double,
59 int*, int*, int*, double*, int*, int* );
60typedef void (*dest_size_cb) (void*, int, int, double, int*, int*, double*);
61
60 62
61typedef struct null_driver_s null_driver_t; 63typedef struct null_driver_s null_driver_t;
@@ -64,13 +66,11 @@ struct null_driver_s {
64 vo_driver_t vo_driver; 66 vo_driver_t vo_driver;
65 67
66 uint32_t m_capabilities;
67 int m_show_video; 68 int m_show_video;
68 int m_video_fullscreen; 69 int m_video_fullscreen;
69 int m_is_scaling;
70 70
71 int depth, bpp, bytes_per_pixel; 71 int depth, bpp, bytes_per_pixel;
72 int yuv2rgb_mode; 72 int yuv2rgb_mode;
73 int yuv2rgb_swap; 73 int yuv2rgb_swap;
74 int yuv2rgb_gamma; 74 int yuv2rgb_brightness;
75 uint8_t *yuv2rgb_cmap; 75 uint8_t *yuv2rgb_cmap;
76 yuv2rgb_factory_t *yuv2rgb_factory; 76 yuv2rgb_factory_t *yuv2rgb_factory;
@@ -79,11 +79,12 @@ struct null_driver_s {
79 vo_scale_t sc; 79 vo_scale_t sc;
80 80
81 int gui_width; 81 /*
82 int gui_height; 82 * DISPLAY to widget...
83 int gui_changed; 83 */
84
85 double display_ratio;
86 void* caller;
87 display_xine_frame_t frameDis; 84 display_xine_frame_t frameDis;
85 void *userData;
86
87 xine_t *xine;
88 alphablend_t alphablend_extra_data;
88}; 89};
89 90
@@ -111,6 +112,6 @@ struct opie_frame_s {
111 112
112static uint32_t null_get_capabilities( vo_driver_t *self ){ 113static uint32_t null_get_capabilities( vo_driver_t *self ){
113 null_driver_t* this = (null_driver_t*)self; 114 self = self;
114 return this->m_capabilities; 115 return VO_CAP_YUY2 | VO_CAP_YV12;
115} 116}
116 117
@@ -120,6 +121,16 @@ static void null_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) {
120 vo_img->proc_called = 1; 121 vo_img->proc_called = 1;
121 122
122 if (!frame->output->m_show_video) { 123 /*
123 /* printf("nullvideo: no video\n"); */ 124 * drop hard if we don't show the video
125 */
126 if (!frame->output->m_show_video)
127 return;
128
129 if( frame->frame.crop_left || frame->frame.crop_top ||
130 frame->frame.crop_right || frame->frame.crop_bottom )
131 {
132 /* we don't support crop, so don't even waste cpu cycles.
133 * cropping will be performed by video_out.c
134 */
124 return; 135 return;
125 } 136 }
@@ -143,13 +154,13 @@ static void null_frame_field (vo_frame_t *vo_img, int which_field) {
143 switch (which_field) { 154 switch (which_field) {
144 case VO_TOP_FIELD: 155 case VO_TOP_FIELD:
145 frame->rgb_dst = (uint8_t *)frame->data; 156 frame->rgb_dst = frame->data;
146 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 157 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
147 break; 158 break;
148 case VO_BOTTOM_FIELD: 159 case VO_BOTTOM_FIELD:
149 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; 160 frame->rgb_dst = frame->data + frame->bytes_per_line ;
150 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line; 161 frame->stripe_inc = 2*frame->stripe_height * frame->bytes_per_line;
151 break; 162 break;
152 case VO_BOTH_FIELDS: 163 case VO_BOTH_FIELDS:
153 frame->rgb_dst = (uint8_t *)frame->data; 164 frame->rgb_dst = frame->data;
154 break; 165 break;
155 } 166 }
@@ -178,4 +189,6 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){
178 189
179 frame = (opie_frame_t*)xine_xmalloc ( sizeof(opie_frame_t) ); 190 frame = (opie_frame_t*)xine_xmalloc ( sizeof(opie_frame_t) );
191 if(!frame)
192 return NULL;
180 193
181 memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t)); 194 memcpy (&frame->sc, &this->sc, sizeof(vo_scale_t));
@@ -188,4 +201,5 @@ static vo_frame_t* null_alloc_frame( vo_driver_t* self ){
188 frame->frame.driver = self; 201 frame->frame.driver = self;
189 frame->frame.proc_slice = null_frame_proc_slice; 202 frame->frame.proc_slice = null_frame_proc_slice;
203 frame->frame.proc_frame = NULL;
190 frame->frame.field = null_frame_field; 204 frame->frame.field = null_frame_field;
191 frame->frame.dispose = null_frame_dispose; 205 frame->frame.dispose = null_frame_dispose;
@@ -230,5 +244,4 @@ static void null_frame_reallocate( null_driver_t *this, opie_frame_t *frame,
230 * (re-) allocate 244 * (re-) allocate
231 */ 245 */
232 if( frame->data ) {
233 if( frame->chunk[0] ){ 246 if( frame->chunk[0] ){
234 free( frame->chunk[0] ); 247 free( frame->chunk[0] );
@@ -243,6 +256,6 @@ static void null_frame_reallocate( null_driver_t *this, opie_frame_t *frame,
243 frame->chunk[2] = NULL; 256 frame->chunk[2] = NULL;
244 } 257 }
258 if(frame->data)
245 free ( frame->data ); 259 free ( frame->data );
246 }
247 260
248 frame->data = xine_xmalloc (frame->sc.output_width 261 frame->data = xine_xmalloc (frame->sc.output_width
@@ -311,8 +324,15 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
311#endif 324#endif
312 325
326 int gui_width = 0;
327 int gui_height = 0;
328 double gui_pixel_aspect = 0.0;
329
313 flags &= VO_BOTH_FIELDS; 330 flags &= VO_BOTH_FIELDS;
314 331
315 /* find out if we need to adapt this frame */ 332 frame->sc.dest_size_cb(frame->sc.user_data, width, height,
333 frame->sc.video_pixel_aspect,
334 &gui_width, &gui_height, &gui_pixel_aspect);
316 335
336 /* find out if we need to adapt this frame */
317 if ((width != frame->sc.delivered_width) 337 if ((width != frame->sc.delivered_width)
318 || (height != frame->sc.delivered_height) 338 || (height != frame->sc.delivered_height)
@@ -321,7 +341,6 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
321 || (format != frame->format) 341 || (format != frame->format)
322 || (this->sc.user_ratio != frame->sc.user_ratio) 342 || (this->sc.user_ratio != frame->sc.user_ratio)
323 || (this->gui_width != frame->sc.gui_width) 343 || (gui_width != frame->sc.gui_width)
324 || (this->gui_height != frame->sc.gui_height)) { 344 || (gui_height != frame->sc.gui_height)) {
325
326 frame->sc.delivered_width = width; 345 frame->sc.delivered_width = width;
327 frame->sc.delivered_height = height; 346 frame->sc.delivered_height = height;
@@ -330,7 +349,6 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
330 frame->format = format; 349 frame->format = format;
331 frame->sc.user_ratio = this->sc.user_ratio; 350 frame->sc.user_ratio = this->sc.user_ratio;
332 frame->sc.gui_width = this->gui_width; 351 frame->sc.gui_width = gui_width;
333 frame->sc.gui_height = this->gui_height; 352 frame->sc.gui_height = gui_height;
334 frame->sc.gui_pixel_aspect = 1.0;
335 353
336 354
@@ -364,13 +382,13 @@ static void null_update_frame_format( vo_driver_t* self, vo_frame_t* img,
364 switch (flags) { 382 switch (flags) {
365 case VO_TOP_FIELD: 383 case VO_TOP_FIELD:
366 frame->rgb_dst = (uint8_t *)frame->data; 384 frame->rgb_dst = frame->data;
367 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; 385 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
368 break; 386 break;
369 case VO_BOTTOM_FIELD: 387 case VO_BOTTOM_FIELD:
370 frame->rgb_dst = (uint8_t *)frame->data + frame->bytes_per_line ; 388 frame->rgb_dst = frame->data + frame->bytes_per_line ;
371 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line; 389 frame->stripe_inc = 2 * frame->stripe_height * frame->bytes_per_line;
372 break; 390 break;
373 case VO_BOTH_FIELDS: 391 case VO_BOTH_FIELDS:
374 frame->rgb_dst = (uint8_t *)frame->data; 392 frame->rgb_dst = frame->data;
375 frame->stripe_inc = frame->stripe_height * frame->bytes_per_line; 393 frame->stripe_inc = frame->stripe_height * frame->bytes_per_line;
376 break; 394 break;
@@ -388,5 +406,5 @@ static void null_display_frame( vo_driver_t* self, vo_frame_t *frame_gen ){
388 406
389 if( display != NULL ) { 407 if( display != NULL ) {
390 (*display)(this->caller, frame->data, 408 (*display)(this->userData, frame->data,
391 frame->sc.output_width, frame->sc.output_height, 409 frame->sc.output_width, frame->sc.output_height,
392 frame->bytes_per_line ); 410 frame->bytes_per_line );
@@ -443,26 +461,29 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen,
443 switch(this->bpp) { 461 switch(this->bpp) {
444 case 16: 462 case 16:
445 blend_rgb16((uint8_t *)frame->data, 463 blend_rgb16(frame->data,
446 overlay, 464 overlay,
447 frame->sc.output_width, 465 frame->sc.output_width,
448 frame->sc.output_height, 466 frame->sc.output_height,
449 frame->sc.delivered_width, 467 frame->sc.delivered_width,
450 frame->sc.delivered_height); 468 frame->sc.delivered_height,
469 &this->alphablend_extra_data);
451 break; 470 break;
452 case 24: 471 case 24:
453 blend_rgb24((uint8_t *)frame->data, 472 blend_rgb24(frame->data,
454 overlay, 473 overlay,
455 frame->sc.output_width, 474 frame->sc.output_width,
456 frame->sc.output_height, 475 frame->sc.output_height,
457 frame->sc.delivered_width, 476 frame->sc.delivered_width,
458 frame->sc.delivered_height); 477 frame->sc.delivered_height,
478 &this->alphablend_extra_data);
459 break; 479 break;
460 case 32: 480 case 32:
461 blend_rgb32((uint8_t *)frame->data, 481 blend_rgb32(frame->data,
462 overlay, 482 overlay,
463 frame->sc.output_width, 483 frame->sc.output_width,
464 frame->sc.output_height, 484 frame->sc.output_height,
465 frame->sc.delivered_width, 485 frame->sc.delivered_width,
466 frame->sc.delivered_height); 486 frame->sc.delivered_height,
487 &this->alphablend_extra_data);
467 break; 488 break;
468 default: 489 default:
@@ -475,5 +496,4 @@ static void null_overlay_blend ( vo_driver_t *this_gen, vo_frame_t *frame_gen,
475 496
476static int null_get_property( vo_driver_t* self, int property ){ 497static int null_get_property( vo_driver_t* self, int property ){
477#if 0
478 null_driver_t *this = (null_driver_t *)self; 498 null_driver_t *this = (null_driver_t *)self;
479 499
@@ -491,8 +511,4 @@ static int null_get_property( vo_driver_t* self, int property ){
491 break; 511 break;
492 } 512 }
493#else
494 property = property;
495 self = self;
496#endif
497 513
498 return 0; 514 return 0;
@@ -500,5 +516,4 @@ static int null_get_property( vo_driver_t* self, int property ){
500static int null_set_property( vo_driver_t* self, int property, 516static int null_set_property( vo_driver_t* self, int property,
501 int value ){ 517 int value ){
502#if 0
503 null_driver_t *this = (null_driver_t *)self; 518 null_driver_t *this = (null_driver_t *)self;
504 519
@@ -518,8 +533,4 @@ static int null_set_property( vo_driver_t* self, int property,
518 break; 533 break;
519 } 534 }
520#else
521 self = self;
522 property = property;
523#endif
524 535
525 return value; 536 return value;
@@ -528,17 +539,15 @@ static void null_get_property_min_max( vo_driver_t* self,
528 int property, int *min, 539 int property, int *min,
529 int *max ){ 540 int *max ){
530 self = self; 541 if(property == VO_PROP_BRIGHTNESS) {
531 property = property; 542 *min = -100;
532 543 *max = +100;
533 *max = 0; 544 }else {
534 *min = 0; 545 *min = 0;
546 *max = 0;
547 }
535} 548}
536static int null_gui_data_exchange( vo_driver_t* self, 549static int null_gui_data_exchange( vo_driver_t* self,
537 int data_type, 550 int data_type,
538 void *data ){ 551 void *data ){
539 self = self;
540 data_type = data_type;
541 data = data;
542
543 return 0; 552 return 0;
544} 553}
@@ -546,10 +555,10 @@ static int null_gui_data_exchange( vo_driver_t* self,
546static void null_dispose ( vo_driver_t* self ){ 555static void null_dispose ( vo_driver_t* self ){
547 null_driver_t* this = (null_driver_t*)self; 556 null_driver_t* this = (null_driver_t*)self;
557 _x_alphablend_free(&this->alphablend_extra_data);
548 free ( this ); 558 free ( this );
549} 559}
550static int null_redraw_needed( vo_driver_t* self ){ 560static int null_redraw_needed( vo_driver_t* self ){
551 self = self; 561 null_driver_t *this = (null_driver_t*)self;
552 562 return _x_vo_scale_redraw_needed(&this->sc);
553 return 0;
554} 563}
555 564
@@ -558,25 +567,21 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine,
558 void* video, 567 void* video,
559 display_xine_frame_t frameDisplayFunc, 568 display_xine_frame_t frameDisplayFunc,
560 void *userData ){ 569 void *userData, vo_scale_cb frame_cb,
561 video = video; 570 dest_size_cb dest_cb) {
562
563
564 null_driver_t *vo; 571 null_driver_t *vo;
565 vo = (null_driver_t*)malloc( sizeof(null_driver_t ) ); 572 vo = (null_driver_t*)xine_xmalloc(sizeof(null_driver_t ));
566 573 vo->xine = xine;
567 /* memset? */
568 memset(vo,0, sizeof(null_driver_t ) );
569 574
575 _x_alphablend_init(&vo->alphablend_extra_data, xine);
570 _x_vo_scale_init (&vo->sc, 0, 0, xine->config); 576 _x_vo_scale_init (&vo->sc, 0, 0, xine->config);
577 vo->sc.gui_width = 18;
578 vo->sc.gui_height = 6;
579 vo->sc.user_ratio = XINE_VO_ASPECT_AUTO;
580 vo->sc.user_data = userData;
581 vo->sc.frame_output_cb = frame_cb;
582 vo->sc.dest_size_cb = dest_cb;
571 583
572 vo->sc.gui_pixel_aspect = 1.0;
573 584
574 vo->m_show_video = 0; // false 585 vo->m_show_video = 0; // false
575 vo->m_video_fullscreen = 0;
576 vo->m_is_scaling = 0;
577 vo->display_ratio = 1.0;
578 vo->gui_width = 16;
579 vo->gui_height = 8;
580 vo->frameDis = NULL;
581 586
582 /* install callback handlers*/ 587 /* install callback handlers*/
@@ -585,5 +590,7 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine,
585 vo->vo_driver.update_frame_format = null_update_frame_format; 590 vo->vo_driver.update_frame_format = null_update_frame_format;
586 vo->vo_driver.display_frame = null_display_frame; 591 vo->vo_driver.display_frame = null_display_frame;
592 vo->vo_driver.overlay_begin = 0;
587 vo->vo_driver.overlay_blend = null_overlay_blend; 593 vo->vo_driver.overlay_blend = null_overlay_blend;
594 vo->vo_driver.overlay_end = 0;
588 vo->vo_driver.get_property = null_get_property; 595 vo->vo_driver.get_property = null_get_property;
589 vo->vo_driver.set_property = null_set_property; 596 vo->vo_driver.set_property = null_set_property;
@@ -593,11 +600,15 @@ xine_video_port_t* init_video_out_plugin( xine_t *xine,
593 vo->vo_driver.redraw_needed = null_redraw_needed; 600 vo->vo_driver.redraw_needed = null_redraw_needed;
594 601
595
596 /* capabilities */ 602 /* capabilities */
597 vo->m_capabilities = VO_CAP_YUY2 | VO_CAP_YV12; 603 vo->yuv2rgb_mode = MODE_16_RGB;
598 vo->yuv2rgb_factory = yuv2rgb_factory_init (MODE_16_RGB, vo->yuv2rgb_swap, 604 vo->yuv2rgb_brightness = 0;
605 vo->yuv2rgb_factory = yuv2rgb_factory_init (vo->yuv2rgb_mode,
606 vo->yuv2rgb_swap,
599 vo->yuv2rgb_cmap); 607 vo->yuv2rgb_cmap);
608 vo->yuv2rgb_factory->set_csc_levels(vo->yuv2rgb_factory,
609 vo->yuv2rgb_brightness,
610 128,128);
600 611
601 vo->caller = userData; 612 vo->userData = userData;
602 vo->frameDis = frameDisplayFunc; 613 vo->frameDis = frameDisplayFunc;
603 614
@@ -622,29 +633,4 @@ void null_set_show_video( xine_vo_driver_t* self, int show ) {
622} 633}
623 634
624int null_is_fullscreen( xine_vo_driver_t* self ){
625 return ((null_driver_t*)self->driver)->m_video_fullscreen;
626}
627void null_set_fullscreen( xine_vo_driver_t* self, int screen ){
628 ((null_driver_t*)self->driver)->m_video_fullscreen = screen;
629}
630int null_is_scaling( xine_vo_driver_t* self ){
631 return ((null_driver_t*)self->driver)->m_is_scaling;
632}
633
634void null_set_videoGamma( xine_vo_driver_t* self , int value ) {
635 ((null_driver_t*) self->driver) ->yuv2rgb_gamma = value;
636 ((null_driver_t*) self->driver) ->yuv2rgb_factory->set_gamma( ((null_driver_t*) self->driver) ->yuv2rgb_factory, value );
637}
638
639void null_set_scaling( xine_vo_driver_t* self, int scale ) {
640 ((null_driver_t*)self->driver)->m_is_scaling = scale;
641}
642
643void null_set_gui_width( xine_vo_driver_t* self, int width ) {
644 ((null_driver_t*)self->driver)->gui_width = width;
645}
646void null_set_gui_height( xine_vo_driver_t* self, int height ) {
647 ((null_driver_t*)self->driver)->gui_height = height;
648}
649 635
650 636
@@ -698,7 +684,4 @@ void null_set_mode( xine_vo_driver_t* self, int depth, int rgb ) {
698 break; 684 break;
699 }; 685 };
700 //free(this->yuv2rgb_factory );
701 // this->yuv2rgb_factory = yuv2rgb_factory_init (this->yuv2rgb_mode, this->yuv2rgb_swap,
702 // this->yuv2rgb_cmap);
703}; 686};
704 687
@@ -706,30 +689,7 @@ void null_display_handler( xine_vo_driver_t* self, display_xine_frame_t t,
706 void* user_data ) { 689 void* user_data ) {
707 null_driver_t* this = (null_driver_t*) self->driver; 690 null_driver_t* this = (null_driver_t*) self->driver;
708 this->caller = user_data; 691 this->userData = user_data;
709 this->frameDis = t; 692 this->frameDis = t;
710} 693}
711 694
712void null_preload_decoders( xine_stream_t *stream )
713{
714 static const uint32_t preloadedAudioDecoders[] = { BUF_AUDIO_MPEG, BUF_AUDIO_VORBIS };
715 static const uint8_t preloadedAudioDecoderCount = sizeof( preloadedAudioDecoders ) / sizeof( preloadedAudioDecoders[ 0 ] );
716 static const uint32_t preloadedVideoDecoders[] = { BUF_VIDEO_MPEG, BUF_VIDEO_MPEG4, BUF_VIDEO_DIVX5 };
717 static const uint8_t preloadedVideoDecoderCount = sizeof( preloadedVideoDecoders ) / sizeof( preloadedVideoDecoders[ 0 ] );
718
719 uint8_t i;
720#if 0
721
722 for ( i = 0; i < preloadedAudioDecoderCount; ++i ) {
723 audio_decoder_t *decoder = get_audio_decoder( stream, ( preloadedAudioDecoders[ i ] >> 16 ) & 0xff );
724 decoder = decoder;
725/* free_audio_decoder( stream, decoder ); */
726 }
727
728 for ( i = 0; i < preloadedVideoDecoderCount; ++i ) {
729 video_decoder_t *decoder = get_video_decoder( stream, ( preloadedVideoDecoders[ i ] >> 16 ) & 0xff );
730 decoder = decoder;
731/* free_video_decoder( stream, decoder ); */
732 }
733#endif
734}
735 695