From 40ff19c88162e407bb6a1cd409ca0cb857f897de Mon Sep 17 00:00:00 2001 From: Thomas Schorpp Date: Wed, 9 Jan 2013 00:28:39 +0200 Subject: [PATCH] vf_stereo3d: add new input and output formats Add new input formats: side_by_side_half_width_left_first side_by_side_half_width_right_first. Add new output formats: anaglyph_green_magenta_dubois anaglyph_yellow_blue_dubois --- DOCS/man/en/vf.rst | 14 ++++++++++ libmpcodecs/vf_stereo3d.c | 70 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 71 insertions(+), 13 deletions(-) diff --git a/DOCS/man/en/vf.rst b/DOCS/man/en/vf.rst index 9d6cb77244..5e5007d1db 100644 --- a/DOCS/man/en/vf.rst +++ b/DOCS/man/en/vf.rst @@ -1341,6 +1341,12 @@ stereo3d[=in:out] side by side parallel (left eye left, right eye right) sbsr or side_by_side_right_first side by side crosseye (right eye left, left eye right) + sbs2l or side_by_side_half_width_left_first + side by side parallel with half width resolution (left eye left, + right eye right) + sbs2r or side_by_side_half_width_right_first + side by side crosseye with half width resolution (right eye left, + left eye right) abl or above_below_left_first above-below (left eye above, right eye below) abl or above_below_right_first @@ -1378,6 +1384,10 @@ stereo3d[=in:out] agmc or anaglyph_green_magenta_color anaglyph green/magenta colored (green filter on left eye, magenta filter on right eye) + agmd or anaglyph_green_magenta_dubois + anaglyph green/magenta colored optimized with the least squares + projection of dubois (green filter on left eye, magenta filter on + right eye) aybg or anaglyph_yellow_blue_gray anaglyph yellow/blue gray (yellow filter on left eye, blue filter on right eye) @@ -1387,6 +1397,10 @@ stereo3d[=in:out] aybc or anaglyph_yellow_blue_color anaglyph yellow/blue colored (yellow filter on left eye, blue filter on right eye) + aybd or anaglyph_yellow_blue_dubois + anaglyph yellow/blue colored optimized with the least squares + projection of dubois (yellow filter on left eye, blue filter on + right eye) irl or interleave_rows_left_first Interleaved rows (left eye has top row, right eye starts on next row) diff --git a/libmpcodecs/vf_stereo3d.c b/libmpcodecs/vf_stereo3d.c index 2c6f289e5d..2106b0819e 100644 --- a/libmpcodecs/vf_stereo3d.c +++ b/libmpcodecs/vf_stereo3d.c @@ -45,13 +45,17 @@ typedef enum stereo_code { ANAGLYPH_GM_GRAY, //anaglyph green/magenta gray ANAGLYPH_GM_HALF, //anaglyph green/magenta half colored ANAGLYPH_GM_COLOR, //anaglyph green/magenta colored + ANAGLYPH_GM_DUBOIS, //anaglyph green/magenta dubois ANAGLYPH_YB_GRAY, //anaglyph yellow/blue gray ANAGLYPH_YB_HALF, //anaglyph yellow/blue half colored ANAGLYPH_YB_COLOR, //anaglyph yellow/blue colored + ANAGLYPH_YB_DUBOIS, //anaglyph yellow/blue dubois MONO_L, //mono output for debugging (left eye only) MONO_R, //mono output for debugging (right eye only) SIDE_BY_SIDE_LR, //side by side parallel (left eye left, right eye right) SIDE_BY_SIDE_RL, //side by side crosseye (right eye left, left eye right) + SIDE_BY_SIDE_2_LR, //side by side parallel with half width resolution + SIDE_BY_SIDE_2_RL, //side by side crosseye with half width resolution ABOVE_BELOW_LR, //above-below (left eye above, right eye below) ABOVE_BELOW_RL, //above-below (right eye above, left eye below) ABOVE_BELOW_2_LR, //above-below with half height resolution @@ -72,37 +76,55 @@ typedef struct component { } component; //==global variables==// -static const int ana_coeff[10][3][6] = { - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_GRAY +static const int ana_coeff[][3][6] = { + [ANAGLYPH_RC_GRAY] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}}, - {{19595, 38470, 7471, 0, 0, 0}, //ANAGLYPH_RC_HALF + [ANAGLYPH_RC_HALF] = + {{19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{65536, 0, 0, 0, 0, 0}, //ANAGLYPH_RC_COLOR + [ANAGLYPH_RC_COLOR] = + {{65536, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 65536, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{29891, 32800, 11559, -2849, -5763, -102}, //ANAGLYPH_RC_DUBOIS + [ANAGLYPH_RC_DUBOIS] = + {{29891, 32800, 11559, -2849, -5763, -102}, {-2627, -2479, -1033, 24804, 48080, -1209}, { -997, -1350, -358, -4729, -7403, 80373}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_GM_GRAY + [ANAGLYPH_GM_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 19595, 38470, 7471}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_HALF + [ANAGLYPH_GM_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, {19595, 38470, 7471, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_GM_COLOR + [ANAGLYPH_GM_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 65536, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 65536}}, - {{ 0, 0, 0, 19595, 38470, 7471}, //ANAGLYPH_YB_GRAY + [ANAGLYPH_GM_DUBOIS] = + {{-4063,-10354, -2556, 34669, 46203, 1573}, + {18612, 43778, 9372, -1049, -983, -4260}, + { -983, -1769, 1376, 590, 4915, 61407}}, + [ANAGLYPH_YB_GRAY] = + {{ 0, 0, 0, 19595, 38470, 7471}, { 0, 0, 0, 19595, 38470, 7471}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_HALF + [ANAGLYPH_YB_HALF] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, {19595, 38470, 7471, 0, 0, 0}}, - {{ 0, 0, 0, 65536, 0, 0}, //ANAGLYPH_YB_COLOR + [ANAGLYPH_YB_COLOR] = + {{ 0, 0, 0, 65536, 0, 0}, { 0, 0, 0, 0, 65536, 0}, - { 0, 0, 65536, 0, 0, 0}} + { 0, 0, 65536, 0, 0, 0}}, + [ANAGLYPH_YB_DUBOIS] = + {{65535,-12650,18451, -987, -7590, -1049}, + {-1604, 56032, 4196, 370, 3826, -1049}, + {-2345,-10676, 1358, 5801, 11416, 56217}}, }; struct vf_priv_s { @@ -150,10 +172,14 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, //check input format switch (vf->priv->in.fmt) { + case SIDE_BY_SIDE_2_LR: + d_width *= 2; case SIDE_BY_SIDE_LR: vf->priv->width = width / 2; vf->priv->in.off_right = vf->priv->width * 3; break; + case SIDE_BY_SIDE_2_RL: + d_width *= 2; case SIDE_BY_SIDE_RL: vf->priv->width = width / 2; vf->priv->in.off_left = vf->priv->width * 3; @@ -193,16 +219,22 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: memcpy(vf->priv->ana_matrix, ana_coeff[vf->priv->out.fmt], sizeof(vf->priv->ana_matrix)); break; + case SIDE_BY_SIDE_2_LR: + d_width /= 2; case SIDE_BY_SIDE_LR: vf->priv->out.width = vf->priv->width * 2; vf->priv->out.off_right = vf->priv->width * 3; break; + case SIDE_BY_SIDE_2_RL: + d_width /= 2; case SIDE_BY_SIDE_RL: vf->priv->out.width = vf->priv->width * 2; vf->priv->out.off_left = vf->priv->width * 3; @@ -276,6 +308,8 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) switch (vf->priv->out.fmt) { case SIDE_BY_SIDE_LR: case SIDE_BY_SIDE_RL: + case SIDE_BY_SIDE_2_LR: + case SIDE_BY_SIDE_2_RL: case ABOVE_BELOW_LR: case ABOVE_BELOW_RL: case ABOVE_BELOW_2_LR: @@ -313,9 +347,11 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) case ANAGLYPH_GM_GRAY: case ANAGLYPH_GM_HALF: case ANAGLYPH_GM_COLOR: + case ANAGLYPH_GM_DUBOIS: case ANAGLYPH_YB_GRAY: case ANAGLYPH_YB_HALF: - case ANAGLYPH_YB_COLOR: { + case ANAGLYPH_YB_COLOR: + case ANAGLYPH_YB_DUBOIS: { int x,y,il,ir,o; unsigned char *source = mpi->planes[0]; unsigned char *dest = dmpi->planes[0]; @@ -395,12 +431,16 @@ static const struct format_preset { {"anaglyph_green_magenta_half_color",ANAGLYPH_GM_HALF}, {"agmc", ANAGLYPH_GM_COLOR}, {"anaglyph_green_magenta_color", ANAGLYPH_GM_COLOR}, + {"agmd", ANAGLYPH_GM_DUBOIS}, + {"anaglyph_green_magenta_dubois", ANAGLYPH_GM_DUBOIS}, {"aybg", ANAGLYPH_YB_GRAY}, {"anaglyph_yellow_blue_gray", ANAGLYPH_YB_GRAY}, {"aybh", ANAGLYPH_YB_HALF}, {"anaglyph_yellow_blue_half_color", ANAGLYPH_YB_HALF}, {"aybc", ANAGLYPH_YB_COLOR}, {"anaglyph_yellow_blue_color", ANAGLYPH_YB_COLOR}, + {"aybd", ANAGLYPH_YB_DUBOIS}, + {"anaglyph_yellow_blue_dubois", ANAGLYPH_YB_DUBOIS}, {"ml", MONO_L}, {"mono_left", MONO_L}, {"mr", MONO_R}, @@ -409,6 +449,10 @@ static const struct format_preset { {"side_by_side_left_first", SIDE_BY_SIDE_LR}, {"sbsr", SIDE_BY_SIDE_RL}, {"side_by_side_right_first", SIDE_BY_SIDE_RL}, + {"sbs2l", SIDE_BY_SIDE_2_LR}, + {"side_by_side_half_width_left_first", SIDE_BY_SIDE_2_LR}, + {"sbs2r", SIDE_BY_SIDE_2_RL}, + {"side_by_side_half_width_right_first",SIDE_BY_SIDE_2_RL}, {"abl", ABOVE_BELOW_LR}, {"above_below_left_first", ABOVE_BELOW_LR}, {"abr", ABOVE_BELOW_RL}, -- 2.11.4.GIT