~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to libass/ass_parse.c

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        return 0;
48
48
}
49
49
 
50
 
static void change_font_size(ASS_Renderer *render_priv, double sz)
 
50
double ensure_font_size(ASS_Renderer *priv, double size)
51
51
{
52
 
    double size = sz * render_priv->font_scale;
53
 
 
54
52
    if (size < 1)
55
53
        size = 1;
56
 
    else if (size > render_priv->height * 2)
57
 
        size = render_priv->height * 2;
58
 
 
59
 
    ass_font_set_size(render_priv->state.font, size);
60
 
 
 
54
    else if (size > priv->height * 2)
 
55
        size = priv->height * 2;
 
56
 
 
57
    return size;
 
58
}
 
59
 
 
60
static void change_font_size(ASS_Renderer *render_priv, double sz)
 
61
{
61
62
    render_priv->state.font_size = sz;
62
63
}
63
64
 
189
190
{
190
191
    unsigned a;
191
192
    double cf;
192
 
    if (now <= t1) {
 
193
 
 
194
    if (now < t1) {
193
195
        a = a1;
194
196
    } else if (now >= t4) {
195
197
        a = a3;
196
 
    } else if (now < t2) {      // and > t1
 
198
    } else if (now < t2 && t2 > t1) {
197
199
        cf = ((double) (now - t1)) / (t2 - t1);
198
200
        a = a1 * (1 - cf) + a2 * cf;
199
 
    } else if (now > t3) {
 
201
    } else if (now >= t3 && t4 > t3) {
200
202
        cf = ((double) (now - t3)) / (t4 - t3);
201
203
        a = a2 * (1 - cf) + a3 * cf;
202
 
    } else {                    // t2 <= now <= t3
 
204
    } else {                    // t2 <= now < t3
203
205
        a = a2;
204
206
    }
205
207
 
216
218
    int res = 0;
217
219
    ASS_Drawing *drawing = render_priv->state.clip_drawing;
218
220
 
219
 
    if (drawing && drawing->glyph)
220
 
        FT_Done_Glyph((FT_Glyph) drawing->glyph);
221
221
    ass_drawing_free(drawing);
222
 
    render_priv->state.clip_drawing = ass_drawing_new(
223
 
        render_priv->fontconfig_priv,
224
 
        render_priv->state.font,
225
 
        render_priv->ftlibrary);
 
222
    render_priv->state.clip_drawing =
 
223
        ass_drawing_new(render_priv->library, render_priv->ftlibrary);
226
224
    drawing = render_priv->state.clip_drawing;
227
225
    skipopt('(');
228
226
    res = mystrtoi(&p, &scale);
259
257
        else
260
258
            val = -1.;
261
259
        change_border(render_priv, val, render_priv->state.border_y);
 
260
        render_priv->state.bm_run_id++;
262
261
    } else if (mystrcmp(&p, "ybord")) {
263
262
        double val;
264
263
        if (mystrtod(&p, &val))
273
272
        else
274
273
            val = 0.;
275
274
        render_priv->state.shadow_x = val;
 
275
        render_priv->state.bm_run_id++;
276
276
    } else if (mystrcmp(&p, "yshad")) {
277
277
        double val;
278
278
        if (mystrtod(&p, &val))
280
280
        else
281
281
            val = 0.;
282
282
        render_priv->state.shadow_y = val;
 
283
        render_priv->state.bm_run_id++;
283
284
    } else if (mystrcmp(&p, "fax")) {
284
285
        double val;
285
286
        if (mystrtod(&p, &val))
331
332
            render_priv->state.blur = val;
332
333
        } else
333
334
            render_priv->state.blur = 0.0;
 
335
        render_priv->state.bm_run_id++;
334
336
        // ASS standard tags
335
337
    } else if (mystrcmp(&p, "fsc")) {
336
338
        char tp = *p++;
359
361
                render_priv->state.hspacing * (1 - pwr) + val * pwr;
360
362
        else
361
363
            render_priv->state.hspacing = render_priv->state.style->Spacing;
 
364
    } else if (mystrcmp(&p, "fs+")) {
 
365
        double val;
 
366
        if (mystrtod(&p, &val)) {
 
367
            val = render_priv->state.font_size + pwr * val;
 
368
        } else
 
369
            val = render_priv->state.style->FontSize;
 
370
        if (render_priv->state.font)
 
371
            change_font_size(render_priv, val);
 
372
    } else if (mystrcmp(&p, "fs-")) {
 
373
        double val;
 
374
        if (mystrtod(&p, &val))
 
375
            val = render_priv->state.font_size - pwr * val;
 
376
        else
 
377
            val = render_priv->state.style->FontSize;
 
378
        if (render_priv->state.font)
 
379
            change_font_size(render_priv, val);
362
380
    } else if (mystrcmp(&p, "fs")) {
363
381
        double val;
364
382
        if (mystrtod(&p, &val))
375
393
        } else
