void Tsubtitles::init(const char *aviFlnm,const char *subFlnm,float Ifps)
{
 done();
 if (aviFlnm[0]!='\0')
  {
   char dsk[256],dir[256],name[256],ext[256];
   _splitpath(aviFlnm,dsk,dir,name,ext);
   char path[256],fname[256];
   _makepath(path,dsk,dir,NULL,NULL);
   _makepath(fname,NULL,NULL,name,ext);
   char *subFlnm=sub_filename(path,fname);
   if (subFlnm)
    {
     __asm emms;
     subs=sub_read_file(subFlnm?subFlnm:aviFlnm,Ifps);
     free(subFlnm);
    } 
  }
 else  
  subs=sub_read_file(subFlnm,Ifps);
 oldsub=NULL;
 current_sub=0;
 nosub_range_start=-1;
 nosub_range_end=-1;
}
void guiLoadSubtitle(char *name)
{
    if (guiInfo.Playing == 0) {
        guiInfo.SubtitleChanged = 1; // what is this for? (mw)
        return;
    }

    if (subdata) {
        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);

        sub_free(subdata);
        subdata = NULL;
        vo_sub  = NULL;

        if (vo_osd_list) {
            int len;
            mp_osd_obj_t *osd;

            osd = vo_osd_list;

            while (osd) {
                if (osd->type == OSDTYPE_SUBTITLE)
                    break;

                osd = osd->next;
            }

            if (osd && (osd->flags & OSDFLAG_VISIBLE)) {
                len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
                memset(osd->bitmap_buffer, 0, len);
                memset(osd->alpha_buffer, 0, len);
            }
        }
    }

    if (name) {
        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);

        subdata = sub_read_file(name, guiInfo.FPS);

        if (!subdata)
            gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name);

        sub_name    = (malloc(2 * sizeof(char *))); // when mplayer will be restarted
        sub_name[0] = strdup(name);                 // sub_name[0] will be read
        sub_name[1] = NULL;
    }

    update_set_of_subtitles();
}
Beispiel #3
0
static void textsub_complete()
  /* called on a </textsub> tag to load and parse the subtitles. */
  {
    int i;
    if (filename == NULL)
      {
        fprintf(stderr, "ERR:  Filename of subtitle file missing");
        exit(1);
      } /*if*/
    textsub_subdata = sub_read_file(filename, movie_fps);
      /* fixme: sub_free never called! */
    if (textsub_subdata == NULL)
      {
        fprintf(stderr, "ERR:  Couldn't load file %s.\n", filename);
        exit(1);
      } /*if*/
    filename = NULL; /* belongs to textsub_subdata now */
    have_textsub = true;
    numspus = textsub_subdata->sub_num;
    spus = realloc(spus, textsub_subdata->sub_num * sizeof(stinfo *));
      /* fixme: need to make sure user doesn't specify both <textsub> and <spu> */
    for (i = 0; i < textsub_subdata->sub_num; ++i)
      {
        subtitle_elt * const thissub = textsub_subdata->subtitles + i;
        stinfo * const newspu = malloc(sizeof(stinfo));
        memset(newspu, 0, sizeof(stinfo));
        if (!textsub_subdata->sub_uses_time)
          {
          /* start and end are in frame numbers */
            newspu->spts = thissub->start * 90000.0 / movie_fps;
            newspu->sd =
                    (thissub->end - thissub->start)
                *
                    90000.0
                /
                    movie_fps;
          }
        else
          {
          /* start and end are in hundredths of a second */
            newspu->spts = thissub->start * 900;
            newspu->sd = (thissub->end - thissub->start) * 900;
          } /*if*/
        newspu->sub_title = thissub;
        spus[i] = newspu;
      } /*for*/
    free(filename);
    filename = NULL;
  } /*textsub_complete*/
Beispiel #4
0
void mplayerLoadSubtitle(const char *name)
{
    if (guiInfo.Playing == GUI_STOP)
        return;

    if (subdata) {
        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_RemovingSubtitle);

        sub_free(subdata);
        subdata = NULL;
        vo_sub  = NULL;

        if (vo_osd_list) {
            int len;
            mp_osd_obj_t *osd;

            osd = vo_osd_list;

            while (osd) {
                if (osd->type == OSDTYPE_SUBTITLE)
                    break;

                osd = osd->next;
            }

            if (osd && (osd->flags & OSDFLAG_VISIBLE)) {
                len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
                memset(osd->bitmap_buffer, 0, len);
                memset(osd->alpha_buffer, 0, len);
            }
        }
    }

    if (name) {
        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_LoadingSubtitle, name);

        subdata = sub_read_file(name, guiInfo.sh_video ? guiInfo.sh_video->fps : 0);

        if (!subdata)
            gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub, name);

        sub_name    = (malloc(2 * sizeof(char *))); // when mplayer will be restarted
        sub_name[0] = strdup(name);                 // sub_name[0] will be read
        sub_name[1] = NULL;
    }

    update_set_of_subtitles();
}
sub_data* SubRead(char *filename, float pts)
{
	return sub_read_file(filename,pts);
}