[Mplayer-cvslog] CVS: main/libmpcodecs vd_ffmpeg.c,1.40,1.41

Arpi of Ize arpi at mplayerhq.hu
Fri Aug 2 21:39:01 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv6185

Modified Files:
	vd_ffmpeg.c 
Log Message:
colorspace part cleanup and support for IMGFMT_422P, _444P
i didn't removed the 422p->yuy2 conversion yet, because of swscaler can't
output yuy2 and 422p->yv12 loses quality :(


Index: vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- vd_ffmpeg.c	2 Aug 2002 12:19:21 -0000	1.40
+++ vd_ffmpeg.c	2 Aug 2002 19:38:59 -0000	1.41
@@ -46,10 +46,7 @@
     int do_dr1;
     int vo_inited;
     int convert;
-    int yuy2_support;
-#if LIBAVCODEC_BUILD >= 4615
-    int yvu9_support;
-#endif
+    int best_csp;
 } vd_ffmpeg_ctx;
 
 //#ifdef FF_POSTPROCESS
@@ -80,29 +77,27 @@
 // to set/get/query special features/parameters
 static int control(sh_video_t *sh,int cmd,void* arg,...){
     vd_ffmpeg_ctx *ctx = sh->context;
+    AVCodecContext *avctx = ctx->avctx;
     switch(cmd){
     case VDCTRL_QUERY_FORMAT:
-        switch(*((int*)arg)){
+	if( (*((int*)arg)) == ctx->best_csp ) return CONTROL_TRUE;//supported
+	// possible conversions:
+	switch( (*((int*)arg)) ){
         case IMGFMT_YV12:
         case IMGFMT_IYUV:
         case IMGFMT_I420:
-#if LIBAVCODEC_BUILD >= 4615
-            if(ctx->yvu9_support) return CONTROL_FALSE;
-            else
-#endif
-                                  return CONTROL_TRUE;
+	    // "converted" using pointer/stride modification
+	    if(avctx->pix_fmt==PIX_FMT_YUV420P) return CONTROL_TRUE;// u/v swap
+	    if(avctx->pix_fmt==PIX_FMT_YUV422P) return CONTROL_TRUE;// half stride
+	    break;
+#if 1
         case IMGFMT_YUY2:
-            if(ctx->yuy2_support) return CONTROL_TRUE;
-                                  return CONTROL_FALSE;
-#if LIBAVCODEC_BUILD >= 4615
-        case IMGFMT_YVU9:
-            if(ctx->yvu9_support) return CONTROL_TRUE;
-                                  return CONTROL_FALSE;
-#endif
-        default:
-            return CONTROL_FALSE;
-                
-        }
+	    // converted using yuv422ptoyuy2()
+	    if(avctx->pix_fmt==PIX_FMT_YUV422P) return CONTROL_TRUE;
+	    break;
+	}
+#endif
+        return CONTROL_FALSE;
     }
     return CONTROL_UNKNOWN;
 }
@@ -283,14 +278,21 @@
 	sh->disp_w = avctx->width;
 	sh->disp_h = avctx->height;
 	ctx->vo_inited=1;
-	ctx->yuy2_support=(avctx->pix_fmt==PIX_FMT_YUV422P);
+	switch(avctx->pix_fmt){
 #if LIBAVCODEC_BUILD >= 4615
-	ctx->yvu9_support=(avctx->pix_fmt==PIX_FMT_YUV410P);
+	case PIX_FMT_YUV410P: ctx->best_csp=IMGFMT_YVU9;break; //svq1
 #endif
-    	if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,
-	    ctx->yuy2_support ? IMGFMT_YUY2 : IMGFMT_YV12))
+	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_YUV444P: ctx->best_csp=IMGFMT_444P;break; //???
+	case PIX_FMT_YUV422:  ctx->best_csp=IMGFMT_YUY2;break; //???
+	default:
+	    ctx->best_csp=0;
+	}
+    	if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h, ctx->best_csp))
     		return -1;
-	ctx->convert=(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_YUY2);
+	ctx->convert=(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_YUY2
+	    && ctx->best_csp!=IMGFMT_YUY2); // yuv422p->yuy2 conversion
     }
     return 0;
 }
@@ -474,8 +476,8 @@
         mpi->stride[2]=lavc_picture.linesize[2];
     }
 
-    if(avctx->pix_fmt==PIX_FMT_YUV422P){
-	// we have 422p but user wants yv12 (420p)
+    if(avctx->pix_fmt==PIX_FMT_YUV422P && mpi->chroma_y_shift==1){
+	// we have 422p but user wants 420p
 	mpi->stride[1]*=2;
 	mpi->stride[2]*=2;
     }




More information about the MPlayer-cvslog mailing list