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

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

?? display.c

?? 文件內包含H.263視頻編碼算法和解碼算法2個文件
?? C
字號:
/************************************************************************
 *
 *  display.c, X11 interface for tmndecode (H.263 decoder)
 
*/

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

#ifdef DISPLAY

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

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

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

/* private prototypes */
static void display_image_ANSI_ARGS_((XImage *ximage, unsigned char *dithered_image));

/* display related data */
unsigned long wpixel[3];
static unsigned char *dithered_image;

/* X11 related variables */
static Display *display;
static Window window;
static GC gc;
static int dpy_depth;

XImage *ximage;

unsigned char pixel[256];

#ifdef SH_MEM

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

extern int XShmQueryExtension _ANSI_ARGS_((Display *dpy));
extern int XShmGetEventBase _ANSI_ARGS_((Display *dpy));

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);
}

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

#endif

/* connect to server, create and map window,
 * allocate colors and (shared) memory
 */
void init_display(name)
char *name;
{
  int crv, cbu, cgu, cgv;
  int y, u, v, r, g, b;
  int i;
  char dummy;
  int screen;
  Visual *visual;
  int dpy_class;
  Colormap cmap;
  int private;
  XColor xcolor;
  unsigned int fg, bg;
  char *hello = "H.263 Display";
  XSizeHints hint;
  XEvent xev;
  XSetWindowAttributes xswa;
  unsigned long tmp_pixel;
  unsigned int mask;

  display = XOpenDisplay(name);

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

  screen = DefaultScreen(display);

  visual = DefaultVisual (display, screen);
  dpy_depth = DefaultDepth (display, screen);
  dpy_class = visual->class;

  if (!((dpy_class == TrueColor && dpy_depth == 32)
        || (dpy_class == TrueColor && dpy_depth == 24)
        || (dpy_class == TrueColor && dpy_depth == 16)
        || (dpy_class == PseudoColor && dpy_depth == 8)))
    error ("requires 8 bit PseudoColor or 16/24/32 bit TrueColor display\n");

  if (dpy_class == TrueColor && dpy_depth == 32)
    printf("TrueColor : 32 bit colordepth\n");
  if (dpy_class == TrueColor && dpy_depth == 24)
    printf("TrueColor : 24 bit colordepth\n");
  if (dpy_class == TrueColor && dpy_depth == 16)
    printf("TrueColor : 16 bit colordepth\n");
  if (dpy_class == PseudoColor && dpy_depth == 8)
    printf("PseudoColor : 8 bit colordepth, 4x4 ordered dither\n");

  /* width and height of the display window */
  if (expand) {
    hint.min_width = hint.max_width = hint.width = 2*horizontal_size;
    hint.min_height = hint.max_height = hint.height = 2*vertical_size;
  }
  else {
    hint.min_width = hint.max_width = hint.width = horizontal_size;
    hint.min_height = hint.max_height = hint.height = vertical_size;
  }

  hint.flags = PSize | PMinSize | PMaxSize;

  /* Get some colors */

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

  /* Make the window */
  mask = CWBackPixel | CWBorderPixel;
  if (dpy_depth == 32 || dpy_depth == 24 || dpy_depth == 16) {
    mask |= CWColormap;
    xswa.colormap = XCreateColormap (display, DefaultRootWindow (display),
             visual, AllocNone);
  }
  xswa.background_pixel = bg;
  xswa.border_pixel = fg;
  window = XCreateWindow (display, DefaultRootWindow (display),
          hint.x, hint.y, hint.width, hint.height,
          1, dpy_depth, InputOutput, visual, mask, &xswa);


  XSelectInput(display, window, StructureNotifyMask);

  /* Tell other applications about this window */

  XSetStandardProperties (display, window, hello, hello, None, NULL, 0, &hint);

  /* Map window. */

  XMapWindow(display, window);

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

  XSelectInput(display, window, NoEventMask);

  /* allocate colors */

  gc = DefaultGC(display, screen);

  if (dpy_depth == 8) {
    XWindowAttributes xwa;

    cmap = DefaultColormap(display, screen);
    private = 0;

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

    /* 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
     * yyyy=0001 and yyyy=1111, this leaves 48 colors for other applications
     *
     * the allocated colors correspond to the following Y, U and V values:
     * Y:   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=32; i<240; i++) {
      /* color space conversion */
      y = 16*((i>>4)&15) + 8;
      u = 32*((i>>2)&3)  - 48;
      v = 32*(i&3)       - 48;

      y = 76309 * (y - 16); /* (255/219)*65536 */
      
      r = clp[(y + crv*v + 32768)>>16];
      g = clp[(y - cgu*u -cgv*v + 32768)>>16];
      b = clp[(y + cbu*u + 32786)>>16];

      /* X11 colors are 16 bit */
      xcolor.red   = r << 8;
      xcolor.green = g << 8;
      xcolor.blue  = b << 8;

      if (XAllocColor(display, 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)
          fprintf(stderr, "Using private colormap (%d colors were "
          "available).\n", i-32);

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

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

        /* create private colormap */

        XGetWindowAttributes(display, window, &xwa);
        cmap = XCreateColormap(display, window, xwa.visual, AllocNone);
        XSetWindowColormap(display, window, cmap);
      }
    }
  }

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

  if (shmem_flag)
    CompletionType = XShmGetEventBase(display) + ShmCompletion;

  InstallXErrorHandler();

  if (shmem_flag)
  {

    if (expand)
      ximage = XShmCreateImage(display, visual, dpy_depth, ZPixmap, NULL,
               &shminfo1,
               2*coded_picture_width, 2*coded_picture_height);
    else
      ximage = XShmCreateImage(display, visual, dpy_depth, ZPixmap, NULL,
               &shminfo1,
               coded_picture_width, coded_picture_height);
    

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

    if (ximage==NULL)
    {
      if (ximage!=NULL)
        XDestroyImage(ximage);
      if (!quiet)
        fprintf(stderr, "Shared memory error, disabling (Ximage error)\n");
      goto shmemerror;
    }

    /* Success here, continue. */

    shminfo1.shmid = shmget(IPC_PRIVATE, 
                            ximage->bytes_per_line * ximage->height,
                            IPC_CREAT | 0777);

    if (shminfo1.shmid<0)
    {
      XDestroyImage(ximage);
      if (!quiet)
        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))
    {
      XDestroyImage(ximage);
      if (shminfo1.shmaddr!=((char *) -1))
        shmdt(shminfo1.shmaddr);
      if (!quiet)
      {
        fprintf(stderr, "Shared memory error, disabling (address error)\n");
      }
      goto shmemerror;
    }

    ximage->data = shminfo1.shmaddr;
    dithered_image = (unsigned char *)ximage->data;
    shminfo1.readOnly = False;
    XShmAttach(display, &shminfo1);

    XSync(display, False);

    if (gXErrorFlag)
    {
      /* Ultimate failure here. */
      XDestroyImage(ximage);
      shmdt(shminfo1.shmaddr);
      if (!quiet)
        fprintf(stderr, "Shared memory error, disabling.\n");
      gXErrorFlag = 0;
      goto shmemerror;
    }
    else
    {
      shmctl(shminfo1.shmid, IPC_RMID, 0);
    }

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


    if (expand) {
      ximage = XCreateImage(display,visual,dpy_depth,ZPixmap,0,&dummy,
            2*coded_picture_width,2*coded_picture_height,8,0);
      if (!(dithered_image =
            (unsigned char *)malloc(coded_picture_width*coded_picture_height*
            (dpy_depth > 8 ? sizeof (int)*4 : 
             sizeof (unsigned char))*4)))
        error("malloc failed");
    }
    else {
      ximage = XCreateImage(display,visual,dpy_depth,ZPixmap,0,&dummy,
            coded_picture_width,coded_picture_height,8,0);
      if (!(dithered_image =
            (unsigned char *)malloc(coded_picture_width*coded_picture_height*
            (dpy_depth > 8 ? sizeof (int) : 
             sizeof (unsigned char)))))
        error("malloc failed");
    }

