Exemplo n.º 1
0
// init driver
static int init(sh_video_t *sh){
    unsigned int out_fmt;

    /* Hack for VSSH codec: new dll can't decode old files
     * In my samples old files have no extradata, so use that info
     * to decide what dll should be used (here and in vd_vfw).
     */
    if (!strcmp(sh->codec->dll, "vsshdsd.dll") && (sh->bih->biSize == 40))
      return 0;

    if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
        mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
	return 0;
    }
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
    out_fmt=sh->codec->outfmt[sh->outfmtidx];
    switch(out_fmt){
    case IMGFMT_YUY2:
    case IMGFMT_UYVY:
	DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
    case IMGFMT_YV12:
    case IMGFMT_I420:
    case IMGFMT_IYUV:
	DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
    case IMGFMT_YVU9:
        DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
    default:
	DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0);    // RGB/BGR
    }
    DS_SetAttr_DivX("Quality",divx_quality);
    DS_VideoDecoder_StartInternal(sh->context);
    mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DShowInitOK);
    return 1;
}
Exemplo n.º 2
0
// init driver
static int init(sh_video_t *sh){
    unsigned int out_fmt;
    if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
        mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
	return 0;
    }
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
    out_fmt=sh->codec->outfmt[sh->outfmtidx];
    switch(out_fmt){
    case IMGFMT_YUY2:
    case IMGFMT_UYVY:
	DMO_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
    case IMGFMT_YV12:
    case IMGFMT_I420:
    case IMGFMT_IYUV:
	DMO_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
    case IMGFMT_YVU9:
        DMO_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
    default:
	DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0);    // RGB/BGR
    }
    DMO_VideoDecoder_StartInternal(sh->context);
    mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
    return 1;
}
Exemplo n.º 3
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    mp_image_t* mpi;
    static vo_mpegpes_t packet;
    mp_mpeg_header_t picture;
    const unsigned char *d = data;

    if(len>10 && !d[0] && !d[1] && d[2]==1 && d[3]==0xB3) {
        float old_aspect = sh->aspect;
        int oldw = sh->disp_w, oldh = sh->disp_h;
        mp_header_process_sequence_header(&picture, &d[4]);
        sh->aspect = mpeg12_aspect_info(&picture);
        sh->disp_w = picture.display_picture_width;
        sh->disp_h = picture.display_picture_height;
        if(sh->aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
            if(!mpcodecs_config_vo(sh, sh->disp_w,sh->disp_h,IMGFMT_MPEGPES))
                return 0;
        }
    }
    
    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
    packet.data=data;
    packet.size=len;
    packet.timestamp=sh->timer*90000.0;
    packet.id=0x1E0; //+sh_video->ds->id;
    mpi->planes[0]=(uint8_t*)(&packet);
    return mpi;
}
Exemplo n.º 4
0
static int init(sh_video_t *sh)
{
    int err;
    char fname[MAX_PATH + 1] = "";
    memset(&dsn, 0, sizeof(dsn));
#ifdef WIN32_LOADER
    dsn.ldt_fs = Setup_LDT_Keeper();
#endif
    dsn.hLib = LoadLibraryA("dshownative.dll");

    if (!dsn.hLib)
    {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dshownative] Cannot find dshownative.dll: %ld\n", GetLastError());
        return 0;
    }

    dsn.DSOpenVideoCodec = (funcDSOpenVideoCodec) GetProcAddress(dsn.hLib, "DSOpenVideoCodec");
    dsn.DSCloseVideoCodec = (funcDSCloseVideoCodec) GetProcAddress(dsn.hLib, "DSCloseVideoCodec");
    dsn.DSVideoDecode = (funcDSVideoDecode) GetProcAddress(dsn.hLib, "DSVideoDecode");
    dsn.DSVideoResync = (funcDSVideoResync) GetProcAddress(dsn.hLib, "DSVideoResync");
    dsn.DSStrError = (funcDSStrError) GetProcAddress(dsn.hLib, "DSStrError");
    dsn.DSGetApiVersion = (funcDSGetApiVersion) GetProcAddress(dsn.hLib, "DSGetApiVersion");

    if (!(dsn.DSOpenVideoCodec && dsn.DSCloseVideoCodec && dsn.DSVideoDecode && dsn.DSVideoResync && dsn.DSStrError && dsn.DSGetApiVersion))
    {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dshownative] dshownative dll symbol mismatch\n");
        return 0;
    }
    if (dsn.DSGetApiVersion() != DSN_API_VERSION)
    {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dshownative] Incompatible API version\n");
        return 0;
    }

    if (sh->ds->demuxer->filename)
        GetFullPathNameA(sh->ds->demuxer->filename, MAX_PATH, fname, NULL);

    if (!(dsn.codec = dsn.DSOpenVideoCodec(sh->codec->dll, sh->codec->guid, sh->bih,
                                           sh->codec->outfmt[sh->outfmtidx], sh->fps, fname, is_mpegts_format, &err)))
    {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dshownative] Codec init failed: %s\n", dsn.DSStrError(err));
        return 0;
    }

    if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YUY2))
    {
        mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dshownative] mpcodecs_config_vo() failed\n");
        return 0;
    }

	special_codec = 1;
    mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: [dshownative] video codec init OK.\n");
    return 1;
}
Exemplo n.º 5
0
// init driver
static int init(sh_video_t *sh) {
	vd_zrmjpeg_ctx_t *ctx;

	VERBOSE("init called\n");
	ctx = malloc(sizeof(*ctx));
	if (!ctx) return 0;
	memset(ctx, 0, sizeof(*ctx));
	sh->context = ctx;

	/* defer init of vo until the first frame is known */
	return 1;
#if 0
	return mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_ZRMJPEGIT);