376
394
            val = -1.;          // reset to default
377
395
        change_border(render_priv, val, val);
 
396
        render_priv->state.bm_run_id++;
378
397
    } else if (mystrcmp(&p, "move")) {
379
398
        double x1, x2, y1, y2;
380
399
        long long t1, t2, delta_t, t;
476
495
            change_alpha(&render_priv->state.c[3],
477
496
                         render_priv->state.style->BackColour, pwr);
478
497
        }
 
498
        render_priv->state.bm_run_id++;
479
499
        // FIXME: simplify
480
500
    } else if (mystrcmp(&p, "an")) {
481
501
        int val;
487
507
            val = ((val - 1) % 3) + 1;  // horizontal alignment
488
508
            val += v * 4;
489
509
            ass_msg(render_priv->library, MSGL_DBG2, "align %d", val);
490
 
            render_priv->state.alignment = val;
 
510
            if ((render_priv->state.parsed_tags & PARSED_A) == 0) {
 
511
                render_priv->state.alignment = val;
 
512
                render_priv->state.parsed_tags |= PARSED_A;
 
513
            }
491
514
        } else
492
515
            render_priv->state.alignment =
493
516
                render_priv->state.style->Alignment;
494
517
    } else if (mystrcmp(&p, "a")) {
495
518
        int val;
496
 
        if (mystrtoi(&p, &val) && val)
497
 
            // take care of a vsfilter quirk: handle illegal \a8 like \a5
498
 
            render_priv->state.alignment = (val == 8) ? 5 : val;
499
 
        else
 
519
        if (mystrtoi(&p, &val) && val) {
 
520
            if ((render_priv->state.parsed_tags & PARSED_A) == 0) {
 
521
                // take care of a vsfilter quirk: handle illegal \a8 like \a5
 
522
                render_priv->state.alignment = (val == 8) ? 5 : val;
 
523
                render_priv->state.parsed_tags |= PARSED_A;
 
524
            }
 
525
        } else
500
526
            render_priv->state.alignment =
501
527
                render_priv->state.style->Alignment;
502
528
    } else if (mystrcmp(&p, "pos")) {
550
576
            mystrtoll(&p, &t4);
551
577
        }
552
578
        skip(')');
553
 
        render_priv->state.fade =
554
 
            interpolate_alpha(render_priv->time -
555
 
                              render_priv->state.event->Start, t1, t2,
556
 
                              t3, t4, a1, a2, a3);
 
579
        if ((render_priv->state.parsed_tags & PARSED_FADE) == 0) {
 
580
            render_priv->state.fade =
 
581
                interpolate_alpha(render_priv->time -
 
582
                        render_priv->state.event->Start, t1, t2,
 
583
                        t3, t4, a1, a2, a3);
 
584
            render_priv->state.parsed_tags |= PARSED_FADE;
 
585
        }
557
586
    } else if (mystrcmp(&p, "org")) {
558
587
        int v1, v2;
559
588
        skip('(');
657
686
            val = render_priv->state.style->PrimaryColour;
658
687
        ass_msg(render_priv->library, MSGL_DBG2, "color: %X", val);
659
688
        change_color(&render_priv->state.c[0], val, pwr);
 
689
        render_priv->state.bm_run_id++;
660
690
    } else if ((*p >= '1') && (*p <= '4') && (++p)
661
691
               && (mystrcmp(&p, "c") || mystrcmp(&p, "a"))) {
662
692
        char n = *(p - 2);
686
716
        switch (cmd) {
687
717
        case 'c':
688
718
            change_color(render_priv->state.c + cidx, val, pwr);
 
719
            render_priv->state.bm_run_id++;
689
720
            break;
690
721
        case 'a':
691
722
            change_alpha(render_priv->state.c + cidx, val >> 24, pwr);
 
723
            render_priv->state.bm_run_id++;
692
724
            break;
693
725
        default:
694
726
            ass_msg(render_priv->library, MSGL_WARN, "Bad command: %c%c",
708
740
            render_priv->state.be = val;
709
741
        } else
710
742
            render_priv->state.be = 0;
 
743
        render_priv->state.bm_run_id++;
711
744
    } else if (mystrcmp(&p, "b")) {
712
745
        int b;
713
746
        if (mystrtoi(&p, &b)) {
756
789
        } else
757
790
            val = 0.;
758
791
        render_priv->state.shadow_x = render_priv->state.shadow_y = val;
 
792
        render_priv->state.bm_run_id++;
759
793
    } else if (mystrcmp(&p, "s")) {
760
794
        int val;
761
795
        if (mystrtoi(&p, &val) && val)
762
796
            render_priv->state.flags |= DECO_STRIKETHROUGH;
763
797
        else
764
798
            render_priv->state.flags &= ~DECO_STRIKETHROUGH;
 
799
        render_priv->state.bm_run_id++;
765
800
    } else if (mystrcmp(&p, "u")) {
766
801
        int val;
767
802
        if (mystrtoi(&p, &val) && val)
768
803
            render_priv->state.flags |= DECO_UNDERLINE;
769
804
        else
770
805
            render_priv->state.flags &= ~DECO_UNDERLINE;
 
806
        render_priv->state.bm_run_id++;
771
807
    } else if (mystrcmp(&p, "pbo")) {
772
808
        double val = 0;
773
809
        if (mystrtod(&p, &val))
784
820
        if (!mystrtoi(&p, &val))
785
821
            val = render_priv->track->WrapStyle;
786
822
        render_priv->state.wrap_style = val;
 
823
    } else if (mystrcmp(&p, "fe")) {
 
824
        int val;
 
825
        if (!mystrtoi(&p, &val))
 
826
            val = render_priv->state.style->Encoding;
 
827
        render_priv->state.font_encoding = val;
787
828
    }
788
829
 
789
830
    return p;
865
906
}
866
907
 
