⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpegvga.patch

📁 MPEG2 PLAYER in linux
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
  /*   *--------------------------------------------------------------****************** 366,429 ****  void InitDisplay(name)  char *name;  {      int ncolors = LUM_RANGE*CB_RANGE*CR_RANGE;-   XColor xcolor;    int i, lum_num, cr_num, cb_num;!   unsigned char r, g, b;!   Colormap dcmap;      if (ditherType == NO_DITHER) return;-   if (noDisplayFlag) return;      MakeWindow(name);  !   gc = XCreateGC(display, window, 0, 0);! !   dcmap = cmap = XDefaultColormap(display, DefaultScreen(display));! !   xcolor.flags = DoRed | DoGreen | DoBlue;  -   if (owncmFlag) goto create_map;-   retry_alloc_colors:    for (i=0; i<ncolors; i++) {        lum_num = (i / (CR_RANGE*CB_RANGE))%LUM_RANGE;      cr_num = (i / CB_RANGE)%CR_RANGE;      cb_num = i % CB_RANGE;        ConvertColor(lum_values[lum_num], cr_values[cr_num], cb_values[cb_num], &r, &g, &b);  !     xcolor.red = r * 256;!     xcolor.green = g * 256;!     xcolor.blue = b * 256;! !     if (XAllocColor(display, cmap, &xcolor) == 0 && cmap == dcmap) {!       int j;!       unsigned long tmp_pixel;!       XWindowAttributes xwa;! !       if (!quietFlag) {!         fprintf(stderr, "Using private colormap.\n");!       }! !       /* Free colors. */!       for(j = 0; j < i; j ++) {!         tmp_pixel = pixel[j];!         XFreeColors(display, cmap, &tmp_pixel, 1, 0);!       }! !       create_map:!       XGetWindowAttributes(display, window, &xwa);!       cmap = XCreateColormap(display, window, xwa.visual, AllocNone);!       XSetWindowColormap(display, window, cmap);! !       goto retry_alloc_colors;      }!     pixel[i] = xcolor.pixel;    }- -   ximage = NULL;  }    --- 301,336 ----  void InitDisplay(name)  char *name;  {+ /* For 256 color modes. */      int ncolors = LUM_RANGE*CB_RANGE*CR_RANGE;    int i, lum_num, cr_num, cb_num;!   int r, g, b;      if (ditherType == NO_DITHER) return;      MakeWindow(name);  !   gl_setpalettecolor(255, 0, 0, 0);	/* black */!   gl_clearscreen(255);      for (i=0; i<ncolors; i++) {        lum_num = (i / (CR_RANGE*CB_RANGE))%LUM_RANGE;      cr_num = (i / CB_RANGE)%CR_RANGE;      cb_num = i % CB_RANGE;  +     r = g = b = 0;      ConvertColor(lum_values[lum_num], cr_values[cr_num], cb_values[cb_num], &r, &g, &b);  !     if (i > 256) {!       printf("mpeg_vga: not enough colors.\n");!       vga_setmode(TEXT);!       exit(-1);      }!     gl_setpalettecolor(i, r >> 2, g >> 2, b >> 2);!     pixel[i] = i;    }  }    ****************** 443,572 ****   *--------------------------------------------------------------   */  ! void InitGrayDisplay(name)! char *name;! {!   int ncolors = 128;!   XColor xcolor;!   int i;!   Colormap dcmap;! !   MakeWindow(name);! !   gc = XCreateGC(display, window, 0, 0);! !   dcmap = cmap = XDefaultColormap(display, DefaultScreen(display));! !   xcolor.flags = DoRed | DoGreen | DoBlue;! !   if (owncmFlag) goto create_map;!   retry_alloc_grays:!   for (i=0; i<ncolors; i++) {! !     xcolor.red = (i*2) * 256;!     xcolor.green = (i*2) * 256;!     xcolor.blue = (i*2) * 256;! !     if(XAllocColor(display, cmap, &xcolor) == 0 && cmap == dcmap) {!       int j;!       unsigned long tmp_pixel;!       XWindowAttributes xwa;! !       if (!quietFlag) {!         fprintf(stderr, "Using private colormap.\n");!       }! !       /* Free colors. */!       for(j = 0; j < i; j ++) {!         tmp_pixel = pixel[j*2];!         XFreeColors(display, cmap, &tmp_pixel, 1, 0);!       }! !       create_map:!       XGetWindowAttributes(display, window, &xwa);!       cmap = XCreateColormap(display, window, xwa.visual, AllocNone);!       XSetWindowColormap(display, window, cmap);! !       goto retry_alloc_grays;!     }!     pixel[(i*2)] = xcolor.pixel;!     pixel[(i*2)+1] = xcolor.pixel;!   }  !   ximage = NULL;! }! ! ! /*!  *--------------------------------------------------------------!  *!  * InitGray256Display --!  *!  *	Initialized display for gray scale dither with 256 levels!  *!  * Results:!  *      None.!  *!  * Side effects:!  *      None.!  *!  *--------------------------------------------------------------!  */! ! ! void InitGray256Display(name)  char *name;  {!   int ncolors = 256;!   XColor xcolor;    int i;-   Colormap dcmap;-   int result;-   XWindowAttributes xwa;      MakeWindow(name);  -   gc = XCreateGC(display, window, 0, 0);- -   dcmap = cmap = XDefaultColormap(display, DefaultScreen(display));- -   xcolor.flags = DoRed | DoGreen | DoBlue;- -   if (owncmFlag) {-     XGetWindowAttributes(display, window, &xwa);-     cmap = XCreateColormap(display, window, xwa.visual, AllocNone);-     XSetWindowColormap(display, window, cmap);-   }- -   retry_alloc_grays:    for (i=0; i<ncolors; i++) {!     xcolor.red = i * 256;!     xcolor.green = i * 256;!     xcolor.blue = i * 256;!     if((result=XAllocColor(display, cmap, &xcolor)) == 0 && cmap == dcmap) {!       int j;!       unsigned long tmp_pixel;! !       if (!quietFlag) {!         fprintf(stderr, "Using private colormap.\n");!       }! !       /* Free colors. */!       for(j = 0; j < i; j ++) {!         tmp_pixel = pixel[j];!         XFreeColors(display, cmap, &tmp_pixel, 1, 0);!       }! !       XGetWindowAttributes(display, window, &xwa);!       cmap = XCreateColormap(display, window, xwa.visual, AllocNone);!       XSetWindowColormap(display, window, cmap);! !       goto retry_alloc_grays;!     }!     pixel[i] = xcolor.pixel;    }- -   ximage = NULL;  }    --- 350,374 ----   *--------------------------------------------------------------   */  ! #define NUM_COLORS 256  ! void InitGrayDisplay(name)  char *name;  {!   int ncolors = NUM_COLORS;    int i;      MakeWindow(name);      for (i=0; i<ncolors; i++) {!     int r, g, b;!     r = i;!     g = i;!     b = i;!     !     gl_setpalettecolor(i, r / 4, g / 4, b / 4);!     pixel[i] = i;    }  }    ****************** 589,608 ****  void InitMonoDisplay(name)  char *name;  {-   XGCValues xgcv;      MakeWindow(name);  -   xgcv.background = BlackPixel(display, DefaultScreen(display));-   xgcv.foreground = WhitePixel(display, DefaultScreen(display));- -   gc = XCreateGC(display, window, GCForeground | GCBackground, &xgcv);- -   ximage = NULL;  }    -   /*   *--------------------------------------------------------------   *--- 391,402 ----****************** 625,632 ****      MakeWindow(name);  -   gc = XCreateGC(display, window, 0, 0);-   ximage = NULL;  }    --- 419,424 ----****************** 650,659 ****  ExecuteDisplay(vid_stream)       VidStream *vid_stream;  {-   char dummy;-   Visual *FindFullColorVisual();-   Visual *fc_visual;-   int depth;    static int rate_deal=-1, one_frame_time;    static struct timeval tftarget, tfnow;    int zero=0;--- 442,447 ----****************** 664,669 ****--- 452,459 ----      fprintf (stderr, "%d\r", totNumFrames);    }  +   if (ditherType == NO_DITHER) return;+     if (partialFlag)      if (!((totNumFrames>=startFrame) &&   	  ((endFrame==-1) || (totNumFrames<=endFrame))))****************** 722,790 ****      while ((foo=getchar())!='\n');    }  -   if (ditherType == NO_DITHER) return;    if (ditherType == PPM_DITHER) {      ExecutePPM(vid_stream);      return;    }  !   if (ximage == NULL) {!     !     if (ditherType == Twox2_DITHER) {!       ximage = XCreateImage(display, None, 8, ZPixmap, 0, &dummy,! 			    vid_stream->mb_width * 32,! 			    vid_stream->mb_height * 32, 8, 0);!     } else if (ditherType == FULL_COLOR_DITHER) {!       fc_visual = FindFullColorVisual(display, &depth);!       ximage = XCreateImage (display, fc_visual, depth, ZPixmap,! 			     0, &dummy, vid_stream->mb_width * 16,! 			     vid_stream->mb_height * 16, 32, 0);!     } else if (ditherType == FULL_COLOR2_DITHER) {!       fc_visual = FindFullColorVisual(display, &depth);!       ximage = XCreateImage (display, fc_visual, depth, ZPixmap,! 			     0, &dummy, vid_stream->mb_width * 32,! 			     vid_stream->mb_height * 32, 32, 0);!     } else if (ditherType == MONO_DITHER || ditherType == MONO_THRESHOLD) {!       ximage = XCreateImage (display, None, 1, XYBitmap, 0, &dummy,! 			     vid_stream->mb_width * 16,! 			     vid_stream->mb_height * 16, 8, 0);!       ximage->byte_order = MSBFirst;!       ximage->bitmap_bit_order = MSBFirst;!     } else {!       ximage = XCreateImage(display, None, 8, ZPixmap, 0, &dummy,! 			    vid_stream->mb_width * 16,! 			    vid_stream->mb_height * 16, 8, 0);!     }!   }!   !   if (!noDisplayFlag) {! #ifdef SH_MEM!     if (shmemFlag) {!       XShmPutImage(display, window, gc, vid_stream->current->ximage, ! 		   0, 0, 0, 0,! 		   vid_stream->current->ximage->width, ! 		   vid_stream->current->ximage->height, True);!       XFlush(display);!       !       while(1) {! 	XEvent xev;! 	! 	XNextEvent(display, &xev);! 	if(xev.type == CompletionType)! 	  break;!       }!     }!     else ! #endif!               {! 	ximage->data = (char *) vid_stream->current->display;   	! 	XPutImage(display, window, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);        }-   }  }-     extern char *inputName;  extern char *strrchr();--- 512,623 ----      while ((foo=getchar())!='\n');    }      if (ditherType == PPM_DITHER) {      ExecutePPM(vid_stream);      return;    }  !   if (!noDisplayFlag)        {! 	void *data = (char *) vid_stream->current->display;   	! 	if (ditherType == Twox2_DITHER) {! 	  /* Twice the size; 256-color mode */! 	  gl_putbox(0, 0, vid_stream->h_size * 2,! 	    vid_stream->v_size * 2, data);! 	} else if (ditherType == FULL_COLOR_DITHER && BYTESPERPIXEL == 3) {! 	  /* Tricky conversion. */! 	  /* The data is padded to 32 bits per pixel, we need 24 bits. */! 	  int i, w;! 	  unsigned int *datap;! 	  void *box;! 	  unsigned char *boxp;! 	  datap = data;! 	  w = vid_stream->h_size;! 	  box = alloca(vid_stream->v_size * w * 3 + 3);! 	  boxp = box;! 	  for (i = 0; i < vid_stream->v_size; i++) {! 	    int j = 0;! 	    /* First byte is blue. */! 	    /* Nasty overlapping memory writes, but it is fast. */! 	    /* Note that boxp points to bytes, datap to words. */!             while (j + 7 < w) {!          	*(unsigned *)boxp = *datap;!             	*(unsigned *)(boxp + 3) = *(datap + 1);!             	*(unsigned *)(boxp + 6) = *(datap + 2);!             	*(unsigned *)(boxp + 9) = *(datap + 3);!             	*(unsigned *)(boxp + 12) = *(datap + 4);!             	*(unsigned *)(boxp + 15) = *(datap + 5);!             	*(unsigned *)(boxp + 18) = *(datap + 6);!             	*(unsigned *)(boxp + 21) = *(datap + 7);!             	j += 8;!             	boxp += 24;!             	datap += 8;!             }!             while (j < w) {!               *(unsigned *)boxp = *datap;!               j++;!               boxp += 3;!               datap++;!             }! 	  }! 	  gl_putbox(0, 0, vid_stream->h_size, vid_stream->v_size, box);! 	} else if (ditherType == FULL_COLOR_DITHER && BYTESPERPIXEL == 2) {! 	  /* The data is 8-8-8 truecolor padded to 32 bits, we need */! 	  /* 15-bit 5-5-5 truecolor. Pretty slow conversion. */! 	  int i, w;! 	  unsigned int *datap;! 	  void *box;! 	  unsigned char *boxp;! 	  datap = data;! 	  w = vid_stream->h_size;! 	  box = alloca(vid_stream->v_size * w * 2 + 3);! 	  boxp = box;! 	  for (i = 0; i < vid_stream->v_size; i++) {! 	    int j = 0;! 	    /* First byte is blue. */! 	    /* Note that boxp points to bytes, datap to words. */!             while (j + 1 < w) {!             	unsigned r, g, b;!         	b = *((unsigned char *)datap);!         	g = *((unsigned char *)datap + 1);!         	r = *((unsigned char *)datap + 2);!             	*(unsigned short *)boxp =!             		((r & 0xf8) << 7) + ((g & 0xf8) << 2) + (b >> 3);!         	b = *((unsigned char *)datap + 4);!         	g = *((unsigned char *)datap + 5);!         	r = *((unsigned char *)datap + 6);!             	*(unsigned short *)(boxp + 2) =!             		((r & 0xf8) << 7) + ((g & 0xf8) << 2) + (b >> 3);!             	j += 2;!             	boxp += 4;!             	datap += 2;!             }!             while (j < w) {!             	unsigned r, g, b;!         	r = *((unsigned char *)datap);!         	g = *((unsigned char *)datap + 1);!         	g = *((unsigned char *)datap + 2);!             	*(unsigned short *)boxp =!             		((r & 0xf8) << 7) + ((g & 0xf8) << 2) + (b >> 3);!             	j++;!             	boxp += 2;!             	datap++;!             }! 	  }! 	  gl_putbox(0, 0, vid_stream->h_size, vid_stream->v_size, box);!         } else if (ditherType == MONO_DITHER || ditherType == MONO_THRESHOLD) {!           /* It's MSBFirst, which is what we need. */!           int i;!           for (i = 0; i < vid_stream->v_size; i++)!             vga_drawscansegment(data + i * vid_stream->h_size / 8,!               0, i, vid_stream->h_size / 8);!         } else {!           /* default 256-color dithering */! 	  gl_putbox(0, 0, vid_stream->h_size, vid_stream->v_size, data);! 	}        }  }    extern char *inputName;  extern char *strrchr();*** main.c	Sun Jan 29 22:17:25 1995--- mpegvga/main.c	Sun Jan 29 22:48:49 1995****************** 128,133 ****--- 128,134 ----    }    if (curVidStream != NULL)      DestroyVidStream(curVidStream);+   restoretextmode();    exit(1);  }  #else****************** 140,145 ****--- 141,147 ----    }    if (curVidStream != NULL)      DestroyVidStream(curVidStream);+   restoretextmode();    exit(1);  }  #endif****************** 307,324 ****        exit(1);  #endif      }-     else if (strcmp(argv[mark], "-shmem_off") == 0) {-       argc--; mark++;-       shmemFlag = 0;-     }      else if (strcmp(argv[mark], "-quiet") == 0) {        argc--; mark++;        quietFlag = 1;      }-     else if (strcmp(argv[mark], "-owncm") == 0) {-       argc--; mark++;-       owncmFlag = 1;-     }      else if (strcmp(argv[mark], "-step") == 0) {        argc--; mark++;        requireKeypressFlag = 1;--- 309,318 ----****************** 432,442 ****      break;      case GRAY_DITHER:-     InitGrayDisplay(name);-     break;-     case GRAY256_DITHER:!     InitGray256Display(name);      break;      case FULL_COLOR_DITHER:--- 426,433 ----      break;      case GRAY_DITHER:    case GRAY256_DITHER:!     InitGrayDisplay(name);      break;      case FULL_COLOR_DITHER:****************** 483,500 ****      }  - #ifdef SH_MEM-     if (shmemFlag && (display != NULL)) {-       if (!XShmQueryExtension(display)) {- 	shmemFlag = 0;- 	if (!quietFlag) {- 	  fprintf(stderr, "Shared memory not supported\n");- 	  fprintf(stderr, "Reverting to normal Xlib.\n");- 	}-       }-     }- #endif-     if (setjmp(env) != 0) {        DestroyVidStream(theStream);--- 474,479 ----****************** 568,575 ****      fprintf(stderr, "      [-framerate num]\n");      fprintf(stderr, "      [-no_display]\n");      fprintf(stderr, "      [-quiet]\n");-     fprintf(stderr, "      [-owncm]\n");-     fprintf(stderr, "      [-shmem_off]\n");  	fprintf(stderr, "      [-l_range num]\n");  	fprintf(stderr, "      [-cr_range num]\n");  	fprintf(stderr, "      [-cb_range num]\n");--- 547,552 ----

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -