comparison tiffenc.c @ 10634:e15eb76d9e47 libavcodec

use lzw compression in gif encoder
author bcoudurier
date Thu, 03 Dec 2009 19:17:39 +0000
parents 38cfe222e1a4
children 8a4984c5cacc
comparison
equal deleted inserted replaced
10633:66242b8fbd32 10634:e15eb76d9e47
30 #endif 30 #endif
31 #include "bytestream.h" 31 #include "bytestream.h"
32 #include "tiff.h" 32 #include "tiff.h"
33 #include "rle.h" 33 #include "rle.h"
34 #include "lzw.h" 34 #include "lzw.h"
35 #include "put_bits.h"
35 36
36 #define TIFF_MAX_ENTRY 32 37 #define TIFF_MAX_ENTRY 32
37 38
38 /** sizes of various TIFF field types (string size = 1)*/ 39 /** sizes of various TIFF field types (string size = 1)*/
39 static const uint8_t type_sizes2[6] = { 40 static const uint8_t type_sizes2[6] = {
350 if(s->compr == TIFF_LZW) 351 if(s->compr == TIFF_LZW)
351 s->lzws = av_malloc(ff_lzw_encode_state_size); 352 s->lzws = av_malloc(ff_lzw_encode_state_size);
352 for (i = 0; i < s->height; i++) { 353 for (i = 0; i < s->height; i++) {
353 if (strip_sizes[i / s->rps] == 0) { 354 if (strip_sizes[i / s->rps] == 0) {
354 if(s->compr == TIFF_LZW){ 355 if(s->compr == TIFF_LZW){
355 ff_lzw_encode_init(s->lzws, ptr, s->buf_size - (*s->buf - s->buf_start), 12); 356 ff_lzw_encode_init(s->lzws, ptr, s->buf_size - (*s->buf - s->buf_start),
357 12, FF_LZW_TIFF, put_bits);
356 } 358 }
357 strip_offsets[i / s->rps] = ptr - buf; 359 strip_offsets[i / s->rps] = ptr - buf;
358 } 360 }
359 if (is_yuv){ 361 if (is_yuv){
360 pack_yuv(s, yuv_line, i); 362 pack_yuv(s, yuv_line, i);
370 } 372 }
371 strip_sizes[i / s->rps] += n; 373 strip_sizes[i / s->rps] += n;
372 ptr += n; 374 ptr += n;
373 if(s->compr == TIFF_LZW && (i==s->height-1 || i%s->rps == s->rps-1)){ 375 if(s->compr == TIFF_LZW && (i==s->height-1 || i%s->rps == s->rps-1)){
374 int ret; 376 int ret;
375 ret = ff_lzw_encode_flush(s->lzws); 377 ret = ff_lzw_encode_flush(s->lzws, flush_put_bits);
376 strip_sizes[(i / s->rps )] += ret ; 378 strip_sizes[(i / s->rps )] += ret ;
377 ptr += ret; 379 ptr += ret;
378 } 380 }
379 } 381 }
380 if(s->compr == TIFF_LZW) 382 if(s->compr == TIFF_LZW)