#endif
}
Exemplo n.º 6
0
// init driver
static int init(sh_video_t *sh){
    // set format fourcc for raw RGB:
    if(sh->bih && sh->bih->biCompression==0){	// set based on bit depth
	switch(sh->bih->biBitCount){
	case 1:  sh->bih->biCompression=IMGFMT_BGR1; break;
	case 4:  sh->bih->biCompression=IMGFMT_BGR4; break;
	case 8:  sh->bih->biCompression=IMGFMT_BGR8; break;
	case 15: sh->bih->biCompression=IMGFMT_BGR15; break;
	// workaround bitcount==16 => bgr15 case for avi files:
	case 16: sh->bih->biCompression=(sh->format)?IMGFMT_BGR16:IMGFMT_BGR15; break;
	case 24: sh->bih->biCompression=IMGFMT_BGR24; break;
	case 32: sh->bih->biCompression=IMGFMT_BGR32; break;
	default:
	    mp_msg(MSGT_DECVIDEO,MSGL_WARN,"RAW: depth %d not supported\n",sh->bih->biBitCount);
	}
    }
    return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->bih ? sh->bih->biCompression : sh->format);
}
Exemplo n.º 7
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags) {
	mp_image_t* mpi;
	vd_zrmjpeg_ctx_t *ctx = sh->context;

	if (!ctx->vo_initialized) {
		ctx->preferred_csp = guess_mjpeg_type(data, len, sh->disp_h);
		if (ctx->preferred_csp == 0) return NULL;
		mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h,
				ctx->preferred_csp);
		ctx->vo_initialized = 1;
	}

	mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
			sh->disp_w, sh->disp_h);
	/* abuse of mpi */
    	mpi->planes[0]=(uint8_t*)data;
	mpi->planes[1]=(uint8_t*)len;
    	return mpi;
}
Exemplo n.º 8
0
// init driver
static int init(sh_video_t *sh){
    unsigned int out_fmt=sh->codec->outfmt[0];
    struct context *ctx;
    void *decoder;
    if(!(decoder=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
        mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
        mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
	return 0;
    }
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0;
    // mpcodecs_config_vo can change the format
    out_fmt=sh->codec->outfmt[sh->outfmtidx];
    sh->context = ctx = calloc(1, sizeof(*ctx));
    ctx->decoder = decoder;
    switch(out_fmt){
    case IMGFMT_YUY2:
    case IMGFMT_UYVY:
	DMO_VideoDecoder_SetDestFmt(ctx->decoder,16,out_fmt);break; // packed YUV
    case IMGFMT_YV12:
    case IMGFMT_I420:
    case IMGFMT_IYUV:
	DMO_VideoDecoder_SetDestFmt(ctx->decoder,12,out_fmt);break; // planar YUV
    case IMGFMT_YVU9:
        DMO_VideoDecoder_SetDestFmt(ctx->decoder,9,out_fmt);break;
    case IMGFMT_RGB24:
    case IMGFMT_BGR24:
        if (sh->disp_w & 3)
        {
            ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
            ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
        }
    default:
	DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0);    // RGB/BGR
    }
    DMO_VideoDecoder_StartInternal(ctx->decoder);
    mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n");
    return 1;
}
Exemplo n.º 9
0
int MovDecoder_InitSubsystem()
{
  long result = 1;
  ComponentResult cres;
  ComponentDescription desc;
  Component prev=NULL;
  CodecInfo cinfo;	// for ImageCodecGetCodecInfo()
  //ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()

  //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
  qtime_qts = LoadLibraryA("QuickTime.qts");
  if (!qtime_qts)
  {
    //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
    return 0;
  }

  handler = LoadLibraryA("qtmlClient.dll");
  if(!handler)
  {
    //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
    return 0;
  }

  result=InitializeQTML(6+16);
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result);

  memset(&desc,0,sizeof(desc));
  desc.componentType= (((unsigned char)'i')<<24)|(((unsigned char)'m')<<16)|(((unsigned char)'d')<<8)|(((unsigned char)'c'));
  desc.componentSubType = bswap_32(sh->format);
  desc.componentManufacturer=0;
  desc.componentFlags=0;
  desc.componentFlagsMask=0;

 // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc));
  prev=FindNextComponent(NULL,&desc);
  if(!prev)
  {
    //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n");
    return(0);
  }
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev);

  ci=OpenComponent(prev);
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci);

  memset(&icap,0,sizeof(icap));
  cres=ImageCodecInitialize(ci,&icap);
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x  size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize);

  memset(&cinfo,0,sizeof(cinfo));
  cres=ImageCodecGetCodecInfo(ci,&cinfo);
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X  decomp: 0x%X format: 0x%X\n",
  cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags);
  //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], ((unsigned char*)&cinfo.typeName)+1);

  //make a yuy2 gworld
  OutBufferRect.top=0;
  OutBufferRect.left=0;
  OutBufferRect.right=sh->disp_w;
  OutBufferRect.bottom=sh->disp_h;

  //Fill the imagedescription for our SVQ3 frame
  //we can probably get this from Demuxer
  if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
  mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
  framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
  memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
  dump_ImageDescription(*framedescHandle);
  //Find codecscomponent for video decompression
  //    result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor );                 
  //    printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor);

  sh->context = (void *)kYUVSPixelFormat;
  #if 1
  {
    int imgfmt = sh->codec->outfmt[sh->outfmtidx];
    int qt_imgfmt;
    switch(imgfmt)
    {
    case IMGFMT_YUY2:
      qt_imgfmt = kYUVSPixelFormat;
      break;
    case IMGFMT_YVU9:
      qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
      break;
    case IMGFMT_YV12:
      qt_imgfmt = 0x79343230;
      break;
    case IMGFMT_UYVY:
      qt_imgfmt = kUYVY422PixelFormat;
      break;
    case IMGFMT_YVYU:
      qt_imgfmt = kYVYU422PixelFormat;
      imgfmt = IMGFMT_YUY2;
      break;
    case IMGFMT_RGB16:
      qt_imgfmt = k16LE555PixelFormat;
      break;
    case IMGFMT_BGR24:
      qt_imgfmt = k24BGRPixelFormat;
      break;
    case IMGFMT_BGR32:
      qt_imgfmt = k32BGRAPixelFormat;
      break;
    case IMGFMT_RGB32:
      qt_imgfmt = k32RGBAPixelFormat;
      break;
    default:
      mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
      return(0);    
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
    sh->context = (void *)qt_imgfmt;
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
  }
  return 1;
}
Exemplo n.º 10
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    png_structp     png;
    png_infop       info;
    png_infop       endinfo;
//    png_bytep       data;
    png_bytep     * row_p;
    png_uint_32     png_width=0,png_height=0;
    int             depth,color;
    png_uint_32     i;
    mp_image_t* mpi;

    int cols;
    png_colorp pal;
    unsigned char *p;

    if(len<=0) return NULL; // skipped frame
    
 png=png_create_read_struct( PNG_LIBPNG_VER_STRING,NULL,NULL,NULL );
 info=png_create_info_struct( png );
 endinfo=png_create_info_struct( png );

 pngPointer=8;
 pngLength=len;
 png_set_read_fn( png,data,pngReadFN );
 png_set_strip_16( png );
 png_set_sig_bytes( png,8 );
 png_read_info( png,info );
 png_get_IHDR( png,info,&png_width,&png_height,&depth,&color,NULL,NULL,NULL );
 png_set_bgr( png );

 switch( info->color_type ) {
   case PNG_COLOR_TYPE_GRAY_ALPHA:
      mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry gray scaled png with alpha channel not supported at moment.\n" );
      break;
   case PNG_COLOR_TYPE_GRAY:
      out_fmt=IMGFMT_Y800;
      break;
   case PNG_COLOR_TYPE_PALETTE:
      out_fmt=IMGFMT_BGR8;
      break;
   case PNG_COLOR_TYPE_RGB_ALPHA:
      out_fmt=IMGFMT_BGR32;
      break;
   case PNG_COLOR_TYPE_RGB:
      out_fmt=IMGFMT_BGR24;
      break;
   default:
      mp_msg( MSGT_DECVIDEO,MSGL_INFO,"Sorry, unsupported PNG colorspace: %d.\n" ,info->color_type);
 }

 // (re)init libvo if image parameters changed (width/height/colorspace)
 if(last_w!=png_width || last_h!=png_height || last_c!=out_fmt){
    last_w=png_width; last_h=png_height; last_c=out_fmt;
    if(!out_fmt) return NULL;
    if(!mpcodecs_config_vo(sh,png_width,png_height,out_fmt)) return NULL;
 }

#if 0
 switch( info->color_type )
  {
   case PNG_COLOR_TYPE_GRAY_ALPHA: printf( "[png] used GrayA -> stripping alpha channel\n" ); break;
   case PNG_COLOR_TYPE_GRAY:       printf( "[png] used Gray -> rgb\n" ); break;
   case PNG_COLOR_TYPE_PALETTE:    printf( "[png] used palette -> rgb\n" ); break;
   case PNG_COLOR_TYPE_RGB_ALPHA:  printf( "[png] used RGBA -> stripping alpha channel\n" ); break;
   case PNG_COLOR_TYPE_RGB:        printf( "[png] read rgb datas.\n" ); break;
  }
#endif

    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, 
	png_width,png_height);
    if(!mpi) return NULL;

// Let's DECODE!
 row_p=malloc( sizeof( png_bytep ) * png_height );
//png_get_rowbytes( png,info ) 
 for ( i=0; i < png_height; i++ ) row_p[i]=mpi->planes[0] + mpi->stride[0]*i;
 png_read_image( png,row_p );
 free( row_p );

 if (out_fmt==IMGFMT_BGR8) {
     png_get_PLTE( png,info,&pal,&cols );
     mpi->planes[1] = (char*)realloc(mpi->planes[1], 4*cols);
     p = mpi->planes[1];
     for (i = 0; i < cols; i++) {
	 *p++ = pal[i].blue;
	 *p++ = pal[i].green;
	 *p++ = pal[i].red;
	 *p++ = 0;
     }
 }
 
 png_read_end( png,endinfo );
 png_destroy_read_struct( &png,&info,&endinfo );

    return mpi;
}
Exemplo n.º 11
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
 mp_image_t * mpi = NULL;
 int	      width,height,depth,i;

 if ( len <= 0 ) return NULL; // skipped frame

 cinfo.err=jpeg_std_error( &jerr.pub );
 jerr.pub.error_exit=my_error_exit;
 if( setjmp( jerr.setjmp_buffer ) )
  {
   mp_msg( MSGT_DECVIDEO,MSGL_ERR,"[ijpg] setjmp error ...\n" );
   return NULL;
  }
  
 jpeg_create_decompress( &cinfo );
 jpeg_buf_src( &cinfo,data,len );
 jpeg_read_header( &cinfo,TRUE );
 sh->disp_w=width=cinfo.image_width;
 sh->disp_h=height=cinfo.image_height;
 jpeg_start_decompress( &cinfo );
 depth=cinfo.output_components * 8;

 switch( depth ) {
   case 8:
   case 24: break;
   default: mp_msg( MSGT_DECVIDEO,MSGL_ERR,"Sorry, unsupported JPEG colorspace: %d.\n",depth ); return NULL;
 }

 if ( last_w!=width || last_h!=height )
  {
   if(!mpcodecs_config_vo( sh,width,height, IMGFMT_RGB24 )) return NULL;
   if(temp_row) free(temp_row);
   temp_row=malloc(3*width+16);
   last_w=width; last_h=height;
  }

 mpi=mpcodecs_get_image( sh,MP_IMGTYPE_TEMP,MP_IMGFLAG_ACCEPT_STRIDE,width,height );
 if ( !mpi ) return NULL;

 row_stride=cinfo.output_width * cinfo.output_components;

 for ( i=0;i < height;i++ )
  {
   unsigned char * drow = mpi->planes[0] + mpi->stride[0] * i;
   unsigned char * row = (mpi->imgfmt==IMGFMT_RGB24 && depth==24) ? drow : temp_row;
   jpeg_read_scanlines( &cinfo,(JSAMPLE**)&row,1 );
   if(depth==8){
       // grayscale -> rgb/bgr 24/32
       int x;
       if(mpi->bpp==32)
         for(x=0;x<width;x++) drow[4*x]=0x010101*row[x];
       else
         for(x=0;x<width;x++) drow[3*x+0]=drow[3*x+1]=drow[3*x+2]=row[x];
   } else {
       int x;
       switch(mpi->imgfmt){
       // rgb24 -> bgr24
       case IMGFMT_BGR24:
           for(x=0;x<3*width;x+=3){
	       drow[x+0]=row[x+2];
	       drow[x+1]=row[x+1];
	       drow[x+2]=row[x+0];
	   }
	   break;
       // rgb24 -> bgr32
       case IMGFMT_BGR32:
           for(x=0;x<width;x++){
#ifdef WORDS_BIGENDIAN
	       drow[4*x+1]=row[3*x+0];
	       drow[4*x+2]=row[3*x+1];
	       drow[4*x+3]=row[3*x+2];
#else
	       drow[4*x+0]=row[3*x+2];
	       drow[4*x+1]=row[3*x+1];
	       drow[4*x+2]=row[3*x+0];
#endif
	   }
	   break;
       }
   }
  }
  
 jpeg_finish_decompress(&cinfo);                                                                   
 jpeg_destroy_decompress(&cinfo);                                                                  
	    
 return mpi;
}
Exemplo n.º 12
0
// init driver
static int init(sh_video_t *sh)
{
    vd_xanim_ctx *priv;
    char dll[1024];
    XA_CODEC_HDR codec_hdr;
    int i;

    priv = malloc(sizeof(vd_xanim_ctx));
    if (!priv)
	return 0;
    sh->context = priv;
    memset(priv, 0, sizeof(vd_xanim_ctx));

    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12)) return 0;

    priv->iq_func = NULL;
    priv->dec_func = NULL;

    for (i=0; i < XA_CLOSE_FUNCS; i++)
	xa_close_func[i] = NULL;

    snprintf(dll, 1024, "%s/%s", codec_path, sh->codec->dll);
    if (xacodec_load(sh, dll) == 0)
	return 0;

    codec_hdr.xapi_rev = XAVID_API_REV;
    codec_hdr.anim_hdr = malloc(4096);
    codec_hdr.description = sh->codec->info;
    codec_hdr.compression = bswap_32(sh->bih->biCompression);
    codec_hdr.decoder = NULL;
    codec_hdr.x = sh->bih->biWidth; /* ->disp_w */
    codec_hdr.y = sh->bih->biHeight; /* ->disp_h */
    /* extra fields to store palette */
    codec_hdr.avi_ctab_flag = 0;
    codec_hdr.avi_read_ext = NULL;
    codec_hdr.extra = NULL;

    switch(sh->codec->outfmt[sh->outfmtidx])
    {
	case IMGFMT_BGR32:
	    codec_hdr.depth = 32;
	    break;
	case IMGFMT_BGR24:
	    codec_hdr.depth = 24;
	    break;
	case IMGFMT_IYUV:
	case IMGFMT_I420:
	case IMGFMT_YV12:
	    codec_hdr.depth = 12;
	    break;
	case IMGFMT_YVU9:
	    codec_hdr.depth = 9;
	    break;
	default:
	    mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported image out format (%s)\n",
		vo_format_name(sh->codec->outfmt[sh->outfmtidx]));
	    return 0;
    }
    mp_msg(MSGT_DECVIDEO, MSGL_INFO, "xacodec: querying for input %dx%d %dbit [fourcc: %4x] (%s)...\n",
	codec_hdr.x, codec_hdr.y, codec_hdr.depth, codec_hdr.compression, codec_hdr.description);

    if (xacodec_query(sh, &codec_hdr) == 0)
	return 0;

