亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? display.c

?? MPEG2解編碼程序源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* display.c, X11 interface                                                 */

/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */

/*
 * Disclaimer of Warranty
 *
 * These software programs are available to the user without any license fee or
 * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
 * any and all warranties, whether express, implied, or statuary, including any
 * implied warranties or merchantability or of fitness for a particular
 * purpose.  In no event shall the copyright-holder be liable for any
 * incidental, punitive, or consequential damages of any kind whatsoever
 * arising from the use of these programs.
 *
 * This disclaimer of warranty extends to the user of these programs and user's
 * customers, employees, agents, transferees, successors, and assigns.
 *
 * The MPEG Software Simulation Group does not represent or warrant that the
 * programs furnished hereunder are free of infringement of any third-party
 * patents.
 *
 * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
 * are subject to royalty fees to patent holders.  Many of these patents are
 * general enough such that they are unavoidable regardless of implementation
 * design.
 *
 */

#ifdef DISPLAY

 /* the Xlib interface is closely modeled after
  * mpeg_play 2.0 by the Berkeley Plateau Research Group
  */

#include <stdio.h>
#include <stdlib.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include "config.h"
#include "global.h"

/* private prototypes */
static void Display_Image _ANSI_ARGS_((XImage *Ximage_Ptr, unsigned char *Dithered_Image));
static void Dither_Frame _ANSI_ARGS_((unsigned char *src[]));
static void Dither_Top_Field _ANSI_ARGS_((unsigned char *src[], unsigned char *dst));
static void Dither_Bottom_Field _ANSI_ARGS_((unsigned char *src[], unsigned char *dst));
static void Dither_Top_Field420 _ANSI_ARGS_((unsigned char *src[],
                                      unsigned char *dst));
static void Dither_Bottom_Field420 _ANSI_ARGS_((unsigned char *src[],
                                      unsigned char *dst));

/* local data */
static unsigned char *Dithered_Image, *Dithered_Image2;

static unsigned char Y_Table[256+16];
static unsigned char Cb_Table[128+16];
static unsigned char Cr_Table[128+16];

/* X11 related variables */
static Display *Display_Ptr;
static Window Window_Instance;
static GC GC_Instance;
static XImage *Ximage_Ptr, *Ximage_Ptr2;
static unsigned char Pixel[256];

#ifdef SH_MEM

#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>

static int HandleXError _ANSI_ARGS_((Display *dpy, XErrorEvent *event));
static void InstallXErrorHandler _ANSI_ARGS_((void));
static void DeInstallXErrorHandler _ANSI_ARGS_((void));

static int Shmem_Flag;
static XShmSegmentInfo Shminfo1, Shminfo2;
static int gXErrorFlag;
static int CompletionType = -1;

static int HandleXError(Dpy, Event)
Display *Dpy;
XErrorEvent *Event;
{
  gXErrorFlag = 1;

  return 0;
}

static void InstallXErrorHandler()
{
  XSetErrorHandler(HandleXError);
  XFlush(Display_Ptr);
}

static void DeInstallXErrorHandler()
{
  XSetErrorHandler(NULL);
  XFlush(Display_Ptr);
}

#endif

/* connect to server, create and map window,
 * allocate colors and (shared) memory
 */