#ifdef SH_MEM
  }

  DeInstallXErrorHandler();
#endif


  if (dpy_depth == 32 || dpy_depth == 24 || dpy_depth == 16) {
    XWindowAttributes xwa;

    XGetWindowAttributes(display, window, &xwa);


    wpixel[0] = xwa.visual->red_mask;
    wpixel[1] = xwa.visual->green_mask;
    wpixel[2] = xwa.visual->blue_mask;

    /* If the colors in 16/24/32-bit mode are wrong, try this instead
       of the above three lines */
    /*
    wpixel[2] = xwa.visual->red_mask;
    wpixel[1] = xwa.visual->green_mask;
    wpixel[0] = xwa.visual->blue_mask;
    */

    InitColorDither(dpy_depth == 24 || dpy_depth == 32);
  }
  else {
    ord4x4_dither_init ();
  }
}

void exit_display()
{
#ifdef SH_MEM
  if (shmem_flag)
  {
    XShmDetach(display, &shminfo1);
    XDestroyImage(ximage);
    shmdt(shminfo1.shmaddr);
  }
#endif
}

static void display_image(ximage,dithered_image)
XImage *ximage;
unsigned char *dithered_image;
{
  int t = 1;

 /* Always work in native bit and byte order. This tells Xlib to
    reverse bit and byte order if necessary when crossing a
    network. Frankly, this part of XImages is somewhat
    underdocumented, so this may not be exactly correct.  */

  if (*(char *)&t == 1) {
    ximage->byte_order = LSBFirst;
    ximage->bitmap_bit_order = LSBFirst;
  }
  else {
    ximage->byte_order = MSBFirst;
    ximage->bitmap_bit_order = MSBFirst;
  }    

  /* display dithered image */
#ifdef SH_MEM
  if (shmem_flag)
  {
    XShmPutImage(display, window, gc, ximage, 
                 0, 0, 0, 0, ximage->width, ximage->height, True);
    XFlush(display);
      
    while (1)
    {
      XEvent xev;
        
      XNextEvent(display, &xev);
      if (xev.type == CompletionType)
        break;
    }
  }
  else 
#endif
  {
    ximage->data = (char *) dithered_image; 
    XPutImage(display, window, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
  }
}


void dither(src)
unsigned char *src[];
{
  if (dpy_depth == 24 || dpy_depth == 32) {
    if (ximage->bits_per_pixel == 24)
      ConvertYUVtoRGB(src[0],src[1],src[2], dithered_image,
		      coded_picture_width,
		      coded_picture_height);
    else
      Color32DitherImage(src, dithered_image);
  }  
  else if (dpy_depth == 16) {
    Color16DitherImage(src, dithered_image);
  }
  else {
    ord4x4_dither_frame (src, dithered_image);
  }

  display_image (ximage, dithered_image);
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕 久热精品 视频在线| 麻豆精品在线观看| 天天操天天干天天综合网| 韩日av一区二区| 欧美日韩午夜在线视频| 国产精品美女久久久久aⅴ | 日本一区二区成人| 香蕉久久一区二区不卡无毒影院 | 精品1区2区在线观看| 一区二区久久久久| 成人国产精品免费观看视频| 91精品国产黑色紧身裤美女| 亚洲人成网站精品片在线观看| 极品尤物av久久免费看| 欧美三级三级三级| 亚洲精品欧美激情| 91在线小视频| 国产精品久久久99| 国产在线精品一区二区不卡了| 欧美高清你懂得| 亚洲美女免费在线| 色综合咪咪久久| 亚洲乱码一区二区三区在线观看| 国产一区二区三区免费| 精品国产乱子伦一区| 美女视频黄免费的久久| 制服丝袜av成人在线看| 樱花影视一区二区| 色欧美88888久久久久久影院| 国产精品久线观看视频| 成人av免费在线| 国产日韩欧美在线一区| 成人网页在线观看| 国产精品三级视频| 99久久er热在这里只有精品66| 国产欧美日韩激情| www.在线成人| 亚洲在线中文字幕| 欧美另类一区二区三区| 免费xxxx性欧美18vr| 日韩精品一区二区三区视频| 久久国产精品色婷婷| 久久午夜电影网| 国产精品亚洲一区二区三区妖精 | 国产毛片精品视频| 中文字幕一区二区三区四区| av电影天堂一区二区在线观看| 亚洲视频一区二区免费在线观看 | 一区二区三区精品视频| 一本久久a久久免费精品不卡| 一区二区三区鲁丝不卡| 欧美嫩在线观看| 精一区二区三区| 中文字幕制服丝袜成人av| 色综合 综合色| 亚洲成av人片| 久久久噜噜噜久久中文字幕色伊伊| 国产精品1区二区.| 亚洲猫色日本管| 日韩一卡二卡三卡国产欧美| 久久不见久久见免费视频1| 国产精品动漫网站| 欧美日韩中文一区| 国产精品18久久久久久vr| 亚洲精品视频在线观看免费| 欧美日本韩国一区| 国产91高潮流白浆在线麻豆| 一区二区三区国产| 日韩三级在线免费观看| jvid福利写真一区二区三区| 亚洲.国产.中文慕字在线| 国产无人区一区二区三区| 欧美主播一区二区三区| 国产麻豆午夜三级精品| 亚洲chinese男男1069| 国产精品每日更新在线播放网址| 欧美日韩免费在线视频| 国产成人午夜视频| 日韩在线一区二区三区| 亚洲欧洲另类国产综合| 日韩一级二级三级| 欧洲视频一区二区| 岛国精品在线观看| 精品在线播放免费| 亚洲电影一级片| 亚洲视频一二三区| 欧美国产精品劲爆| 精品国产一区a| 欧美精品日韩一区| 91麻豆精品秘密| 成人一区二区三区中文字幕| 精品影视av免费| 日韩精品一二区| 亚洲一区二区在线免费看| 中文字幕免费在线观看视频一区| 日韩一二三四区| 欧美日韩中文国产| 欧美熟乱第一页| 欧美亚洲综合在线| 色婷婷av一区二区三区gif| 高清成人免费视频| 国产成人精品网址| 国产69精品久久久久777| 久久超碰97中文字幕| 免费在线观看日韩欧美| 天天色天天爱天天射综合| 亚洲一区在线观看视频| 成人欧美一区二区三区视频网页 | 欧美一级日韩免费不卡| 在线精品视频免费播放| 91丨porny丨户外露出| 成人一道本在线| 99久久久无码国产精品| 99久久国产免费看| 91免费观看在线| 一本一道久久a久久精品| 一本在线高清不卡dvd| 91成人免费网站| 欧美色精品在线视频| 欧美日韩一卡二卡三卡 | 99re在线精品| 91香蕉视频黄| 欧美亚洲免费在线一区| 欧美日韩黄色一区二区| 日韩一区二区精品| 久久久精品欧美丰满| 国产精品美女久久福利网站| 亚洲另类在线视频| 日韩综合小视频| 国产综合色产在线精品| 成人国产亚洲欧美成人综合网 | 久久成人免费网| 国产成人日日夜夜| av资源网一区| 欧美日韩亚洲不卡| 精品福利一区二区三区 | 一卡二卡欧美日韩| 美日韩一区二区三区| 国产91精品欧美| 欧美性感一区二区三区| 91精品婷婷国产综合久久性色| 欧美va亚洲va在线观看蝴蝶网| 欧美国产欧美亚州国产日韩mv天天看完整| 国产精品久久国产精麻豆99网站| 亚洲国产视频一区| 国产原创一区二区| 色999日韩国产欧美一区二区| 欧美精品在线观看一区二区| 久久久一区二区三区捆绑**| 有坂深雪av一区二区精品| 美腿丝袜一区二区三区| 99久久综合狠狠综合久久| 在线不卡欧美精品一区二区三区| 精品国产乱码久久久久久1区2区| 国产精品污网站| 青青草原综合久久大伊人精品 | 免费观看在线综合| www.亚洲在线| 日韩免费性生活视频播放| 综合欧美亚洲日本| 精品亚洲国内自在自线福利| 色哟哟国产精品| 久久久一区二区三区捆绑**| 香蕉加勒比综合久久| 99在线精品视频| 精品国产在天天线2019| 亚洲一区av在线| 成人黄色a**站在线观看| 欧美zozozo| 亚洲一区二区综合| 99国产麻豆精品| 国产三级三级三级精品8ⅰ区| 亚洲一二三四区不卡| 不卡视频一二三四| 精品国产伦一区二区三区观看方式| 亚洲影院久久精品| 成人av在线资源| 久久精品日韩一区二区三区| 日韩精品一级二级| 欧美日韩不卡在线| 一区二区三区日韩欧美精品| 粉嫩绯色av一区二区在线观看 | 欧美日韩国产a| 亚洲欧洲中文日韩久久av乱码| 国产福利精品导航| 精品理论电影在线| 日韩国产精品91| 欧美日韩国产不卡| 亚洲成人免费看| 欧美色偷偷大香| 亚洲综合av网| 欧日韩精品视频| 一区二区三区美女视频| 91丝袜国产在线播放| 国产精品久线在线观看| 国产成人在线视频播放| 久久精品一区二区三区四区| 极品少妇xxxx精品少妇| 精品第一国产综合精品aⅴ| 另类综合日韩欧美亚洲|