[MPlayer-dev-eng] made a little change in vobsub.c

陆 然 hephooey at hotmail.com
Fri Mar 22 18:01:19 CET 2002


i made a little change in vobsub.c now it can go without .ifo. since i 
don't know how to change the color into palette in vobsub.c, i just get 
some data from a movie and use the data in palette. it's my first 
programing and i don't know how to use cvs and patch. so i just paste the 
source here.

i added a function, i'm a newbie so i just change some code of 
vobsub_parse_one_line, the code must can be smarter.

static int
vobsub_get_from_idx(vobsub_t *vob, FILE *fd)
{
    ssize_t line_size;
    int compl = 0;
    int id =0;
    unsigned int orig_frame_x;
    unsigned int orig_frame_y;
    do {
	int line_reserve = 0;
	char *line = NULL;
	line_size = getline(&line, &line_reserve, fd);
	if (line_size < 0) {
	    if (line)
		free(line);
	    break;
	}
	if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#')
	    continue;
	else if (strncmp("size:", line, 5) == 0){
	    char *xsize;
	    char *ysize;
	    xsize = line+5;
	    ysize = line+10;
	    orig_frame_x = strtol(xsize, NULL, 0);
	    orig_frame_y = strtol(ysize, NULL, 0);
	    
/*cannot convert the color of .idx to palete, so use data
get from a movie, the color can be read from .idx file*/

            vob->palette[0]=2649584;
	    vob->palette[1]=5369946;
	    vob->palette[2]=1081472;
	    vob->palette[3]=15368320;
	    vob->palette[4]=9445941;
	    vob->palette[5]=7003594;
	    vob->palette[6]=13799952;
	    vob->palette[7]=5982610;
	    vob->palette[8]=8093824;
	    vob->palette[9]=13799952;
	    vob->palette[10]=3192429;
	    vob->palette[11]=12877952;
	    vob->palette[12]=1865654;
	    vob->palette[13]=6410191;
	    vob->palette[14]=8958778;
	    vob->palette[15]=3976868;
	    vob->spudec = spudec_new_scaled(vob->palette, orig_frame_x, 
orig_frame_y);
	    fprintf(stderr, "OK");
	    id =1;
	}
	else {
	    if (verbose)
		fprintf(stderr, "vobsub: ignoring %s", line);
	    continue;
	}
	if (id=1)
	    /*fprintf(stderr, "Completed");*/
	break;
    } while (1);
    return;
}

and after open the idx in vob_open, just add a line to call the function. 

hope the code can be helpfut



_________________________________________________________________
享用世界上最大的 Web 电子邮件系统 ―― MSN Hotmail。
http://www.hotmail.com/cn




More information about the MPlayer-dev-eng mailing list