changeset 8190:c3716e345dfb

ffhuffyuv
author michael
date Thu, 14 Nov 2002 19:27:51 +0000
parents 332f083385ac
children 5dc5606f88a4
files etc/codecs.conf libmpcodecs/vd_ffmpeg.c libmpcodecs/ve_lavc.c
diffstat 3 files changed, 59 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/etc/codecs.conf	Thu Nov 14 12:19:31 2002 +0000
+++ b/etc/codecs.conf	Thu Nov 14 19:27:51 2002 +0000
@@ -230,6 +230,15 @@
 ; time to decide what to do with the mpeg4/divx variants...
 ; ff* is fastest...
 
+videocodec ffhuffyuv
+  info "FFHuffYUV"
+  status working
+  fourcc HFYU
+  driver ffmpeg
+  dll huffyuv
+  out YV12,YUY2,422P
+  out BGR32,BGR24
+
 videocodec ffsvq1
   info "FFmpeg Sorenson Video v1"
   status working
--- a/libmpcodecs/vd_ffmpeg.c	Thu Nov 14 12:19:31 2002 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Thu Nov 14 19:27:51 2002 +0000
@@ -236,6 +236,7 @@
     if (sh->bih && (sh->bih->biSize != sizeof(BITMAPINFOHEADER)) &&
 	(sh->format == mmioFOURCC('M','4','S','2') ||
 	 sh->format == mmioFOURCC('M','P','4','S') ||
+	 sh->format == mmioFOURCC('H','F','Y','U') ||
 	 sh->format == mmioFOURCC('W','M','V','2')
          ))
     {
@@ -243,6 +244,10 @@
 	avctx->extradata = malloc(avctx->extradata_size);
 	memcpy(avctx->extradata, sh->bih+1, avctx->extradata_size);
     }
+    
+#if LIBAVCODEC_BUILD >= 4639
+    avctx->bits_per_sample= sh->bih->biBitCount;
+#endif    
 
     /* open it */
     if (avcodec_open(avctx, lavc_codec) < 0) {
@@ -361,12 +366,14 @@
 	case PIX_FMT_YUV410P: ctx->best_csp=IMGFMT_YVU9;break; //svq1
 #endif
 	case PIX_FMT_YUV420P: ctx->best_csp=IMGFMT_YV12;break; //mpegs
-	case PIX_FMT_YUV422P: ctx->best_csp=IMGFMT_422P;break; //mjpeg
+	case PIX_FMT_YUV422P: ctx->best_csp=IMGFMT_422P;break; //mjpeg / huffyuv
 	case PIX_FMT_YUV444P: ctx->best_csp=IMGFMT_444P;break; //???
 #if LIBAVCODEC_BUILD >= 4631
 	case PIX_FMT_YUV411P: ctx->best_csp=IMGFMT_411P;break; //dv ntsc
 #endif
-	case PIX_FMT_YUV422:  ctx->best_csp=IMGFMT_YUY2;break; //???
+	case PIX_FMT_YUV422:  ctx->best_csp=IMGFMT_YUY2;break; //huffyuv perhaps in the future
+	case PIX_FMT_BGR24 :  ctx->best_csp=IMGFMT_BGR24;break; //huffyuv
+	case PIX_FMT_BGRA32:  ctx->best_csp=IMGFMT_BGR32;break; //huffyuv
 	default:
 	    ctx->best_csp=0;
 	}
--- a/libmpcodecs/ve_lavc.c	Thu Nov 14 12:19:31 2002 +0000
+++ b/libmpcodecs/ve_lavc.c	Thu Nov 14 19:27:51 2002 +0000
@@ -92,6 +92,8 @@
 static float lavc_param_p_masking= 0.0;
 static int lavc_param_normalize_aqp= 0;
 static int lavc_param_interlaced_dct= 0;
+static int lavc_param_prediction_method= FF_PRED_LEFT;
+static char *lavc_param_format="YV12";
 
 #include "cfgparser.h"
 
