Commit 6f0caee4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

transform: non functional changes to support more than 8-bits

parent 9dfcc9e5
...@@ -100,7 +100,7 @@ static void R270(int *sx, int *sy, int w, int h, int dx, int dy) ...@@ -100,7 +100,7 @@ static void R270(int *sx, int *sy, int w, int h, int dx, int dy)
typedef void (*convert_t)(int *, int *, int, int, int, int); typedef void (*convert_t)(int *, int *, int, int, int, int);
#define PLANAR(f) \ #define PLANAR(f) \
static void Planar##f(plane_t *restrict dst, const plane_t *restrict src) \ static void Plane8_##f(plane_t *restrict dst, const plane_t *restrict src) \
{ \ { \
for (int y = 0; y < dst->i_visible_lines; y++) { \ for (int y = 0; y < dst->i_visible_lines; y++) { \
for (int x = 0; x < dst->i_visible_pitch; x++) { \ for (int x = 0; x < dst->i_visible_pitch; x++) { \
...@@ -123,22 +123,27 @@ typedef struct { ...@@ -123,22 +123,27 @@ typedef struct {
bool is_rotated; bool is_rotated;
convert_t convert; convert_t convert;
convert_t iconvert; convert_t iconvert;
void (*planar)(plane_t *dst, const plane_t *src); void (*plane8)(plane_t *dst, const plane_t *src);
} transform_description_t; } transform_description_t;
static const transform_description_t descriptions[] = { #define DESC(str, rotated, f, invf) \
{ "90", true, R90, R270, PlanarR90, }, { str, rotated, f, invf, Plane8_##f, }
{ "180", false, R180, R180, PlanarR180, },
{ "270", true, R270, R90, PlanarR270, },
{ "hflip", false, HFlip, HFlip, PlanarHFlip, },
{ "vflip", false, VFlip, VFlip, PlanarVFlip, },
{ "", false, NULL, NULL, NULL, } static const transform_description_t descriptions[] = {
DESC("90", true, R90, R270),
DESC("180", false, R180, R180),
DESC("270", true, R270, R90),
DESC("hflip", false, HFlip, HFlip),
DESC("vflip", false, VFlip, VFlip),
}; };
static const size_t n_transforms =
sizeof (descriptions) / sizeof (descriptions[0]);
struct filter_sys_t { struct filter_sys_t {
const transform_description_t *dsc;
const vlc_chroma_description_t *chroma; const vlc_chroma_description_t *chroma;
void (*plane)(plane_t *, const plane_t *);
convert_t convert;
}; };
static picture_t *Filter(filter_t *filter, picture_t *src) static picture_t *Filter(filter_t *filter, picture_t *src)
...@@ -152,12 +157,8 @@ static picture_t *Filter(filter_t *filter, picture_t *src) ...@@ -152,12 +157,8 @@ static picture_t *Filter(filter_t *filter, picture_t *src)
} }
const vlc_chroma_description_t *chroma = sys->chroma; const vlc_chroma_description_t *chroma = sys->chroma;
if (chroma->plane_count < 3) {
/* TODO */
} else {
for (unsigned i = 0; i < chroma->plane_count; i++) for (unsigned i = 0; i < chroma->plane_count; i++)
sys->dsc->planar(&dst->p[i], &src->p[i]); sys->plane(&dst->p[i], &src->p[i]);
}
picture_CopyProperties(dst, src); picture_CopyProperties(dst, src);
picture_Release(src); picture_Release(src);
...@@ -170,11 +171,12 @@ static int Mouse(filter_t *filter, vlc_mouse_t *mouse, ...@@ -170,11 +171,12 @@ static int Mouse(filter_t *filter, vlc_mouse_t *mouse,
VLC_UNUSED( mold ); VLC_UNUSED( mold );
const video_format_t *fmt = &filter->fmt_out.video; const video_format_t *fmt = &filter->fmt_out.video;
const transform_description_t *dsc = filter->p_sys->dsc; const filter_sys_t *sys = filter->p_sys;
*mouse = *mnew; *mouse = *mnew;
dsc->convert(&mouse->i_x, &mouse->i_y, sys->convert(&mouse->i_x, &mouse->i_y,
fmt->i_visible_width, fmt->i_visible_height, mouse->i_x, mouse->i_y); fmt->i_visible_width, fmt->i_visible_height,
mouse->i_x, mouse->i_y);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -215,24 +217,27 @@ static int Open(vlc_object_t *object) ...@@ -215,24 +217,27 @@ static int Open(vlc_object_t *object)
sys->chroma = chroma; sys->chroma = chroma;
char *type_name = var_InheritString(filter, CFG_PREFIX"type"); char *type_name = var_InheritString(filter, CFG_PREFIX"type");
const transform_description_t *dsc = NULL;
sys->dsc = NULL; for (size_t i = 0; i < n_transforms; i++)
for (int i = 0; !sys->dsc && *descriptions[i].name; i++) { if (type_name && !strcmp(descriptions[i].name, type_name)) {
if (type_name && *type_name && !strcmp(descriptions[i].name, type_name)) dsc = &descriptions[i];
sys->dsc = &descriptions[i]; break;
} }
if (!sys->dsc) { if (dsc == NULL) {
sys->dsc = &descriptions[0]; dsc = &descriptions[0];
msg_Warn(filter, "No valid transform mode provided, using '%s'", sys->dsc->name); msg_Warn(filter, "No valid transform mode provided, using '%s'",
dsc->name);
} }
free(type_name); free(type_name);
if (sys->dsc->is_rotated) { sys->plane = dsc->plane8;
sys->convert = dsc->convert;
if (dsc->is_rotated) {
if (!filter->b_allow_fmt_out_change) { if (!filter->b_allow_fmt_out_change) {
msg_Err(filter, "Format change is not allowed"); msg_Err(filter, "Format change is not allowed");
free(sys); goto error;
return VLC_EGENERIC;
} }
dst->i_width = src->i_height; dst->i_width = src->i_height;
...@@ -247,8 +252,7 @@ static int Open(vlc_object_t *object) ...@@ -247,8 +252,7 @@ static int Open(vlc_object_t *object)
dst->i_y_offset = INT_MAX; dst->i_y_offset = INT_MAX;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
int tx, ty; int tx, ty;
sys->dsc->iconvert(&tx, &ty, dsc->iconvert(&tx, &ty, src->i_width, src->i_height,
src->i_width, src->i_height,
src->i_x_offset + i * (src->i_visible_width - 1), src->i_x_offset + i * (src->i_visible_width - 1),
src->i_y_offset + i * (src->i_visible_height - 1)); src->i_y_offset + i * (src->i_visible_height - 1));
dst->i_x_offset = __MIN(dst->i_x_offset, (unsigned)(1 + tx)); dst->i_x_offset = __MIN(dst->i_x_offset, (unsigned)(1 + tx));
...@@ -259,6 +263,9 @@ static int Open(vlc_object_t *object) ...@@ -259,6 +263,9 @@ static int Open(vlc_object_t *object)
filter->pf_video_filter = Filter; filter->pf_video_filter = Filter;
filter->pf_video_mouse = Mouse; filter->pf_video_mouse = Mouse;
return VLC_SUCCESS; return VLC_SUCCESS;
error:
free(sys);
return VLC_EGENERIC;
} }
static void Close(vlc_object_t *object) static void Close(vlc_object_t *object)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment