Beispiel #1
0
int cmd_menu( char * in )
{ // menu = number,x,y,sx,sy,msg
 int             x,y,sx,sy,msg;
 unsigned char   tmp[64];

 CHECKDEFLIST( "menu" );
 CHECKWINLIST( "menu" );

 CHECK( "main" );
 CHECK( "sub" );
 CHECK( "playbar" );
 
 x=cutItemToInt( in,',',0 );
 y=cutItemToInt( in,',',1 );
 sx=cutItemToInt( in,',',2 );
 sy=cutItemToInt( in,',',3 );
 cutItem( in,tmp,',',4 ); msg=appFindMessage( tmp );

 defList->NumberOfMenuItems++;
 defList->MenuItems[ defList->NumberOfMenuItems ].x=x;
 defList->MenuItems[ defList->NumberOfMenuItems ].y=y;
 defList->MenuItems[ defList->NumberOfMenuItems ].width=sx;
 defList->MenuItems[ defList->NumberOfMenuItems ].height=sy;

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] menuitem: %d\n",defList->NumberOfMenuItems );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );

 if ( ( defList->MenuItems[ defList->NumberOfMenuItems ].msg=msg ) == -1 )
  ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,tmp );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  message: %d\n",defList->Items[ defList->NumberOfItems ].msg );

 defList->MenuItems[ defList->NumberOfMenuItems ].Bitmap.Image=NULL;
 return 0;
}
Beispiel #2
0
static void aspect_calc_panscan(struct mp_log *log, struct mp_vo_opts *opts,
                                int w, int h, int d_w, int d_h,
                                int window_w, int window_h, double monitor_par,
                                int *out_w, int *out_h)
{
    mp_dbg(log, "aspect(0) fitin: %dx%d monitor_par: %.2f\n",
           window_w, window_h, monitor_par);
    int fwidth = window_w;
    int fheight = (float)window_w / d_w * d_h / monitor_par;
    mp_dbg(log, "aspect(1) wh: %dx%d (org: %dx%d)\n",
           fwidth, fheight, d_w, d_h);
    if (fheight > window_h || fheight < h) {
        int tmpw = (float)window_h / d_h * d_w * monitor_par;
        if (tmpw <= window_w) {
            fheight = window_h;
            fwidth = tmpw;
        } else if (fheight > window_h) {
            mp_warn(log, "No suitable new aspect found!\n");
        }
    }
    mp_dbg(log, "aspect(2) wh: %dx%d (org: %dx%d)\n",
           fwidth, fheight, d_w, d_h);

    int vo_panscan_area = window_h - fheight;
    double f_w = fwidth / (double)fheight;
    double f_h = 1;
    if (!vo_panscan_area) {
        vo_panscan_area = window_w - fwidth;
        f_w = 1;
        f_h = fheight / (double)fwidth;
    }

    *out_w = fwidth + vo_panscan_area * opts->panscan * f_w;
    *out_h = fheight + vo_panscan_area * opts->panscan * f_h;
}
Beispiel #3
0
static int demux_mpg_read_packet(demuxer_t *demux,int id){
  int d;
  int len;
  int set_pts=0; // !=0 iff pts has been set to a proper value
  unsigned char c=0;
  unsigned long long pts=0;
  unsigned long long dts=0;
  int l;
  int pes_ext2_subid=-1;
  double stream_pts = MP_NOPTS_VALUE;
  demux_stream_t *ds=NULL;
  demux_packet_t* dp;
  mpg_demuxer_t *priv = (mpg_demuxer_t *) demux->priv;

  mp_dbg(MSGT_DEMUX,MSGL_DBG3,"demux_read_packet: %X\n",id);

//  if(id==0x1F0){
//    demux->synced=0; // force resync after 0x1F0
//    return -1;
//}

//  if(id==0x1BA) packet_start_pos=stream_tell(demux->stream);
  if((id<0x1BC || id>=0x1F0) && id != 0x1FD) return -1;
  if(id==0x1BE) return -1; // padding stream
  if(id==0x1BF) return -1; // private2

  len=stream_read_word(demux->stream);
  mp_dbg(MSGT_DEMUX,MSGL_DBG3,"PACKET len=%d",len);
//  if(len==62480){ demux->synced=0;return -1;} /* :) */
  if(len==0 || len>MAX_PS_PACKETSIZE){
    mp_dbg(MSGT_DEMUX,MSGL_DBG2,"Invalid PS packet len: %d\n",len);
    return -2;  // invalid packet !!!!!!
  }

  mpeg_pts_error=0;

  if(id==0x1BC) {
    parse_psm(demux, len);
    return 0;
  }

  while(len>0){   // Skip stuFFing bytes
    c=stream_read_char(demux->stream);
    --len;
    if(c!=0xFF)break;
  }
  if((c>>6)==1){  // Read (skip) STD scale & size value
//    printf("  STD_scale=%d",(c>>5)&1);
    d=((c&0x1F)<<8)|stream_read_char(demux->stream);
    len-=2;
//    printf("  STD_size=%d",d);
    c=stream_read_char(demux->stream);
  }
  // Read System-1 stream timestamps:
  if((c>>4)==2){
    pts=read_mpeg_timestamp(demux->stream,c);
    set_pts=1;
    len-=4;
  } else
  if((c>>4)==3){
Beispiel #4
0
void wsScreenSaverOff(Display *mDisplay)
{
    int interval, prefer_blank, allow_exp, nothing;

#ifdef CONFIG_XDPMS

    if (DPMSQueryExtension(mDisplay, &nothing, &nothing)) {
        BOOL onoff;
        CARD16 state;
        DPMSInfo(mDisplay, &state, &onoff);

        if (onoff) {
            Status stat;
            mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "Disabling DPMS.\n");
            dpms_disabled = 1;
            stat = DPMSDisable(mDisplay); // monitor powersave off
            mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "stat: %d.\n", stat);
        }
    }

#endif
    XGetScreenSaver(mDisplay, &timeout_save, &interval, &prefer_blank, &allow_exp);

    if (timeout_save)
        XSetScreenSaver(mDisplay, 0, interval, prefer_blank, allow_exp);              // turning off screensaver
}
Beispiel #5
0
static void aspect_calc_panscan(struct mp_log *log, struct mp_vo_opts *opts,
                                struct mp_image_params *video,
                                int window_w, int window_h, double monitor_par,
                                int *out_w, int *out_h)
{
    mp_dbg(log, "aspect(0) fitin: %dx%d monitor_par: %.2f\n",
           window_w, window_h, monitor_par);
    int fwidth = window_w;
    int fheight = (float)window_w / video->d_w * video->d_h / monitor_par;
    mp_dbg(log, "aspect(1) wh: %dx%d (org: %dx%d)\n",
           fwidth, fheight, video->d_w, video->d_h);
    if (fheight > window_h || fheight < video->h) {
        int tmpw = (float)window_h / video->d_h * video->d_w * monitor_par;
        if (tmpw <= window_w) {
            fheight = window_h;
            fwidth = tmpw;
        } else if (fheight > window_h) {
            mp_warn(log, "No suitable new aspect found!\n");
        }
    }
    mp_dbg(log, "aspect(2) wh: %dx%d (org: %dx%d)\n",
           fwidth, fheight, video->d_w, video->d_h);

    int vo_panscan_area = window_h - fheight;
    if (!vo_panscan_area)
        vo_panscan_area = window_w - fwidth;

    *out_w = fwidth + vo_panscan_area * opts->panscan * fwidth / fheight;
    *out_h = fheight + vo_panscan_area * opts->panscan;
}
Beispiel #6
0
int cmd_font( char * in )
{ // font=fontname,fontid
 char    name[512];
 char    id[512];
 wItem * item;

 CHECKDEFLIST( "font" );
 CHECKWINLIST( "font" );

 CHECK( "sub" );
 CHECK( "menu" );

 cutItem( in,name,',',0 );
 cutItem( in,id,',',1 );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] font\n" );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  name: %s\n",name );

 (*currSubItem)++;
 item=&currSubItems[ *currSubItem ];

 item->type=itFont;
 item->fontid=fntRead( path,name );
 switch ( item->fontid )
  {
   case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1;
   case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1;
   case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1;
   case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1;
  }
 return 0;
}
Beispiel #7
0
static void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
    unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag,
    unsigned int *map, XA_CHDR *chdr)
{
    sh_video_t *sh = (sh_video_t*)image_p;
    vd_xanim_ctx *priv = sh->context;
    mp_image_t *mpi;
    // note: 3ivX codec doesn't set y_w, uv_w, they are random junk :(
    int ystride=imagex; //(yuv->y_w)?yuv->y_w:imagex;
    int uvstride=imagex/2; //(yuv->uv_w)?yuv->uv_w:(imagex/2);

    mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV221111_Convert(%p  %dx%d %d;%d [%dx%d]  %p %p %d %p %p)\n",
	image_p,imagex,imagey,i_x,i_y, sh->disp_w, sh->disp_h,
	yuv,yuv_tabs,map_flag,map,chdr);

    mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUV: %p %p %p %X (%X) %Xx%X %Xx%X\n",
	yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
	yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);

    // standard YV12 - simply export it!
    mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
    priv->mpi=mpi; if(!mpi) return; // ERROR!
    mpi->planes[0]=yuv->Ybuf;
    mpi->planes[1]=yuv->Ubuf;
    mpi->planes[2]=yuv->Vbuf;
    mpi->width=imagex;
    mpi->stride[0]=ystride; //i_x; // yuv->y_w
    mpi->stride[1]=mpi->stride[2]=uvstride;  //=i_x/4; // yuv->uv_w
}
Beispiel #8
0
static int parse_psm(demuxer_t *demux, int len) {
  unsigned char c, id, type;
  unsigned int plen, prog_len, es_map_len;
  mpg_demuxer_t *priv = (mpg_demuxer_t *) demux->priv;

  mp_dbg(MSGT_DEMUX,MSGL_V, "PARSE_PSM, len=%d\n", len);
  if(! len || len > 1018)
    return 0;

  c = stream_read_char(demux->stream);
  if(! (c & 0x80)) {
    stream_skip(demux->stream, len - 1);  //not yet valid, discard
    return 0;
  }
  stream_skip(demux->stream, 1);
  prog_len = stream_read_word(demux->stream);		//length of program descriptors
  stream_skip(demux->stream, prog_len);			//.. that we ignore
  es_map_len = stream_read_word(demux->stream);		//length of elementary streams map
  es_map_len = FFMIN(es_map_len, len - prog_len - 8);	//sanity check
  while(es_map_len > 0) {
    type = stream_read_char(demux->stream);
    id = stream_read_char(demux->stream);
    if(id >= 0xB0 && id <= 0xEF && priv) {
      int idoffset = id - 0xB0;
      switch(type) {
        case 0x1:
          priv->es_map[idoffset] = VIDEO_MPEG1;
          break;
        case 0x2:
          priv->es_map[idoffset] = VIDEO_MPEG2;
          break;
        case 0x3:
        case 0x4:
          priv->es_map[idoffset] = AUDIO_MP2;
          break;
        case 0x0f:
        case 0x11:
          priv->es_map[idoffset] = AUDIO_AAC;
          break;
        case 0x10:
          priv->es_map[idoffset] = VIDEO_MPEG4;
          break;
        case 0x1b:
          priv->es_map[idoffset] = VIDEO_H264;
          break;
        case 0x81:
          priv->es_map[idoffset] = AUDIO_A52;
          break;
      }
      mp_dbg(MSGT_DEMUX,MSGL_V, "PSM ES, id=0x%x, type=%x, stype: %x\n", id, type, priv->es_map[idoffset]);
    }
    plen = stream_read_word(demux->stream);		//length of elementary stream descriptors
    plen = FFMIN(plen, es_map_len);			//sanity check
    stream_skip(demux->stream, plen);			//skip descriptors for now
    es_map_len -= 4 + plen;
  }
  stream_skip(demux->stream, 4);			//skip crc32
  return 1;
}
Beispiel #9
0
Datei: shmem.c Projekt: kax4/mpv
void* shmem_alloc(int64_t size){
void* p;
static int devzero = -1;
if (size > SIZE_MAX) {
  mp_msg(MSGT_OSDEP, MSGL_FATAL,
         "Shared memory allocation larger than system max. allocation size.\n");
  return NULL;
}
while(1){
  switch(shmem_type){
  case 0:  // ========= MAP_ANON|MAP_SHARED ==========
#ifdef MAP_ANON
    p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_ANON|MAP_SHARED,-1,0);
    if(p==MAP_FAILED) break; // failed
    mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using mmap anon (%p)\n",size,p);
    return p;
#else
// system does not support MAP_ANON at all (e.g. solaris 2.5.1/2.6), just fail
    mp_dbg(MSGT_OSDEP, MSGL_DBG3, "shmem: using mmap anon failed\n");
#endif
    break;
  case 1:  // ========= MAP_SHARED + /dev/zero ==========
    if (devzero == -1 && (devzero = open("/dev/zero", O_RDWR, 0)) == -1) break;
    p=mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,devzero,0);
    if(p==MAP_FAILED) break; // failed
    mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using mmap /dev/zero (%p)\n",size,p);
    return p;
  case 2: { // ========= shmget() ==========
#ifdef HAVE_SHM
    struct shmid_ds shmemds;
    int shmemid;
    if ((shmemid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0600)) == -1) break;
    if ((p = shmat(shmemid, 0, 0)) == (void *)-1){
      mp_msg(MSGT_OSDEP, MSGL_ERR, "shmem: shmat() failed: %s\n", strerror(errno));
      shmctl (shmemid, IPC_RMID, &shmemds);
      break;
    }
    if (shmctl(shmemid, IPC_RMID, &shmemds) == -1) {
      mp_msg(MSGT_OSDEP, MSGL_ERR, "shmem: shmctl() failed: %s\n", strerror(errno));
      if (shmdt(p) == -1) perror ("shmdt()");
      break;
    }
    mp_dbg(MSGT_OSDEP, MSGL_DBG2, "shmem: %"PRId64" bytes allocated using SHM (%p)\n",size,p);
    return p;
#else
    mp_msg(MSGT_OSDEP, MSGL_FATAL, "shmem: no SHM support was compiled in!\n");
    return NULL;
#endif
    }
  default:
    mp_msg(MSGT_OSDEP, MSGL_FATAL,
	"FATAL: Cannot allocate %"PRId64" bytes of shared memory :(\n",size);
    return NULL;
  }
  ++shmem_type;
}
}
Beispiel #10
0
// Runs charset auto-detection on the input buffer, and returns the result.
// If auto-detection fails, NULL is returned.
// If user_cp doesn't refer to any known auto-detection (for example because
// it's a real iconv codepage), user_cp is returned without even looking at
// the buf data.
const char *mp_charset_guess(struct mp_log *log, bstr buf, const char *user_cp,
                             int flags)
{
    if (!mp_charset_requires_guess(user_cp))
        return user_cp;

    // Do our own UTF-8 detection, because at least ENCA seems to get it
    // wrong sometimes (suggested by divVerent).
    int r = bstr_validate_utf8(buf);
    if (r >= 0 || (r > -8 && (flags & MP_ICONV_ALLOW_CUTOFF)))
        return "UTF-8";

    bstr params[3] = {{0}};
    split_colon(user_cp, 3, params);

    bstr type = params[0];
    char lang[100];
    snprintf(lang, sizeof(lang), "%.*s", BSTR_P(params[1]));
    const char *fallback = params[2].start; // last item, already 0-terminated

    const char *res = NULL;

#if HAVE_ENCA
    if (bstrcasecmp0(type, "enca") == 0)
        res = enca_guess(log, buf, lang);
#endif
#if HAVE_LIBGUESS
    if (bstrcasecmp0(type, "guess") == 0)
        res = libguess_guess(log, buf, lang);
#endif
    if (bstrcasecmp0(type, "utf8") == 0 || bstrcasecmp0(type, "utf-8") == 0) {
        if (!fallback)
            fallback = params[1].start; // must be already 0-terminated
    }

    if (res) {
        mp_dbg(log, "%.*s detected charset: '%s'\n",
               BSTR_P(type), res);
    } else {
        res = fallback;
        mp_dbg(log, "Detection with %.*s failed: fallback to %s\n",
               BSTR_P(type), res && res[0] ? res : "broken UTF-8/Latin1");
    }

    if (!res && !(flags & MP_STRICT_UTF8))
        res = "UTF-8-BROKEN";

    return res;
}
Beispiel #11
0
int cmd_end( char * in )
{
 if ( strlen( window_name ) ) { window_name[0]=0; currSection=NULL; currSubItem=NULL; currSubItems=NULL; }
  else defList=NULL;
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] end section\n" );
 return 0;
}
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
    unsigned char *start=NULL;
    int y,len=-1;
    while(len<minlen){
	int len2=0;
	double pts;
	int x=ds_get_packet_pts(sh_audio->ds,&start, &pts);
	if(x<=0) break; // error
	if (pts != MP_NOPTS_VALUE) {
	    sh_audio->pts = pts;
	    sh_audio->pts_bytes = 0;
	}
	y=avcodec_decode_audio(sh_audio->context,(int16_t*)buf,&len2,start,x);
//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
	if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
	if(y<x) sh_audio->ds->buffer_pos+=y-x;  // put back data (HACK!)
	if(len2>0){
	  //len=len2;break;
	  if(len<0) len=len2; else len+=len2;
	  buf+=len2;
	  sh_audio->pts_bytes += len2;
	}
        mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d  \n",y,len2);
    }
  return len;
}
Beispiel #13
0
int conv24to32( txSample * bf )
{
 unsigned char * tmpImage;
 int             i,c;

 if ( bf->BPP == 24 )
  {
   tmpImage=bf->Image;
   bf->ImageSize=bf->Width * bf->Height * 4;
   bf->BPP=32;
   if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL )
    {
     mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" );
     return 1;
    }
   memset( bf->Image,0,bf->ImageSize );
   for ( c=0,i=0;i < (int)(bf->Width * bf->Height * 3); )
    {
     bf->Image[c++]=tmpImage[i++];	//red
     bf->Image[c++]=tmpImage[i++];	//green
     bf->Image[c++]=tmpImage[i++]; c++;	//blue
    }
   free( tmpImage );
  }
 return 0;
}
// This function adds/inserts one file into the gui playlist.
static int import_file_into_gui(char *temp, int insert)
{
    char *filename, *pathname;
    plItem *item;

    filename = strdup(mp_basename(temp));
    pathname = strdup(temp);

    if (strlen(pathname) - strlen(filename) > 0)
        pathname[strlen(pathname) - strlen(filename) - 1] = 0;                                            // we have some path, so remove / at end
    else
        pathname[strlen(pathname) - strlen(filename)] = 0;

    mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[interface] playtree, add: %s/%s\n", pathname, filename);

    item = calloc(1, sizeof(plItem));

    if (!item)
        return 0;

    item->name = filename;
    item->path = pathname;

    if (insert)
        gtkSet(gtkInsertPlItem, 0, (void *)item);            // inserts the item after current, and makes current=item
    else
        gtkSet(gtkAddPlItem, 0, (void *)item);

    return 1;
}
Beispiel #15
0
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
	DMO_AudioDecoder* ds_adec = sh_audio->context;
//	int len=-1;
        int size_in=0;
        int size_out=0;
        int srcsize=DMO_AudioDecoder_GetSrcSize(ds_adec, maxlen);
        mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DMO says: srcsize=%d  (buffsize=%d)  out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
        if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
        if(sh_audio->a_in_buffer_len<srcsize){
          sh_audio->a_in_buffer_len+=
            demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
            srcsize-sh_audio->a_in_buffer_len);
        }
        DMO_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
            buf,maxlen, &size_in,&size_out);
        mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DMO: audio %d -> %d converted  (in_buf_len=%d of %d)  %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds));
        if(size_in>=sh_audio->a_in_buffer_len){
          sh_audio->a_in_buffer_len=0;
        } else {
          sh_audio->a_in_buffer_len-=size_in;
          memmove(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
        }
//        len=size_out;
  return size_out;
}
Beispiel #16
0
int cmd_button( char * in )
{
 unsigned char   fname[512];
 unsigned char   tmp[512];
 int             x,y,sx,sy;
 char            msg[32];

 CHECKDEFLIST( "button" );
 CHECKWINLIST( "button" );

 CHECK( "sub" );
 CHECK( "menu" );  

 cutItem( in,fname,',',0 );
 x=cutItemToInt( in,',',1 );
 y=cutItemToInt( in,',',2 );
 sx=cutItemToInt( in,',',3 );
 sy=cutItemToInt( in,',',4 );
 cutItem( in,msg,',',5 );

 (*currSubItem)++;
 currSubItems[ *currSubItem ].type=itButton;
 currSubItems[ *currSubItem ].x=x;
 currSubItems[ *currSubItem ].y=y;
 currSubItems[ *currSubItem ].width=sx;
 currSubItems[ *currSubItem ].height=sy;
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] button: fname: %s\n",fname );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  x: %d y: %d sx: %d sy: %d\n",x,y,sx,sy );

 if ( ( currSubItems[ *currSubItem ].msg=appFindMessage( msg ) ) == -1 )
   { ERRORMESSAGE( MSGTR_SKIN_BITMAP_UnknownMessage,msg ); return 0; }
 currSubItems[ *currSubItem ].pressed=btnReleased;
 if ( currSubItems[ *currSubItem ].msg == evPauseSwitchToPlay ) currSubItems[ *currSubItem ].pressed=btnDisabled;
 currSubItems[ *currSubItem ].tmp=1;

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  message: %d\n",currSubItems[ *currSubItem ].msg );

 currSubItems[ *currSubItem ].Bitmap.Image=NULL;
 if ( strcmp( fname,"NULL" ) )
  {
   strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); 
   if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) ) return 1;
  }

 return 0;
}
Beispiel #17
0
int cmd_potmeter( char * in )
{ // potmeter=phasebitmaps,phases,default value,x,y,sx,sy,msg
 int             x,y,ph,sx,sy,msg,d;
 unsigned char   tmp[512];
 unsigned char   phfname[512];
 wItem         * item;

 CHECKDEFLIST( "potmeter" );
 CHECKWINLIST( "potmeter" );

 CHECK( "sub" );
 CHECK( "menu" );

 cutItem( in,phfname,',',0 );
 ph=cutItemToInt( in,',',1 );
 d=cutItemToInt( in,',',2 );
 x=cutItemToInt( in,',',3 );
 y=cutItemToInt( in,',',4 );
 sx=cutItemToInt( in,',',5 );
 sy=cutItemToInt( in,',',6 );
 cutItem( in,tmp,',',7 ); msg=appFindMessage( tmp );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] potmeter: phases filename: '%s'\n",phfname );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  position: %d,%d %dx%d\n",x,y,sx,sy );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  phases: %d\n",ph );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  default value: %d\n",d );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  message: %d\n",msg );

 (*currSubItem)++;
 item=&currSubItems[ *currSubItem ];

 item->type=itPotmeter;
 item->x=x; item->y=y;
 item->width=sx; item->height=sy;
 item->phases=ph;
 item->msg=msg;
 item->value=(float)d;

 item->Bitmap.Image=NULL;
 if ( strcmp( phfname,"NULL" ) )
  {
   strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp )); 
   if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
  }
 return 0;
}
Beispiel #18
0
int cmd_section( char * in )
{
 strlower( in );
 defList=NULL;
 if ( !strcmp( in,"movieplayer" ) ) defList=skinAppMPlayer;
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] sectionname: %s\n",in );
 return 0;
}
Beispiel #19
0
static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
{
    unsigned char *start=NULL;
    int y,len=-1;
    while(len<minlen){
	AVPacket pkt;
	int len2=maxlen;
	double pts;
	int x=ds_get_packet_pts(sh_audio->ds,&start, &pts);
	if(x<=0) {
	    start = NULL;
	    x = 0;
	    ds_parse(sh_audio->ds, &start, &x, MP_NOPTS_VALUE, 0);
	    if (x <= 0)
	        break; // error
	} else {
	    int in_size = x;
	    int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0);
	    sh_audio->ds->buffer_pos -= in_size - consumed;
	}

	av_init_packet(&pkt);
	pkt.data = start;
	pkt.size = x;
	if (pts != MP_NOPTS_VALUE) {
	    sh_audio->pts = pts;
	    sh_audio->pts_bytes = 0;
	}
	y=avcodec_decode_audio3(sh_audio->context,(int16_t*)buf,&len2,&pkt);
//printf("return:%d samples_out:%d bitstream_in:%d sample_sum:%d\n", y, len2, x, len); fflush(stdout);
	// LATM may need many packets to find mux info
	if (y == AVERROR(EAGAIN))
	    continue;
	if(y<0){ mp_msg(MSGT_DECAUDIO,MSGL_V,"lavc_audio: error\n");break; }
	if(!sh_audio->parser && y<x)
	    sh_audio->ds->buffer_pos+=y-x;  // put back data (HACK!)
	if(len2>0){
	  if (((AVCodecContext *)sh_audio->context)->channels >= 5) {
            int samplesize = av_get_bytes_per_sample(((AVCodecContext *)
                                    sh_audio->context)->sample_fmt);
            reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_LAVC_DEFAULT,
                                AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
                                ((AVCodecContext *)sh_audio->context)->channels,
                                len2 / samplesize, samplesize);
	  }
	  //len=len2;break;
	  if(len<0) len=len2; else len+=len2;
	  buf+=len2;
	  maxlen -= len2;
	  sh_audio->pts_bytes += len2;
	}
        mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"Decoded %d -> %d  \n",y,len2);

        if (setup_format(sh_audio, sh_audio->context))
            break;
    }
  return len;
}
Beispiel #20
0
int cmd_decoration( char * in )
{
 char    tmp[512];

 CHECKDEFLIST( "decoration" );
 CHECKWINLIST( "decoration" );

 CHECK( "sub" );
 CHECK( "menu" );
 CHECK( "playbar" );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",in );
 strlower( in );
 cutItem( in,tmp,',',0 );
 if ( strcmp( tmp,"enable" )&&strcmp( tmp,"disable" ) ) { ERRORMESSAGE( MSGTR_SKIN_UnknownParameter,tmp ); return 1; }
 if ( strcmp( tmp,"enable" ) ) defList->mainDecoration=0;
  else defList->mainDecoration=1;

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window decoration is %s\n",(defList->mainDecoration?"enabled":"disabled") );
 return 0;
}
Beispiel #21
0
int cmd_dlabel( char * in )
{ // dlabel=x,y,sx,align,fontid,string ...
 char    tmp[512];
 char    sid[63];
 int     x,y,sx,id,a;
 wItem * item;

 CHECKDEFLIST( "dlabel" );
 CHECKWINLIST( "dlabel" );

 CHECK( "sub" );
 CHECK( "menu" );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] dlabel\n" );

 x=cutItemToInt( in,',',0 );
 y=cutItemToInt( in,',',1 );
 sx=cutItemToInt( in,',',2 );
 a=cutItemToInt( in,',',3 );
 cutItem( in,sid,',',4 ); id=fntFindID( sid );
 if ( id < 0 ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NonExistentFontID,sid ); return 1; }
 cutItem( in,tmp,',',5 ); cutItem( tmp,tmp,'"',1 );

 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  pos: %d,%d width: %d align: %d\n",x,y,sx,a );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  id: %s ( %d )\n",sid,id );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  str: '%s'\n",tmp );

 (*currSubItem)++;
 item=&currSubItems[ *currSubItem ];

 item->type=itDLabel;
 item->fontid=id; item->align=a;
 item->x=x; item->y=y;
 item->width=sx; item->height=-1;
 if ( ( item->label=malloc( strlen( tmp ) + 1 ) ) == NULL ) { ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1; }
 strcpy( item->label,tmp );

 return 0;
}
Beispiel #22
0
int cmd_window( char * in )
{
 CHECKDEFLIST( "window" );

 strlcpy( window_name,strlower( in ),sizeof( window_name ) );
 if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; }
  else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub;
   else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; }
    else if ( !strncmp( in,"menu",4 ) ) { currSection=&skinAppMPlayer->menuBase; currSubItem=&skinAppMPlayer->NumberOfMenuItems; currSubItems=skinAppMPlayer->MenuItems; }
     else ERRORMESSAGE( MSGTR_UNKNOWNWINDOWTYPE );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] window: %s\n",window_name );
 return 0;
}
Beispiel #23
0
static unsigned long long read_mpeg_timestamp(stream_t *s,int c){
  unsigned int d,e;
  unsigned long long pts;
  d=stream_read_word(s);
  e=stream_read_word(s);
  if( ((c&1)!=1) || ((d&1)!=1) || ((e&1)!=1) ){
    ++mpeg_pts_error;
    return 0; // invalid pts
  }
  pts=(((uint64_t)((c>>1)&7))<<30)|((d>>1)<<15)|(e>>1);
  mp_dbg(MSGT_DEMUX,MSGL_DBG3," pts {%llu}",pts);
  return pts;
}
Beispiel #24
0
int bpRead( char * fname, txSample * bf )
{
 fname=fExist( fname );
 if ( fname == NULL ) return -2;
 if ( pngRead( fname,bf ) ) 
  {
   mp_dbg( MSGT_GPLAYER,MSGL_FATAL,"[bitmap] unknown file type ( %s )\n",fname );
   return -5;
  }
 if ( bf->BPP < 24 )
  {
   mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] Sorry, only 24 and 32 bpp bitmaps are supported.\n" );
   return -1;
  }
 if ( conv24to32( bf ) ) return -8;
#ifdef WORDS_BIGENDIAN
 swab(bf->Image, bf->Image, bf->ImageSize);
#endif
 bgr2rgb( bf );
 Normalize( bf );
 return 0;
}
Beispiel #25
0
int cmd_selected( char * in )
{
 unsigned char   fname[512];
 unsigned char   tmp[512];

 CHECKDEFLIST( "selected" );
 CHECKWINLIST( "selected" );

 CHECK( "main" );
 CHECK( "sub" );
 CHECK( "playbar" );

 cutItem( in,fname,',',0 );
 defList->menuSelected.type=itBase;
 strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp )); 
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname );
 if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1;
 defList->menuSelected.width=defList->menuSelected.Bitmap.Width;
 defList->menuSelected.height=defList->menuSelected.Bitmap.Height;
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  width: %d height: %d\n",defList->menuSelected.width,defList->menuSelected.height );
 return 0;
}
Beispiel #26
0
int set_rectangle(sh_video_t *sh_video, int param, int value)
{
    vf_instance_t *vf = sh_video->vfilter;
    int data[] = { param, value };

    mp_dbg(MSGT_DECVIDEO, MSGL_V, "set rectangle \n");
    if (vf) {
        int ret = vf->control(vf, VFCTRL_CHANGE_RECTANGLE, data);
        if (ret)
            return 1;
    }
    return 0;
}
Beispiel #27
0
void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag)
{
    mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "YUV2x2_Blk_Func(image_type=%d, blks=%d, dith_flag=%d)\n",
	image_type, blks, dith_flag);
    switch(blks){
    case 1:
	return (void*) XA_2x2_OUT_1BLK_Convert;
    case 4:
	return (void*) XA_2x2_OUT_4BLKS_Convert;
    }

    mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Unimplemented: YUV2x2_Blk_Func(image_type=%d  blks=%d  dith=%d)\n",image_type,blks,dith_flag);
    return (void*) XA_dummy;
}
Beispiel #28
0
// decode a frame
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
    vd_vfw_ctx *priv = sh->context;
    mp_image_t* mpi;
    HRESULT ret;

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

    mpi=mpcodecs_get_image(sh,
	(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ?
	MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH,
	sh->disp_w, sh->disp_h);
    if(!mpi){	// temporary!
	mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
	return NULL;
    }

    // set stride:  (trick discovered by Andreas Ackermann - thanx!)
    sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
    priv->o_bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);

    sh->bih->biSizeImage = len;

#ifdef BUILD_VFWEX
    ret = ICDecompressEx(priv->handle,
#else
    ret = ICDecompress(priv->handle,
#endif
	  ( (sh->ds->flags&1) ? 0 : ICDECOMPRESS_NOTKEYFRAME ) |
	  ( ((flags&3)==2 && !(sh->ds->flags&1))?(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL):0 ),
	   sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]);

    if ((int)ret){
      mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%ld\n",ret);
      return NULL;
    }

    // export palette:
    if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
	if (priv->palette)
	{
	    mpi->planes[1] = priv->palette;
	    mpi->flags |= MP_IMGFLAG_RGB_PALETTE;
	    mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Found and copied palette\n");
	}
	else
	    mpi->planes[1]=NULL;
    }

    return mpi;
}
Beispiel #29
0
int cmd_background( char * in )
{
 CHECKDEFLIST( "background" );
 CHECKWINLIST( "background" );

 CHECK( "menu" );
 CHECK( "main" );
 
 currSection->R=cutItemToInt( in,',',0 );
 currSection->G=cutItemToInt( in,',',1 );
 currSection->B=cutItemToInt( in,',',2 );
 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin]  background color is #%x%x%x.\n",currSection->R,currSection->G,currSection->B );
 
 return 0;
}
Beispiel #30
0
static void XA_YUV_2x2_clr(XA_2x2_Color *cmap2x2, unsigned int Y0, unsigned int Y1,
    unsigned int Y2, unsigned int Y3, unsigned int U, unsigned int V,
    unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
{

  mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV_2x2_clr(%p [%d,%d,%d,%d][%d][%d] %d %p %p)\n",
          cmap2x2,Y0,Y1,Y2,Y3,U,V,map_flag,map,chdr);

  cmap2x2->clr0_0=Y0;
  cmap2x2->clr0_1=Y1;
  cmap2x2->clr0_2=Y2;
  cmap2x2->clr0_3=Y3;
  cmap2x2->clr1_0=U;
  cmap2x2->clr1_1=V;
  return;
}