@@ -167,6 +169,10 @@
 #if LIBAVCODEC_BUILD >= 4629
         {"idct", &lavc_param_idct, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL},
 #endif
+#if LIBAVCODEC_BUILD >= 4639
+        {"pred", &lavc_param_prediction_method, CONF_TYPE_INT, CONF_RANGE, 0, 20, NULL},
+        {"format", &lavc_param_format, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#endif
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 #endif
@@ -341,7 +347,17 @@
 #if LIBAVCODEC_BUILD >= 4627
     if(lavc_param_interlaced_dct) lavc_venc_context->flags|= CODEC_FLAG_INTERLACED_DCT;
 #endif
-
+#if LIBAVCODEC_BUILD >= 4639
+    lavc_venc_context->prediction_method= lavc_param_prediction_method;
+    if(!strcasecmp(lavc_param_format, "YV12"))
+        lavc_venc_context->pix_fmt= PIX_FMT_YUV420P;
+    else if(!strcasecmp(lavc_param_format, "422P"))
+        lavc_venc_context->pix_fmt= PIX_FMT_YUV422P;
+    else{
+        mp_msg(MSGT_MENCODER,MSGL_ERR,"%s is not a supported format\n", lavc_param_format);
+        return 0;
+    }
+#endif
     /* lavc internal 2pass bitrate control */
     switch(lavc_param_vpass){
     case 1: 
@@ -407,6 +423,14 @@
     if(lavc_venc_context->stats_in) free(lavc_venc_context->stats_in);
     lavc_venc_context->stats_in= NULL;
 #endif
+#if LIBAVCODEC_BUILD >= 4639
+    if(lavc_venc_context->bits_per_sample)
+        mux_v->bih->biBitCount= lavc_venc_context->bits_per_sample;
+    if(lavc_venc_context->extradata_size){
+        memcpy(mux_v->bih + 1, lavc_venc_context->extradata, lavc_venc_context->extradata_size);
+        mux_v->bih->biSize= sizeof(BITMAPINFOHEADER) + lavc_venc_context->extradata_size;
+    }
+#endif
     
     return 1;
 }
@@ -421,7 +445,13 @@
     case IMGFMT_YV12:
     case IMGFMT_IYUV:
     case IMGFMT_I420:
-      return VFCAP_CSP_SUPPORTED | VFCAP_ACCEPT_STRIDE;
+        if(!strcasecmp(lavc_param_format, "YV12"))
+            return VFCAP_CSP_SUPPORTED | VFCAP_ACCEPT_STRIDE;
+        break;
+    case IMGFMT_422P:
+        if(!strcasecmp(lavc_param_format, "422P"))
+            return VFCAP_CSP_SUPPORTED | VFCAP_ACCEPT_STRIDE;
+        break;
     }
     return 0;
 }
@@ -486,6 +516,13 @@
 	memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+28);
 	mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+28;
     }
+    else if (lavc_param_vcodec && !strcasecmp(lavc_param_vcodec, "huffyuv"))
+    {
+    /* XXX: hack: huffyuv needs to store huffman tables (allthough we dunno the size yet ...) */
+	mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+1000);
+	memset(mux_v->bih, 0, sizeof(BITMAPINFOHEADER)+1000);
+	mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+1000;
+    }
     else
     {
 	mux_v->bih=malloc(sizeof(BITMAPINFOHEADER));
@@ -518,6 +555,8 @@
 	mux_v->bih->biCompression = mmioFOURCC('M', 'P', '4', '2');
     else if (!strcasecmp(lavc_param_vcodec, "wmv1"))
 	mux_v->bih->biCompression = mmioFOURCC('W', 'M', 'V', '1');
+    else if (!strcasecmp(lavc_param_vcodec, "huffyuv"))
+	mux_v->bih->biCompression = mmioFOURCC('H', 'F', 'Y', 'U');
     else
 	mux_v->bih->biCompression = mmioFOURCC(lavc_param_vcodec[0],
 		lavc_param_vcodec[1], lavc_param_vcodec[2], lavc_param_vcodec[3]); /* FIXME!!! */