Beispiel #1
0
void libass_override_styles(LibassConfiguration *libass_conf,ASS_Track *track, Palette *palette)
{
    assert(track != NULL);
    int styles_count = track->n_styles;
    int i = 0, j = 0, len = 0;
    char **styles_list = NULL;
    char *setting_value[] = { color2hex(&(palette->foreground)),
                              color2hex(&(palette->foreground)), 
                              color2hex(&(palette->outline)),
                               "1", "4", "0"};
    char *setting_label[] = { "PrimaryColour", 
                              "SecondaryColour", 
                              "OutlineColour", 
                              "BorderStyle", "Outline", "Shadow" };

    printf("Max styles allocated : %i\n",track->max_styles);
    printf("Number styles used : %i\n", track->n_styles);

    styles_list = (char **) calloc(sizeof(char *) * 6, 1);
    

    for (j=0;j<6;j++){
        len = strlen(setting_label[j]) + 1 + strlen(setting_value[j]) + 1;

        styles_list[j] = (char *)calloc(sizeof(char), len);
            
        sprintf(styles_list[j], "%s=%s",setting_label[j], 
                                        setting_value[j]);
    }
    
    ass_set_style_overrides(libass_conf->library,styles_list);
    ass_process_force_style(track);
}
Beispiel #2
0
Datei: ass_mp.c Projekt: kax4/mpv
ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
{
    ASS_Track *track = ass_new_track(library);

    track->track_type = TRACK_TYPE_ASS;
    track->Timer = 100.;
    track->PlayResY = MP_ASS_FONT_PLAYRESY;
    track->WrapStyle = 0;

    if (opts->ass_styles_file && opts->ass_style_override)
        ass_read_styles(track, opts->ass_styles_file, sub_cp);

    if (track->n_styles == 0) {
        track->Kerning = true;
        int sid = ass_alloc_style(track);
        track->default_style = sid;
        ASS_Style *style = track->styles + sid;
        style->Name = strdup("Default");
        style->Alignment = 2;
        mp_ass_set_style(style, opts->sub_text_style);
    }

    if (opts->ass_style_override)
        ass_process_force_style(track);

    return track;
}
Beispiel #3
0
ASS_Track* ass_default_track(ASS_Library* library) {
	ASS_Track* track = ass_new_track(library);

	track->track_type = TRACK_TYPE_ASS;
	track->Timer = 100.;
	track->PlayResY = 360;
	track->WrapStyle = 0;

	if (track->n_styles == 0) {
		// stupid hack to stop libass to add a default track
		// in front in ass_read_styles - this makes it impossible
		// to completely override the "Default" track.
		int sid = ass_alloc_style(track);
		init_style(track->styles + sid, "MPlayerDummy", track->PlayResY);
	}

	if (ass_styles_file)
		ass_read_styles(track, ass_styles_file, sub_cp);


	if (track->default_style <= 0) {
		int sid = ass_alloc_style(track);
		init_style(track->styles + sid, "Default", track->PlayResY);
		track->default_style = sid;
		if(fake_video) {
			track->PlayResX = 480;
			track->PlayResY = 270;
		}
	}

	ass_process_force_style(track);
	return track;
}
Beispiel #4
0
ASS_Track* ass_default_track(ASS_Library* library) {
	ASS_Track* track = ass_new_track(library);

	track->track_type = TRACK_TYPE_ASS;
	track->Timer = 100.;
	track->PlayResY = 288;
	track->WrapStyle = 0;

	if (ass_styles_file)
		ass_read_styles(track, ass_styles_file, sub_cp);

	if (track->n_styles == 0) {
		ASS_Style* style;
		int sid;
		double fs;
		uint32_t c1, c2;

		sid = ass_alloc_style(track);
		style = track->styles + sid;
		style->Name = strdup("Default");
		style->FontName = (font_fontconfig >= 0 && sub_font_name) ? strdup(sub_font_name) : (font_fontconfig >= 0 && font_name) ? strdup(font_name) : strdup("Sans");
		style->treat_fontname_as_pattern = 1;

		fs = track->PlayResY * text_font_scale_factor / 100.;
		// approximate autoscale coefficients
		if (subtitle_autoscale == 2)
			fs *= 1.3;
		else if (subtitle_autoscale == 3)
			fs *= 1.4;
		style->FontSize = fs;

		if (ass_color) c1 = strtoll(ass_color, NULL, 16);
		else c1 = 0xFFFF0000;
		if (ass_border_color) c2 = strtoll(ass_border_color, NULL, 16);
		else c2 = 0x00000000;

		style->PrimaryColour = c1;
		style->SecondaryColour = c1;
		style->OutlineColour = c2;
		style->BackColour = 0x00000000;
		style->BorderStyle = 1;
		style->Alignment = 2;
		style->Outline = 2;
		style->MarginL = 10;
		style->MarginR = 10;
		style->MarginV = 5;
		style->ScaleX = 1.;
		style->ScaleY = 1.;
	}

	ass_process_force_style(track);
	return track;
}
Beispiel #5
0
// Add default styles, if the track does not have any styles yet.
// Apply style overrides if the user provides any.
static void mp_ass_add_default_styles(ASS_Track *track, struct MPOpts *opts)
{
    if (opts->ass_styles_file && opts->ass_style_override)
        ass_read_styles(track, opts->ass_styles_file, NULL);

    if (track->n_styles == 0) {
        if (!track->PlayResY) {
            track->PlayResY = MP_ASS_FONT_PLAYRESY;
            track->PlayResX = track->PlayResY * 4 / 3;
        }
        track->Kerning = true;
        int sid = ass_alloc_style(track);
        track->default_style = sid;
        ASS_Style *style = track->styles + sid;
        style->Name = strdup("Default");
        mp_ass_set_style(style, track->PlayResY, opts->sub_text_style);
    }

    if (opts->ass_style_override)
        ass_process_force_style(track);
}
Beispiel #6
0
ASS_Track *mp_ass_default_track(ASS_Library *library)
{
    ASS_Track *track = ass_new_track(library);

    track->track_type = TRACK_TYPE_ASS;
    track->Timer = 100.;
    track->PlayResY = 288;
    track->WrapStyle = 0;

    if (ass_styles_file)
        ass_read_styles(track, ass_styles_file, sub_cp);

    if (track->n_styles == 0) {
        track->Kerning = true;
        int sid = ass_alloc_style(track);
        ASS_Style *style = track->styles + sid;
        style->Name = strdup("Default");
        style->FontName = (font_fontconfig >= 0
                           && sub_font_name) ? strdup(sub_font_name)
            : (font_fontconfig >= 0
               && font_name) ? strdup(font_name) : strdup("Sans");
        style->treat_fontname_as_pattern = 1;

        double fs = track->PlayResY * text_font_scale_factor / 100.;
        /* The font size is always proportional to video height only;
         * real -subfont-autoscale behavior is not implemented.
         * Apply a correction that corresponds to about 4:3 aspect ratio
         * video to get a size somewhat closer to what non-libass rendering
         * would produce with the same text_font_scale_factor
         * and subtitle_autoscale.
         */
        if (subtitle_autoscale == 2)
            fs *= 1.3;
        else if (subtitle_autoscale == 3)
            fs *= 1.7;

        uint32_t c1 = 0xFFFFFF00;
        uint32_t c2 = 0x00000000;
        if (ass_color)
            c1 = strtoll(ass_color, NULL, 16);
        if (ass_border_color)
            c2 = strtoll(ass_border_color, NULL, 16);

        style->FontSize = fs;
        style->PrimaryColour = c1;
        style->SecondaryColour = c1;
        style->OutlineColour = c2;
        style->BackColour = 0x00000000;
        style->BorderStyle = 1;
        style->Alignment = 2;
        style->Outline = fs / 16;
        style->MarginL = 10;
        style->MarginR = 10;
        style->MarginV = 5;
        style->ScaleX = 1.;
        style->ScaleY = 1.;
    }

    ass_process_force_style(track);
    return track;
}