~paulbrianstewart/mplayer/medibuntu.natty

« back to all changes in this revision

Viewing changes to libavcodec/dvdsubdec.c

  • Committer: Gauvain Pocentek
  • Date: 2010-09-25 09:39:02 UTC
  • mfrom: (66.1.6 maverick)
  • Revision ID: gauvain@images-20100925093902-9q2akz3ls3qzhaaw
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* merge from debian, remaining changes:
  - build depend against, lame, x264, xvid
* debian/patches/60eval-api.patch, backport patch from upstream to
  unbreak compilation for eval.h move not yet in 0.6
* gmplayer is gone now, please see smplayer as alternative frontend.
  LP: #503537, #493088, #467534, #467524, #460326, #390399, #285570,
      #208680, #118709, #513065, #459595, #455913, #179918, #65165.
* enable the mencoder package
* sort build depends alphabetically
* enable dvdnav support, Closes: #582508, #488226, LP: #611749
* prepare new upload
* no longer build mplayer-gui, it doesn't build anymore with shared
  swscale
* merge from debian/experimental, remaining changes:
  - build depend against, lame, x264, xvid
  - enable mencoder and mplayer-gui
* ensure that quilt patches are actually applied
* New Upstream Version, LP: #539315
* Build (against) again the System FFmpeg 
* tighten dependency on FFmpeg 0.6
* remove patches merged upstream
* remove 22disable-xscreensaver.patch
* refresh patches
* readd x264, xvid and mp3lame support, LP: #606125
* remove old parallel building mechanism, fixes FTBFS
* New upstream version
* compile against internal ffmpeg for now, LP: #587203, #588097
* recompile for directfb transtion, LP: #587163
* remove patches that were merged upstream
* avoid removing DOCS/html directory. it is included in release
  tarball
* convert to source Format: 3.0 (quilt)
* refreshed patches
* remove files that are included in upstream tarball
* rework debian/rules file
  - support parallel building
  - merge build rules for mplayer and mencoder package
  - remove unreferenced COMMON_CONFIGURE_FLAGS macro
  - rename DEB_BUILD_CONFIGURE -> CONFIGURE_FLAGS
  - don't build documentation - release tarballs have them prebuilt
  - build HTML documentation only if not already avaiable in the build
    tree
  - remove remaining references to debian/strip.sh from debian/rules