//    free(codec_hdr.anim_hdr);

    priv->decinfo = malloc(sizeof(XA_DEC_INFO));
    if (priv->decinfo == NULL)
    {
	mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
	    strerror(errno));
	return 0;
    }
    priv->decinfo->cmd = 0;
    priv->decinfo->skip_flag = 0;
    priv->decinfo->imagex = priv->decinfo->xe = codec_hdr.x;
    priv->decinfo->imagey = priv->decinfo->ye = codec_hdr.y;
    priv->decinfo->imaged = codec_hdr.depth;
    priv->decinfo->chdr = NULL;
    priv->decinfo->map_flag = 0; /* xaFALSE */
    priv->decinfo->map = NULL;
    priv->decinfo->xs = priv->decinfo->ys = 0;
    priv->decinfo->special = 0;
    priv->decinfo->extra = codec_hdr.extra;
    mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "decinfo->extra, filled by codec: %p [%s]\n",
	&priv->decinfo->extra, (char *)priv->decinfo->extra);

    return 1;
}
Exemplo n.º 13
0
// init driver
static int init(sh_video_t *sh)
{
   sh->context = (void *)init_global_rawdv_decoder();
   return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2);
}
Exemplo n.º 14
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
{
    int r;
    mp_image_t* mpi;
    lzo_context_t *priv = sh->context;
    int w = priv->bufsz;

    if (len <= 0) {
	    return NULL; // skipped frame
    }
    
    r = lzo1x_decode(priv->buffer, &w, data, &len);
    if (r) {
	/* this should NEVER happen */
	mp_msg (MSGT_DECVIDEO, MSGL_ERR, 
		"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
      return NULL;
    }

    if (priv->codec == -1) {
	// detect RGB24 vs. YV12 via decoded size
	mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
	    MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
	    );

	if (w == 0) {
	    priv->codec = IMGFMT_BGR24;
	    mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is BGR24\n", MOD_NAME);
	} else if (w == (sh->bih->biSizeImage)/2) {
	    priv->codec = IMGFMT_YV12;
	    mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is YV12\n", MOD_NAME);
	} else {
	    priv->codec = -1;
	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"[%s] Unsupported out_fmt\n", MOD_NAME);
	    return NULL;
	}

	if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,priv->codec)) {
	    priv->codec = -1;
	    return NULL;
	}
    }

    mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
	sh->disp_w, sh->disp_h);


    if (!mpi) {
	    mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] mpcodecs_get_image failed\n", MOD_NAME);
	    return NULL;
    }

    mpi->planes[0] = priv->buffer;
    if (priv->codec == IMGFMT_BGR24)
        mpi->stride[0] = 3 * sh->disp_w;
    else {
        mpi->stride[0] = sh->disp_w;
        mpi->planes[2] = priv->buffer + sh->disp_w*sh->disp_h;
        mpi->stride[2] = sh->disp_w / 2;
        mpi->planes[1] = priv->buffer + sh->disp_w*sh->disp_h*5/4;
        mpi->stride[1] = sh->disp_w / 2;
    }

    mp_msg (MSGT_DECVIDEO, MSGL_DBG2, 
		"[%s] decompressed %lu bytes into %lu bytes\n", MOD_NAME,
		(long) len, (long)w);

    return mpi;
}
Exemplo n.º 15
0
// init driver
static int init(sh_video_t *sh){
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0;
    return 1;
}
Exemplo n.º 16
0
static mp_image_t* decode(sh_video_t *sh, void* data, int len, int flags)
{
	xvid_dec_frame_t dec;
	xvid_dec_stats_t stats;
	mp_image_t* mpi = NULL;

	priv_t* p = sh->context;


	if(!data || len <= 0)
		return NULL;

	memset(&dec,0,sizeof(xvid_dec_frame_t));
	memset(&stats, 0, sizeof(xvid_dec_stats_t));
	dec.version = XVID_VERSION;
	stats.version = XVID_VERSION;

	dec.bitstream = data;
	dec.length = len;

	dec.general |= XVID_LOWDELAY
	/* XXX: if lowdelay is unset, and xvidcore internal buffers are
	 *      used => crash. MUST FIX */
	        | (filmeffect ? XVID_FILMEFFECT : 0 )
	        | (lumadeblock ? XVID_DEBLOCKY : 0 )
	        | (chromadeblock ? XVID_DEBLOCKUV : 0 );
#if XVID_API >= XVID_MAKE_API(4,1)
	dec.general |= (lumadering ? XVID_DEBLOCKY|XVID_DERINGY : 0 );
	dec.general |= (chromadering ? XVID_DEBLOCKUV|XVID_DERINGUV : 0 );
#endif
	dec.output.csp = p->cs;

	/* Decoding loop because xvidcore may return VOL information for
	 * on the fly buffer resizing. In that case we must decode VOL,
	 * init VO, then decode the frame */
	do {
		int consumed;

		/* If we don't know frame size yet, don't even try to request
		 * a buffer, we must loop until we find a VOL, so VO plugin
		 * is initialized and we can obviously output something */
		if (p->vo_initialized) {
			mpi = mpcodecs_get_image(sh, p->img_type,
					MP_IMGFLAG_ACCEPT_STRIDE,
					sh->disp_w, sh->disp_h);
			if (!mpi) return NULL;

			if(p->cs != XVID_CSP_INTERNAL) {
				dec.output.plane[0] = mpi->planes[0];
				dec.output.plane[1] = mpi->planes[1];
				dec.output.plane[2] = mpi->planes[2];

				dec.output.stride[0] = mpi->stride[0];
				dec.output.stride[1] = mpi->stride[1];
				dec.output.stride[2] = mpi->stride[2];
			}
		}

		/* Decode data */
		consumed = xvid_decore(p->hdl, XVID_DEC_DECODE, &dec, &stats);
		if (consumed < 0) {
			mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Decoding error\n");
			return NULL;
		}

		/* Found a VOL information stats, if VO plugin is not initialized
		 * yet then do it now */
		if (stats.type == XVID_TYPE_VOL && !p->vo_initialized) {
			sh->original_aspect = stats2aspect(&stats);
			if(!mpcodecs_config_vo(sh, stats.data.vol.width, stats.data.vol.height, IMGFMT_YV12))
				return NULL;

			/* Don't take this path twice */
			p->vo_initialized = !p->vo_initialized;
		}

		/* Don't forget to update buffer position and buffer length */
		dec.bitstream += consumed;
		dec.length -= consumed;
	} while ((stats.type == XVID_TYPE_VOL || stats.type == XVID_TYPE_NOTHING) && dec.length > 0);

	/* There are two ways to get out of the decoding loop:
	 *  - a frame has been returned
	 *  - no more data in buffer and no frames returned */

	/* If mpi is NULL, it proves nothing has been returned by the decoder
	 * so don't try to display internal buffers. */
	if (mpi != NULL && p->cs == XVID_CSP_INTERNAL) {
		mpi->planes[0] = dec.output.plane[0];
		mpi->planes[1] = dec.output.plane[1];
		mpi->planes[2] = dec.output.plane[2];

		mpi->stride[0] = dec.output.stride[0];
		mpi->stride[1] = dec.output.stride[1];
		mpi->stride[2] = dec.output.stride[2];
	}

	/* If we got out the decoding loop because the buffer was empty and there was nothing
	 * to output yet, then just return NULL */
	return (stats.type == XVID_TYPE_NOTHING) ? NULL : mpi;
}
Exemplo n.º 17
0
// init driver
static int init(sh_video_t *sh){
    HRESULT ret;
//    unsigned int outfmt=sh->codec->outfmt[sh->outfmtidx];
    int i, o_bih_len;
    vd_vfw_ctx *priv;
    const char *dll = codec_idx2str(sh->codec->dll_idx);

    /* Hack for VSSH codec: new dll can't decode old files
     * In my samples old files have no extradata, so use that info
     * to decide what dll should be used (here and in vd_dshow).
     */
    if (!strcmp(dll, "vssh264.dll") && (sh->bih->biSize > 40))
      return 0;

    priv = malloc(sizeof(vd_vfw_ctx));
    if (!priv)
	return 0;
    memset(priv, 0, sizeof(vd_vfw_ctx));
    sh->context = priv;

    mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n");


//    win32_codec_name = dll;
//    sh->hic = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_FASTDECOMPRESS);
//    priv->handle = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_DECOMPRESS);
    priv->handle = ICOpen( (long)(dll), sh->bih->biCompression, ICMODE_DECOMPRESS);
    if(!priv->handle){
	mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
	return 0;
    }

//    sh->bih->biBitCount=32;

    o_bih_len = ICDecompressGetFormatSize(priv->handle, sh->bih);

    if(o_bih_len < sizeof(BITMAPINFOHEADER)){
       mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormatSize returned a bogus value: %d\n", o_bih_len);
       return 0;
    }

    priv->o_bih = malloc(o_bih_len);
    memset(priv->o_bih, 0, o_bih_len);

    mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormatSize ret: %d\n", o_bih_len);

    ret = ICDecompressGetFormat(priv->handle, sh->bih, priv->o_bih);
    if(ret < 0){
	mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret);
	for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]);
	return 0;
    }
    mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n");

