~ubuntu-branches/ubuntu/maverick/zapping/maverick

« back to all changes in this revision

Viewing changes to src/video_xv.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-08 11:07:34 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108110734-ygvf6uljvgcjmca7
Tags: 0.9.6-1ubuntu1
* Resynchronise with Debian (Closes: #4022):
  - Fix desktop file to not use absolute path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include "zimage.h"
36
36
#include "zmisc.h"
37
37
#include "capture.h"
 
38
#include "tveng_private.h"
38
39
 
39
40
#ifdef USE_XV /* Real stuff */
40
41
 
275
276
      g_assert_not_reached ();
276
277
    }
277
278
 
278
 
  printv ("Created image: %s %dx%d, %d, %d\n",
 
279
  printv ("Created image: %s %ux%u, %lu, %lu\n",
279
280
          new_image->fmt.pixel_format->name,
280
281
          new_image->fmt.width,
281
282
          new_image->fmt.height,
464
465
    nv: boolean
465
466
 */
466
467
 
 
468
static tv_bool
 
469
set_control                     (tveng_device_info *    info,
 
470
                                 tv_control *           control,
 
471
                                 int                    value)
 
472
{
 
473
 
 
474
#if 0 /* TO DO */
 
475
  if ((c->atom == info->filter) &&
 
476
          (info->port != None))
 
477
        {
 
478
          XvSetPortAttribute(info->display,
 
479
                             info->port,
 
480
                             info->filter,
 
481
                             value);
 
482
        }
 
483
      else if ((c->atom == info->double_buffer) &&
 
484
               (info->port != None))
 
485
        {
 
486
          XvSetPortAttribute(info->display,
 
487
                             info->port,
 
488
                             info->double_buffer,
 
489
                             value);
 
490
        }
 
491
      else if ((c->atom == info->colorkey) &&
 
492
               (info->port != None))
 
493
        {
 
494
          int r, g, b;
 
495
          int rm=0xff, gm=0xff, bm=0xff, rs=16, gs=8, bs=0; /* masks, shifts */
 
496
          /* Adjust colorkey to the current pixformat */
 
497
          switch (info->current_bpp)
 
498
            {
 
499
            case 15:
 
500
              rm = gm = bm = 0xf8;
 
501
              rs = 7; gs = 2; bs = -3;
 
502
              break;
 
503
            case 16:
 
504
              rm = bm = 0xf8; gm = 0xfc;
 
505
              rs = 8; gs = 3; bs = -3;
 
506
              break;
 
507
            default:
 
508
              break;
 
509
            }
 
510
          r = (value>>16)&rm;
 
511
          if (rs > 0)
 
512
            r <<= rs;
 
513
          else
 
514
            r >>= -rs;
 
515
          g = (value>>8)&gm;
 
516
          if (gs > 0)
 
517
            g <<= gs;
 
518
          else
 
519
            g >>= -gs;
 
520
          b = value&bm;
 
521
          if (bs > 0)
 
522
            b <<= bs;
 
523
          else
 
524
            b >>= -bs;
 
525
          value = r+g+b;
 
526
          XvSetPortAttribute(info->display,
 
527
                             info->port,
 
528
                             info->colorkey,
 
529
                             value);
 
530
        }
 
531
 
 
532
#endif
 
533
 
 
534
  return FALSE;
 
535
}
 
536
 
 
537
static tv_bool
 
538
get_control                     (tveng_device_info *    info,
 
539
                                 tv_control *           control)
 
540
{
 
541
 
 
542
#if 0 /* TO DO */
 
543
 
 
544
  if ((c->atom == info->filter) &&
 
545
           (info->port != None))
 
546
    {
 
547
      XvGetPortAttribute(info->display,
 
548
                         info->port,
 
549
                         info->filter,
 
550
                         &value);
 
551
    }
 
552
  else if ((c->atom == info->double_buffer) &&
 
553
           (info->port != None))
 
554
    {
 
555
      XvGetPortAttribute(info->display,
 
556
                         info->port,
 
557
                         info->double_buffer,
 
558
                         &value);
 
559
    }
 
560
  else if ((c->atom == info->colorkey) &&
 
561
           (info->port != None))
 
562
    {
 
563
      int r,g,b, val;
 
564
      int rm=0xff, gm=0xff, bm=0xff, rs=16, gs=8, bs=0; /* masks, shifts */
 
565
 
 
566
      XvGetPortAttribute(info->display,
 
567
                         info->port,
 
568
                         info->colorkey,
 
569
                         &(val));
 
570
 
 
571
      /* Adjust colorkey to the current pixformat */
 
572
      switch (info->current_bpp)
 
573
        {
 
574
        case 15:
 
575
          rm = gm = bm = 0xf8;
 
576
          rs = 7; gs = 2; bs = -3;
 
577
          break;
 
578
        case 16:
 
579
          rm = bm = 0xf8; gm = 0xfc;
 
580
          rs = 8; gs = 3; bs = -3;
 
581
          break;
 
582
        default:
 
583
          break;
 
584
        }
 
585
      if (rs > 0)
 
586
        r = val >> rs;
 
587
      else
 
588
        r = val << -rs;
 
589
      r &= rm;
 
590
      if (gs > 0)
 
591
        g = val >> gs;
 
592
      else
 
593
        g = val << -gs;
 
594
      g &= gm;
 
595
      if (bs > 0)
 
596
        b = val >> bs;
 
597
      else
 
598
        b = val << -bs;
 
599
      b &= bm;
 
600
      value = (r<<16)+(g<<8)+b;
 
601
    }
 
602
  else
 
603
    {
 
604
      return 0;
 
605
    }
 
606
 
 
607
  if (c->pub.value != value)
 
608
    {
 
609
      c->pub.value = value;
 
610
      tv_callback_notify (info, &c->pub, c->pub._callback);
 
611
    }
 
612
 
 
613
#endif
 
614
 
 
615
  return FALSE;
 
616
}
 
617
 
 
618
static tv_bool
 
619
get_control_list                (tveng_device_info *    info)
 
620
{
 
621
 
 
622
#if 0 /* TO DO */
 
623
 
 
624
  XvAttribute *at;
 
625
  int attributes, i;
 
626
  Display *dpy;
 
627
 
 
628
  /* ? REQUIRE_IO_MODE (-1); */
 
629
 
 
630
  TVLOCK;
 
631
 
 
632
  tv_clear_error (info);
 
633
 
 
634
  info->port = port;
 
635
  dpy = info->display;
 
636
  info->filter = info->colorkey =
 
637
    info->double_buffer = None;
 
638
 
 
639
  /* Add the controls in this port to the struct of controls */
 
640
  at = XvQueryPortAttributes(dpy, port, &attributes);
 
641
 
 
642
  for (i=0; i<attributes; i++)
 
643
    {
 
644
      ccontrol c;
 
645
 
 
646
      if (info->debug_level)
 
647
        fprintf(stderr, "  TVeng.c Xv atom: %s%s%s (%i -> %i)\n",
 
648
                at[i].name,
 
649
                (at[i].flags & XvGettable) ? " gettable" : "",
 
650
                (at[i].flags & XvSettable) ? " settable" : "",
 
651
                at[i].min_value, at[i].max_value);
 
652
 
 
653
      /* Any attribute not settable and Gettable is of little value */
 
654
      if ((!(at[i].flags & XvGettable)) ||
 
655
          (!(at[i].flags & XvSettable)))
 
656
        continue;
 
657
 
 
658
      CLEAR (c);
 
659
 
 
660
      if (!strcmp("XV_FILTER", at[i].name))
 
661
          {
 
662
            info->filter = XInternAtom(dpy, "XV_FILTER",
 
663
                                                False);
 
664
            c.atom = info->filter;
 
665
            if (!(c.pub.label = strdup (_("Filter"))))
 
666
              goto failure;
 
667
            c.pub.minimum = at[i].min_value;
 
668
            c.pub.maximum = at[i].max_value;
 
669
            c.pub.type = TV_CONTROL_TYPE_BOOLEAN;
 
670
            c.pub.menu = NULL;
 
671
            c.pub._parent = NULL; /* TVENG_CONTROLLER_MOTHER; */
 
672
            /* XXX clone, not panel. */
 
673
            if (!append_panel_control(info, &c.pub, sizeof (c)))
 
674
              {
 
675
              failure:
 
676
                XFree (at);
 
677
                UNTVLOCK;
 
678
                return;
 
679
              }
 
680
          }
 
681
 
 
682
      else if (!strcmp("XV_DOUBLE_BUFFER", at[i].name))
 
683
          {
 
684
            info->double_buffer = XInternAtom(dpy, "XV_DOUBLE_BUFFER",
 
685
                                                       False);
 
686
            c.atom = info->double_buffer;
 
687
            if (!(c.pub.label = strdup (_("Filter"))))
 
688
              goto failure2;
 
689
            c.pub.minimum = at[i].min_value;
 
690
            c.pub.maximum = at[i].max_value;
 
691
            c.pub.type = TV_CONTROL_TYPE_BOOLEAN;
 
692
            c.pub.menu = NULL;
 
693
            c.pub._parent = NULL; /* TVENG_CONTROLLER_MOTHER; */
 
694
            if (!append_panel_control(info, &c.pub, sizeof (c)))
 
695
              {
 
696
              failure2:
 
697
                XFree (at);
 
698
                UNTVLOCK;
 
699
                return;
 
700
              }
 
701
          }
 
702
 
 
703
      else if (!strcmp("XV_COLORKEY", at[i].name))
 
704
          {
 
705
            info->colorkey = XInternAtom(dpy, "XV_COLORKEY",
 
706
                                                False);
 
707
            c.atom = info->colorkey;
 
708
            /* TRANSLATORS: Color replaced by video in overlay mode. */
 
709
            if (!(c.pub.label = strdup (_("Colorkey"))))
 
710
              goto failure3;
 
711
            c.pub.minimum = at[i].min_value;
 
712
            c.pub.maximum = at[i].max_value;
 
713
            c.pub.type = TV_CONTROL_TYPE_COLOR;
 
714
            c.pub.menu = NULL;
 
715
            c.pub._parent = NULL; /* TVENG_CONTROLLER_MOTHER; */
 
716
            if (!append_panel_control(info, &c.pub, sizeof (c)))
 
717
              {
 
718
              failure3:
 
719
                XFree (at);
 
720
                UNTVLOCK;
 
721
                return;
 
722
              }
 
723
          }
 
724
    }
 
725
 
 
726
  XFree (at);
 
727
 
 
728
  p_tveng_update_controls(info);
 
729
 
 
730
  UNTVLOCK;
 
731
 
 
732
#endif
 
733
 
 
734
  return FALSE;
 
735
}
 
736
 
 
737
static void
 
738
init_panel                      ()
 
739
{
 
740
  struct panel_device panel;
 
741
 
 
742
  CLEAR (panel);
 
743
 
 
744
  panel.set_control = set_control;
 
745
  panel.get_control = get_control;
 
746
 
 
747
  get_control_list (NULL);
 
748
}
 
749
 
467
750
static void
468
751
register_port                   (XvPortID               xvport,
469
752
                                 tv_pixfmt              pixfmt,