/* * This file is part of MPlayer. * * MPlayer is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include #include "config.h" #include "mpvcore/mp_msg.h" #include "video/img_format.h" #include "video/mp_image.h" #include "vf.h" #include "video/memcpy_pic.h" enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST, TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE, ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE }; #define fixed_mode(p) ((p)<=BOTTOM_FIRST) struct vf_priv_s { enum mode mode; int verbose; unsigned char *buf[3]; }; /* * Copy fields from either current or buffered previous frame to the * output and store the current frame unmodified to the buffer. */ static void do_plane(unsigned char *to, unsigned char *from, int w, int h, int ts, int fs, unsigned char **bufp, enum mode mode) { unsigned char *buf, *end; int top; if(!*bufp) { mode=PROGRESSIVE; if(!(*bufp=malloc(h*w))) return; } for(end=to+h*ts, buf=*bufp, top=1; tonum_planes; p++) pw[p] = ((mpi->w * mpi->fmt.bpp[p] + 7) / 8) >> mpi->fmt.xs[p]; mode=vf->priv->mode; if(!vf->priv->buf[0]) mode=PROGRESSIVE; else mode=analyze_plane(vf->priv->buf[0], mpi->planes[0], pw[0], dmpi->h, pw[0], mpi->stride[0], mode, vf->priv->verbose, mpi->fields); for (int p = 0; p < mpi->num_planes; p++) { do_plane(dmpi->planes[p], mpi->planes[p], pw[p], dmpi->plane_h[p], dmpi->stride[p], mpi->stride[p], &vf->priv->buf[p], mode); } talloc_free(mpi); return dmpi; } static void uninit(struct vf_instance *vf) { if (!vf->priv) return; free(vf->priv->buf[0]); free(vf->priv->buf[1]); free(vf->priv->buf[2]); free(vf->priv); } static int query_format(struct vf_instance *vf, unsigned int fmt) { if (IMGFMT_IS_HWACCEL(fmt)) return 0; struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt); if (desc.num_planes > 3) return 0; return vf_next_query_format(vf, fmt); } static int vf_open(vf_instance_t *vf, char *args) { vf->filter = filter; vf->uninit = uninit; vf->query_format = query_format; if(!(vf->priv = calloc(1, sizeof(struct vf_priv_s)))) { uninit(vf); return 0; } vf->priv->mode=AUTO_ANALYZE; vf->priv->verbose=0; while(args && *args) { switch(*args) { case 't': vf->priv->mode=TOP_FIRST; break; case 'a': vf->priv->mode=AUTO; break; case 'b': vf->priv->mode=BOTTOM_FIRST; break; case 'u': vf->priv->mode=ANALYZE; break; case 'T': vf->priv->mode=TOP_FIRST_ANALYZE; break; case 'A': vf->priv->mode=AUTO_ANALYZE; break; case 'B': vf->priv->mode=BOTTOM_FIRST_ANALYZE; break; case 'U': vf->priv->mode=FULL_ANALYZE; break; case 'p': vf->priv->mode=PROGRESSIVE; break; case 'v': vf->priv->verbose=1; break; case ':': break; default: uninit(vf); return 0; /* bad args */ } if( (args=strchr(args, ':')) ) args++; } return 1; } const vf_info_t vf_info_phase = { "phase shift fields", "phase", "Ville Saari", "", vf_open, NULL };