void Initialize_Display_Process(name)
char *name;
{
  int crv, cbu, cgu, cgv;
  int Y, Cb, Cr, R, G, B;
  int i;
  char dummy;
  int screen;
  Colormap cmap;
  int private;
  XColor xcolor;
  unsigned int fg, bg;
  char *hello = "MPEG-2 Display";
  XSizeHints hint;
  XVisualInfo vinfo;
  XEvent xev;
  unsigned long tmp_pixel;
  XWindowAttributes xwa;

  Display_Ptr = XOpenDisplay(name);

  if (Display_Ptr == NULL)
    Error("Can not open display\n");

  screen = DefaultScreen(Display_Ptr);

  hint.x = 200;
  hint.y = 200;
  hint.width = horizontal_size;
  hint.height = vertical_size;
  hint.flags = PPosition | PSize;

  /* Get some colors */

  bg = WhitePixel (Display_Ptr, screen);
  fg = BlackPixel (Display_Ptr, screen);

  /* Make the window */

  if (!XMatchVisualInfo(Display_Ptr, screen, 8, PseudoColor, &vinfo))
  {
    if (!XMatchVisualInfo(Display_Ptr, screen, 8, GrayScale, &vinfo))
      Error("requires 8 bit display\n");
  }

  Window_Instance = XCreateSimpleWindow (Display_Ptr, DefaultRootWindow (Display_Ptr),
             hint.x, hint.y, hint.width, hint.height, 4, fg, bg);

  XSelectInput(Display_Ptr, Window_Instance, StructureNotifyMask);

  /* Tell other applications about this window */

  XSetStandardProperties (Display_Ptr, Window_Instance, hello, hello, None, NULL, 0, &hint);

  /* Map window. */

  XMapWindow(Display_Ptr, Window_Instance);

  /* Wait for map. */
  do
  {
    XNextEvent(Display_Ptr, &xev);
  }
  while (xev.type != MapNotify || xev.xmap.event != Window_Instance);

  XSelectInput(Display_Ptr, Window_Instance, NoEventMask);

  /* matrix coefficients */
  crv = Inverse_Table_6_9[matrix_coefficients][0];
  cbu = Inverse_Table_6_9[matrix_coefficients][1];
  cgu = Inverse_Table_6_9[matrix_coefficients][2];
  cgv = Inverse_Table_6_9[matrix_coefficients][3];

  /* allocate colors */

  GC_Instance = DefaultGC(Display_Ptr, screen);
  cmap = DefaultColormap(Display_Ptr, screen);
  private = 0;

  /* color allocation:
   * i is the (internal) 8 bit color number, it consists of separate
   * bit fields for Y, U and V: i = (yyyyuuvv), we don't use yyyy=0000
   * and yyyy=1111, this leaves 32 colors for other applications
   *
   * the allocated colors correspond to the following Y, U and V values:
   * Y:   24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232
   * U,V: -48, -16, 16, 48
   *
   * U and V values span only about half the color space; this gives
   * usually much better quality, although highly saturated colors can
   * not be displayed properly
   *
   * translation to R,G,B is implicitly done by the color look-up table
   */
  for (i=16; i<240; i++)
  {
    /* color space conversion */
    Y  = 16*((i>>4)&15) + 8;
    Cb = 32*((i>>2)&3)  - 48;
    Cr = 32*(i&3)       - 48;

    Y = 76309 * (Y - 16); /* (255/219)*65536 */

    R = Clip[(Y + crv*Cr + 32768)>>16];
    G = Clip[(Y - cgu*Cb - cgv*Cr + 32768)>>16];
    B = Clip[(Y + cbu*Cb + 32786)>>16];

    /* X11 colors are 16 bit */
    xcolor.red   = R << 8;
    xcolor.green = G << 8;
    xcolor.blue  = B << 8;

    if (XAllocColor(Display_Ptr, cmap, &xcolor) != 0)
      Pixel[i] = xcolor.pixel;
    else
    {
      /* allocation failed, have to use a private colormap */

      if (private)
        Error("Couldn't allocate private colormap");

      private = 1;

      if (!Quiet_Flag)
        fprintf(stderr, "Using private colormap (%d colors were available).\n",
          i-16);

      /* Free colors. */
      while (--i >= 16)
      {
        tmp_pixel = Pixel[i]; /* because XFreeColors expects unsigned long */
        XFreeColors(Display_Ptr, cmap, &tmp_pixel, 1, 0);
      }

      /* i is now 15, this restarts the outer loop */

      /* create private colormap */

      XGetWindowAttributes(Display_Ptr, Window_Instance, &xwa);
      cmap = XCreateColormap(Display_Ptr, Window_Instance, xwa.visual, AllocNone);
      XSetWindowColormap(Display_Ptr, Window_Instance, cmap);
    }
  }

#ifdef SH_MEM
  if (XShmQueryExtension(Display_Ptr))
    Shmem_Flag = 1;
  else
  {
    Shmem_Flag = 0;
    if (!Quiet_Flag)
      fprintf(stderr, "Shared memory not supported\nReverting to normal Xlib\n");
  }

  if (Shmem_Flag)
    CompletionType = XShmGetEventBase(Display_Ptr) + ShmCompletion;

  InstallXErrorHandler();

  if (Shmem_Flag)
  {

    Ximage_Ptr = XShmCreateImage(Display_Ptr, None, 8, ZPixmap, NULL,
                             &Shminfo1,
                             Coded_Picture_Width, Coded_Picture_Height);

    if (!progressive_sequence)
      Ximage_Ptr2 = XShmCreateImage(Display_Ptr, None, 8, ZPixmap, NULL,
                                &Shminfo2,
                                Coded_Picture_Width, Coded_Picture_Height);

    /* If no go, then revert to normal Xlib calls. */

    if (Ximage_Ptr==NULL || (!progressive_sequence && Ximage_Ptr2==NULL))
    {
      if (Ximage_Ptr!=NULL)
        XDestroyImage(Ximage_Ptr);
      if (!progressive_sequence && Ximage_Ptr2!=NULL)
        XDestroyImage(Ximage_Ptr2);
      if (!Quiet_Flag)
        fprintf(stderr, "Shared memory error, disabling (Ximage error)\n");
      goto shmemerror;
    }

    /* Success here, continue. */

    Shminfo1.shmid = shmget(IPC_PRIVATE, 
                            Ximage_Ptr->bytes_per_line * Ximage_Ptr->height,
                            IPC_CREAT | 0777);
    if (!progressive_sequence)
      Shminfo2.shmid = shmget(IPC_PRIVATE, 
                              Ximage_Ptr2->bytes_per_line * Ximage_Ptr2->height,
                              IPC_CREAT | 0777);

    if (Shminfo1.shmid<0 || (!progressive_sequence && Shminfo2.shmid<0))
    {
      XDestroyImage(Ximage_Ptr);
      if (!progressive_sequence)
        XDestroyImage(Ximage_Ptr2);
      if (!Quiet_Flag)
        fprintf(stderr, "Shared memory error, disabling (seg id error)\n");
      goto shmemerror;
    }

    Shminfo1.shmaddr = (char *) shmat(Shminfo1.shmid, 0, 0);
    Shminfo2.shmaddr = (char *) shmat(Shminfo2.shmid, 0, 0);

    if (Shminfo1.shmaddr==((char *) -1) ||
        (!progressive_sequence && Shminfo2.shmaddr==((char *) -1)))
    {
      XDestroyImage(Ximage_Ptr);
      if (Shminfo1.shmaddr!=((char *) -1))
        shmdt(Shminfo1.shmaddr);
      if (!progressive_sequence)
      {
        XDestroyImage(Ximage_Ptr2);
        if (Shminfo2.shmaddr!=((char *) -1))
          shmdt(Shminfo2.shmaddr);
      }
      if (!Quiet_Flag)
      {
        fprintf(stderr, "Shared memory error, disabling (address error)\n");
      }
      goto shmemerror;
    }

    Ximage_Ptr->data = Shminfo1.shmaddr;
    Dithered_Image = (unsigned char *)Ximage_Ptr->data;
    Shminfo1.readOnly = False;
    XShmAttach(Display_Ptr, &Shminfo1);
    if (!progressive_sequence)
    {
      Ximage_Ptr2->data = Shminfo2.shmaddr;
      Dithered_Image2 = (unsigned char *)Ximage_Ptr2->data;
      Shminfo2.readOnly = False;
      XShmAttach(Display_Ptr, &Shminfo2);
    }

    XSync(Display_Ptr, False);

    if (gXErrorFlag)
    {
      /* Ultimate failure here. */
      XDestroyImage(Ximage_Ptr);
      shmdt(Shminfo1.shmaddr);
      if (!progressive_sequence)
      {
        XDestroyImage(Ximage_Ptr2);
        shmdt(Shminfo2.shmaddr);
      }
      if (!Quiet_Flag)
        fprintf(stderr, "Shared memory error, disabling.\n");
      gXErrorFlag = 0;
      goto shmemerror;
    }
    else
    {
      shmctl(Shminfo1.shmid, IPC_RMID, 0);
      if (!progressive_sequence)
        shmctl(Shminfo2.shmid, IPC_RMID, 0);
    }

    if (!Quiet_Flag)
    {
      fprintf(stderr, "Sharing memory.\n");
    }
  }
  else
  {
shmemerror:
    Shmem_Flag = 0;
#endif

    Ximage_Ptr = XCreateImage(Display_Ptr,None,8,ZPixmap,0,&dummy,
                          Coded_Picture_Width,Coded_Picture_Height,8,0);

    if (!(Dithered_Image = (unsigned char *)malloc(Coded_Picture_Width*
                                                   Coded_Picture_Height)))
      Error("malloc failed");

    if (!progressive_sequence)
    {
      Ximage_Ptr2 = XCreateImage(Display_Ptr,None,8,ZPixmap,0,&dummy,
                             Coded_Picture_Width,Coded_Picture_Height,8,0);

      if (!(Dithered_Image2 = (unsigned char *)malloc(Coded_Picture_Width*
                                                      Coded_Picture_Height)))
        Error("malloc failed");
    }

#ifdef SH_MEM
  }

  DeInstallXErrorHandler();
#endif
}

