~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/bmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "bytestream.h"
24
24
#include "bmp.h"
25
25
 
26
 
static int bmp_decode_init(AVCodecContext *avctx){
 
26
static av_cold int bmp_decode_init(AVCodecContext *avctx){
27
27
    BMPContext *s = avctx->priv_data;
28
28
 
29
29
    avcodec_get_frame_defaults((AVFrame*)&s->picture);
34
34
 
35
35
static int bmp_decode_frame(AVCodecContext *avctx,
36
36
                            void *data, int *data_size,
37
 
                            uint8_t *buf, int buf_size)
 
37
                            const uint8_t *buf, int buf_size)
38
38
{
39
39
    BMPContext *s = avctx->priv_data;
40
40
    AVFrame *picture = data;
48
48
    uint32_t rgb[3];
49
49
    uint8_t *ptr;
50
50
    int dsize;
51
 
    uint8_t *buf0 = buf;
 
51
    const uint8_t *buf0 = buf;
52
52
 
53
53
    if(buf_size < 14){
54
54
        av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size);
84
84
        return -1;
85
85
    }
86
86
 
87
 
    width = bytestream_get_le32(&buf);
88
 
    height = bytestream_get_le32(&buf);
 
87
    if (ihsize == 40) {
 
88
        width = bytestream_get_le32(&buf);
 
89
        height = bytestream_get_le32(&buf);
 
90
    } else if (ihsize == 12) {
 
91
        width  = bytestream_get_le16(&buf);
 
92
        height = bytestream_get_le16(&buf);
 
93
    } else {
 
94
        av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome");
 
95
        return -1;
 
96
    }
89
97
 
90
98
    if(bytestream_get_le16(&buf) != 1){ /* planes */
91
99
        av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n");
94
102
 
95
103
    depth = bytestream_get_le16(&buf);
96
104
 
97
 
    if(ihsize > 16)
 
105
    if(ihsize == 40)
98
106
        comp = bytestream_get_le32(&buf);
99
107
    else
100
108
        comp = BMP_RGB;
111
119
        rgb[2] = bytestream_get_le32(&buf);
112
120
    }
113
121
 
114
 
    avctx->codec_id = CODEC_ID_BMP;
115
122
    avctx->width = width;
116
123
    avctx->height = height > 0? height: -height;
117
124
 
194
201
        break;
195
202
    case 16:
196
203
        for(i = 0; i < avctx->height; i++){
197
 
            uint16_t *src = (uint16_t *) buf;
 
204
            const uint16_t *src = (const uint16_t *) buf;
198
205
            uint16_t *dst = (uint16_t *) ptr;
199
206
 
200
207
            for(j = 0; j < avctx->width; j++)
206
213
        break;
207
214
    case 32:
208
215
        for(i = 0; i < avctx->height; i++){
209
 
            uint8_t *src = buf;
 
216
            const uint8_t *src = buf;
210
217
            uint8_t *dst = ptr;
211
218
 
212
219
            for(j = 0; j < avctx->width; j++){
232
239
    return buf_size;
233
240
}
234
241
 
235
 
static int bmp_decode_end(AVCodecContext *avctx)
 
242
static av_cold int bmp_decode_end(AVCodecContext *avctx)
236
243
{
237
244
    BMPContext* c = avctx->priv_data;
238
245
 
250
257
    bmp_decode_init,
251
258
    NULL,
252
259
    bmp_decode_end,
253
 
    bmp_decode_frame
 
260
    bmp_decode_frame,
 
261
    .long_name = "BMP image",
254
262
};