#if 0
    // workaround for pegasus MJPEG:
    if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth;
    if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight;
    if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes;
#endif

    // ok let libvo and vd core to handshake and decide the optimal csp:
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;

    if (!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_FLIP)) {
	priv->o_bih->biHeight=-sh->bih->biHeight; // flip image!
    }

    // ok, let's set the choosen colorspace:
    set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]);

    // fake it to RGB for broken DLLs (divx3)
    if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK)
	priv->o_bih->biCompression = 0;

    // sanity check:
#ifdef BUILD_VFWEX
    ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih);
#else
    ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih);
#endif
    if (ret)
    {
	mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressQuery failed: Error %d\n", (int)ret);
//	return 0;
    } else
	mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressQuery OK\n");

#ifdef BUILD_VFWEX
    ret = ICDecompressBeginEx(priv->handle, sh->bih, priv->o_bih);
#else
    ret = ICDecompressBegin(priv->handle, sh->bih, priv->o_bih);
#endif
    if (ret)
    {
	mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressBegin failed: Error %d\n", (int)ret);
//	return 0;
    }

    // for broken codecs set it again:
    if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK)
	set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]);

    mp_msg(MSGT_WIN32, MSGL_V, "Input format:\n");
    if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(sh->bih,MSGL_V);
    mp_msg(MSGT_WIN32, MSGL_V, "Output format:\n");
    if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(priv->o_bih,MSGL_V);

    // set postprocessing level in xvid/divx4 .dll
    ICSendMessage(priv->handle, ICM_USER+80, (long)(&divx_quality), 0);

    // don't do this palette mess always, it makes div3 dll crashing...
    if(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_BGR8){
	if(ICDecompressGetPalette(priv->handle, sh->bih, priv->o_bih)){
	    priv->palette = (unsigned char*)(priv->o_bih+1);
	    mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetPalette OK\n");
	} else {
	    if(sh->bih->biSize>=40+4*4)
		priv->palette = (unsigned char*)(sh->bih+1);
	}
    }

    mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
    return 1;
}
Exemplo n.º 18
0
/* decode a frame */
static
mp_image_t *decode(sh_video_t *sh, void *raw, int len, int flags)
{
  SGIInfo *info = sh->context;
  unsigned char *data = raw;
  mp_image_t *mpi;

  if (len <= 0) {
    return NULL; /* skip frame */
  }

  read_sgi_header(data, info);

  /* make sure this is an SGI image file */
  if (info->magic != SGI_MAGIC) {
    mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Bad magic number in image.\n");
    return NULL;
  }

  /* check image depth */
  if (info->bytes_per_channel != 1) {
    mp_msg(MSGT_DECVIDEO, MSGL_INFO,
        "Unsupported bytes per channel value %i.\n", info->bytes_per_channel);
    return NULL;
  }

  /* check image dimension */
  if (info->dimension != 2 && info->dimension != 3) {
    mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported image dimension %i.\n",
        info->dimension);
    return NULL;
  }

  /* change rgba images to rgb so alpha channel will be ignored */
  if (info->zsize == SGI_RGBA_IMAGE) {
    info->zsize = SGI_RGB_IMAGE;
  }

  /* check image depth */
  if (info->zsize != SGI_RGB_IMAGE && info->zsize != SGI_GRAYSCALE_IMAGE) {
    mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Unsupported image depth.\n");
    return NULL;
  }

  /* (re)init libvo if image size is changed */
  if (last_x != info->xsize || last_y != info->ysize)
  {
    last_x = info->xsize;
    last_y = info->ysize;

    if (!mpcodecs_config_vo(sh, info->xsize, info->ysize, outfmt)) {
      mp_msg(MSGT_DECVIDEO, MSGL_INFO, "Config vo failed:\n");
      return NULL;
    }
  }

  if (!(mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
          info->xsize, info->ysize))) {
    return NULL;
  }

  if (info->rle) {
    decode_rle_sgi(info, data, mpi);
  } else {
    decode_uncompressed_sgi(info, data, mpi);
  }

  return mpi;
}
Exemplo n.º 19
0
// init driver
static int init(sh_video_t *sh){
#ifndef CONFIG_QUICKTIME
    long result = 1;
#endif
    ComponentResult cres;
    ComponentDescription desc;
    Component prev=NULL;
    CodecInfo cinfo;	// for ImageCodecGetCodecInfo()
    ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()

    codec_initialized = 0;
#ifdef CONFIG_QUICKTIME
    EnterMovies();
#else

#ifdef WIN32_LOADER
    Setup_LDT_Keeper();
#endif

    //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
    qtime_qts = LoadLibraryA("QuickTime.qts");
    if(!qtime_qts){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
    return 0;
    }

    handler = LoadLibraryA("qtmlClient.dll");
    if(!handler){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
    return 0;
    }

    InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
    EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
    FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent");
    CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents");
    GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo");
    OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent");
    ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize");
    ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo");
    ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand");
    ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress");
    ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress");
    GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
    QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
    NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
    //     = GetProcAddress(handler, "");

    if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
	return 0;
    }

    result=InitializeQTML(6+16);
