~ubuntu-branches/ubuntu/lucid/avidemux/lucid

« back to all changes in this revision

Viewing changes to plugins/ADM_videoFilters/Ass/ADM_libAss/ass_library.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-08-20 08:42:44 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20090820084244-bhh15xxd7x2vbcuh
Tags: 1:2.5.1+repack-0ubuntu1
* New upstream bugfix release (LP: #416066):
  - Re-enabled several video and audio encoders (regression introduced
    in 2.5.0)
  - Updated the FFmpeg libraries
  - More video encoders are now plugins
  - DV video encoder now supports more profiles
  - Fixed loading and saving issues with LAME, x264 and Xvid options
    (regression introduced in 2.5.0)
  - Fraps video decoding support
  - Lowpass-5 mode added to libavcodec deinterlacer filter plugin
  - Fixed formatting of parameters for various filters on 64-bit platforms
  - Updated libass
  - Fixed sizing of the bitrate control on various video encoder configure
    windows (regression introduced in 2.5.0)
  - Improved filter dialog for GTK+ interface
  - New navigation icons for GTK+ interface
  - Fixed the behaviour of several GTK+ open/save dialogs (regression
    introduced in 2.5.0)
  - asharp filter's Block Adaptive mode can now be disabled using the Qt
    interface
  - Re-enabled the colour chooser dialog using the Qt interface (regression
    introduced in 2.5.0)
  - GCC 4.4 support
  - Fixed issues with CMake build scripts when using multiple make jobs
    (regression introduced in 2.5.0)
* Remove debian/patches dir and drop all patches, now applied by upstream.
* Drop quilt support.
* debian/libavidemux0.install: Also install missing libraries.
* Move debian/install to debian/avidemux.install.
* debian/rules:
  - Build the internal ffmpeg version properly (thanks to Christian Marillat).
  - A bit of cleanup.
* debian/control:
  - Bump Standards-Version.
  - Update Homepage field.
  - Adjust libavidemux0 short description.
  - gtk -> GTK, qt -> QT.
  - Set myself as Maintainer.
* Repack the tarball to remove the debian/ dir provided by upstream:
  - Create debian/README.source.
  - Update debian/watch.
  - Add get-orig-source target to debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
 
3
 *
 
4
 * This file is part of libass.
 
5
 *
 
6
 * libass is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * libass is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with libass; if not, write to the Free Software Foundation, Inc.,
 
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
19
 */
 
20
 
 
21
#include <inttypes.h>
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
#include <string.h>
 
25
#include <stdarg.h>
 
26
 
 
27
#include "ass.h"
 
28
#include "ass_library.h"
 
29
#include "ass_utils.h"
 
30
 
 
31
static void ass_msg_handler(int level, const char *fmt, va_list va, void *data)
 
32
{
 
33
    if (level > MSGL_INFO)
 
34
        return;
 
35
    fprintf(stderr, "[ass] ");
 
36
    vfprintf(stderr, fmt, va);
 
37
    fprintf(stderr, "\n");
 
38
}
 
39
 
 
40
ass_library_t *ass_library_init(void)
 
41
{
 
42
    ass_library_t* lib = calloc(1, sizeof(ass_library_t));
 
43
    lib->msg_callback = ass_msg_handler;
 
44
 
 
45
    return lib;
 
46
}
 
47
 
 
48
void ass_library_done(ass_library_t *priv)
 
49
{
 
50
    if (priv) {
 
51
        ass_set_fonts_dir(priv, NULL);
 
52
        ass_set_style_overrides(priv, NULL);
 
53
        ass_clear_fonts(priv);
 
54
        free(priv);
 
55
    }
 
56
}
 
57
 
 
58
void ass_set_fonts_dir(ass_library_t *priv, const char *fonts_dir)
 
59
{
 
60
    if (priv->fonts_dir)
 
61
        free(priv->fonts_dir);
 
62
 
 
63
    priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0;
 
64
}
 
65
 
 
66
void ass_set_extract_fonts(ass_library_t *priv, int extract)
 
67
{
 
68
    priv->extract_fonts = !!extract;
 
69
}
 
70
 
 
71
void ass_set_style_overrides(ass_library_t *priv, char **list)
 
72
{
 
73
    char **p;
 
74
    char **q;
 
75
    int cnt;
 
76
 
 
77
    if (priv->style_overrides) {
 
78
        for (p = priv->style_overrides; *p; ++p)
 
79
            free(*p);
 
80
        free(priv->style_overrides);
 
81
    }
 
82
 
 
83
    if (!list)
 
84
        return;
 
85
 
 
86
    for (p = list, cnt = 0; *p; ++p, ++cnt) {
 
87
    }
 
88
 
 
89
    priv->style_overrides = malloc((cnt + 1) * sizeof(char *));
 
90
    for (p = list, q = priv->style_overrides; *p; ++p, ++q)
 
91
        *q = strdup(*p);
 
92
    priv->style_overrides[cnt] = NULL;
 
93
}
 
94
 
 
95
static void grow_array(void **array, int nelem, size_t elsize)
 
96
{
 
97
    if (!(nelem & 31))
 
98
        *array = realloc(*array, (nelem + 32) * elsize);
 
99
}
 
100
 
 
101
void ass_add_font(ass_library_t *priv, char *name, char *data, int size)
 
102
{
 
103
    int idx = priv->num_fontdata;
 
104
    if (!name || !data || !size)
 
105
        return;
 
106
    grow_array((void **) &priv->fontdata, priv->num_fontdata,
 
107
               sizeof(*priv->fontdata));
 
108
 
 
109
    priv->fontdata[idx].name = strdup(name);
 
110
 
 
111
    priv->fontdata[idx].data = malloc(size);
 
112
    memcpy(priv->fontdata[idx].data, data, size);
 
113
 
 
114
    priv->fontdata[idx].size = size;
 
115
 
 
116
    priv->num_fontdata++;
 
117
}
 
118
 
 
119
void ass_clear_fonts(ass_library_t *priv)
 
120
{
 
121
    int i;
 
122
    for (i = 0; i < priv->num_fontdata; ++i) {
 
123
        free(priv->fontdata[i].name);
 
124
        free(priv->fontdata[i].data);
 
125
    }
 
126
    free(priv->fontdata);
 
127
    priv->fontdata = NULL;
 
128
    priv->num_fontdata = 0;
 
129
}
 
130
 
 
131
/*
 
132
 * Register a message callback function with libass.  Without setting one,
 
133
 * a default handler is used which prints everything with MSGL_INFO or
 
134
 * higher to the standard output.
 
135
 *
 
136
 * \param msg_cb the callback function
 
137
 * \param data additional data that will be passed to the callback
 
138
 */
 
139
void ass_set_message_cb(ass_library_t *priv,
 
140
                        void (*msg_cb)(int, const char *, va_list, void *),
 
141
                        void *data)
 
142
{
 
143
    if (msg_cb) {
 
144
        priv->msg_callback = msg_cb;
 
145
        priv->msg_callback_data = data;
 
146
    }
 
147
}