[MPlayer-cvslog] r32008 - in trunk: Makefile libmpcodecs/dec_video.c libmpcodecs/vf_ass.c libmpcodecs/vf_vo.c mencoder.c mplayer.c
cigaes
subversion at mplayerhq.hu
Mon Aug 23 21:13:05 CEST 2010
Author: cigaes
Date: Mon Aug 23 21:13:05 2010
New Revision: 32008
Log:
EOSD/ASS code factorization
Move some code that was partially duplicated between vf_vo and vf_ass with
subtle differences into a separate file.
Modified:
trunk/Makefile
trunk/libmpcodecs/dec_video.c
trunk/libmpcodecs/vf_ass.c
trunk/libmpcodecs/vf_vo.c
trunk/mencoder.c
trunk/mplayer.c
Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/Makefile Mon Aug 23 21:13:05 2010 (r32008)
@@ -336,6 +336,7 @@ SRCS_COMMON = asxparser.c \
codec-cfg.c \
cpudetect.c \
edl.c \
+ eosd.c \
find_sub.c \
fmt-conversion.c \
m_config.c \
Modified: trunk/libmpcodecs/dec_video.c
==============================================================================
--- trunk/libmpcodecs/dec_video.c Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/libmpcodecs/dec_video.c Mon Aug 23 21:13:05 2010 (r32008)
@@ -39,6 +39,7 @@
#include "libmpdemux/stheader.h"
#include "vd.h"
#include "vf.h"
+#include "eosd.h"
#include "dec_video.h"
@@ -185,6 +186,7 @@ void uninit_video(sh_video_t *sh_video)
dlclose(sh_video->dec_handle);
#endif
vf_uninit_filter_chain(sh_video->vfilter);
+ eosd_uninit();
sh_video->initialized = 0;
}
Modified: trunk/libmpcodecs/vf_ass.c
==============================================================================
--- trunk/libmpcodecs/vf_ass.c Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/libmpcodecs/vf_ass.c Mon Aug 23 21:13:05 2010 (r32008)
@@ -39,10 +39,12 @@
#include "libvo/fastmemcpy.h"
#include "libvo/sub.h"
+#include "libvo/video_out.h"
#include "m_option.h"
#include "m_struct.h"
#include "libass/ass_mp.h"
+#include "eosd.h"
#define _r(c) ((c)>>24)
#define _g(c) (((c)>>16)&0xFF)
@@ -62,8 +64,6 @@ static const struct vf_priv_s {
// 0 = insert always
int auto_insert;
- ASS_Renderer* ass_priv;
-
unsigned char* planes[3];
unsigned char* dirty_rows;
} vf_priv_dflt;
@@ -73,6 +73,8 @@ static int config(struct vf_instance *vf
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
+ mp_eosd_res_t res = {0};
+
if (outfmt == IMGFMT_IF09) return 0;
vf->priv->outh = height + ass_top_margin + ass_bottom_margin;
@@ -87,10 +89,13 @@ static int config(struct vf_instance *vf
vf->priv->planes[2] = malloc(vf->priv->outw * vf->priv->outh);
vf->priv->dirty_rows = malloc(vf->priv->outh);
- if (vf->priv->ass_priv) {
- ass_configure(vf->priv->ass_priv, vf->priv->outw, vf->priv->outh, 0);
- ass_set_aspect_ratio(vf->priv->ass_priv, 1, 1);
- }
+ res.w = vf->priv->outw;
+ res.h = vf->priv->outh;
+ res.srcw = width;
+ res.srch = height;
+ res.mt = ass_top_margin;
+ res.mb = ass_bottom_margin;
+ eosd_configure(&res, 0);
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width, d_height, flags, outfmt);
}
@@ -324,10 +329,7 @@ static int render_frame(struct vf_instan
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
- ASS_Image* images = 0;
- if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE))
- images = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, NULL);
-
+ ASS_Image* images = eosd_render_frame(pts, NULL);
prepare_image(vf, mpi);
if (images) render_frame(vf, mpi, images);
@@ -349,21 +351,15 @@ static int control(vf_instance_t *vf, in
{
switch (request) {
case VFCTRL_INIT_EOSD:
- vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data);
- if (!vf->priv->ass_priv) return CONTROL_FALSE;
- ass_configure_fonts(vf->priv->ass_priv);
return CONTROL_TRUE;
case VFCTRL_DRAW_EOSD:
- if (vf->priv->ass_priv) return CONTROL_TRUE;
- break;
+ return CONTROL_TRUE;
}
return vf_next_control(vf, request, data);
}
static void uninit(struct vf_instance *vf)
{
- if (vf->priv->ass_priv)
- ass_renderer_done(vf->priv->ass_priv);
if (vf->priv->planes[1])
free(vf->priv->planes[1]);
if (vf->priv->planes[2])
Modified: trunk/libmpcodecs/vf_vo.c
==============================================================================
--- trunk/libmpcodecs/vf_vo.c Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/libmpcodecs/vf_vo.c Mon Aug 23 21:13:05 2010 (r32008)
@@ -38,10 +38,6 @@
struct vf_priv_s {
double pts;
const vo_functions_t *vo;
-#ifdef CONFIG_ASS
- ASS_Renderer* ass_priv;
- int prev_visibility;
-#endif
};
#define video_out (vf->priv->vo)
@@ -81,11 +77,6 @@ static int config(struct vf_instance *vf
if(config_video_out(video_out,width,height,d_width,d_height,flags,"MPlayer",outfmt))
return 0;
-#ifdef CONFIG_ASS
- if (vf->priv->ass_priv)
- ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED));
-#endif
-
++vo_config_count;
return 1;
}
@@ -130,34 +121,17 @@ static int control(struct vf_instance *v
#ifdef CONFIG_ASS
case VFCTRL_INIT_EOSD:
{
- vf->priv->ass_priv = ass_renderer_init((ASS_Library*)data);
- if (!vf->priv->ass_priv) return CONTROL_FALSE;
- ass_configure_fonts(vf->priv->ass_priv);
- vf->priv->prev_visibility = 0;
return CONTROL_TRUE;
}
case VFCTRL_DRAW_EOSD:
{
EOSD_ImageList images = {NULL, 2};
+ mp_eosd_res_t res = {0};
double pts = vf->priv->pts;
- if (!vo_config_count || !vf->priv->ass_priv) return CONTROL_FALSE;
- if (sub_visibility && vf->priv->ass_priv && ass_track && (pts != MP_NOPTS_VALUE)) {
- mp_eosd_res_t res;
- memset(&res, 0, sizeof(res));
- if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
- double dar = (double) (res.w - res.ml - res.mr) / (res.h - res.mt - res.mb);
- ass_set_frame_size(vf->priv->ass_priv, res.w, res.h);
- ass_set_margins(vf->priv->ass_priv, res.mt, res.mb, res.ml, res.mr);
- ass_set_aspect_ratio(vf->priv->ass_priv, dar, (double)res.srcw/res.srch);
- }
-
- images.imgs = ass_mp_render_frame(vf->priv->ass_priv, ass_track, (pts+sub_delay) * 1000 + .5, &images.changed);
- if (!vf->priv->prev_visibility)
- images.changed = 2;
- vf->priv->prev_visibility = 1;
- } else
- vf->priv->prev_visibility = 0;
- vf->priv->prev_visibility = sub_visibility;
+ if (!vo_config_count) return CONTROL_FALSE;
+ if (video_out->control(VOCTRL_GET_EOSD_RES, &res) == VO_TRUE)
+ eosd_configure(&res, !!(vf->default_caps & VFCAP_EOSD_UNSCALED));
+ images.imgs = eosd_render_frame(pts, &images.changed);
return (video_out->control(VOCTRL_DRAW_EOSD, &images) == VO_TRUE) ? CONTROL_TRUE : CONTROL_FALSE;
}
#endif
@@ -222,13 +196,7 @@ static void draw_slice(struct vf_instanc
static void uninit(struct vf_instance *vf)
{
- if (vf->priv) {
-#ifdef CONFIG_ASS
- if (vf->priv->ass_priv)
- ass_renderer_done(vf->priv->ass_priv);
-#endif
free(vf->priv);
- }
}
//===========================================================================//
Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/mencoder.c Mon Aug 23 21:13:05 2010 (r32008)
@@ -97,6 +97,7 @@
#include "path.h"
#include "spudec.h"
#include "vobsub.h"
+#include "eosd.h"
int vo_doublebuffering=0;
@@ -1052,10 +1053,11 @@ default: {
#endif
sh_video->vfilter=append_filters(sh_video->vfilter);
+ eosd_init(sh_video->vfilter);
#ifdef CONFIG_ASS
if (ass_enabled)
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
+ eosd_ass_init(ass_library);
#endif
// after reading video params we should load subtitles because
Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c Mon Aug 23 01:38:40 2010 (r32007)
+++ trunk/mplayer.c Mon Aug 23 21:13:05 2010 (r32008)
@@ -124,6 +124,7 @@
#include "spudec.h"
#include "subreader.h"
#include "vobsub.h"
+#include "eosd.h"
#ifdef CONFIG_X11
#include "libvo/x11_common.h"
@@ -2322,10 +2323,11 @@ int reinit_video_chain(void) {
#endif
sh_video->vfilter=append_filters(sh_video->vfilter);
+ eosd_init(sh_video->vfilter);
#ifdef CONFIG_ASS
if (ass_enabled)
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
+ eosd_ass_init(ass_library);
#endif
current_module="init_video_codec";
More information about the MPlayer-cvslog
mailing list