[MPlayer-dev-eng] stereo3d filter
Endre Kollár
taxy443 at gmail.com
Tue Oct 19 13:12:32 CEST 2010
2010/10/19 Endre Kollár <taxy443 at gmail.com>:
> 2010/10/17 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
>> On Sun, Oct 17, 2010 at 02:12:13PM +0200, Endre Kollár wrote:
>>> 2010/10/17 Reimar Döffinger <Reimar.Doeffinger at gmx.de>
>>>
>>> > > Im not sure that i understand it. The "Re: [MPlayer-dev-eng] [PATCH] view
>>> > > stereoscopic videos" should be the subject of the letter. That was your
>>> > ask?
>>> > >
>>> > > I do not understand what the debate is really about the coding style.
>>> > Kernel
>>> > > source, simply run the "checkpatch.pl" script, and tells you where the
>>> > style
>>> > > of errors is. Are there big differeces between this style and the kernel
>>> > > style?
>>> >
>>> > Forget the cosmetics debate.
>>> > I was thinking more of e.g. these comments:
>>> > http://permalink.gmane.org/gmane.comp.video.mplayer.devel/54804
>>> >
>>>
>>> Uh, I was looking for the final version, but I could not find their way
>>> around.
>>> http://article.gmane.org/gmane.comp.video.mplayer.devel/54802
>>>
>>> It looks much nicer than what I used.
>>> Do you suggest to make a diff of my changes? Merge a version? Which?
>>
>> Ideally? We'd get a version of above patch with only the requested changes
>> (so we don't have to restart review from scratch) and then you'd send your
>> patches on top of that after it is applied.
>> _______________________________________________
>> MPlayer-dev-eng mailing list
>> MPlayer-dev-eng at mplayerhq.hu
>> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>>
>
> I am sorry that above patch included my changes. I interpreted too
> late this message(I do not understand why). But it is not difficult.
> Starting in function find_best_out, easy to trace changes.
>
i send as help the patch with only MY changes and mixed with cleanup things.
-------------- next part --------------
--- vf_stereo3d.3.c 2010-10-18 11:38:58.000000000 +0200
+++ vf_stereo3d.4.c 2010-10-18 14:56:24.000000000 +0200
@@ -58,10 +58,23 @@ typedef enum stereo_code {
STEREO_CODE_COUNT //no value set - TODO: needs autodetection
} stereo_code;
+static const unsigned int outfmt_list[]={
+// RGB
+ IMGFMT_RGB24,
+ IMGFMT_BGR24,
+ IMGFMT_BGR32,
+ IMGFMT_RGB32,
+ 0
+};
+
typedef struct component {
stereo_code fmt;
unsigned int width;
unsigned int height;
+ unsigned int bypp;
+ unsigned int pixelfmt;
+ unsigned int red;
+ unsigned int blue;
unsigned int off_left;
unsigned int off_right;
unsigned int stride;
@@ -121,7 +134,7 @@ static inline uint8_t ana_convert(int co
int rr, int gr, int br)
{
int sum;
-
+
sum = coeff[0] * rl;
sum += coeff[1] * gl;
sum += coeff[2] * bl;
@@ -131,9 +144,54 @@ static inline uint8_t ana_convert(int co
return av_clip_uint8(sum >> 16);
}
+static unsigned int find_best_out(vf_instance_t *vf)
+{
+unsigned int ret = 0;
+int i;
+unsigned int format = 0;
+
+ for(i=0; outfmt_list[i] != 0; i++){
+ format=outfmt_list[i];
+ ret = vf_next_query_format(vf, format);
+ mp_msg(MSGT_VFILTER,MSGL_DBG2,"[stereo3D]: query(%s) -> %d\n",vo_format_name(format),ret&3);
+
+ if(ret&VFCAP_CSP_SUPPORTED_BY_HW)
+ break;
+ }
+ if(ret&VFCAP_CSP_SUPPORTED_BY_HW){
+ switch (vf->priv->out.fmt) {
+ case ANAGLYPH_RC_GRAY:
+ case ANAGLYPH_RC_HALF:
+ case ANAGLYPH_RC_COLOR:
+ case ANAGLYPH_RC_DUBOIS:
+ case ANAGLYPH_GM_GRAY:
+ case ANAGLYPH_GM_HALF:
+ case ANAGLYPH_GM_COLOR:
+ case ANAGLYPH_YB_GRAY:
+ case ANAGLYPH_YB_HALF:
+ case ANAGLYPH_YB_COLOR:
+ return format;
+ break;
+ default:
+ return IMGFMT_RGB24;
+ break;
+ }
+ }else
+ return IMGFMT_RGB24;
+
+}
+
+
static int config(struct vf_instance *vf, int width, int height, int d_width,
int d_height, unsigned int flags, unsigned int outfmt)
{
+ unsigned int best=find_best_out(vf);
+
+ if (outfmt != IMGFMT_RGB24) {
+ mp_msg(MSGT_VFILTER, MSGL_WARN, "[stereo3d] input format is not supported\n");
+ return 0;
+ }
+
if ((width & 1) || (height & 1)) {
mp_msg(MSGT_VFILTER, MSGL_WARN, "[stereo3d] invalid height or width\n");
return 0;
@@ -183,12 +241,41 @@ static int config(struct vf_instance *vf
break;
}
//default output values
+ vf->priv->out.pixelfmt = best;
+ switch (best) {
+ case IMGFMT_RGB24:
+ vf->priv->out.bypp = 3;
+ vf->priv->out.red = 0;
+ vf->priv->out.blue = 2;
+ break;
+ case IMGFMT_BGR24:
+ vf->priv->out.bypp = 3;
+ vf->priv->out.red = 2;
+ vf->priv->out.blue = 0;
+ break;
+ case IMGFMT_RGB32:
+ vf->priv->out.bypp = 4;
+ vf->priv->out.red = 0;
+ vf->priv->out.blue = 2;
+ break;
+ case IMGFMT_BGR32:
+ vf->priv->out.bypp = 4;
+ vf->priv->out.red = 2;
+ vf->priv->out.blue = 0;
+ break;
+ default:
+ mp_msg(MSGT_VFILTER, MSGL_WARN, "[stereo3d] output format is not supported\n");
+ return 0;
+ break;
+ }
+ mp_msg(MSGT_VFILTER,MSGL_V,"[stereo3D]: %s output format\n",vo_format_name(best));
+
vf->priv->out.width = vf->priv->width;
vf->priv->out.height = vf->priv->height;
vf->priv->out.hres = 1;
vf->priv->out.off_left = 0;
vf->priv->out.off_right = 0;
- vf->priv->out.stride = vf->priv->width * 3;
+ vf->priv->out.stride = vf->priv->width * vf->priv->out.bypp;
//check output format
switch (vf->priv->out.fmt) {
@@ -207,32 +294,32 @@ static int config(struct vf_instance *vf
break;
case SIDE_BY_SIDE_LR:
vf->priv->out.width = vf->priv->width * 2;
- vf->priv->out.off_right = vf->priv->width * 3;
- vf->priv->out.stride = vf->priv->width * 6;
+ vf->priv->out.off_right = vf->priv->out.stride;
+ vf->priv->out.stride = vf->priv->out.stride * 2;
break;
case SIDE_BY_SIDE_RL:
vf->priv->out.width = vf->priv->width * 2;
- vf->priv->out.off_left = vf->priv->width * 3;
- vf->priv->out.stride = vf->priv->width * 6;
+ vf->priv->out.off_left = vf->priv->out.stride;
+ vf->priv->out.stride = vf->priv->out.stride * 2;
break;
case ABOVE_BELOW_LR:
vf->priv->out.height = vf->priv->height * 2;
- vf->priv->out.off_right = vf->priv->width * vf->priv->height * 3;
+ vf->priv->out.off_right = vf->priv->out.stride * vf->priv->height;
break;
case ABOVE_BELOW_RL:
vf->priv->out.height = vf->priv->height * 2;
- vf->priv->out.off_left = vf->priv->width * vf->priv->height * 3;
+ vf->priv->out.off_left = vf->priv->out.stride * vf->priv->height;
break;
case ABOVE_BELOW_2_LR:
vf->priv->out.hres = 2;
- vf->priv->out.off_right = vf->priv->width * vf->priv->height / 2 * 3;
+ vf->priv->out.off_right = vf->priv->out.stride * vf->priv->height / 2;
break;
case ABOVE_BELOW_2_RL:
vf->priv->out.hres = 2;
- vf->priv->out.off_left = vf->priv->width * vf->priv->height / 2 * 3;
+ vf->priv->out.off_left = vf->priv->out.stride * vf->priv->height / 2;
break;
case MONO_R:
- //same as MONO_L only needs switching of input offsets
+ //same as MONO_L only needs switching of input offsets
vf->priv->in.off_left = vf->priv->in.off_right;
//nobreak;
case MONO_L:
@@ -249,17 +336,17 @@ static int config(struct vf_instance *vf
d_height = d_height * vf->priv->out.height / height;
}
return vf_next_config(vf, vf->priv->out.width, vf->priv->out.height,
- d_width, d_height, flags, outfmt);
+ d_width, d_height, flags, best);
}
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
mp_image_t *dmpi;
if (vf->priv->in.fmt == vf->priv->out.fmt) { //nothing to do
- dmpi = mpi;
+ dmpi = mpi;
} else {
- dmpi = vf_get_image(vf->next, IMGFMT_RGB24, MP_IMGTYPE_TEMP, 0,
- vf->priv->out.width, vf->priv->out.height);
+ dmpi = vf_get_image(vf->next, vf->priv->out.pixelfmt, MP_IMGTYPE_TEMP,
+ 0, vf->priv->out.width, vf->priv->out.height);
dmpi->h = vf->priv->out.height;
dmpi->width = vf->priv->out.width;
switch (vf->priv->out.fmt) {
@@ -278,7 +365,7 @@ static int put_image(struct vf_instance
vf->priv->in.hres, vf->priv->in.stride *
vf->priv->out.hres);
memcpy_pic(dmpi->planes[0] + vf->priv->out.off_right +
- (i * vf->priv->out.stride), mpi->planes[0] +
+ (i * vf->priv->out.stride), mpi->planes[0] +
vf->priv->in.off_right, 3 * vf->priv->width,
vf->priv->height / (vf->priv->in.hres *
vf->priv->out.hres), vf->priv->out.stride *
@@ -307,6 +394,11 @@ static int put_image(struct vf_instance
case ANAGLYPH_YB_HALF:
case ANAGLYPH_YB_COLOR: {
int x,y,rl,gl,bl,rr,gr,br,il,ir,o;
+ unsigned int out_bypp = vf->priv->out.bypp;
+ unsigned int out_red = vf->priv->out.red;
+ unsigned int out_blue = vf->priv->out.blue;
+ unsigned int out_has_a = (out_bypp == 4);
+
for (y = 0; y < vf->priv->out.height; y++) {
o = vf->priv->out.stride * y;
il = vf->priv->in.off_left + (y / vf->priv->in.hres) *
@@ -320,15 +412,16 @@ static int put_image(struct vf_instance
rr = mpi->planes[0][ir ];
gr = mpi->planes[0][ir + 1];
br = mpi->planes[0][ir + 2];
- dmpi->planes[0][o ] = ana_convert(
+ dmpi->planes[0][o + out_red ] = ana_convert(
vf->priv->ana_matrix[0], rl, gl, bl, rr, gr, br);
- dmpi->planes[0][o + 1] = ana_convert(
+ dmpi->planes[0][o + 1 ] = ana_convert(
vf->priv->ana_matrix[1], rl, gl, bl, rr, gr, br);
- dmpi->planes[0][o + 2] = ana_convert(
+ dmpi->planes[0][o + out_blue] = ana_convert(
vf->priv->ana_matrix[2], rl, gl, bl, rr, gr, br);
+ if(out_has_a) dmpi->planes[0][o + 3] = 0;
il += 3;
ir += 3;
- o += 3;
+ o += out_bypp;
}
}
break;
@@ -345,9 +438,8 @@ static int put_image(struct vf_instance
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
- switch (fmt)
- case IMGFMT_RGB24:
- return vf_next_query_format(vf, fmt);
+ if (fmt == IMGFMT_RGB24)
+ return vf_next_query_format(vf, find_best_out(vf));
return 0;
}
@@ -452,8 +544,10 @@ static const m_obj_presets_t format_pres
#undef ST_OFF
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
static const m_option_t vf_opts_fields[] = {
- {"stereo_in", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, (m_obj_presets_t*)&format_preset_in},
- {"stereo_out", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, (m_obj_presets_t*)&format_preset_out},
+ {"stereo_in", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0,
+ (m_obj_presets_t*)&format_preset_in},
+ {"stereo_out", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0,
+ (m_obj_presets_t*)&format_preset_out},
{"in", ST_OFF(in.fmt), CONF_TYPE_INT, 0,0,0, NULL},
{"out", ST_OFF(out.fmt), CONF_TYPE_INT, 0,0,0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
More information about the MPlayer-dev-eng
mailing list