mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
aspect ratio clenaup
& a/b type aspect argument patch from (Rémi Guyomarch <rguyom at pobox dot com>) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8238 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
7a5657ff93
commit
899bf1b58e
@ -40,7 +40,7 @@ int quant_store[MBR+1][MBC+1];
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
AVCodecContext *avctx;
|
AVCodecContext *avctx;
|
||||||
int last_aspect;
|
float last_aspect;
|
||||||
int do_slices;
|
int do_slices;
|
||||||
int do_dr1;
|
int do_dr1;
|
||||||
int vo_inited;
|
int vo_inited;
|
||||||
@ -330,37 +330,16 @@ static int init_vo(sh_video_t *sh){
|
|||||||
vd_ffmpeg_ctx *ctx = sh->context;
|
vd_ffmpeg_ctx *ctx = sh->context;
|
||||||
AVCodecContext *avctx = ctx->avctx;
|
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->width != sh->disp_w ||
|
||||||
avctx->height != sh->disp_h ||
|
avctx->height != sh->disp_h ||
|
||||||
!ctx->vo_inited)
|
!ctx->vo_inited)
|
||||||
{
|
{
|
||||||
#if LIBAVCODEC_BUILD >= 4623
|
#if LIBAVCODEC_BUILD >= 4640
|
||||||
mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "aspect_ratio_info: %d\n", avctx->aspect_ratio_info);
|
mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "aspect_ratio: %d\n", avctx->aspect_ratio);
|
||||||
mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "par_width: %f\n", (float)avctx->aspected_width);
|
sh->aspect =
|
||||||
mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "par_height: %f\n", (float)avctx->aspected_height);
|
ctx->last_aspect = avctx->aspect_ratio;
|
||||||
#endif
|
#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_w = avctx->width;
|
||||||
sh->disp_h = avctx->height;
|
sh->disp_h = avctx->height;
|
||||||
ctx->vo_inited=1;
|
ctx->vo_inited=1;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ static int lavc_param_mpeg_quant=0;
|
|||||||
static int lavc_param_fdct=0;
|
static int lavc_param_fdct=0;
|
||||||
static int lavc_param_idct=0;
|
static int lavc_param_idct=0;
|
||||||
#if LIBAVCODEC_BUILD >= 4623
|
#if LIBAVCODEC_BUILD >= 4623
|
||||||
static float lavc_param_aspect=0.0;
|
static char* lavc_param_aspect = NULL;
|
||||||
#endif
|
#endif
|
||||||
static float lavc_param_lumi_masking= 0.0;
|
static float lavc_param_lumi_masking= 0.0;
|
||||||
static float lavc_param_dark_masking= 0.0;
|
static float lavc_param_dark_masking= 0.0;
|
||||||
@ -151,7 +152,7 @@ struct config lavcopts_conf[]={
|
|||||||
{"vfdct", &lavc_param_fdct, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
|
{"vfdct", &lavc_param_fdct, CONF_TYPE_INT, CONF_RANGE, 0, 10, NULL},
|
||||||
#endif
|
#endif
|
||||||
#if LIBAVCODEC_BUILD >= 4623
|
#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
|
#endif
|
||||||
#if LIBAVCODEC_BUILD >= 4625
|
#if LIBAVCODEC_BUILD >= 4625
|
||||||
{"lumi_mask", &lavc_param_lumi_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
{"lumi_mask", &lavc_param_lumi_masking, CONF_TYPE_FLOAT, CONF_RANGE, -1.0, 1.0, NULL},
|
||||||
@ -289,27 +290,27 @@ static int config(struct vf_instance_s* vf,
|
|||||||
lavc_venc_context->dark_masking= lavc_param_dark_masking;
|
lavc_venc_context->dark_masking= lavc_param_dark_masking;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LIBAVCODEC_BUILD >= 4623
|
#if LIBAVCODEC_BUILD >= 4640
|
||||||
if (lavc_param_aspect != 0.0)
|
if (lavc_param_aspect != NULL)
|
||||||
{
|
{
|
||||||
/* 625 means CIF */
|
int par_width, par_height, e;
|
||||||
if (lavc_param_aspect == (float)(4.0/3.0))
|
float ratio=0;
|
||||||
lavc_venc_context->aspect_ratio_info = FF_ASPECT_4_3_625;
|
|
||||||
else if (lavc_param_aspect == (float)(16.0/9.0))
|
e= sscanf (lavc_param_aspect, "%d/%d", &par_width, &par_height);
|
||||||
lavc_venc_context->aspect_ratio_info = FF_ASPECT_16_9_625;
|
if(e==2){
|
||||||
else if (lavc_param_aspect == (float)(221.0/100.0))
|
if(par_height)
|
||||||
{
|
ratio= (float)par_width / (float)par_height;
|
||||||
lavc_venc_context->aspect_ratio_info = FF_ASPECT_EXTENDED;
|
}else{
|
||||||
lavc_venc_context->aspected_width = 221;
|
e= sscanf (lavc_param_aspect, "%f", &ratio);
|
||||||
lavc_venc_context->aspected_height = 100;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (e && ratio > 0.1 && ratio < 10.0) {
|
||||||
printf("Unsupported aspect ratio (%f)\n", lavc_param_aspect);
|
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
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user