//    result=InitializeQTML(0);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result);
//    result=EnterMovies();
//    printf("EnterMovies->%d\n",result);
#endif /* CONFIG_QUICKTIME */

#if 0
    memset(&desc,0,sizeof(desc));
    while((prev=FindNextComponent(prev,&desc))){
	ComponentDescription desc2;
	unsigned char* c1=&desc2.componentType;
	unsigned char* c2=&desc2.componentSubType;
	memset(&desc2,0,sizeof(desc2));
//	printf("juhee %p (%p)\n",prev,&desc);
	GetComponentInfo(prev,&desc2,NULL,NULL,NULL);
	mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n",
	    c1[3],c1[2],c1[1],c1[0],
	    c2[3],c2[2],c2[1],c2[0],
	    desc2.componentType,desc2.componentSubType,
	    desc2.componentFlags);
    }
#endif


    memset(&desc,0,sizeof(desc));
    desc.componentType= (((unsigned char)'i')<<24)|
			(((unsigned char)'m')<<16)|
			(((unsigned char)'d')<<8)|
			(((unsigned char)'c'));
#if 0
    desc.componentSubType=
		    (((unsigned char)'S'<<24))|
			(((unsigned char)'V')<<16)|
			(((unsigned char)'Q')<<8)|
			(((unsigned char)'3'));
#else
    desc.componentSubType = bswap_32(sh->format);
