~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libvo/vo_svga.c

  • Committer: Reinhard Tartler
  • Date: 2006-07-08 08:47:54 UTC
  • Revision ID: siretart@tauware.de-20060708084754-c3ff228cc9c2d8de
upgrade to pre8

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "sub.h"
46
46
 
47
47
#include "mp_msg.h"
 
48
#include "help_mp.h"
48
49
//#include "mp_image.h"
49
50
 
50
51
#include <assert.h>
52
53
//silence warnings, probably it have to go in some global header
53
54
#define UNUSED(x) ((void)(x)) 
54
55
 
55
 
extern int verbose;
56
56
 
57
57
static int query_format(uint32_t format);
58
58
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
172
172
 
173
173
        force_vm=vga_getmodenumber(s);
174
174
        if(force_vm>0) {
175
 
          if(verbose) printf("vo_svga: Forcing mode %i\n",force_vm);
 
175
          if( mp_msg_test(MSGT_VO,MSGL_V) ) mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm);
176
176
        }else{ 
177
177
          force_vm = 0;
178
178
        }
191
191
int i;
192
192
 
193
193
  if (mode_capabilities&CAP_ACCEL_CLEAR){
194
 
    if(verbose > 2)
195
 
      printf("vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n",
 
194
    if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
195
      mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n",
196
196
             x,y,w,h);
197
197
    if(mode_capabilities&CAP_ACCEL_BACKGR)  
198
198
      vga_accel(ACCEL_SYNC);
201
201
    return;
202
202
  }
203
203
  if (mode_capabilities & CAP_LINEAR){
204
 
    if(verbose > 2)
205
 
      printf("vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h);
 
204
    if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
205
      mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h);
206
206
    rgbplane=PageStore[0].vbase + (y*mode_stride) + (x*modeinfo->bytesperpixel);
207
207
    for(i=0;i<h;i++){
208
208
//i'm afraid that memcpy is better optimized than memset;)
213
213
    return;
214
214
  }
215
215
  //native
216
 
  if(verbose > 2)
217
 
    printf("vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h);
 
216
  if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
217
    mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h);
218
218
  if(modeinfo->bytesperpixel!=0) w*=modeinfo->bytesperpixel;
219
219
  for(i=0;i<h;i++){
220
220
    vga_drawscansegment(zerobuf,x,y+i,w);
229
229
int page;
230
230
 
231
231
  if(mpi->flags & MP_IMGFLAG_DIRECT){
232
 
    if(verbose > 2)
233
 
      printf("vo_svga: drawing direct rendered surface\n");
 
232
    if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
233
      mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n");
234
234
    cpage=(uint32_t)mpi->priv;
235
235
    assert((cpage>=0)&&(cpage<max_pages));
236
236
    return VO_TRUE; //it's already done
259
259
        (stride == mode_stride) ){ //only monolite image can be accelerated
260
260
      w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source
261
261
//ACCELERATE
262
 
      if(verbose>2) 
263
 
        printf("vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
 
262
      if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
263
        mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
264
264
      if(mode_capabilities & CAP_ACCEL_BACKGR)
265
265
        vga_accel(ACCEL_SYNC);
266
266
 
270
270
  
271
271
    if( mode_capabilities&CAP_LINEAR){
272
272
//DIRECT  
273
 
      if(verbose>2) 
274
 
        printf("vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
 
273
      if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
274
        mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
275
275
      bytesperline=(w*mpi->bpp)/8;
276
276
      base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8;     
277
277
 
292
292
  //one byte per pixel! svgalib innovation
293
293
    if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w;
294
294
  
295
 
    if(verbose>2) 
296
 
      printf("vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
 
295
    if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
296
      mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
297
297
    y+=PageStore[cpage].yoffset;//y position of the page beggining
298
298
    for(i=0;i<h;i++){
299
299
      vga_drawscansegment(rgbplane,x,y+i,length);
328
328
  for(i=1;i<=lastmode;i++){
329
329
    vminfo = vga_getmodeinfo(i);
330
330
    if( vminfo == NULL ) continue;
331
 
    if(verbose>3)
332
 
      printf("vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i));
 
331
    if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
 
332
      mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i));
333
333
    if( vga_hasmode(i) == 0 ) continue;
334
334
    if( req_bpp != bpp_from_vminfo(vminfo) )continue;
335
335
    if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue;
341
341
    if( bestmode==0 || prev_badness >= badness ){//modeX etc...
342
342
      prev_badness=badness;
343
343
      bestmode=i;
344
 
      if(verbose>3)
345
 
        printf("vo_svga: found good mode %d with badness %d\n",i,badness);
 
344
      if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
 
345
        mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: found good mode %d with badness %d\n",i,badness);
346
346
    }
347
347
  }
348
348
  return bestmode;
404
404
  int32_t req_bpp;
405
405
  
406
406
  uint32_t accflags;
407
 
  if(verbose)
408
 
    printf("vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
 
407
  if( mp_msg_test(MSGT_VO,MSGL_V) )
 
408
    mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
409
409
           d_width, d_height, flags, title, format);
410
410
//Only RGB modes supported
411
411
  if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;} 
414
414
  if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;}
415
415
    
416
416
  if(!force_vm) {
417
 
    if (verbose) {
418
 
      printf("vo_svga: Looking for the best resolution...\n");
419
 
      printf("vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
 
417
    if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
 
418
      mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n");
 
419
      mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
420
420
    }
421
421
    vid_mode=find_best_svga_mode(req_w,req_h,req_bpp);
422
422
    if(vid_mode==0) 
425
425
  }else{//force_vm
426
426
    vid_mode=force_vm;
427
427
    if(vga_hasmode(vid_mode) == 0){
428
 
      printf("vo_svga: forced vid_mode %d (%s) not available\n",
 
428
      mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable,
429
429
             vid_mode,vga_getmodename(vid_mode));
430
430
      return 1; //error;
431
431
    }
432
432
    modeinfo=vga_getmodeinfo(vid_mode);
433
433
    if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){
434
 
      printf("vo_svga: forced vid_mode %d (%s) too small\n",
 
434
      mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall,
435
435
             vid_mode,vga_getmodename(vid_mode));
436
436
      return 1;
437
437
    }
438
438
  }
439
439
  mode_bpp=bpp_from_vminfo(modeinfo);
440
440
     
441
 
  printf("vo_svga: vid_mode: %d, %dx%d %dbpp\n",
 
441
  mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
442
442
         vid_mode,modeinfo->width,modeinfo->height,mode_bpp);
443
443
  
444
444
  if (vga_setmode(vid_mode) == -1) {
445
 
    printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode);
 
445
    mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
446
446
    uninit();
447
447
    return 1; // error
448
448
  }
492
492
    }
493
493
  }//fi force native
494
494
  if(mode_capabilities&CAP_LINEAR){
495
 
    printf("vo_svga: video mode is linear and memcpy could be used for image transfer\n");
 
495
    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed);
496
496
  }
497
497
  if(mode_capabilities&CAP_ACCEL_PUTIMAGE){
498
 
    printf("vo_svga: video mode have hardware acceleration and put_image could be used\n");
499
 
    printf("vo_svga: If it works for you i would like to know \nvo_svga: (send log with `mplayer test.avi -v -v -v -v &> svga.log`). Thx\n");
 
498
    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration);
 
499
    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow);
