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

📄 display.cc.openptc

📁 ac3的解码程序
💻 OPENPTC
📖 第 1 页 / 共 3 页
字号:
        fprintf(stderr, "Shared memory error, disabling.\n");      gXErrorFlag = 0;      goto shmemerror;    }    else {      shmctl(shminfo1.shmid, IPC_RMID, 0);      if (!prog_seq)        shmctl(shminfo2.shmid, IPC_RMID, 0);    }    if (!quiet){      fprintf(stderr, "Sharing memory.\n");    }  }  else if (shmem_flag != 2) {shmemerror:    shmem_flag = 0;#endif    ximage = XCreateImage(display,None,bpp,ZPixmap,0,&dummy,                          coded_picture_width,coded_picture_height,8,0);    if (!(dithered_image = new unsigned char[coded_picture_width*                                                   coded_picture_height]))      error("new failed");    if (!prog_seq){      ximage2 = XCreateImage(display,None,bpp,ZPixmap,0,&dummy,                             coded_picture_width,coded_picture_height,8,0);      if (!(dithered_image2 = new unsigned char[coded_picture_width*                                                      coded_picture_height]))        error("new failed");    }#ifdef SH_MEM  }  DeInstallXErrorHandler();#endif#endif  display_lock.unlock();  return 1;}void DisplayX11::exit_display(){#ifdef SH_MEM#ifdef USE_DGA  if (shmem_flag==2)    XF86DGADirectVideo (display, XDefaultScreen (display), 0);#endif  if (shmem_flag==1){    XShmDetach(display, &shminfo1);    shmdt(shminfo1.shmaddr);    if (!prog_seq){      XShmDetach(display, &shminfo2);      XDestroyImage(ximage2);      shmdt(shminfo2.shmaddr);    }  }#else  XDestroyImage(ximage);#endif}#ifdef SOLARIS_SDK_XILvoid DisplayX11::display_image(XilImage ximg, unsigned char *dithered_img){#elsevoid DisplayX11::display_image(XImage *ximg, unsigned char *dithered_img){#endif  DEBUGGER("void DisplayX11::display_image(ximage, unsigned char *dithered_image)");  playedlastframe=1;  // indicate that frame is displayed  if (sync)     sync->wait(1);    // wait for presentation time stamp (PTS), id=1#ifdef SH_MEM                            // display dithered image  if (shmem_flag==2)    return;#endif return;#ifdef SOLARIS_SDK_XIL  xil_import(ximg, TRUE);  if (resized){    // , general and linear are Ok (These is no good for this: bilinear, bicubic)    xil_scale(ximage, resized_image, "general", horizontal_factor, vertical_factor);    // if (bands==1)   // Use XIL for color conversion    xil_copy(resized_image, displayimage);    // else     //   xil_color_convert(resized_image, displayimage);  }  else {    // if (bands==1)   // Use XIL for color conversion    xil_copy(ximg, displayimage);    // else     //   xil_color_convert(ximg, displayimage);  }  // check for geometry changes  if (XCheckWindowEvent(display, window, StructureNotifyMask, &event))  resize();#else#ifdef SH_MEM                            // display dithered image  if (shmem_flag==1){    XShmPutImage(display, window, gc, ximg, 0,0,0,0,ximg->width,ximg->height,True);    XFlush(display);  }  else #endif // SH_MEM  {    ximg->data=(char*) dithered_img;    XPutImage(display, window, gc, ximg, 0, 0, 0, 0, ximg->width, ximg->height);  }#endif // SOLARIS_SDK_XIL}#ifdef SOLARIS_SDK_XILint DisplayX11::dither_image_rgb24(unsigned char* src[], unsigned char* dithered_img){  register int h=0, w=-1;  register unsigned char *Y, *Cb, *Cr;    Y=src[0];  Cb=src[1];  Cr=src[2];  register Xil_unsigned8* data;  data=dithered_img;    //  map data in XIL image    for (h=0; h<coded_picture_height; h++){    for (w=0; w<coded_picture_width; w++){      *data++ = clp[(int)(*Y + 1.371*(*Cr-128))];        *data++ = clp[(int)(*Y - 0.698*(*Cr-128) - 0.336*(*Cr-128))];       *data++ = clp[(int)(*Y++ + 1.732*(*Cb-128))];      if ((w % 4)==0){        Cr++;        Cb++;      }    }  }  return 0;};#endif#ifdef LINUXextern "C" void yuv_2_rgb(void *,void *,void *,int,int,int,int,int,void *,int,int,int,int);int DisplayX11::dither_image_rgb16(unsigned char* src[], unsigned char* dithered_img){  int height,width,display_width;  height=coded_picture_height;  dithered_img = (unsigned char *)con->lock();  if (shmem_flag == 2)    display_width = xwidth;  else    display_width=coded_picture_width;  width=coded_picture_width;  display_width = con->pitch() ;  yuv_2_rgb(src[0],src[1],src[2],width,height,width,width/2,0,dithered_img,0,0,display_width,rgb_mode);  con->unlock();  con->update();  return 0;}#endifvoid DisplayX11::dither_image(unsigned char *src[]){#ifdef SOLARIS_SDK_XIL  dithered_image=getImage1Data();#endif  if (prog_seq){    if (chroma_format!=CHROMA444){#ifdef SOLARIS_SDK_XIL      if (vinfo.c_class==TrueColor && vinfo.depth==24){        dither_image_rgb24(src, dithered_image);        return;      }#endif#ifdef LINUX       if (bpp == 16 ) {        dither_image_rgb16(src, dithered_image);        return;      }#endif      ditherframe(src);    }    else      ditherframe444(src);  }  else {#ifdef SOLARIS_SDK_XIL    dithered_image2=getImage2Data();#endif#ifdef LINUX       if (bpp == 16 ){        dither_image_rgb16(src, dithered_image);        return;      }#endif    if ((pict_struct==FRAME_PICTURE && topfirst) || pict_struct==BOTTOM_FIELD){      /* top field first */      if (chroma_format!=CHROMA444){        dithertop(src,dithered_image);        ditherbot(src,dithered_image2);      }      else {        dithertop444(src,dithered_image);        ditherbot444(src,dithered_image2);      }    }    else {      /* bottom field first */      if (chroma_format!=CHROMA444){        ditherbot(src,dithered_image);        dithertop(src,dithered_image2);      }      else {        ditherbot444(src,dithered_image);        dithertop444(src,dithered_image2);      }    }  }}/* only for 4:2:0 and 4:2:2! */void DisplayX11::ditherframe(unsigned char *src[]){  int i;  register unsigned int uv;  register unsigned char *py,*pu,*pv,*dst;  py = src[0];  pu = src[1];  pv = src[2];  dst = dithered_image;  for (int j=0; j<coded_picture_height; j+=4){    /* line j + 0 */    for (i=0; i<coded_picture_width; i+=8){      uv = uvtab[(*pu++<<8)|*pv++];      *dst++ = ytab[((*py++)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +8)<<4)|(uv>>4)];      uv = uvtab[((*pu++<<8)|*pv++)+1028];      *dst++ = ytab[((*py++ +2)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +10)<<4)|(uv>>4)];      uv = uvtab[(*pu++<<8)|*pv++];      *dst++ = ytab[((*py++)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +8)<<4)|(uv>>4)];      uv = uvtab[((*pu++<<8)|*pv++)+1028];      *dst++ = ytab[((*py++ +2)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +10)<<4)|(uv>>4)];    }    if (chroma_format==CHROMA420){      pu -= chrom_width;      pv -= chrom_width;    }    /* line j + 1 */    for (i=0; i<coded_picture_width; i+=8){      uv = uvtab[((*pu++<<8)|*pv++)+2056];      *dst++ = ytab[((*py++ +12)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +4)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+3084];      *dst++ = ytab[((*py++ +14)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +6)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+2056];      *dst++ = ytab[((*py++ +12)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +4)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+3084];      *dst++ = ytab[((*py++ +14)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +6)<<4)|(uv&15)];    }    /* line j + 2 */    for (i=0; i<coded_picture_width; i+=8){      uv = uvtab[((*pu++<<8)|*pv++)+1542];      *dst++ = ytab[((*py++ +3)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +11)<<4)|(uv>>4)];      uv = uvtab[((*pu++<<8)|*pv++)+514];      *dst++ = ytab[((*py++ +1)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +9)<<4)|(uv>>4)];      uv = uvtab[((*pu++<<8)|*pv++)+1542];      *dst++ = ytab[((*py++ +3)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +11)<<4)|(uv>>4)];      uv = uvtab[((*pu++<<8)|*pv++)+514];      *dst++ = ytab[((*py++ +1)<<4)|(uv&15)];      *dst++ = ytab[((*py++ +9)<<4)|(uv>>4)];    }    if (chroma_format==CHROMA420){      pu -= chrom_width;      pv -= chrom_width;    }    /* line j + 3 */    for (i=0; i<coded_picture_width; i+=8){      uv = uvtab[((*pu++<<8)|*pv++)+3598];      *dst++ = ytab[((*py++ +15)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +7)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+2570];      *dst++ = ytab[((*py++ +13)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +5)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+3598];      *dst++ = ytab[((*py++ +15)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +7)<<4)|(uv&15)];      uv = uvtab[((*pu++<<8)|*pv++)+2570];      *dst++ = ytab[((*py++ +13)<<4)|(uv>>4)];      *dst++ = ytab[((*py++ +5)<<4)|(uv&15)];    }  }}void DisplayX11::dithertop(unsigned char *src[], unsigned char *dst){  int i;  unsigned int y,uv1,uv2;  unsigned char *py,*py2,*pu,*pv,*dst2;  py = src[0];  py2 = src[0] + (coded_picture_width<<1);  pu = src[1];  pv = src[2];  dst2 = dst + coded_picture_width;  for (int j=0; j<coded_picture_height; j+=4){    /* line j + 0, j + 1 */    for (i=0; i<coded_picture_width; i+=4){      y = *py++;      uv2 = (*pu++<<8)|*pv++;      uv1 = uvtab[uv2];      uv2 = uvtab[uv2+2056];      *dst++  = ytab[((y)<<4)|(uv1&15)];      *dst2++ = ytab[((((y + *py2++)>>1)+12)<<4)|(uv2>>4)];      y = *py++;      *dst++  = ytab[((y+8)<<4)|(uv1>>4)];      *dst2++ = ytab[((((y + *py2++)>>1)+4)<<4)|(uv2&15)];      y = *py++;      uv2 = (*pu++<<8)|*pv++;      uv1 = uvtab[uv2+1028];      uv2 = uvtab[uv2+3072];      *dst++  = ytab[((y+2)<<4)|(uv1&15)];      *dst2++ = ytab[((((y + *py2++)>>1)+14)<<4)|(uv2>>4)];      y = *py++;      *dst++  = ytab[((y+10)<<4)|(uv1>>4)];      *dst2++ = ytab[((((y + *py2++)>>1)+6)<<4)|(uv2&15)];    }    py += coded_picture_width;    if (j!=(coded_picture_height-4)) py2 += coded_picture_width;    else                             py2 -= coded_picture_width;    dst += coded_picture_width;    dst2 += coded_picture_width;    if (chroma_format==CHROMA420){      pu -= chrom_width;      pv -= chrom_width;    }    else {      pu += chrom_width;      pv += chrom_width;    }    /* line j + 2, j + 3 */    for (i=0; i<coded_picture_width; i+=4){      y = *py++;

⌨️ 快捷键说明

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