~ubuntu-branches/ubuntu/saucy/gst-libav1.0/saucy-proposed

« back to all changes in this revision

Viewing changes to gst-libs/ext/libav/libavcodec/pnmdec.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2013-07-30 09:00:15 UTC
  • mfrom: (1.1.16) (7.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20130730090015-sc1ou2yssu7q5w4e
Tags: 1.1.3-1
* New upstream development snapshot:
  + debian/control:
    - Build depend on GStreamer and gst-plugins-base >= 1.1.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "avcodec.h"
23
23
#include "bytestream.h"
 
24
#include "internal.h"
24
25
#include "put_bits.h"
25
26
#include "pnm.h"
26
27
 
27
28
 
28
29
static int pnm_decode_frame(AVCodecContext *avctx, void *data,
29
 
                            int *data_size, AVPacket *avpkt)
 
30
                            int *got_frame, AVPacket *avpkt)
30
31
{
31
32
    const uint8_t *buf   = avpkt->data;
32
33
    int buf_size         = avpkt->size;
33
34
    PNMContext * const s = avctx->priv_data;
34
35
    AVFrame *picture     = data;
35
 
    AVFrame * const p    = (AVFrame*)&s->picture;
 
36
    AVFrame * const p    = &s->picture;
36
37
    int i, j, n, linesize, h, upgrade = 0;
37
38
    unsigned char *ptr;
38
39
    int components, sample_len;
48
49
        avctx->release_buffer(avctx, p);
49
50
 
50
51
    p->reference = 0;
51
 
    if (avctx->get_buffer(avctx, p) < 0) {
 
52
    if (ff_get_buffer(avctx, p) < 0) {
52
53
        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
53
54
        return -1;
54
55
    }
58
59
    switch (avctx->pix_fmt) {
59
60
    default:
60
61
        return -1;
61
 
    case PIX_FMT_RGB48BE:
 
62
    case AV_PIX_FMT_RGB48BE:
62
63
        n = avctx->width * 6;
63
64
        components=3;
64
65
        sample_len=16;
65
66
        goto do_read;
66
 
    case PIX_FMT_RGB24:
 
67
    case AV_PIX_FMT_RGB24:
67
68
        n = avctx->width * 3;
68
69
        components=3;
69
70
        sample_len=8;
70
71
        goto do_read;
71
 
    case PIX_FMT_GRAY8:
 
72
    case AV_PIX_FMT_GRAY8:
72
73
        n = avctx->width;
73
74
        components=1;
74
75
        sample_len=8;
75
76
        if (s->maxval < 255)
76
77
            upgrade = 1;
77
78
        goto do_read;
78
 
    case PIX_FMT_GRAY16BE:
79
 
    case PIX_FMT_GRAY16LE:
 
79
    case AV_PIX_FMT_GRAY16BE:
 
80
    case AV_PIX_FMT_GRAY16LE:
80
81
        n = avctx->width * 2;
81
82
        components=1;
82
83
        sample_len=16;
83
84
        if (s->maxval < 65535)
84
85
            upgrade = 2;
85
86
        goto do_read;
86
 
    case PIX_FMT_MONOWHITE:
87
 
    case PIX_FMT_MONOBLACK:
 
87
    case AV_PIX_FMT_MONOWHITE:
 
88
    case AV_PIX_FMT_MONOBLACK:
88
89
        n = (avctx->width + 7) >> 3;
89
90
        components=1;
90
91
        sample_len=1;
133
134
        }
134
135
        }
135
136
        break;
136
 
    case PIX_FMT_YUV420P:
 
137
    case AV_PIX_FMT_YUV420P:
137
138
        {
138
139
            unsigned char *ptr1, *ptr2;
139
140
 
161
162
            }
162
163
        }
163
164
        break;
164
 
    case PIX_FMT_RGB32:
 
165
    case AV_PIX_FMT_RGB32:
165
166
        ptr      = p->data[0];
166
167
        linesize = p->linesize[0];
167
168
        if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
180
181
        }
181
182
        break;
182
183
    }
183
 
    *picture   = *(AVFrame*)&s->picture;
184
 
    *data_size = sizeof(AVPicture);
 
184
    *picture   = s->picture;
 
185
    *got_frame = 1;
185
186
 
186
187
    return s->bytestream - s->bytestream_start;
187
188
}
191
192
AVCodec ff_pgm_decoder = {
192
193
    .name           = "pgm",
193
194
    .type           = AVMEDIA_TYPE_VIDEO,
194
 
    .id             = CODEC_ID_PGM,
 
195
    .id             = AV_CODEC_ID_PGM,
195
196
    .priv_data_size = sizeof(PNMContext),
196
197
    .init           = ff_pnm_init,
197
198
    .close          = ff_pnm_end,
198
199
    .decode         = pnm_decode_frame,
199
200
    .capabilities   = CODEC_CAP_DR1,
200
 
    .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
201
 
    .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
 
201
    .long_name      = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
202
202
};
203
203
#endif
204
204
 
206
206
AVCodec ff_pgmyuv_decoder = {
207
207
    .name           = "pgmyuv",
208
208
    .type           = AVMEDIA_TYPE_VIDEO,
209
 
    .id             = CODEC_ID_PGMYUV,
 
209
    .id             = AV_CODEC_ID_PGMYUV,
210
210
    .priv_data_size = sizeof(PNMContext),
211
211
    .init           = ff_pnm_init,
212
212
    .close          = ff_pnm_end,
213
213
    .decode         = pnm_decode_frame,
214
214
    .capabilities   = CODEC_CAP_DR1,
215
 
    .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
216
 
    .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
 
215
    .long_name      = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
217
216
};
218
217
#endif
219
218
 
221
220
AVCodec ff_ppm_decoder = {
222
221
    .name           = "ppm",
223
222
    .type           = AVMEDIA_TYPE_VIDEO,
224
 
    .id             = CODEC_ID_PPM,
 
223
    .id             = AV_CODEC_ID_PPM,
225
224
    .priv_data_size = sizeof(PNMContext),
226
225
    .init           = ff_pnm_init,
227
226
    .close          = ff_pnm_end,
228
227
    .decode         = pnm_decode_frame,
229
228
    .capabilities   = CODEC_CAP_DR1,
230
 
    .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
231
 
    .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
 
229
    .long_name      = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
232
230
};
233
231
#endif
234
232
 
236
234
AVCodec ff_pbm_decoder = {
237
235
    .name           = "pbm",
238
236
    .type           = AVMEDIA_TYPE_VIDEO,
239
 
    .id             = CODEC_ID_PBM,
 
237
    .id             = AV_CODEC_ID_PBM,
240
238
    .priv_data_size = sizeof(PNMContext),
241
239
    .init           = ff_pnm_init,
242
240
    .close          = ff_pnm_end,
243
241
    .decode         = pnm_decode_frame,
244
242
    .capabilities   = CODEC_CAP_DR1,
245
 
    .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
246
 
    .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
 
243
    .long_name      = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
247
244
};
248
245
#endif
249
246
 
251
248
AVCodec ff_pam_decoder = {
252
249
    .name           = "pam",
253
250
    .type           = AVMEDIA_TYPE_VIDEO,
254
 
    .id             = CODEC_ID_PAM,
 
251
    .id             = AV_CODEC_ID_PAM,
255
252
    .priv_data_size = sizeof(PNMContext),
256
253
    .init           = ff_pnm_init,
257
254
    .close          = ff_pnm_end,
258
255
    .decode         = pnm_decode_frame,
259
256
    .capabilities   = CODEC_CAP_DR1,
260
 
    .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
261
 
    .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
 
257
    .long_name      = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
262
258
};
263
259
#endif