#endif
    desc.componentManufacturer=0;
    desc.componentFlags=0;
    desc.componentFlagsMask=0;

    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc));
    prev=FindNextComponent(NULL,&desc);
    if(!prev){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n");
	return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev);

    ci=OpenComponent(prev);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci);

    memset(&icap,0,sizeof(icap));
    cres=ImageCodecInitialize(ci,&icap);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x  size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize);

    memset(&cinfo,0,sizeof(cinfo));
    cres=ImageCodecGetCodecInfo(ci,&cinfo);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X  decomp: 0x%X format: 0x%X\n",
	cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0],
	((unsigned char*)&cinfo.typeName)+1);

    //make a yuy2 gworld
    OutBufferRect.top=0;
    OutBufferRect.left=0;
    OutBufferRect.right=sh->disp_w;
    OutBufferRect.bottom=sh->disp_h;

    //Fill the imagedescription for our SVQ3 frame
    //we can probably get this from Demuxer
#if 0
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200);
    printf("framedescHandle=%p  *p=%p\n",framedescHandle,*framedescHandle);
{ FILE* f=fopen("/root/.wine/fake_windows/IDesc","r");
  if(!f) printf("filenot found: IDesc\n");
  fread(*framedescHandle,sizeof(ImageDescription)+200,1,f);
  fclose(f);
}
#else
    if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
    memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
    dump_ImageDescription(*framedescHandle);
#endif
//Find codecscomponent for video decompression
//    result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor );
//    printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor);

    sh->context = (void *)kYUVSPixelFormat;
#if 1
    {
	int imgfmt = sh->codec->outfmt[sh->outfmtidx];
	int qt_imgfmt;
    switch(imgfmt)
    {
	case IMGFMT_YUY2:
	    qt_imgfmt = kYUVSPixelFormat;
	    break;
	case IMGFMT_YVU9:
	    qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
	    break;
	case IMGFMT_YV12:
	    qt_imgfmt = 0x79343230;
	    break;
	case IMGFMT_UYVY:
	    qt_imgfmt = kUYVY422PixelFormat;
	    break;
	case IMGFMT_YVYU:
	    qt_imgfmt = kYVYU422PixelFormat;
	    imgfmt = IMGFMT_YUY2;
	    break;
	case IMGFMT_RGB16:
	    qt_imgfmt = k16LE555PixelFormat;
	    break;
	case IMGFMT_BGR24:
	    qt_imgfmt = k24BGRPixelFormat;
	    break;
	case IMGFMT_BGR32:
	    qt_imgfmt = k32BGRAPixelFormat;
	    break;
	case IMGFMT_RGB32:
	    qt_imgfmt = k32RGBAPixelFormat;
	    break;
	default:
	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
	    return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
    sh->context = (void *)qt_imgfmt;
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
    }
#else
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
#endif

    return 1;
}
Exemplo n.º 20
0
/*
 * init driver
 */
static int init(sh_video_t *sh){
    theora_struct_t *context = NULL;
    int failed = 1;
    int errorCode = 0;
    ogg_packet op;
    int i;

    /* check whether video output format is supported */
    switch(sh->codec->outfmt[sh->outfmtidx])
    {
       case IMGFMT_YV12: /* well, this should work... */ break;
       default: 
	  mp_msg (MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",
		  sh->codec->outfmt[sh->outfmtidx]);
	  return 0;
    }

    /* this is not a loop, just a context, from which we can break on error */
    do
    {
       context = calloc (sizeof (theora_struct_t), 1);
       sh->context = context;
       if (!context)
	  break;

       theora_info_init(&context->inf);
       theora_comment_init(&context->cc);
       
       /* Read all header packets, pass them to theora_decode_header. */
       for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++)
       {
          op.bytes = ds_get_packet (sh->ds, &op.packet);
          op.b_o_s = 1;
          if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) )
          {
            mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
            break;
          }
       }
       if (errorCode)
          break;

       /* now init codec */
       errorCode = theora_decode_init (&context->st, &context->inf);
       if (errorCode)
       {
	  mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode init failed: %i \n",
		 errorCode);
	  break;
       }
       failed = 0;
    } while (0);

    if (failed)
    {
       if (context)
       {
	  free (context);
	  sh->context = NULL;
       }
       return 0;
    }

    if(sh->aspect==0.0 && context->inf.aspect_denominator!=0)
    {
       sh->aspect = (float)(context->inf.aspect_numerator * context->inf.frame_width)/
          (context->inf.aspect_denominator * context->inf.frame_height);
    }
    
    mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n");

    return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12);
}
Exemplo n.º 21
0
// init driver
static int init(sh_video_t *sh){
    OSErr result = 1;
    int extradata_size = sh->bih ? sh->bih->biSize - sizeof(*sh->bih) : 0;
    void *extradata = sh->bih + 1;

    if (!sh->ImageDesc)
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"sh->ImageDesc not set, try -demuxer mov if this fails.\n");

#ifndef CONFIG_QUICKTIME
#ifdef WIN32_LOADER
    Setup_LDT_Keeper();
#endif

    //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
    qtime_qts = LoadLibraryA("QuickTime.qts");
    if(!qtime_qts){
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
        return 0;
    }

    handler = LoadLibraryA("qtmlClient.dll");
    if(!handler){
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
        return 0;
    }

    InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
    EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
    ExitMovies = (void (*)(void))GetProcAddress(handler, "ExitMovies");
    DecompressSequenceBegin = (OSErr (*)(ImageSequence*,ImageDescriptionHandle,CGrafPtr,void *,const Rect *,MatrixRecordPtr,short,RgnHandle,CodecFlags,CodecQ,DecompressorComponent))GetProcAddress(handler, "DecompressSequenceBegin");
    DecompressSequenceFrameS = (OSErr (*)(ImageSequence,Ptr,long,CodecFlags,CodecFlags*,ICMCompletionProcRecordPtr))GetProcAddress(handler, "DecompressSequenceFrameS");
    GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
    QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
    NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
    DisposeHandle = (void (*)(Handle))GetProcAddress(handler, "DisposeHandle");
    DisposeGWorld = (void (*)(GWorldPtr))GetProcAddress(handler, "DisposeGWorld");
    CDSequenceEnd = (OSErr (*)(ImageSequence))GetProcAddress(handler, "CDSequenceEnd");

    if(!InitializeQTML || !EnterMovies || !DecompressSequenceBegin || !DecompressSequenceFrameS){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
	return 0;
    }

    result=InitializeQTML(kInitializeQTMLDisableDirectSound |
                          kInitializeQTMLUseGDIFlag |
                          kInitializeQTMLDisableDDClippers);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %d\n",result);
