changeset 2373:f977a8871c2c libavcodec

split ffhuffyuv into 2 codecs: "huffyuv" is compatible with the official version "ffvhuff" contains our improvements
author lorenm
date Sun, 28 Nov 2004 18:29:38 +0000
parents 2d95a6cd757a
children b36811e1386a
files allcodecs.c avcodec.h huffyuv.c
diffstat 3 files changed, 54 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/allcodecs.c	Sun Nov 28 15:33:15 2004 +0000
+++ b/allcodecs.c	Sun Nov 28 18:29:38 2004 +0000
@@ -83,6 +83,7 @@
     register_avcodec(&pbm_encoder);
     register_avcodec(&pam_encoder);
     register_avcodec(&huffyuv_encoder);
+    register_avcodec(&ffvhuff_encoder);
     register_avcodec(&asv1_encoder);
     register_avcodec(&asv2_encoder);
     register_avcodec(&ffv1_encoder);
@@ -143,6 +144,7 @@
     register_avcodec(&mace3_decoder);
     register_avcodec(&mace6_decoder);
     register_avcodec(&huffyuv_decoder);
+    register_avcodec(&ffvhuff_decoder);
     register_avcodec(&ffv1_decoder);
     register_avcodec(&snow_decoder);
     register_avcodec(&cyuv_decoder);
--- a/avcodec.h	Sun Nov 28 15:33:15 2004 +0000
+++ b/avcodec.h	Sun Nov 28 18:29:38 2004 +0000
@@ -17,7 +17,7 @@
 
 #define FFMPEG_VERSION_INT     0x000409
 #define FFMPEG_VERSION         "0.4.9-pre1"
-#define LIBAVCODEC_BUILD       4733
+#define LIBAVCODEC_BUILD       4734
 
 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
 #define LIBAVCODEC_VERSION     FFMPEG_VERSION
@@ -99,6 +99,7 @@
     CODEC_ID_PGM,
     CODEC_ID_PGMYUV,
     CODEC_ID_PAM,
+    CODEC_ID_FFVHUFF,
 
     /* various pcm "codecs" */
     CODEC_ID_PCM_S16LE= 0x10000,
@@ -1816,6 +1817,7 @@
 extern AVCodec wmv1_encoder;
 extern AVCodec wmv2_encoder;
 extern AVCodec huffyuv_encoder;
+extern AVCodec ffvhuff_encoder;
 extern AVCodec h264_encoder;
 extern AVCodec asv1_encoder;
 extern AVCodec asv2_encoder;
@@ -1858,6 +1860,7 @@
 extern AVCodec mace3_decoder;
 extern AVCodec mace6_decoder;
 extern AVCodec huffyuv_decoder;
+extern AVCodec ffvhuff_decoder;
 extern AVCodec oggvorbis_decoder;
 extern AVCodec cyuv_decoder;
 extern AVCodec h264_decoder;
--- a/huffyuv.c	Sun Nov 28 15:33:15 2004 +0000
+++ b/huffyuv.c	Sun Nov 28 18:29:38 2004 +0000
@@ -495,10 +495,6 @@
     
     switch(avctx->pix_fmt){
     case PIX_FMT_YUV420P:
-        if(avctx->strict_std_compliance>=0){
-            av_log(avctx, AV_LOG_ERROR, "Warning: YV12-huffyuv is not supported by windows huffyuv use a different colorspace or use (v)strict=-1\n");
-            return -1;
-        }
         s->bitstream_bpp= 12;
         break;
     case PIX_FMT_YUV422P:
@@ -512,22 +508,30 @@
     s->decorrelate= s->bitstream_bpp >= 24;
     s->predictor= avctx->prediction_method;
     s->interlaced= avctx->flags&CODEC_FLAG_INTERLACED_ME ? 1 : 0;
-    if(s->interlaced != ( height > 288 )){
-        av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n");
-    }
     if(avctx->context_model==1){
         s->context= avctx->context_model;
-        if(avctx->strict_std_compliance>=0){
-            av_log(avctx, AV_LOG_ERROR, "Warning: per-frame huffman tables are not supported by windows huffyuv; use context=0 or use (v)strict=-1\n");
-            return -1;
-        }
         if(s->flags & (CODEC_FLAG_PASS1|CODEC_FLAG_PASS2)){
             av_log(avctx, AV_LOG_ERROR, "context=1 is not compatible with 2 pass huffyuv encoding\n");
             return -1;
         }
-        av_log(avctx, AV_LOG_INFO, "using per-frame huffman tables\n");
     }else s->context= 0;
     
+    if(avctx->codec->id==CODEC_ID_HUFFYUV){
+        if(avctx->pix_fmt==PIX_FMT_YUV420P){
+            av_log(avctx, AV_LOG_ERROR, "Error: YV12 is not supported by huffyuv; use vcodec=ffvhuff or format=422p\n");
+            return -1;
+        }
+        if(avctx->context_model){
+            av_log(avctx, AV_LOG_ERROR, "Error: per-frame huffman tables are not supported by huffyuv; use vcodec=ffvhuff\n");
+            return -1;
+        }
+        if(s->interlaced != ( height > 288 ))
+            av_log(avctx, AV_LOG_INFO, "using huffyuv 2.2.0 or newer interlacing flag\n");
+    }else if(avctx->strict_std_compliance>=0){
+        av_log(avctx, AV_LOG_ERROR, "This codec is under development; files encoded with it may not be decodeable with future versions!!! Set vstrict=-1 to use it anyway.\n");
+        return -1;
+    }
+    
     ((uint8_t*)avctx->extradata)[0]= s->predictor;
     ((uint8_t*)avctx->extradata)[1]= s->bitstream_bpp;
     ((uint8_t*)avctx->extradata)[2]= 0x20 | (s->interlaced ? 0x10 : 0);
@@ -1172,6 +1176,14 @@
     AVOPTION_END()
 };
 
+static const AVOption ffvhuff_options[] =
+{
+    AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
+    AVOPTION_CODEC_INT("context_model", "context_model", context_model, 0, 2, 0),
+    AVOPTION_END()
+};
+
+
 AVCodec huffyuv_decoder = {
     "huffyuv",
     CODEC_TYPE_VIDEO,
@@ -1185,6 +1197,19 @@
     NULL
 };
 
+AVCodec ffvhuff_decoder = {
+    "ffvhuff",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_FFVHUFF,
+    sizeof(HYuvContext),
+    decode_init,
+    NULL,
+    decode_end,
+    decode_frame,
+    CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
+    NULL
+};
+
 #ifdef CONFIG_ENCODERS
 
 AVCodec huffyuv_encoder = {
@@ -1198,4 +1223,15 @@
     .options = huffyuv_options,
 };
 
+AVCodec ffvhuff_encoder = {
+    "ffvhuff",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_FFVHUFF,
+    sizeof(HYuvContext),
+    encode_init,
+    encode_frame,
+    encode_end,
+    .options = ffvhuff_options,
+};
+
 #endif //CONFIG_ENCODERS