~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavcodec/pcx.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-19 15:04:55 UTC
  • mfrom: (1.2.1 upstream)
  • mto: (1.3.4 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20110419150455-c1nac6gjm3t2aa4n
Tags: 4:0.7~b1-1
* New upstream version
* bump SONAME and SHLIBS
* configure flags --disable-stripping was removed upstream
* the MAINTAINERS file was removed upstream
* remove patch disable-configuration-warning.patch
* drop avfilter confflags, it is enable by default in 0.7
* libfaad wrapper has been removed upstream
* also update the *contents* of the lintian overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * This decoder does not support CGA palettes. I am unable to find samples
6
6
 * and Netpbm cannot generate them.
7
7
 *
8
 
 * This file is part of FFmpeg.
 
8
 * This file is part of Libav.
9
9
 *
10
 
 * FFmpeg is free software; you can redistribute it and/or
 
10
 * Libav is free software; you can redistribute it and/or
11
11
 * modify it under the terms of the GNU Lesser General Public
12
12
 * License as published by the Free Software Foundation; either
13
13
 * version 2.1 of the License, or (at your option) any later version.
14
14
 *
15
 
 * FFmpeg is distributed in the hope that it will be useful,
 
15
 * Libav is distributed in the hope that it will be useful,
16
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
18
 * Lesser General Public License for more details.
19
19
 *
20
20
 * You should have received a copy of the GNU Lesser General Public
21
 
 * License along with FFmpeg; if not, write to the Free Software
 
21
 * License along with Libav; if not, write to the Free Software
22
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
23
 */
24
24
 
 
25
#include "libavutil/imgutils.h"
25
26
#include "avcodec.h"
26
27
#include "bytestream.h"
27
28
#include "get_bits.h"
87
88
                 bytes_per_scanline;
88
89
    uint8_t *ptr;
89
90
    uint8_t const *bufstart = buf;
 
91
    uint8_t *scanline;
 
92
    int ret = -1;
90
93
 
91
94
    if (buf[0] != 0x0a || buf[1] > 5) {
92
95
        av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
140
143
    if (p->data[0])
141
144
        avctx->release_buffer(avctx, p);
142
145
 
143
 
    if (avcodec_check_dimensions(avctx, w, h))
 
146
    if (av_image_check_size(w, h, 0, avctx))
144
147
        return -1;
145
148
    if (w != avctx->width || h != avctx->height)
146
149
        avcodec_set_dimensions(avctx, w, h);
154
157
    ptr    = p->data[0];
155
158
    stride = p->linesize[0];
156
159
 
 
160
    scanline = av_malloc(bytes_per_scanline);
 
161
    if (!scanline)
 
162
        return AVERROR(ENOMEM);
 
163
 
157
164
    if (nplanes == 3 && bits_per_pixel == 8) {
158
 
        uint8_t scanline[bytes_per_scanline];
159
 
 
160
165
        for (y=0; y<h; y++) {
161
166
            buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
162
167
 
170
175
        }
171
176
 
172
177
    } else if (nplanes == 1 && bits_per_pixel == 8) {
173
 
        uint8_t scanline[bytes_per_scanline];
174
178
        const uint8_t *palstart = bufstart + buf_size - 769;
175
179
 
176
180
        for (y=0; y<h; y++, ptr+=stride) {
184
188
        }
185
189
        if (*buf++ != 12) {
186
190
            av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
187
 
            return -1;
 
191
            goto end;
188
192
        }
189
193
 
190
194
    } else if (nplanes == 1) {   /* all packed formats, max. 16 colors */
191
 
        uint8_t scanline[bytes_per_scanline];
192
195
        GetBitContext s;
193
196
 
194
197
        for (y=0; y<h; y++) {
202
205
        }
203
206
 
204
207
    } else {    /* planar, 4, 8 or 16 colors */
205
 
        uint8_t scanline[bytes_per_scanline];
206
208
        int i;
207
209
 
208
210
        for (y=0; y<h; y++) {
230
232
    *picture = s->picture;
231
233
    *data_size = sizeof(AVFrame);
232
234
 
233
 
    return buf - bufstart;
 
235
    ret = buf - bufstart;
 
236
end:
 
237
    av_free(scanline);
 
238
    return ret;
234
239
}
235
240
 
236
241
static av_cold int pcx_end(AVCodecContext *avctx) {
242
247
    return 0;
243
248
}
244
249
 
245
 
AVCodec pcx_decoder = {
 
250
AVCodec ff_pcx_decoder = {
246
251
    "pcx",
247
252
    AVMEDIA_TYPE_VIDEO,
248
253
    CODEC_ID_PCX,