#endif /* CONFIG_QUICKTIME */

    result=EnterMovies();
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"EnterMovies returned %d\n",result);

    //make a yuy2 gworld
    OutBufferRect.top=0;
    OutBufferRect.left=0;
    OutBufferRect.right=sh->disp_w;
    OutBufferRect.bottom=sh->disp_h;

    //Fill the imagedescription for our SVQ3 frame
    //we can probably get this from Demuxer
    if (!sh->ImageDesc && extradata_size >= sizeof(ImageDescription) &&
        ((ImageDescription *)extradata)->idSize <= extradata_size)
        sh->ImageDesc = extradata;
    if (sh->ImageDesc) {
        mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
        framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
        memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
    } else {
        // assume extradata consists only of the atoms, build the other parts
        ImageDescription *idesc;
        int size = sizeof(*idesc) + extradata_size;
        mp_msg(MSGT_DECVIDEO, MSGL_V, "Generating a ImageDescription\n");
        framedescHandle=(ImageDescriptionHandle)NewHandleClear(size);
        idesc = *framedescHandle;
        memcpy(idesc + 1, extradata, extradata_size);
        idesc->idSize = size;
        idesc->width  = sh->disp_w;
        idesc->height = sh->disp_h;
    }
    dump_ImageDescription(*framedescHandle);

    (**framedescHandle).cType = bswap_32(sh->format);
    sh->context = (void *)kYUVSPixelFormat;
    {
	int imgfmt = sh->codec->outfmt[sh->outfmtidx];
	int qt_imgfmt;
    switch(imgfmt)
    {
	case IMGFMT_YUY2:
	    qt_imgfmt = kYUVSPixelFormat;
	    break;
	case IMGFMT_YVU9:
	    qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
	    break;
	case IMGFMT_YV12:
	    qt_imgfmt = 0x79343230;
	    break;
	case IMGFMT_UYVY:
	    qt_imgfmt = k2vuyPixelFormat;
	    break;
	case IMGFMT_YVYU:
	    qt_imgfmt = kYVYU422PixelFormat;
	    imgfmt = IMGFMT_YUY2;
	    break;
	case IMGFMT_RGB16:
	    qt_imgfmt = k16LE555PixelFormat;
	    break;
	case IMGFMT_BGR24:
	    qt_imgfmt = k24BGRPixelFormat;
	    break;
	case IMGFMT_BGR32:
	    qt_imgfmt = k32BGRAPixelFormat;
	    break;
	case IMGFMT_RGB32:
	    qt_imgfmt = k32RGBAPixelFormat;
	    break;
	default:
	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
	    return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
    sh->context = (void *)qt_imgfmt;
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
    }

    mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
	sh->disp_w, sh->disp_h);
    if(!mpi) return 0;

    result = QTNewGWorldFromPtr(
        &OutBufferGWorld,
	(OSType)sh->context,
        &OutBufferRect,   //we should benchmark if yvu9 is faster for svq3, too
        0,
        0,
        0,
        mpi->planes[0],
        mpi->stride[0]);
    if (result) {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"QTNewGWorldFromPtr result=%d\n",result);
        return 0;
    }

    result = DecompressSequenceBegin(&imageSeq, framedescHandle, (CGrafPtr)OutBufferGWorld,
                                     NULL, NULL, NULL, srcCopy,  NULL, 0,
                                     codecNormalQuality, 0);
    if(result) {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"DecompressSequenceBegin result=%d\n",result);
        return 0;
    }

    return 1;
}
Exemplo n.º 22
0
/*
 * init driver
 */
static int init(sh_video_t *sh){
    theora_struct_t *context = NULL;
    uint8_t *extradata = (uint8_t *)(sh->bih + 1);
    int extradata_size = sh->bih->biSize - sizeof(*sh->bih);
    int errorCode = 0;
    ogg_packet op;
    int i;

    context = calloc (sizeof (theora_struct_t), 1);
    sh->context = context;
    if (!context)
        goto err_out;

    th_info_init(&context->ti);
    th_comment_init(&context->tc);
    context->tsi = NULL;
	

    /* Read all header packets, pass them to theora_decode_header. */
    for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++)
    {
        if (extradata_size > 2) {
            op.bytes  = AV_RB16(extradata);
            op.packet = extradata + 2;
            op.b_o_s  = 1;
            if (extradata_size < op.bytes + 2) {
                mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Theora header too small\n");
                goto err_out;
            }
            extradata      += op.bytes + 2;
            extradata_size -= op.bytes + 2;
        } else {
            op.bytes = ds_get_packet (sh->ds, &op.packet);
            op.b_o_s = 1;
        }

        if ( (errorCode = th_decode_headerin (&context->ti, &context->tc, &context->tsi, &op)) < 0)
        {
            mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
            goto err_out;
        }
    }

    /* now init codec */
    context->tctx = th_decode_alloc (&context->ti, &context->tsi);
    if (!context->tctx)
    {
        mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode init failed\n");
        goto err_out;
    }
    /* free memory used for decoder setup information */
    th_setup_free(context->tsi);		

    if(sh->aspect==0.0 && context->ti.aspect_denominator!=0)
    {
       sh->aspect = ((double)context->ti.aspect_numerator * context->ti.frame_width)/
          ((double)context->ti.aspect_denominator * context->ti.frame_height);
    }

    mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n");
    mp_msg(MSGT_DECVIDEO,MSGL_INFO,"Frame: %dx%d, Picture %dx%d, Offset [%d,%d]\n", context->ti.frame_width, context->ti.frame_height, context->ti.pic_width, context->ti.pic_height, context->ti.pic_x, context->ti.pic_y);

    return mpcodecs_config_vo (sh,context->ti.frame_width,context->ti.frame_height,theora_pixelformat2imgfmt(context->ti.pixel_fmt));

err_out:
    free(context);
    sh->context = NULL;
    return 0;
}
Exemplo n.º 23
0
// init driver
static int init(sh_video_t *sh){
    return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_MPEGPES);
}
Exemplo n.º 24
0
/*************************************************************************
 * init driver
 */
static int init(sh_video_t *sh){
    return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,sh->format);
}