~siretart/libav/trusty-security

« back to all changes in this revision

Viewing changes to libavcodec/ansi.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2013-10-22 23:24:08 UTC
  • mfrom: (1.3.36 sid)
  • Revision ID: package-import@ubuntu.com-20131022232408-b8tvvn4pyzri9mi3
Tags: 6:9.10-1ubuntu1
* Build all -extra flavors from this source package, as libav got demoted
  from main to universe, cf LP: #1243235
* Simplify debian/rules to follow exactly the code that debian executes
* New upstream (LP: #1180288) fixes lots of security issues (LP: #1242802)
* Merge from unstable, remaining changes:
  - build-depend on libtiff5-dev rather than libtiff4-dev,
    avoids FTBFS caused by imlib
  - follow the regular debian codepaths

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 * ASCII/ANSI art decoder
25
25
 */
26
26
 
 
27
#include "libavutil/common.h"
27
28
#include "libavutil/lfg.h"
28
29
#include "avcodec.h"
29
30
#include "cga_data.h"
 
31
#include "internal.h"
30
32
 
31
33
#define ATTR_BOLD         0x01  /**< Bold/Bright-foreground (mode 1) */
32
34
#define ATTR_FAINT        0x02  /**< Faint (mode 2) */
73
75
static av_cold int decode_init(AVCodecContext *avctx)
74
76
{
75
77
    AnsiContext *s = avctx->priv_data;
76
 
    avctx->pix_fmt = PIX_FMT_PAL8;
 
78
    avctx->pix_fmt = AV_PIX_FMT_PAL8;
77
79
 
78
80
    /* defaults */
79
81
    s->font        = ff_vga16_font;
221
223
            if (s->frame.data[0])
222
224
                avctx->release_buffer(avctx, &s->frame);
223
225
            avcodec_set_dimensions(avctx, width, height);
224
 
            ret = avctx->get_buffer(avctx, &s->frame);
 
226
            ret = ff_get_buffer(avctx, &s->frame);
225
227
            if (ret < 0) {
226
228
                av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
227
229
                return ret;
309
311
}
310
312
 
311
313
static int decode_frame(AVCodecContext *avctx,
312
 
                            void *data, int *data_size,
 
314
                            void *data, int *got_frame,
313
315
                            AVPacket *avpkt)
314
316
{
315
317
    AnsiContext *s = avctx->priv_data;
323
325
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
324
326
        return ret;
325
327
    }
 
328
    if (!avctx->frame_number) {
 
329
        memset(s->frame.data[0], 0, avctx->height * FFABS(s->frame.linesize[0]));
 
330
        memset(s->frame.data[1], 0, AVPALETTE_SIZE);
 
331
    }
 
332
 
326
333
    s->frame.pict_type           = AV_PICTURE_TYPE_I;
327
334
    s->frame.palette_has_changed = 1;
328
335
    memcpy(s->frame.data[1], ff_cga_palette, 16 * 4);
368
375
            } else {
369
376
                s->state = STATE_NORMAL;
370
377
                draw_char(avctx, 0x1B);
371
 
                    return -1;
372
378
                continue;
373
379
            }
374
380
            break;
409
415
        buf++;
410
416
    }
411
417
 
412
 
    *data_size = sizeof(AVFrame);
 
418
    *got_frame = 1;
413
419
    *(AVFrame*)data = s->frame;
414
420
    return buf_size;
415
421
}
425
431
AVCodec ff_ansi_decoder = {
426
432
    .name           = "ansi",
427
433
    .type           = AVMEDIA_TYPE_VIDEO,
428
 
    .id             = CODEC_ID_ANSI,
 
434
    .id             = AV_CODEC_ID_ANSI,
429
435
    .priv_data_size = sizeof(AnsiContext),
430
436
    .init           = decode_init,
431
437
    .close          = decode_close,