[Ffmpeg-devel] [PATCH] TIFF encoder (Google SoC qualification task)
Kamil Nowosad
k.nowosad
Wed Apr 4 12:07:40 CEST 2007
Hi
I've attached two another patches.
The first one changes field invert in TiffEncoderContext to photometric_interpretation.
The second changes the tiff encoder code, so that it uses
AVCodecContext.coder_type, instead of compression_level.
--
Best regards,
Kamil Nowosad
-------------- next part --------------
Index: libavcodec/tiffenc.c
===================================================================
--- libavcodec/tiffenc.c (wersja 8622)
+++ libavcodec/tiffenc.c (kopia robocza)
@@ -44,7 +44,7 @@
unsigned int bpp; ///< bits per pixel
int compr; ///< compression level
int bpp_tab_size; ///< bpp_tab size
- int invert; ///< photometric interpretation
+ int photometric interpretation; ///< photometric interpretation
int strips; ///< number of strips
int rps; ///< row per strip
uint8_t entries[TIFF_MAX_ENTRY*12]; ///< entires in header
@@ -202,23 +202,23 @@
switch (avctx->pix_fmt) {
case PIX_FMT_RGB24:
s->bpp = 24;
- s->invert = 2;
+ s->photometric_interpretation = 2;
break;
case PIX_FMT_GRAY8:
s->bpp = 8;
- s->invert = 1;
+ s->photometric_interpretation = 1;
break;
case PIX_FMT_PAL8:
s->bpp = 8;
- s->invert = 3;
+ s->photometric_interpretation = 3;
break;
case PIX_FMT_MONOBLACK:
s->bpp = 1;
- s->invert = 1;
+ s->photometric_interpretation = 1;
break;
case PIX_FMT_MONOWHITE:
s->bpp = 1;
- s->invert = 0;
+ s->photometric_interpretation = 0;
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
@@ -300,7 +300,7 @@
add_entry(s, TIFF_BPP, TIFF_SHORT, s->bpp_tab_size, bpp_tab);
add_entry(s, TIFF_COMPR, TIFF_SHORT, 1, (uint16_t[]) {s->compr});
- add_entry(s, TIFF_INVERT, TIFF_SHORT, 1, (uint16_t[]) {s->invert});
+ add_entry(s, TIFF_INVERT, TIFF_SHORT, 1, (uint16_t[]) {s->photometric_interpretation});
add_entry(s, TIFF_STRIP_OFFS, TIFF_LONG, strips, strip_offsets);
if (s->bpp_tab_size)
-------------- next part --------------
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c (wersja 8622)
+++ libavcodec/utils.c (kopia robocza)
@@ -633,7 +633,7 @@
{"color_table_id", NULL, OFFSET(color_table_id), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"internal_buffer_count", NULL, OFFSET(internal_buffer_count), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"global_quality", NULL, OFFSET(global_quality), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
-{"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "coder"},
+{"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, FF_CODER_TYPE_DEFAULT, INT_MIN, INT_MAX, V|E, "coder"},
{"vlc", "variable length coder / huffman coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_VLC, INT_MIN, INT_MAX, V|E, "coder"},
{"ac", "arithmetic coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_AC, INT_MIN, INT_MAX, V|E, "coder"},
{"raw", "raw (no encoding)", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_RAW, INT_MIN, INT_MAX, V|E, "coder"},
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (wersja 8622)
+++ libavcodec/avcodec.h (kopia robocza)
@@ -1566,9 +1566,10 @@
*/
int global_quality;
+#define FF_CODER_TYPE_DEFAULT -1
#define FF_CODER_TYPE_VLC 0
#define FF_CODER_TYPE_AC 1
-#define FF_CODER_TYPE_RAW 2
+#define FF_CODER_TYPE_RAW 2 ///< no coder
#define FF_CODER_TYPE_RLE 3
#define FF_CODER_TYPE_DEFLATE 4
/**
Index: libavcodec/tiffenc.c
===================================================================
--- libavcodec/tiffenc.c (wersja 8622)
+++ libavcodec/tiffenc.c (kopia robocza)
@@ -30,6 +30,12 @@
#define TIFF_MAX_ENTRY 32
+#ifdef CONFIG_ZLIB
+#define TIFF_DEFAULT TIFF_DEFLATE
+#else
+#define TIFF_DEFAULT TIFF_PACKBITS
+#endif
+
/** sizes of various TIFF field types (string size = 1)*/
static const uint8_t type_sizes2[6] = {
0, 1, 1, 2, 4, 8
@@ -187,13 +193,26 @@
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
- s->compr = TIFF_PACKBITS;
- if (avctx->compression_level == 0) {
+ /** set the compression */
+ switch (avctx->coder_type) {
+ case FF_CODER_TYPE_DEFAULT:
+ s->compr = TIFF_DEFAULT;
+ break;
+ case FF_CODER_TYPE_RAW:
s->compr = TIFF_RAW;
+ break;
+ case FF_CODER_TYPE_RLE:
+ s->compr = TIFF_PACKBITS;
+ break;
#ifdef CONFIG_ZLIB
- } else if ((avctx->compression_level > 2)) {
+ case FF_CODER_TYPE_DEFLATE:
s->compr = TIFF_DEFLATE;
+ break;
#endif
+ default:
+ av_log(avctx, AV_LOG_ERROR,
+ "This compression not supported\n");
+ return -1;
}
s->width = avctx->width;
More information about the ffmpeg-devel
mailing list