1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

cleanup: some random minor code simplification and cleanup

This commit is contained in:
Uoti Urpala 2011-01-19 18:00:22 +02:00
parent 6d65f6889a
commit 8612c771fc
7 changed files with 19 additions and 22 deletions

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <ass/ass.h>
#include <ass/ass_types.h>
@ -280,7 +281,7 @@ ASS_Track *ass_read_stream(ASS_Library *library, const char *fname, char *charse
return track;
}
void ass_configure(ASS_Renderer *priv, int w, int h, int unscaled)
void ass_configure(ASS_Renderer *priv, int w, int h, bool unscaled)
{
int hinting;
ass_set_frame_size(priv, w, h);

View File

@ -22,6 +22,7 @@
#define MPLAYER_ASS_MP_H
#include <stdint.h>
#include <stdbool.h>
#include "config.h"
#include "subreader.h"
@ -46,9 +47,10 @@ extern int ass_hinting;
ASS_Track *ass_default_track(ASS_Library *library);
ASS_Track *ass_read_subdata(ASS_Library *library, sub_data *subdata,
double fps);
ASS_Track *ass_read_stream(ASS_Library *library, const char *fname, char *charset);
ASS_Track *ass_read_stream(ASS_Library *library, const char *fname,
char *charset);
void ass_configure(ASS_Renderer *priv, int w, int h, int hinting);
void ass_configure(ASS_Renderer *priv, int w, int h, bool unscaled);
void ass_configure_fonts(ASS_Renderer *priv);
ASS_Library *ass_init(void);

View File

@ -60,8 +60,6 @@ void set_default_mplayer_options(struct MPOpts *opts)
.use_lircc = 1,
#ifdef CONFIG_APPLE_REMOTE
.use_ar = 1,
#else
.use_ar = 0,
#endif
.default_bindings = 1,
}

View File

@ -40,7 +40,7 @@ struct vf_priv_s {
struct vo *vo;
#ifdef CONFIG_ASS
ASS_Renderer *ass_priv;
int prev_visibility;
bool prev_visibility;
double scale_ratio;
#endif
};
@ -84,7 +84,8 @@ static int config(struct vf_instance *vf,
vf->priv->scale_ratio = (double) d_width / d_height * height / width;
if (vf->priv->ass_priv)
ass_configure(vf->priv->ass_priv, width, height, !!(vf->default_caps & VFCAP_EOSD_UNSCALED));
ass_configure(vf->priv->ass_priv, width, height,
vf->default_caps & VFCAP_EOSD_UNSCALED);
#endif
return 1;
@ -133,7 +134,7 @@ static int control(struct vf_instance *vf, int request, void* data)
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;
vf->priv->prev_visibility = false;
return CONTROL_TRUE;
}
case VFCTRL_DRAW_EOSD:
@ -142,10 +143,8 @@ static int control(struct vf_instance *vf, int request, void* data)
mp_eosd_images_t images = {NULL, 2};
double pts = video_out->next_pts;
if (!video_out->config_ok || !vf->priv->ass_priv) return CONTROL_FALSE;
if (sub_visibility && vf->priv->ass_priv && osd->ass_track
&& (pts != MP_NOPTS_VALUE)) {
mp_eosd_res_t res;
memset(&res, 0, sizeof(res));
if (sub_visibility && osd->ass_track && (pts != MP_NOPTS_VALUE)) {
struct mp_eosd_res res = {0};
if (vo_control(video_out, VOCTRL_GET_EOSD_RES, &res) == VO_TRUE) {
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);
@ -158,9 +157,9 @@ static int control(struct vf_instance *vf, int request, void* data)
&images.changed);
if (!vf->priv->prev_visibility)
images.changed = 2;
vf->priv->prev_visibility = 1;
vf->priv->prev_visibility = true;
} else
vf->priv->prev_visibility = 0;
vf->priv->prev_visibility = false;
return vo_control(video_out, VOCTRL_DRAW_EOSD, &images) == VO_TRUE;
}
#endif

View File

@ -77,7 +77,7 @@ struct voctrl_get_equalizer_args {
#define VOCTRL_BORDER 27
#define VOCTRL_DRAW_EOSD 28
#define VOCTRL_GET_EOSD_RES 29
typedef struct {
typedef struct mp_eosd_res {
int w, h; // screen dimensions, including black borders
int mt, mb, ml, mr; // borders (top, bottom, left, right)
} mp_eosd_res_t;

View File

@ -1803,7 +1803,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
draw_eosd(vo);
return VO_TRUE;
case VOCTRL_GET_EOSD_RES: {
mp_eosd_res_t *r = data;
struct mp_eosd_res *r = data;
r->w = vo->dwidth;
r->h = vo->dheight;
r->ml = r->mr = vc->border_x;

View File

@ -1093,9 +1093,8 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr
sub_data *subd = NULL;
struct ass_track *asst = NULL;
if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES) {
if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES)
return;
}
#ifdef CONFIG_ASS
if (opts->ass_enabled) {
@ -1108,10 +1107,8 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr
subd = sub_read_file(filename, fps, &mpctx->opts);
if (subd) {
asst = ass_read_subdata(ass_library, subd, fps);
if (asst) {
sub_free(subd);
subd = NULL;
}
sub_free(subd);
subd = NULL;
}
}
} else