[Ffmpeg-devel] [PATCH] TIFF encoder (Google SoC qualification task)
Kamil Nowosad
k.nowosad
Fri Apr 13 13:33:06 CEST 2007
Hi
On Tue, Apr 10, 2007 at 07:15:35PM +0200, Michael Niedermayer wrote:
> > }
> > + if (!is_yuv)
> > s->bpp_tab_size = (s->bpp >> 3);
> [...]
> > + else
> > memcpy(zbuf + j * bytes_per_row,
> > p->data[0] + j * p->linesize[0], bytes_per_row);
> > zn += bytes_per_row;
>
> iam still waiting for a patch which fixes the indention after this ...
Sorry for the delay.
I've attached 3 patches:
The first patch fixes the indention.
The second changes the choice of compression from compression_level to
coder_type.
Third fixes the ffv1 encoder, becasue it broke when coder_type ==
FF_CODER_TYPE_DEFAULT passed.
--
Best regards,
Kamil Nowosad
-------------- next part --------------
Index: libavcodec/tiffenc.c
===================================================================
--- libavcodec/tiffenc.c (wersja 8725)
+++ libavcodec/tiffenc.c (kopia robocza)
@@ -332,8 +332,8 @@
j += s->subsampling[1] - 1;
}
else
- memcpy(zbuf + j * bytes_per_row,
- p->data[0] + j * p->linesize[0], bytes_per_row);
+ memcpy(zbuf + j * bytes_per_row,
+ p->data[0] + j * p->linesize[0], bytes_per_row);
zn += bytes_per_row;
}
n = encode_strip(s, zbuf, ptr, zn, s->compr);
-------------- next part --------------
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c (wersja 8725)
+++ libavcodec/utils.c (kopia robocza)
@@ -633,12 +633,13 @@
{"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"},
{"rle", "run-length coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_RLE, INT_MIN, INT_MAX, V|E, "coder"},
{"deflate", "deflate-based coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_DEFLATE, INT_MIN, INT_MAX, V|E, "coder"},
+{"lzw", "LZW coder", 0, FF_OPT_TYPE_CONST, FF_CODER_TYPE_LZW, INT_MIN, INT_MAX, V|E, "coder"},
{"context", "context model", OFFSET(context_model), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
Index: libavcodec/tiffenc.c
===================================================================
--- libavcodec/tiffenc.c (wersja 8725)
+++ libavcodec/tiffenc.c (kopia robocza)
@@ -36,6 +36,12 @@
#define TIFF_MAX_ENTRY 32
+#ifdef CONFIG_ZLIB
+#define TIFF_DEFAULT TIFF_DEFLATE
+#else
+#define TIFF_DEFAULT TIFF_LZW
+#endif
+
/** sizes of various TIFF field types (string size = 1)*/
static const uint8_t type_sizes2[6] = {
0, 1, 1, 2, 4, 8
@@ -224,15 +230,21 @@
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
- s->compr = TIFF_PACKBITS;
- if (avctx->compression_level == 0) {
+ if (avctx->coder_type == FF_CODER_TYPE_RAW)
s->compr = TIFF_RAW;
- } else if(avctx->compression_level == 2) {
- s->compr = TIFF_LZW;
+ else if (avctx->coder_type == FF_CODER_TYPE_RLE)
+ s->compr = TIFF_PACKBITS;
#ifdef CONFIG_ZLIB
- } else if ((avctx->compression_level >= 3)) {
+ else if (avctx->coder_type == FF_CODER_TYPE_DEFLATE)
s->compr = TIFF_DEFLATE;
#endif
+ else if (avctx->coder_type == FF_CODER_TYPE_LZW)
+ s->compr = TIFF_LZW;
+ else if (avctx->coder_type == FF_CODER_TYPE_DEFAULT)
+ s->compr = TIFF_DEFAULT;
+ else {
+ av_log(avctx, AV_LOG_ERROR, "selected coder is not supported\n");
+ goto fail;
}
s->width = avctx->width;
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (wersja 8725)
+++ libavcodec/avcodec.h (kopia robocza)
@@ -1572,11 +1572,13 @@
*/
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_RLE 3
#define FF_CODER_TYPE_DEFLATE 4
+#define FF_CODER_TYPE_LZW 5
/**
* coder type
* - encoding: Set by user.
-------------- next part --------------
Index: libavcodec/ffv1.c
===================================================================
--- libavcodec/ffv1.c (wersja 8725)
+++ libavcodec/ffv1.c (kopia robocza)
@@ -558,6 +558,13 @@
common_init(avctx);
s->version=0;
+ if (avctx->coder_type == FF_CODER_TYPE_DEFAULT)
+ avctx->coder_type = FF_CODER_TYPE_VLC;
+ else if (avctx->coder_type != FF_CODER_TYPE_VLC &&
+ avctx->coder_type != FF_CODER_TYPE_AC){
+ av_log(avctx, AV_LOG_ERROR, "selected coder is not supported\n");
+ return -1;
+ }
s->ac= avctx->coder_type;
s->plane_count=2;
More information about the ffmpeg-devel
mailing list