~ubuntu-branches/ubuntu/precise/libav/precise-updates

« back to all changes in this revision

Viewing changes to libavcodec/qdrw.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.2.8) (1.1.13 experimental)
  • Revision ID: package-import@ubuntu.com-20120112223000-cmfo7w78q13i2fd9
Tags: 4:0.8~beta2-1ubuntu1
* Merge from debian, remaining changes:
  - don't build against libdirac, lame, libopenjpeg, librtmp, 
    x264, and xvid  (all in universe)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
                        AVPacket *avpkt)
38
38
{
39
39
    const uint8_t *buf = avpkt->data;
 
40
    const uint8_t *buf_end = avpkt->data + avpkt->size;
40
41
    int buf_size = avpkt->size;
41
42
    QdrawContext * const a = avctx->priv_data;
42
43
    AVFrame * const p= (AVFrame*)&a->pic;
59
60
 
60
61
    outdata = a->pic.data[0];
61
62
 
 
63
    if (buf_end - buf < 0x68 + 4)
 
64
        return AVERROR_INVALIDDATA;
62
65
    buf += 0x68; /* jump to palette */
63
66
    colors = AV_RB32(buf);
64
67
    buf += 4;
67
70
        av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors);
68
71
        return -1;
69
72
    }
 
73
    if (buf_end - buf < (colors + 1) * 8)
 
74
        return AVERROR_INVALIDDATA;
70
75
 
71
76
    pal = (uint32_t*)p->data[1];
72
77
    for (i = 0; i <= colors; i++) {
89
94
    }
90
95
    p->palette_has_changed = 1;
91
96
 
 
97
    if (buf_end - buf < 18)
 
98
        return AVERROR_INVALIDDATA;
92
99
    buf += 18; /* skip unneeded data */
93
100
    for (i = 0; i < avctx->height; i++) {
94
101
        int size, left, code, pix;
100
107
        out = outdata;
101
108
        size = AV_RB16(buf); /* size of packed line */
102
109
        buf += 2;
 
110
        if (buf_end - buf < size)
 
111
            return AVERROR_INVALIDDATA;
 
112
 
103
113
        left = size;
104
114
        next = buf + size;
105
115
        while (left > 0) {
115
125
            } else { /* copy */
116
126
                if ((out + code) > (outdata +  a->pic.linesize[0]))
117
127
                    break;
 
128
                if (buf_end - buf < code + 1)
 
129
                    return AVERROR_INVALIDDATA;
118
130
                memcpy(out, buf, code + 1);
119
131
                out += code + 1;
120
132
                buf += code + 1;
151
163
}
152
164
 
153
165
AVCodec ff_qdraw_decoder = {
154
 
    "qdraw",
155
 
    AVMEDIA_TYPE_VIDEO,
156
 
    CODEC_ID_QDRAW,
157
 
    sizeof(QdrawContext),
158
 
    decode_init,
159
 
    NULL,
160
 
    decode_end,
161
 
    decode_frame,
162
 
    CODEC_CAP_DR1,
 
166
    .name           = "qdraw",
 
167
    .type           = AVMEDIA_TYPE_VIDEO,
 
168
    .id             = CODEC_ID_QDRAW,
 
169
    .priv_data_size = sizeof(QdrawContext),
 
170
    .init           = decode_init,
 
171
    .close          = decode_end,
 
172
    .decode         = decode_frame,
 
173
    .capabilities   = CODEC_CAP_DR1,
163
174
    .long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"),
164
175
};