[Mplayer-cvslog] CVS: main/libmpcodecs vd_ffmpeg.c,1.70,1.71 ve_lavc.c,1.39,1.40

Michael Niedermayer CVS michael at mplayerhq.hu
Wed Nov 20 14:16:31 CET 2002


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

Modified Files:
	vd_ffmpeg.c ve_lavc.c 
Log Message:
aspect ratio clenaup
& a/b type aspect argument patch from (Rémi Guyomarch <rguyom at pobox dot com>)


Index: vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- vd_ffmpeg.c	15 Nov 2002 00:12:38 -0000	1.70
+++ vd_ffmpeg.c	20 Nov 2002 13:16:09 -0000	1.71
@@ -40,7 +40,7 @@
 
 typedef struct {
     AVCodecContext *avctx;
-    int last_aspect;
+    float last_aspect;
     int do_slices;
     int do_dr1;
     int vo_inited;
@@ -330,37 +330,16 @@
     vd_ffmpeg_ctx *ctx = sh->context;
     AVCodecContext *avctx = ctx->avctx;
 
-    if (avctx->aspect_ratio_info != ctx->last_aspect ||
+    if (avctx->aspect_ratio != ctx->last_aspect ||
 	avctx->width != sh->disp_w ||
 	avctx->height != sh->disp_h ||
 	!ctx->vo_inited)
     {
-#if LIBAVCODEC_BUILD >= 4623
-	mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "aspect_ratio_info: %d\n", avctx->aspect_ratio_info);
-	mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "par_width: %f\n", (float)avctx->aspected_width);
-	mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "par_height: %f\n", (float)avctx->aspected_height);
+#if LIBAVCODEC_BUILD >= 4640
+	mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "aspect_ratio: %d\n", avctx->aspect_ratio);
+	sh->aspect = 
+        ctx->last_aspect = avctx->aspect_ratio;
 #endif
-	ctx->last_aspect = avctx->aspect_ratio_info;
-	switch(avctx->aspect_ratio_info)
-	{
-	    case FF_ASPECT_4_3_625:
-	    case FF_ASPECT_4_3_525:
-		sh->aspect = 4.0/3.0;
-		break;
-	    case FF_ASPECT_16_9_625:
-	    case FF_ASPECT_16_9_525:
-		sh->aspect = 16.0/9.0;
-		break;
-	    case FF_ASPECT_SQUARE:
-		sh->aspect = 0.0;
-		break;
-#if LIBAVCODEC_BUILD >= 4623
-	    case FF_ASPECT_EXTENDED:
-		if (avctx->aspected_width && avctx->aspected_height)
-		    sh->aspect = (float)avctx->aspected_width/(float)avctx->aspected_height;
-		break;
-#endif
-	}
 	sh->disp_w = avctx->width;
 	sh->disp_h = avctx->height;
 	ctx->vo_inited=1;

Index: ve_lavc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_lavc.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- ve_lavc.c	14 Nov 2002 22:36:16 -0000	1.39
+++ ve_lavc.c	20 Nov 2002 13:16:09 -0000	1.40
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <math.h>
 
 #include "../config.h"
 
@@ -83,7 +84,7 @@
 static int lavc_param_fdct=0;
 static int lavc_param_idct=0;
 #if LIBAVCODEC_BUILD >= 4623
-static float lavc_param_aspect=0.0;
+static char* lavc_param_aspect = NULL;
 #endif
 static float lavc_param_lumi_masking= 0.0;
 static float lavc_param_dark_masking= 0.0;
@@ -151,7 +152,7 @@
         {"vfdct", &lavc_param_fdct, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
 #endif
 #if LIBAVCODEC_BUILD >= 4623
-	{"aspect", &lavc_param_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 3.0, NULL},
+	{"aspect", &lavc_param_aspect, CONF_TYPE_STRING, 0, 0, 0, NULL},
 #endif
 #if LIBAVCODEC_BUILD >= 4625
 	{"lumi_mask", &lavc_param_lumi_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
@@ -289,27 +290,27 @@
     lavc_venc_context->dark_masking= lavc_param_dark_masking;
 #endif
 
-#if LIBAVCODEC_BUILD >= 4623
-    if (lavc_param_aspect != 0.0)
+#if LIBAVCODEC_BUILD >= 4640
+    if (lavc_param_aspect != NULL)
     {
-	/* 625 means CIF */
-	if (lavc_param_aspect == (float)(4.0/3.0))
-	    lavc_venc_context->aspect_ratio_info = FF_ASPECT_4_3_625;
-	else if (lavc_param_aspect == (float)(16.0/9.0))
-	    lavc_venc_context->aspect_ratio_info = FF_ASPECT_16_9_625;
-	else if (lavc_param_aspect == (float)(221.0/100.0))
-	{
-    	    lavc_venc_context->aspect_ratio_info = FF_ASPECT_EXTENDED;
-	    lavc_venc_context->aspected_width = 221;
-	    lavc_venc_context->aspected_height = 100;
+	int par_width, par_height, e;
+	float ratio=0;
+	
+	e= sscanf (lavc_param_aspect, "%d/%d", &par_width, &par_height);
+	if(e==2){
+            if(par_height)
+                ratio= (float)par_width / (float)par_height;
+        }else{
+	    e= sscanf (lavc_param_aspect, "%f", &ratio);
 	}
-	else
-	{
-	    printf("Unsupported aspect ratio (%f)\n", lavc_param_aspect);
+
+	if (e && ratio > 0.1 && ratio < 10.0) {
+	    lavc_venc_context->aspect_ratio= ratio;
+	    mp_dbg(MSGT_MENCODER, MSGL_DBG2, "aspect_ratio: %f\n", ratio);
+	} else {
+	    mp_dbg(MSGT_MENCODER, MSGL_ERR, "aspect ratio: cannot parse \"%s\"\n", lavc_param_aspect);
+	    return 0;
 	}
-	mp_dbg(MSGT_MENCODER, MSGL_DBG2, "aspect_ratio_info: %d\n", lavc_venc_context->aspect_ratio_info);
-	mp_dbg(MSGT_MENCODER, MSGL_DBG2, "par_width: %d\n", lavc_venc_context->aspected_width);
-	mp_dbg(MSGT_MENCODER, MSGL_DBG2, "par_height: %d\n", lavc_venc_context->aspected_height);
     }
 #endif
 




More information about the MPlayer-cvslog mailing list