changeset 8237:d7bc284a2b4a

aspect ratio clenaup & a/b type aspect argument patch from (Rmi Guyomarch <rguyom at pobox dot com>)
author michael
date Wed, 20 Nov 2002 13:16:09 +0000
parents 7e2ca93330d0
children 3f5788602dfd
files libmpcodecs/vd_ffmpeg.c libmpcodecs/ve_lavc.c
diffstat 2 files changed, 27 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Tue Nov 19 23:35:51 2002 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Wed Nov 20 13:16:09 2002 +0000
@@ -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;
--- a/libmpcodecs/ve_lavc.c	Tue Nov 19 23:35:51 2002 +0000
+++ b/libmpcodecs/ve_lavc.c	Wed Nov 20 13:16:09 2002 +0000
@@ -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