Revision 66909bc4 libavcodec/faxcompr.c

View differences:

libavcodec/faxcompr.c
258 258
    return -1;
259 259
}
260 260

  
261
int ff_ccitt_unpack_1d(AVCodecContext *avctx,
261
int ff_ccitt_unpack(AVCodecContext *avctx,
262 262
                       const uint8_t *src, int srcsize,
263
                       uint8_t *dst, int height, int stride)
264
{
265
    int j;
266
    GetBitContext gb;
267
    int *runs, *last;
268

  
269
    runs = av_malloc(avctx->width * sizeof(runs[0]));
270
    last = av_malloc(avctx->width * sizeof(last[0]));
271
    init_get_bits(&gb, src, srcsize*8);
272
    for(j = 0; j < height; j++){
273
        if(find_group3_syncmarker(&gb, srcsize*8) < 0)
274
            break;
275
        if(decode_group3_1d_line(avctx, &gb, avctx->width, runs) < 0){
276
            put_line(dst, stride, avctx->width, last);
277
        }else{
278
            put_line(dst, stride, avctx->width, runs);
279
            FFSWAP(int*, last, runs);
280
        }
281
        dst += stride;
282
    }
283
    av_free(runs);
284
    av_free(last);
285
    return 0;
286
}
287

  
288
int ff_ccitt_unpack_2d(AVCodecContext *avctx,
289
                       const uint8_t *src, int srcsize,
290
                       uint8_t *dst, int height, int stride, int g4)
263
                       uint8_t *dst, int height, int stride, enum TiffCompr compr)
291 264
{
292 265
    int j;
293 266
    GetBitContext gb;
......
301 274
    ref[2] = 0;
302 275
    init_get_bits(&gb, src, srcsize*8);
303 276
    for(j = 0; j < height; j++){
304
        if(g4){
277
        if(compr == TIFF_G4){
305 278
            ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, ref);
306 279
            if(ret < 0){
307 280
                av_free(runs);
......
311 284
        }else{
312 285
            if(find_group3_syncmarker(&gb, srcsize*8) < 0)
313 286
                break;
314
            if(get_bits1(&gb))
287
            if(compr==TIFF_CCITT_RLE || get_bits1(&gb))
315 288
                ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs);
316 289
            else
317 290
                ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, ref);

Also available in: Unified diff