~ubuntu-branches/ubuntu/vivid/libav/vivid

« back to all changes in this revision

Viewing changes to libavcodec/iff.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:
29
29
#include "bytestream.h"
30
30
#include "avcodec.h"
31
31
#include "get_bits.h"
 
32
#include "internal.h"
32
33
 
33
34
typedef struct {
34
35
    AVFrame frame;
152
153
 
153
154
    if (avctx->bits_per_coded_sample <= 8) {
154
155
        avctx->pix_fmt = (avctx->bits_per_coded_sample < 8 ||
155
 
                          avctx->extradata_size) ? PIX_FMT_PAL8
156
 
                                                 : PIX_FMT_GRAY8;
 
156
                          avctx->extradata_size) ? AV_PIX_FMT_PAL8
 
157
                                                 : AV_PIX_FMT_GRAY8;
157
158
    } else if (avctx->bits_per_coded_sample <= 32) {
158
 
        avctx->pix_fmt = PIX_FMT_BGR32;
 
159
        avctx->pix_fmt = AV_PIX_FMT_BGR32;
159
160
    } else {
160
161
        return AVERROR_INVALIDDATA;
161
162
    }
246
247
}
247
248
 
248
249
static int decode_frame_ilbm(AVCodecContext *avctx,
249
 
                            void *data, int *data_size,
 
250
                            void *data, int *got_frame,
250
251
                            AVPacket *avpkt)
251
252
{
252
253
    IffContext *s = avctx->priv_data;
260
261
            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
261
262
            return res;
262
263
        }
263
 
    } else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
 
264
    } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
264
265
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
265
266
        return res;
266
 
    } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
 
267
    } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != AV_PIX_FMT_GRAY8) {
267
268
        if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
268
269
            return res;
269
270
    }
270
271
    s->init = 1;
271
272
 
272
273
    if (avctx->codec_tag == MKTAG('I','L','B','M')) { // interleaved
273
 
        if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
274
 
            for(y = 0; y < avctx->height; y++ ) {
 
274
        if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
 
275
            for (y = 0; y < avctx->height && buf < buf_end; y++ ) {
275
276
                uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
276
277
                memset(row, 0, avctx->width);
277
278
                for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) {
279
280
                    buf += s->planesize;
280
281
                }
281
282
            }
282
 
        } else { // PIX_FMT_BGR32
 
283
        } else { // AV_PIX_FMT_BGR32
283
284
            for(y = 0; y < avctx->height; y++ ) {
284
285
                uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
285
286
                memset(row, 0, avctx->width << 2);
289
290
                }
290
291
            }
291
292
        }
292
 
    } else if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { // IFF-PBM
 
293
    } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) { // IFF-PBM
293
294
        for(y = 0; y < avctx->height; y++ ) {
294
295
            uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]];
295
296
            memcpy(row, buf, FFMIN(avctx->width, buf_end - buf));
297
298
        }
298
299
    }
299
300
 
300
 
    *data_size = sizeof(AVFrame);
 
301
    *got_frame = 1;
301
302
    *(AVFrame*)data = s->frame;
302
303
    return buf_size;
303
304
}
304
305
 
305
306
static int decode_frame_byterun1(AVCodecContext *avctx,
306
 
                            void *data, int *data_size,
 
307
                            void *data, int *got_frame,
307
308
                            AVPacket *avpkt)
308
309
{
309
310
    IffContext *s = avctx->priv_data;
317
318
            av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
318
319
            return res;
319
320
        }
320
 
    } else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) {
 
321
    } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {
321
322
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
322
323
        return res;
323
 
    } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) {
 
324
    } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != AV_PIX_FMT_GRAY8) {
324
325
        if ((res = ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1])) < 0)
325
326
            return res;
326
327
    }
327
328
    s->init = 1;
328
329
 
329
330
    if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
330
 
        if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) {
 
331
        if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
331
332
            for(y = 0; y < avctx->height ; y++ ) {
332
333
                uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
333
334
                memset(row, 0, avctx->width);
336
337
                    decodeplane8(row, s->planebuf, s->planesize, plane);
337
338
                }
338
339
            }
339
 
        } else { //PIX_FMT_BGR32
 
340
        } else { //AV_PIX_FMT_BGR32
340
341
            for(y = 0; y < avctx->height ; y++ ) {
341
342
                uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]];
342
343
                memset(row, 0, avctx->width << 2);
353
354
        }
354
355
    }
355
356
 
356
 
    *data_size = sizeof(AVFrame);
 
357
    *got_frame = 1;
357
358
    *(AVFrame*)data = s->frame;
358
359
    return buf_size;
359
360
}
370
371
AVCodec ff_iff_ilbm_decoder = {
371
372
    .name           = "iff_ilbm",
372
373
    .type           = AVMEDIA_TYPE_VIDEO,
373
 
    .id             = CODEC_ID_IFF_ILBM,
 
374
    .id             = AV_CODEC_ID_IFF_ILBM,
374
375
    .priv_data_size = sizeof(IffContext),
375
376
    .init           = decode_init,
376
377
    .close          = decode_end,
377
378
    .decode         = decode_frame_ilbm,
378
379
    .capabilities   = CODEC_CAP_DR1,
379
 
    .long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"),
 
380
    .long_name      = NULL_IF_CONFIG_SMALL("IFF ILBM"),
380
381
};
381
382
 
382
383
AVCodec ff_iff_byterun1_decoder = {
383
384
    .name           = "iff_byterun1",
384
385
    .type           = AVMEDIA_TYPE_VIDEO,
385
 
    .id             = CODEC_ID_IFF_BYTERUN1,
 
386
    .id             = AV_CODEC_ID_IFF_BYTERUN1,
386
387
    .priv_data_size = sizeof(IffContext),
387
388
    .init           = decode_init,
388
389
    .close          = decode_end,
389
390
    .decode         = decode_frame_byterun1,
390
391
    .capabilities   = CODEC_CAP_DR1,
391
 
    .long_name = NULL_IF_CONFIG_SMALL("IFF ByteRun1"),
 
392
    .long_name      = NULL_IF_CONFIG_SMALL("IFF ByteRun1"),
392
393
};