41 #define TIFF_MAX_ENTRY 32
96 static void tnput(uint8_t ** p,
int n,
const uint8_t * val,
enum TiffTypes type,
101 flip ^= ((
int[]) {0, 0, 0, 1, 3, 3})[type];
104 *(*p)++ = val[i ^
flip];
123 bytestream_put_le16(&entries_ptr, tag);
124 bytestream_put_le16(&entries_ptr, type);
125 bytestream_put_le32(&entries_ptr, count);
128 tnput(&entries_ptr, count, ptr_val, type, 0);
130 bytestream_put_le32(&entries_ptr, *s->
buf - s->
buf_start);
132 tnput(s->
buf, count, ptr_val, type, 0);
156 uint8_t * dst,
int n,
int compr)
165 if (compress(dst, &zlen, src, n) != Z_OK) {
193 for (i = 0; i < w; i++){
204 int buf_size,
void *
data)
214 uint32_t *strip_sizes =
NULL;
215 uint32_t *strip_offsets =
NULL;
217 uint32_t res[2] = { 72, 1 };
218 static const uint16_t bpp_tab[] = { 8, 8, 8, 8 };
221 uint8_t *yuv_line =
NULL;
222 int shift_h, shift_v;
227 s->buf_size = buf_size;
232 avctx->coded_frame= &s->picture;
234 #if FF_API_TIFFENC_COMPLEVEL
237 "algorithm is deprecated. Please use the compression_algo private "
238 "option instead.\n");
239 if (avctx->compression_level == 0) {
241 }
else if(avctx->compression_level == 2) {
244 }
else if ((avctx->compression_level >= 3)) {
250 s->width = avctx->width;
251 s->height = avctx->height;
252 s->subsampling[0] = 1;
253 s->subsampling[1] = 1;
255 switch (avctx->pix_fmt) {
258 s->photometric_interpretation = 2;
262 s->photometric_interpretation = 1;
266 s->photometric_interpretation = 3;
270 s->photometric_interpretation = 1;
274 s->photometric_interpretation = 0;
281 s->photometric_interpretation = 6;
284 s->bpp = 8 + (16 >> (shift_h + shift_v));
285 s->subsampling[0] = 1 << shift_h;
286 s->subsampling[1] = 1 << shift_v;
292 "This colors format is not supported\n");
296 s->bpp_tab_size = (s->bpp >> 3);
302 s->rps =
FFMAX(8192 / (((s->width * s->bpp) >> 3) + 1), 1);
303 s->rps = ((s->rps - 1) / s->subsampling[1] + 1) * s->subsampling[1];
305 strips = (s->height - 1) / s->rps + 1;
311 bytestream_put_le16(&ptr, 0x4949);
312 bytestream_put_le16(&ptr, 42);
315 bytestream_put_le32(&ptr, 0);
317 strip_sizes =
av_mallocz(
sizeof(*strip_sizes) * strips);
318 strip_offsets =
av_mallocz(
sizeof(*strip_offsets) * strips);
320 bytes_per_row = (((s->width - 1)/s->subsampling[0] + 1) * s->bpp
321 * s->subsampling[0] * s->subsampling[1] + 7) >> 3;
324 if (yuv_line ==
NULL){
336 zlen = bytes_per_row * s->rps;
338 strip_offsets[0] = ptr - buf;
340 for (j = 0; j < s->rps; j++) {
343 memcpy(zbuf + zn, yuv_line, bytes_per_row);
344 j += s->subsampling[1] - 1;
347 memcpy(zbuf + j * bytes_per_row,
348 p->data[0] + j * p->linesize[0], bytes_per_row);
358 strip_sizes[0] = ptr - buf - strip_offsets[0];
364 for (i = 0; i < s->height; i++) {
365 if (strip_sizes[i / s->rps] == 0) {
370 strip_offsets[i / s->rps] = ptr - buf;
374 n =
encode_strip(s, yuv_line, ptr, bytes_per_row, s->compr);
375 i += s->subsampling[1] - 1;
379 ptr, bytes_per_row, s->compr);
384 strip_sizes[i / s->rps] += n;
386 if(s->compr ==
TIFF_LZW && (i==s->height-1 || i%s->rps == s->rps-1)){
389 strip_sizes[(i / s->rps )] += ret ;
424 uint16_t pal[256 * 3];
425 for (i = 0; i < 256; i++) {
426 uint32_t rgb = *(uint32_t *) (p->data[1] + i * 4);
427 pal[i] = ((rgb >> 16) & 0xff) * 257;
428 pal[i + 256] = ((rgb >> 8 ) & 0xff) * 257;
429 pal[i + 512] = ( rgb & 0xff) * 257;
435 uint32_t refbw[12] = {15, 1, 235, 1, 128, 1, 240, 1, 128, 1, 240, 1};
439 bytestream_put_le32(&offset, ptr - buf);
443 bytestream_put_le16(&ptr, s->num_entries);
445 bytestream_put_le32(&ptr, 0);
456 #define OFFSET(x) offsetof(TiffEncoderContext, x)
457 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM