~siretart/libav/trusty-security

« back to all changes in this revision

Viewing changes to libavcodec/dpx.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:
23
23
#include "libavutil/imgutils.h"
24
24
#include "bytestream.h"
25
25
#include "avcodec.h"
 
26
#include "internal.h"
26
27
 
27
28
typedef struct DPXContext {
28
29
    AVFrame picture;
51
52
 
52
53
static int decode_frame(AVCodecContext *avctx,
53
54
                        void *data,
54
 
                        int *data_size,
 
55
                        int *got_frame,
55
56
                        AVPacket *avpkt)
56
57
{
57
58
    const uint8_t *buf = avpkt->data;
62
63
    AVFrame *const p = &s->picture;
63
64
    uint8_t *ptr;
64
65
 
65
 
    int magic_num, offset, endian;
 
66
    unsigned int offset;
 
67
    int magic_num, endian;
66
68
    int x, y;
67
69
    int w, h, stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
68
70
 
125
127
    switch (bits_per_color) {
126
128
        case 8:
127
129
            if (elements == 4) {
128
 
                avctx->pix_fmt = PIX_FMT_RGBA;
 
130
                avctx->pix_fmt = AV_PIX_FMT_RGBA;
129
131
            } else {
130
 
                avctx->pix_fmt = PIX_FMT_RGB24;
 
132
                avctx->pix_fmt = AV_PIX_FMT_RGB24;
131
133
            }
132
134
            source_packet_size = elements;
133
135
            target_packet_size = elements;
134
136
            break;
135
137
        case 10:
136
 
            avctx->pix_fmt = PIX_FMT_RGB48;
 
138
            avctx->pix_fmt = AV_PIX_FMT_RGB48;
137
139
            target_packet_size = 6;
138
140
            source_packet_size = 4;
139
141
            break;
140
142
        case 12:
141
143
        case 16:
142
144
            if (endian) {
143
 
                avctx->pix_fmt = PIX_FMT_RGB48BE;
 
145
                avctx->pix_fmt = AV_PIX_FMT_RGB48BE;
144
146
            } else {
145
 
                avctx->pix_fmt = PIX_FMT_RGB48LE;
 
147
                avctx->pix_fmt = AV_PIX_FMT_RGB48LE;
146
148
            }
147
149
            target_packet_size = 6;
148
150
            source_packet_size = elements * 2;
158
160
        return -1;
159
161
    if (w != avctx->width || h != avctx->height)
160
162
        avcodec_set_dimensions(avctx, w, h);
161
 
    if (avctx->get_buffer(avctx, p) < 0) {
 
163
    if (ff_get_buffer(avctx, p) < 0) {
162
164
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
163
165
        return -1;
164
166
    }
211
213
    }
212
214
 
213
215
    *picture   = s->picture;
214
 
    *data_size = sizeof(AVPicture);
 
216
    *got_frame = 1;
215
217
 
216
218
    return buf_size;
217
219
}
236
238
AVCodec ff_dpx_decoder = {
237
239
    .name           = "dpx",
238
240
    .type           = AVMEDIA_TYPE_VIDEO,
239
 
    .id             = CODEC_ID_DPX,
 
241
    .id             = AV_CODEC_ID_DPX,
240
242
    .priv_data_size = sizeof(DPXContext),
241
243
    .init           = decode_init,
242
244
    .close          = decode_end,
243
245
    .decode         = decode_frame,
244
 
    .long_name = NULL_IF_CONFIG_SMALL("DPX image"),
 
246
    .long_name      = NULL_IF_CONFIG_SMALL("DPX image"),
 
247
    .capabilities   = CODEC_CAP_DR1,
245
248
};