File npv/config.h changed (mode: 100644) (index 6b052c1..44d737c) |
... |
... |
STATIC u8 *npv_faces[] = { |
11 |
11 |
"/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf", |
"/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf", |
12 |
12 |
0 |
0 |
13 |
13 |
}; |
}; |
|
14 |
|
/* |
|
15 |
|
* face em square pixel size can be very far from actual glyph size, then |
|
16 |
|
* give the user some adjustment super powers |
|
17 |
|
*/ |
|
18 |
|
STATIC u8 npv_em_adjust_numerator = 3; |
|
19 |
|
STATIC u8 npv_em_adjust_denominator = 2; |
14 |
20 |
/* for missing play/pause glyphs */ |
/* for missing play/pause glyphs */ |
15 |
21 |
#define NPV_FACES_ASCII_ONLY 1 |
#define NPV_FACES_ASCII_ONLY 1 |
16 |
22 |
/* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */ |
/* we don't use a xkb state machine, only bear 8bits truncated raw keycodes */ |
File npv/video/osd/local/code.frag.c changed (mode: 100644) (index 89e7c43..04dad3c) |
... |
... |
STATIC bool duration_resolve(int64_t *duration, avutil_rational_t *tb) |
328 |
328 |
STATIC u8 *timer_to_gs(int64_t ts, avutil_rational_t tb) |
STATIC u8 *timer_to_gs(int64_t ts, avutil_rational_t tb) |
329 |
329 |
{ |
{ |
330 |
330 |
/* P = Play, S = minus Sign */ |
/* P = Play, S = minus Sign */ |
331 |
|
static u8 gs[sizeof(TIMER_TMPL)]; |
|
|
331 |
|
static u8 gs[sizeof(TIMER_TMPL_MAX)]; |
332 |
332 |
u8 i; |
u8 i; |
333 |
333 |
bool is_neg; |
bool is_neg; |
334 |
334 |
int64_t remaining; |
int64_t remaining; |
|
... |
... |
STATIC void g_x(bool mode, FT_BitmapGlyph gb, struct pen_t *p) |
499 |
499 |
|
|
500 |
500 |
gb_sdf = gb->bitmap.buffer + gb->bitmap.pitch |
gb_sdf = gb->bitmap.buffer + gb->bitmap.pitch |
501 |
501 |
* gb_y + gb_x; |
* gb_y + gb_x; |
502 |
|
/* the default spread is 2 pixels */ |
|
503 |
|
if (161 <= *gb_sdf && *gb_sdf <= 255) |
|
504 |
|
pix_do(mode, 0xff, 0xff, 0xff, |
|
505 |
|
scaler_pix, restore_pix); |
|
506 |
|
else if (128 <= *gb_sdf && *gb_sdf <= 160) |
|
507 |
|
pix_do(mode, 0, 0, 0, scaler_pix, |
|
|
502 |
|
/* the spread is 2 pixels */ |
|
503 |
|
if (128 <= *gb_sdf) { |
|
504 |
|
if (*gb_sdf < 192) |
|
505 |
|
pix_do(mode, 0, 0, 0, scaler_pix, |
508 |
506 |
restore_pix); |
restore_pix); |
|
507 |
|
else |
|
508 |
|
pix_do(mode, 0xff, 0xff, 0xff, |
|
509 |
|
scaler_pix, restore_pix); |
|
510 |
|
} |
509 |
511 |
} |
} |
510 |
512 |
++gb_x; |
++gb_x; |
511 |
513 |
++x; |
++x; |
|
... |
... |
STATIC void rop_x(u8 mode, u8 *gs) |
522 |
524 |
u8 i; |
u8 i; |
523 |
525 |
|
|
524 |
526 |
if (mode == BLEND) |
if (mode == BLEND) |
525 |
|
memcpy(restore_l.timer_gs, gs, sizeof(TIMER_TMPL)); |
|
|
527 |
|
memcpy(restore_l.timer_gs, gs, sizeof(TIMER_TMPL_MAX)); |
526 |
528 |
pen.x = 0; |
pen.x = 0; |
527 |
529 |
pen.y = timer_baseline_l; |
pen.y = timer_baseline_l; |
528 |
530 |
i = 0; |
i = 0; |
File npv/video/osd/main.c changed (mode: 100644) (index 8994469..677d0b3) |
44 |
44 |
#define G_GREATER_THAN 18 |
#define G_GREATER_THAN 18 |
45 |
45 |
#define G_VERTICAL_BAR 19 |
#define G_VERTICAL_BAR 19 |
46 |
46 |
#define GS_N 20 |
#define GS_N 20 |
47 |
|
#define TIMER_TMPL "PS00:00:00/00:00:00" |
|
|
47 |
|
#define TIMER_TMPL_MAX "PPS00:00:00/00:00:00" |
|
48 |
|
#define TIMER_GS_N_MAX 20 |
48 |
49 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
49 |
50 |
#include "npv/video/osd/local/state.frag.c" |
#include "npv/video/osd/local/state.frag.c" |
50 |
51 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
|
71 |
72 |
#undef G_BLACK_LOWER_RIGHT_TRIANGLE |
#undef G_BLACK_LOWER_RIGHT_TRIANGLE |
72 |
73 |
#undef GS_N |
#undef GS_N |
73 |
74 |
#undef TIMER_TMPL |
#undef TIMER_TMPL |
|
75 |
|
#undef TIMER_TMPL_GS_N |
74 |
76 |
/*----------------------------------------------------------------------------*/ |
/*----------------------------------------------------------------------------*/ |
75 |
77 |
#define CLEANUP |
#define CLEANUP |
76 |
78 |
#include "npv/namespace/ffmpeg.h" |
#include "npv/namespace/ffmpeg.h" |
File npv/video/osd/public/code.frag.c changed (mode: 100644) (index 123905d..eb5ba94) |
... |
... |
STATIC void init_once(u8 **faces_files) |
92 |
92 |
STATIC void update_dimensions(void *scaler_pixs, u16 width, u16 height, |
STATIC void update_dimensions(void *scaler_pixs, u16 width, u16 height, |
93 |
93 |
u32 line_bytes_n) |
u32 line_bytes_n) |
94 |
94 |
{ |
{ |
|
95 |
|
static const FT_Int sdf_cfg_spread = 2; |
|
96 |
|
static const FT_Int sdf_cfg_flip_sign = 0; |
|
97 |
|
static const FT_Bool sdf_cfg_overlaps = (FT_Bool)false; |
95 |
98 |
FT_Error ft_r; |
FT_Error ft_r; |
96 |
99 |
FT_Face f; |
FT_Face f; |
97 |
100 |
FTC_ScalerRec scaler_rec; |
FTC_ScalerRec scaler_rec; |
|
... |
... |
STATIC void update_dimensions(void *scaler_pixs, u16 width, u16 height, |
102 |
105 |
* choices which may end up in the config file: |
* choices which may end up in the config file: |
103 |
106 |
* XXX: ascender in most font files ~ em height |
* XXX: ascender in most font files ~ em height |
104 |
107 |
*/ |
*/ |
105 |
|
if (height / 12 > 80) |
|
106 |
|
scaler_rec.height = height / 12; |
|
107 |
|
else |
|
108 |
|
scaler_rec.height = 80; |
|
109 |
|
scaler_rec.width = scaler_rec.height; |
|
110 |
|
pout("scaler:em to %ux%u pixels\n", scaler_rec.width, scaler_rec.height); |
|
|
108 |
|
scaler_rec.width = (FT_UInt)width / TIMER_GS_N_MAX \ |
|
109 |
|
* (FT_UInt)npv_em_adjust_numerator / (FT_UInt)npv_em_adjust_denominator; |
|
110 |
|
scaler_rec.height = scaler_rec.width; |
|
111 |
|
pout("scaler:heuristic:em to %ux%u pixels from width=%u pixels and user configuration\n", scaler_rec.width, scaler_rec.height, width); |
111 |
112 |
i = 0; |
i = 0; |
112 |
113 |
loop { |
loop { |
113 |
114 |
FT_Glyph g; |
FT_Glyph g; |
|
... |
... |
STATIC void update_dimensions(void *scaler_pixs, u16 width, u16 height, |
118 |
119 |
/* XXX: freetype cache wants ids with uniq ptrs */ |
/* XXX: freetype cache wants ids with uniq ptrs */ |
119 |
120 |
scaler_rec.face_id = |
scaler_rec.face_id = |
120 |
121 |
&(cache_l.faces.ids[cache_l.gs[i].face_id]); |
&(cache_l.faces.ids[cache_l.gs[i].face_id]); |
121 |
|
if (height / 12 > 80) |
|
122 |
|
scaler_rec.height = height / 12; |
|
123 |
|
else |
|
124 |
|
scaler_rec.height = 80; |
|
125 |
|
scaler_rec.width = scaler_rec.height; |
|
|
122 |
|
scaler_rec.width = (FT_UInt)width / TIMER_GS_N_MAX \ |
|
123 |
|
* (FT_UInt)npv_em_adjust_numerator / (FT_UInt)npv_em_adjust_denominator; |
|
124 |
|
scaler_rec.height = scaler_rec.width; |
126 |
125 |
scaler_rec.pixel = 1; |
scaler_rec.pixel = 1; |
127 |
126 |
/* |
/* |
128 |
127 |
* using the SDF render mode in order to draw properly the |
* using the SDF render mode in order to draw properly the |
129 |
128 |
* contour of glyphs |
* contour of glyphs |
130 |
129 |
*/ |
*/ |
|
130 |
|
ft_r = FT_Property_Set(npv_video_osd_library_l, "sdf", "spread", &sdf_cfg_spread); |
|
131 |
|
if (ft_r != FT_Err_Ok) |
|
132 |
|
fatal("freetype:unable to set the spread property of the sdf renderer:0x%02x\n",ft_r); |
|
133 |
|
ft_r = FT_Property_Set(npv_video_osd_library_l, "sdf", "flip_sign", &sdf_cfg_flip_sign); |
|
134 |
|
if (ft_r != FT_Err_Ok) |
|
135 |
|
fatal("freetype:unable to set the flip_sign property of the sdf renderer:0x%02x\n",ft_r); |
|
136 |
|
ft_r = FT_Property_Set(npv_video_osd_library_l, "sdf", "overlaps", &sdf_cfg_overlaps); |
|
137 |
|
if (ft_r != FT_Err_Ok) |
|
138 |
|
fatal("freetype:unable to set the overlaps property of the sdf renderer:0x%02x\n",ft_r); |
131 |
139 |
ft_r = FTC_ImageCache_LookupScaler(cache_l.img_cache, |
ft_r = FTC_ImageCache_LookupScaler(cache_l.img_cache, |
132 |
140 |
&scaler_rec, FT_LOAD_RENDER |
&scaler_rec, FT_LOAD_RENDER |
133 |
141 |
| FT_LOAD_TARGET_(FT_RENDER_MODE_SDF), |
| FT_LOAD_TARGET_(FT_RENDER_MODE_SDF), |