Revision 936cfbc5 libavcodec/cscd.c

View differences:

libavcodec/cscd.c
35 35
    unsigned char* decomp_buf;
36 36
} CamStudioContext;
37 37

  
38
static void copy_frame_default(AVFrame *f, const uint8_t *src,
38
static void copy_frame_default(AVFrame *f, const uint8_t *src, int src_stride,
39 39
                               int linelen, int height) {
40 40
    int i;
41 41
    uint8_t *dst = f->data[0];
42 42
    dst += (height - 1) * f->linesize[0];
43 43
    for (i = height; i; i--) {
44 44
        memcpy(dst, src, linelen);
45
        src += linelen;
45
        src += src_stride;
46 46
        dst -= f->linesize[0];
47 47
    }
48 48
}
49 49

  
50
static void add_frame_default(AVFrame *f, const uint8_t *src,
50
static void add_frame_default(AVFrame *f, const uint8_t *src, int src_stride,
51 51
                              int linelen, int height) {
52 52
    int i, j;
53 53
    uint8_t *dst = f->data[0];
......
55 55
    for (i = height; i; i--) {
56 56
        for (j = linelen; j; j--)
57 57
            *dst++ += *src++;
58
        src += src_stride - linelen;
58 59
        dst -= f->linesize[0] + linelen;
59 60
    }
60 61
}
61 62

  
62 63
#if !HAVE_BIGENDIAN
63
#define copy_frame_16 copy_frame_default
64
#define copy_frame_32 copy_frame_default
65
#define add_frame_16 add_frame_default
66
#define add_frame_32 add_frame_default
64
#define copy_frame_16(f, s, l, h) copy_frame_default(f, s, l, l, h)
65
#define copy_frame_32(f, s, l, h) copy_frame_default(f, s, l, l, h)
66
#define add_frame_16(f, s, l, h) add_frame_default(f, s, l, l, h)
67
#define add_frame_32(f, s, l, h) add_frame_default(f, s, l, l, h)
67 68
#else
68 69
static void copy_frame_16(AVFrame *f, const uint8_t *src,
69 70
                          int linelen, int height) {
......
192 193
              copy_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
193 194
              break;
194 195
          default:
195
              copy_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
196
              copy_frame_default(&c->pic, c->decomp_buf, FFALIGN(c->linelen, 4),
197
                                 c->linelen, c->height);
196 198
        }
197 199
    } else {
198 200
        c->pic.pict_type = FF_P_TYPE;
......
205 207
              add_frame_32(&c->pic, c->decomp_buf, c->linelen, c->height);
206 208
              break;
207 209
          default:
208
              add_frame_default(&c->pic, c->decomp_buf, c->linelen, c->height);
210
              add_frame_default(&c->pic, c->decomp_buf, FFALIGN(c->linelen, 4),
211
                                c->linelen, c->height);
209 212
        }
210 213
    }
211 214

  
......
216 219

  
217 220
static av_cold int decode_init(AVCodecContext *avctx) {
218 221
    CamStudioContext *c = avctx->priv_data;
222
    int stride;
219 223
    switch (avctx->bits_per_coded_sample) {
220 224
        case 16: avctx->pix_fmt = PIX_FMT_RGB555; break;
221 225
        case 24: avctx->pix_fmt = PIX_FMT_BGR24; break;
......
230 234
    c->pic.data[0] = NULL;
231 235
    c->linelen = avctx->width * avctx->bits_per_coded_sample / 8;
232 236
    c->height = avctx->height;
233
    c->decomp_size = c->height * c->linelen;
237
    stride = c->linelen;
238
    if (avctx->bits_per_coded_sample == 24)
239
        stride = FFALIGN(stride, 4);
240
    c->decomp_size = c->height * stride;
234 241
    c->decomp_buf = av_malloc(c->decomp_size + AV_LZO_OUTPUT_PADDING);
235 242
    if (!c->decomp_buf) {
236 243
        av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");

Also available in: Unified diff