void Terminate_Display_Process()

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡视频在线观看| 亚洲人妖av一区二区| 日韩精品成人一区二区在线| 欧美日韩视频专区在线播放| 激情综合色播激情啊| 91精品国产日韩91久久久久久| 亚洲午夜激情网站| 欧美精品九九99久久| 日韩—二三区免费观看av| 欧美一区二区三区影视| 久久福利视频一区二区| 精品国产乱码久久久久久浪潮| 激情综合色播激情啊| 国产欧美日韩精品一区| 暴力调教一区二区三区| 亚洲精品老司机| 欧美日韩大陆一区二区| 欧美a级理论片| 久久蜜桃av一区精品变态类天堂| 福利一区二区在线| 一区二区三区四区激情| 欧美精品丝袜中出| 久久不见久久见免费视频7| 久久色.com| 91亚洲国产成人精品一区二区三| 一区二区三区不卡在线观看| 欧美日韩在线精品一区二区三区激情 | 午夜国产精品一区| 精品av综合导航| 99免费精品视频| 图片区小说区区亚洲影院| 2020日本不卡一区二区视频| 91免费版在线看| 美女性感视频久久| 国产精品国模大尺度视频| 欧美日韩国产123区| 国产伦精品一区二区三区免费迷 | 欧美韩国日本一区| 欧美三级在线看| 国产自产2019最新不卡| 一区二区三区高清| 亚洲精品在线电影| 色婷婷精品大视频在线蜜桃视频| 久久99国产精品免费| 国产精品福利av | 久久蜜桃一区二区| 欧美亚洲综合在线| 国产成人亚洲综合a∨婷婷| 亚洲国产精品久久久男人的天堂 | 国产精品国产三级国产aⅴ中文 | 精品一区二区av| 最新久久zyz资源站| 欧美xxx久久| 欧美日韩五月天| 欧美aaaaaa午夜精品| 国产精品动漫网站| 成人网页在线观看| 26uuu亚洲综合色| 国产成人aaa| 欧美大片日本大片免费观看| 日韩av中文字幕一区二区三区| 中文字幕久久午夜不卡| 午夜精品福利久久久| 欧美日韩国产精选| 亚洲成人精品一区二区| 91美女在线观看| 精品一二三四区| 亚洲宅男天堂在线观看无病毒| 日韩精品综合一本久道在线视频| jvid福利写真一区二区三区| 青青草国产成人av片免费| 色噜噜狠狠色综合欧洲selulu| 国产精品自拍毛片| 一区二区在线观看视频 | 中文久久乱码一区二区| 欧美色精品在线视频| 国产成人精品1024| 热久久久久久久| 亚洲一区二区三区在线播放| 国产精品热久久久久夜色精品三区| 欧美三级午夜理伦三级中视频| 97精品久久久久中文字幕| 精品一区二区三区在线播放视频| 亚洲综合在线五月| 国产精品久久久一本精品| 精品国免费一区二区三区| 在线这里只有精品| 韩国欧美国产1区| 美国欧美日韩国产在线播放| 亚洲一级二级在线| 夜夜嗨av一区二区三区中文字幕| 精品欧美乱码久久久久久1区2区| 欧美一区二区三区爱爱| 欧美日韩一区二区三区在线| 一本一本大道香蕉久在线精品| 国产91在线|亚洲| 国产中文字幕一区| 蜜桃传媒麻豆第一区在线观看| 亚洲国产sm捆绑调教视频| 亚洲精品视频免费观看| 久久尤物电影视频在线观看| 久久久www免费人成精品| 精品美女一区二区| 精品国产免费一区二区三区四区| 日韩一区二区高清| 日韩亚洲欧美一区二区三区| 日韩欧美中文字幕制服| 国产午夜亚洲精品理论片色戒| 欧美v日韩v国产v| 26uuu色噜噜精品一区| 久久免费偷拍视频| 久久精品人人做人人综合| 久久久www成人免费毛片麻豆| 欧美国产国产综合| 综合网在线视频| 婷婷国产在线综合| 日韩国产成人精品| 国产综合色在线| 床上的激情91.| 91玉足脚交白嫩脚丫在线播放| 色婷婷综合久久久久中文| 色婷婷av一区二区三区gif| 波多野结衣一区二区三区| 91高清在线观看| 欧美私人免费视频| 欧美一个色资源| 久久久精品蜜桃| 亚洲美女屁股眼交3| 午夜电影网亚洲视频| 久久99国产精品久久99果冻传媒| 久久国产精品99久久久久久老狼| av一二三不卡影片| 欧美日韩aaa| 国产亚洲人成网站| 亚洲欧美色综合| 日韩精品91亚洲二区在线观看| 九九久久精品视频| 国产91精品一区二区麻豆网站| 91麻豆成人久久精品二区三区| 欧美性猛交一区二区三区精品 | 亚洲一区二区欧美日韩| 精品一区二区三区不卡| jlzzjlzz欧美大全| 制服丝袜亚洲色图| 日本一二三四高清不卡| 亚洲午夜久久久久久久久电影院| 免费精品99久久国产综合精品| 顶级嫩模精品视频在线看| 欧美三区免费完整视频在线观看| 国产精品天美传媒| 天堂在线亚洲视频| 91国偷自产一区二区开放时间 | 久久综合九色欧美综合狠狠 | 色婷婷一区二区三区四区| 日韩欧美三级在线| 亚洲视频狠狠干| 久久爱另类一区二区小说| www.亚洲色图.com| 国产精品超碰97尤物18| 亚洲成人激情av| jvid福利写真一区二区三区| 欧美色国产精品| 亚洲一区二区四区蜜桃| 粉嫩久久99精品久久久久久夜| 欧美日韩免费高清一区色橹橹| 久久久不卡网国产精品二区| 日韩在线卡一卡二| 91小视频在线观看| 久久久久国色av免费看影院| 国产真实乱对白精彩久久| 欧美日韩精品一区二区| 亚洲综合精品自拍| caoporn国产精品| 国产精品国产自产拍在线| 国产传媒久久文化传媒| 久久久久一区二区三区四区| 日韩成人dvd| 欧美成人精品二区三区99精品| 亚洲国产精品一区二区www在线| 色悠久久久久综合欧美99| 亚洲欧洲精品天堂一级| 国产精品1区2区3区| 日韩精品一区国产麻豆| 三级不卡在线观看| 精品视频在线免费看| 日韩国产精品久久久久久亚洲| 欧美日韩一卡二卡三卡| 秋霞影院一区二区| 正在播放亚洲一区| 久久精品国产久精国产| 欧美一区二区三级| 国产精品88888| 国产亚洲人成网站| 91农村精品一区二区在线| 日韩一区二区在线观看| 麻豆国产一区二区| 91精品蜜臀在线一区尤物| 久久精品99久久久| 欧美大片在线观看| 国产福利精品一区|