* remove copied vdpau headers
* copy in mencoder.c from upstream
* enable mplayer-gui (Closes: #579925) and mencoder packages. 
  (Closes: #396954, #400940, #580168)
* Fix rtsp vulnerability. Patch applied by DSA. Closes: #581245
* Fix another integer overflow, Closes: #524805
* prepare new upload
* sync libao2/ao_pulse.c with svn r30062, Closes: #558196, #580113
* make configure use pkg-config for fribidi checks. Closes: #582784,
  LP: #556200
* document 23mplayer-debug-printf.patch
* avoid mentioning of GTK frontend in mplayer description
* improve package descriptions of mplayer-doc and mplayer-dbg
* medium urgency because of fixed security issue
* fix SVN_VERION regex in debian rules to unbreak get-orig-source
  target. Closes: #582369
* forcefully disable arts support. Closes: #581225
* Remove mencoder from Depends in mplayer-dbg package.
* new upstream snapshot from rc3 branch.
* remove patches applied upstream:
  
  - 24_enable_fontconfig_by_default.diff
  - 30_add_gmplayer_man_rules.diff
  - 40_improve_desktop_file.patch
  - 41_fix_forcedsubsonly.patch
  - 50_fix_crashes_with_invalid_SDPs.patch
  - 50_fix_initial_volume_setting_pulse_output.patch
  - 61-malloc-bsd.patch
  - 62-disable-vidix-on-kfreebsd-amd64.patch
  - 63-sys-kd-include.patch
* don't install apport hook
* gross hack to avoid building mplayer-nogui and mplayer-gui packages
* add md5sum to remove to avoid spurious conffile prompt, Closes: #568272
* Make mplayer build on kFreeBSD (backports from upstream), Closes: #578622
  - Revert obscure hack that disables the malloc.h check on certain BSD
    platforms. 
  - disable vidix on kFreeBSD-amd64
  - rename 'struct keypad' -> 'struct m_keypad' to avoid FTBFS on
    kFreeBSD/amd64
* enable fontconfig by default. (Closes: #573257)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
#include "avcodec.h"
22
 
#include "bitstream.h"
 
22
#include "get_bits.h"
23
23
#include "colorspace.h"
24
24
#include "dsputil.h"
25
25
 
173
173
 
174
174
    if (buf_size < 10)
175
175
        return -1;
176
 
    sub_header->rects = NULL;
177
 
    sub_header->num_rects = 0;
178
 
    sub_header->format = 0;
179
 
    sub_header->start_display_time = 0;
180
 
    sub_header->end_display_time = 0;
 
176
    memset(sub_header, 0, sizeof(*sub_header));
181
177
 
182
178
    if (AV_RB16(buf) == 0) {   /* HD subpicture with 4-byte offsets */
183
179
        big_offsets = 1;
191
187
 
192
188
    cmd_pos = READ_OFFSET(buf + cmd_pos);
193
189
 
194
 
    while ((cmd_pos + 2 + offset_size) < buf_size) {
 
190
    while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
195
191
        date = AV_RB16(buf + cmd_pos);
196
192
        next_cmd_pos = READ_OFFSET(buf + cmd_pos + 2);
197
 
#ifdef DEBUG
198
 
        av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n",
199
 
               cmd_pos, next_cmd_pos, date);
200
 
#endif
 
193
        dprintf(NULL, "cmd_pos=0x%04x next=0x%04x date=%d\n",
 
194
                cmd_pos, next_cmd_pos, date);
201
195
        pos = cmd_pos + 2 + offset_size;
202
196
        offset1 = -1;
203
197
        offset2 = -1;
204
198
        x1 = y1 = x2 = y2 = 0;
205
199
        while (pos < buf_size) {
206
200
            cmd = buf[pos++];
207
 
#ifdef DEBUG
208
 
            av_log(NULL, AV_LOG_INFO, "cmd=%02x\n", cmd);
209
 
#endif
 
201
            dprintf(NULL, "cmd=%02x\n", cmd);
210
202
            switch(cmd) {
211
203
            case 0x00:
212
204
                /* menu subpicture */
239
231
                alpha[1] = buf[pos + 1] >> 4;
240
232
                alpha[0] = buf[pos + 1] & 0x0f;
241
233
                pos += 2;
242
 
#ifdef DEBUG
243
 
            av_log(NULL, AV_LOG_INFO, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
244
 
#endif
 
234
            dprintf(NULL, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]);
245
235
                break;
246
236
            case 0x05:
247
237
            case 0x85:
253
243
                y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5];
254
244
                if (cmd & 0x80)
255
245
                    is_8bit = 1;
256
 
#ifdef DEBUG
257
 
                av_log(NULL, AV_LOG_INFO, "x1=%d x2=%d y1=%d y2=%d\n",
258
 
                       x1, x2, y1, y2);
259
 
#endif
 
246
                dprintf(NULL, "x1=%d x2=%d y1=%d y2=%d\n", x1, x2, y1, y2);
260
247
                pos += 6;
261
248
                break;
262
249
            case 0x06:
264
251
                    goto fail;
265
252
                offset1 = AV_RB16(buf + pos);
266
253
                offset2 = AV_RB16(buf + pos + 2);
267
 
#ifdef DEBUG
268
 
                av_log(NULL, AV_LOG_INFO, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
269
 
#endif
 
254
                dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
270
255
                pos += 4;
271
256
                break;
272
257
            case 0x86:
274
259
                    goto fail;
275
260
                offset1 = AV_RB32(buf + pos);
276
261
                offset2 = AV_RB32(buf + pos + 4);
277
 
#ifdef DEBUG
278
 
                av_log(NULL, AV_LOG_INFO, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
279
 
#endif
 
262
                dprintf(NULL, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2);
280
263
                pos += 8;
281
264
                break;
282
265
 
299
282
            case 0xff:
300
283
                goto the_end;
301
284
            default:
302
 
#ifdef DEBUG
303
 
                av_log(NULL, AV_LOG_INFO, "unrecognised subpicture command 0x%x\n", cmd);
304
 
#endif
 
285
                dprintf(NULL, "unrecognised subpicture command 0x%x\n", cmd);
305
286
                goto the_end;
306
287
            }
307
288
        }
337
318
                           buf, offset1, buf_size, is_8bit);
338
319
                decode_rle(bitmap + w, w * 2, w, h / 2,
339
320
                           buf, offset2, buf_size, is_8bit);
 
321
                sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
340
322
                if (is_8bit) {
341
323
                    if (yuv_palette == 0)
342
324
                        goto fail;
343
 
                    sub_header->rects[0]->pict.data[1] = av_malloc(256 * 4);
344
325
                    sub_header->rects[0]->nb_colors = 256;
345
326
                    yuv_a_to_rgba(yuv_palette, alpha, (uint32_t*)sub_header->rects[0]->pict.data[1], 256);
346
327
                } else {
347
 
                    sub_header->rects[0]->pict.data[1] = av_malloc(4 * 4);
348
328
                    sub_header->rects[0]->nb_colors = 4;
349
329
                    guess_palette((uint32_t*)sub_header->rects[0]->pict.data[1],
350
330
                                  colormap, alpha, 0xffff00);
353
333
                sub_header->rects[0]->y = y1;
354
334
                sub_header->rects[0]->w = w;
355
335
                sub_header->rects[0]->h = h;
 
336
                sub_header->rects[0]->type = SUBTITLE_BITMAP;
356
337
                sub_header->rects[0]->pict.linesize[0] = w;
357
338
            }
358
339
        }
475
456
 
476
457
static int dvdsub_decode(AVCodecContext *avctx,
477
458
                         void *data, int *data_size,
478
 
                         const uint8_t *buf, int buf_size)
 
459
                         AVPacket *avpkt)
479
460
{
 
461
    const uint8_t *buf = avpkt->data;
 
462
    int buf_size = avpkt->size;
480
463
    AVSubtitle *sub = (void *)data;
481
464
    int is_menu;
482
465
 
492
475
        goto no_subtitle;
493
476
 
494
477
#if defined(DEBUG)
495
 
    av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n",
496
 
           sub->start_display_time,
497
 
           sub->end_display_time);
 
478
    dprintf(NULL, "start=%d ms end =%d ms\n",
 
479
            sub->start_display_time,
 
480
            sub->end_display_time);
498
481
    ppm_save("/tmp/a.ppm", sub->rects[0]->pict.data[0],
499
482
             sub->rects[0]->w, sub->rects[0]->h, sub->rects[0]->pict.data[1]);
500
483
#endif
505
488
 
506
489
AVCodec dvdsub_decoder = {
507
490
    "dvdsub",
508
 
    CODEC_TYPE_SUBTITLE,
 
491
    AVMEDIA_TYPE_SUBTITLE,
509
492
    CODEC_ID_DVD_SUBTITLE,
510
493
    0,
511
494
    NULL,