867
908
/**
 
909
 * \brief determine karaoke effects
 
910
 * Karaoke effects cannot be calculated during parse stage (get_next_char()),
 
911
 * so they are done in a separate step.
 
912
 * Parse stage: when karaoke style override is found, its parameters are stored in the next glyph's
 
913
 * (the first glyph of the karaoke word)'s effect_type and effect_timing.
 
914
 * This function:
 
915
 * 1. sets effect_type for all glyphs in the word (_karaoke_ word)
 
916
 * 2. sets effect_timing for all glyphs to x coordinate of the border line between the left and right karaoke parts
 
917
 * (left part is filled with PrimaryColour, right one - with SecondaryColour).
 
918
 */
 
919
void process_karaoke_effects(ASS_Renderer *render_priv)
 
920
{
 
921
    GlyphInfo *cur, *cur2;
 
922
    GlyphInfo *s1, *e1;      // start and end of the current word
 
923
    GlyphInfo *s2;           // start of the next word
 
924
    int i;
 
925
    int timing;                 // current timing
 
926
    int tm_start, tm_end;       // timings at start and end of the current word
 
927
    int tm_current;
 
928
    double dt;
 
929
    int x;
 
930
    int x_start, x_end;
 
931
 
 
932
    tm_current = render_priv->time - render_priv->state.event->Start;
 
933
    timing = 0;
 
934
    s1 = s2 = 0;
 
935
    for (i = 0; i <= render_priv->text_info.length; ++i) {
 
936
        cur = render_priv->text_info.glyphs + i;
 
937
        if ((i == render_priv->text_info.length)
 
938
            || (cur->effect_type != EF_NONE)) {
 
939
            s1 = s2;
 
940
            s2 = cur;
 
941
            if (s1) {
 
942
                e1 = s2 - 1;
 
943
                tm_start = timing + s1->effect_skip_timing;
 
944
                tm_end = tm_start + s1->effect_timing;
 
945
                timing = tm_end;
 
946
                x_start = 1000000;
 
947
                x_end = -1000000;
 
948
                for (cur2 = s1; cur2 <= e1; ++cur2) {
 
949
                    x_start = FFMIN(x_start, d6_to_int(cur2->bbox.xMin + cur2->pos.x));
 
950
                    x_end = FFMAX(x_end, d6_to_int(cur2->bbox.xMax + cur2->pos.x));
 
951
                }
 
952
 
 
953
                dt = (tm_current - tm_start);
 
954
                if ((s1->effect_type == EF_KARAOKE)
 
955
                    || (s1->effect_type == EF_KARAOKE_KO)) {
 
956
                    if (dt > 0)
 
957
                        x = x_end + 1;
 
958
                    else
 
959
                        x = x_start;
 
960
                } else if (s1->effect_type == EF_KARAOKE_KF) {
 
961
                    dt /= (tm_end - tm_start);
 
962
                    x = x_start + (x_end - x_start) * dt;
 
963
                } else {
 
964
                    ass_msg(render_priv->library, MSGL_ERR,
 
965
                            "Unknown effect type");
 
966
                    continue;
 
967
                }
 
968
 
 
969
                for (cur2 = s1; cur2 <= e1; ++cur2) {
 
970
                    cur2->effect_type = s1->effect_type;
 
971
                    cur2->effect_timing = x - d6_to_int(cur2->pos.x);
 
972
                }
 
973
            }
 
974
        }
 
975
    }
 
976
}
 
977
 
 
978
 
 
979
/**
868
980
 * \brief Get next ucs4 char from string, parsing and executing style overrides
869
981
 * \param str string pointer
870
982
 * \return ucs4 code of the next char