500
500
  }
501
501
  
502
502
//here is the place to handle strides for accel_ modes;
530
530
    }
531
531
  }
532
532
  assert(max_pages>0);
533
 
  printf("vo_svga: video mode have %d page(s)\n",max_pages);
 
533
  mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages);
534
534
  //15bpp
535
535
  if(modeinfo->bytesperpixel!=0)
536
536
    vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * modeinfo->bytesperpixel);
545
545
  x_pos = (modeinfo->width  - req_w) / 2;
546
546
  y_pos = (modeinfo->height - req_h) / 2;
547
547
  x_pos &= ~(15); //align x offset position to 16 pixels
548
 
  printf("vo_svga: centering image. start at (%d,%d)\n",x_pos,y_pos);
 
548
  mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos);
549
549
 
550
550
#ifdef CONFIG_VIDIX
551
551
 
552
552
  if(vidix_name[0]){ 
553
553
    vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height, 
554
554
        format, mode_bpp, modeinfo->width,modeinfo->height);
555
 
    printf("vo_svga: Using VIDIX. w=%i h=%i  mw=%i mh=%i\n",width,height,
 
555
    mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height,
556
556
           modeinfo->width,modeinfo->height);
557
557
    vidix_start();
558
558
    /*set colorkey*/       
593
593
 
594
594
static void draw_osd(void)
595
595
{
596
 
  if(verbose > 3)
597
 
     printf("vo_svga: draw_osd()\n");
 
596
  if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
 
597
     mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n");
598
598
  //only modes with bytesperpixel>0 can draw OSD
599
599
  if(modeinfo->bytesperpixel==0) return;
600
600
  if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD
622
622
  PageStore[old_page].locks=PAGE_EMPTY;
623
623
  PageStore[cpage].locks=PAGE_BUSY;
624
624
 
625
 
  if(verbose > 2)
626
 
    printf("vo_svga: viewing page %d\n",cpage);
 
625
  if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
626
    mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: viewing page %d\n",cpage);
627
627
  if(sync_flip && old_page!=cpage){
628
 
    if(verbose > 2) printf("vo_svga:vga_waitretrace\n");
 
628
    if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n");
629
629
    vga_waitretrace();
630
630
  }
631
631
  vga_setdisplaystart(PageStore[cpage].doffset);
650
650
int i,lastmode;
651
651
vga_modeinfo * vminfo;
652
652
 
653
 
  if (verbose >3)
654
 
    printf("vo_svga: query_format=%X \n",format);
 
653
  if ( mp_msg_test(MSGT_VO,MSGL_DBG4) )
 
654
    mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format);
655
655
//only RGB modes supported
656
656
  if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0; 
657
657
 
688
688
                       unsigned char *srca, int stride) {
689
689
  char* base;
690
690
 
691
 
  if(verbose>2)
692
 
    printf("vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n",
 
691
  if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
692
    mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n",
693
693
           x0,y0,w,h,src,srca,stride);
694
694
  if(!blackbar_osd) {
695
695
    //drawing in the image, so place the stuff there
697
697
    y0+=y_pos;
698
698
  }
699
699
  
700
 
  if(verbose>3)
701
 
    printf("vo_svga: OSD draw in page %d\n",cpage);
 
700
  if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
 
701
    mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage);
702
702
  base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel;
703
703
  switch (mode_bpp) {
704
704
    case 32: 
745
745
      mpi->planes[0] = PageStore[page].vbase + 
746
746
             y_pos*mode_stride + (x_pos*mpi->bpp)/8;
747
747
      mpi->priv=(void *)page;
748
 
      if(verbose>2)
749
 
        printf("vo_svga: direct render allocated! page=%d\n",page);
 
748
      if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
 
749
        mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page);
750
750
      return(VO_TRUE);
751
751
    }
752
752
  }