summaryrefslogtreecommitdiffstats
path: root/video/filter
diff options
context:
space:
mode:
Diffstat (limited to 'video/filter')
-rw-r--r--video/filter/vf.c5
-rw-r--r--video/filter/vf.h1
-rw-r--r--video/filter/vf_crop.c7
-rw-r--r--video/filter/vf_expand.c13
-rw-r--r--video/filter/vf_mirror.c89
-rw-r--r--video/filter/vf_screenshot.c74
-rw-r--r--video/filter/vf_vapoursynth.c14
-rw-r--r--video/filter/vf_vdpaupp.c4
8 files changed, 17 insertions, 190 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 888e937fa5..4f9f43f2e0 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -54,7 +54,6 @@ extern const vf_info_t vf_info_hqdn3d;
extern const vf_info_t vf_info_dsize;
extern const vf_info_t vf_info_pullup;
extern const vf_info_t vf_info_delogo;
-extern const vf_info_t vf_info_screenshot;
extern const vf_info_t vf_info_sub;
extern const vf_info_t vf_info_yadif;
extern const vf_info_t vf_info_stereo3d;
@@ -74,9 +73,9 @@ static const vf_info_t *const filter_list[] = {
&vf_info_format,
&vf_info_noformat,
&vf_info_flip,
- &vf_info_mirror,
#if HAVE_LIBAVFILTER
+ &vf_info_mirror,
&vf_info_lavfi,
&vf_info_rotate,
&vf_info_noise,
@@ -88,8 +87,6 @@ static const vf_info_t *const filter_list[] = {
&vf_info_yadif,
#endif
- &vf_info_screenshot,
-
&vf_info_eq,
&vf_info_dsize,
&vf_info_sub,
diff --git a/video/filter/vf.h b/video/filter/vf.h
index f7ee9d011b..76835528b5 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -144,7 +144,6 @@ enum vf_ctrl {
VFCTRL_SEEK_RESET = 1, // reset on picture and PTS discontinuities
VFCTRL_SET_EQUALIZER, // set color options (brightness,contrast etc)
VFCTRL_GET_EQUALIZER, // get color options (brightness,contrast etc)
- VFCTRL_SCREENSHOT, // Take screenshot, arg is mp_image**
VFCTRL_INIT_OSD, // Filter OSD renderer present?
VFCTRL_SET_DEINTERLACE, // Set deinterlacing status
VFCTRL_GET_DEINTERLACE, // Get deinterlacing status
diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c
index 498b2a9037..02787b8f22 100644
--- a/video/filter/vf_crop.c
+++ b/video/filter/vf_crop.c
@@ -58,7 +58,7 @@ static int config(struct vf_instance *vf,
// check:
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
- MP_WARN(vf, "[CROP] Bad position/width/height - cropped area outside of the original!\n");
+ MP_WARN(vf, "Bad position/width/height - cropped area outside of the original!\n");
return 0;
}
vf_rescale_dsize(&d_width, &d_height, width, height,
@@ -85,11 +85,6 @@ static int vf_open(vf_instance_t *vf){
vf->config=config;
vf->filter=filter;
vf->query_format=query_format;
- MP_INFO(vf, "Crop: %d x %d, %d ; %d\n",
- vf->priv->crop_w,
- vf->priv->crop_h,
- vf->priv->crop_x,
- vf->priv->crop_y);
return 1;
}
diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c
index 44a8ec5767..6d5b694613 100644
--- a/video/filter/vf_expand.c
+++ b/video/filter/vf_expand.c
@@ -63,18 +63,12 @@ static int config(struct vf_instance *vf,
vf->priv->exp_y = vf->priv->cfg_exp_y;
vf->priv->exp_w = vf->priv->cfg_exp_w;
vf->priv->exp_h = vf->priv->cfg_exp_h;
- // calculate the missing parameters:
-#if 0
- if(vf->priv->exp_w<width) vf->priv->exp_w=width;
- if(vf->priv->exp_h<height) vf->priv->exp_h=height;
-#else
if ( vf->priv->exp_w == -1 ) vf->priv->exp_w=width;
else if (vf->priv->exp_w < -1 ) vf->priv->exp_w=width - vf->priv->exp_w;
else if ( vf->priv->exp_w<width ) vf->priv->exp_w=width;
if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height;
else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h;
else if( vf->priv->exp_h<height ) vf->priv->exp_h=height;
-#endif
if (vf->priv->aspect) {
float adjusted_aspect = vf->priv->aspect;
adjusted_aspect *= ((double)width/height) / ((double)d_width/d_height);
@@ -149,13 +143,6 @@ static int vf_open(vf_instance_t *vf){
vf->config=config;
vf->query_format=query_format;
vf->filter=filter;
- MP_INFO(vf, "Expand: %d x %d, %d ; %d, aspect: %f, round: %d\n",
- vf->priv->cfg_exp_w,
- vf->priv->cfg_exp_h,
- vf->priv->cfg_exp_x,
- vf->priv->cfg_exp_y,
- vf->priv->aspect,
- vf->priv->round);
return 1;
}
diff --git a/video/filter/vf_mirror.c b/video/filter/vf_mirror.c
index d92f320235..342c6abd2a 100644
--- a/video/filter/vf_mirror.c
+++ b/video/filter/vf_mirror.c
@@ -15,93 +15,14 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
+#include <stddef.h>
-#include "config.h"
-#include "common/msg.h"
-
-#include "video/img_format.h"
-#include "video/mp_image.h"
#include "vf.h"
+#include "vf_lavfi.h"
-static int config(struct vf_instance *vf, int width, int height,
- int d_width, int d_height,
- unsigned int flags, unsigned int fmt)
-{
- struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
- int a_w = MP_ALIGN_DOWN(width, desc.align_x);
- vf_rescale_dsize(&d_width, &d_height, width, height, a_w, height);
- return vf_next_config(vf, a_w, height, d_width, d_height, flags, fmt);
-}
-
-static inline void mirror_4_m(uint8_t *dst, uint8_t *src, int p,
- int c0, int c1, int c2, int c3)
-{
- for (int x = 0; x < p; x++) {
- dst[x * 4 + 0] = src[(p - x - 1) * 4 + c0];
- dst[x * 4 + 1] = src[(p - x - 1) * 4 + c1];
- dst[x * 4 + 2] = src[(p - x - 1) * 4 + c2];
- dst[x * 4 + 3] = src[(p - x - 1) * 4 + c3];
- }
-}
-
-static inline void mirror(uint8_t *dst, uint8_t *src, int bp, int w)
-{
- for (int x = 0; x < w; x++)
- memcpy(dst + x * bp, src + (w - x - 1) * bp, bp);
-}
-
-static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
+static int vf_open(vf_instance_t *vf)
{
- mp_image_t *dmpi = vf_alloc_out_image(vf);
- if (!dmpi)
- return NULL;
- mp_image_copy_attributes(dmpi, mpi);
-
- for (int p = 0; p < mpi->num_planes; p++) {
- int plane_h = mp_image_plane_h(mpi, p);
- for (int y = 0; y < plane_h; y++) {
- void *p_src = mpi->planes[p] + mpi->stride[p] * y;
- void *p_dst = dmpi->planes[p] + dmpi->stride[p] * y;
- int w = mp_image_plane_w(dmpi, p);
- if (mpi->imgfmt == IMGFMT_YUYV) {
- mirror_4_m(p_dst, p_src, w / 2, 2, 1, 0, 3);
- } else if (mpi->imgfmt == IMGFMT_UYVY) {
- mirror_4_m(p_dst, p_src, w / 2, 0, 3, 2, 1);
- } else {
- // make the compiler unroll the memcpy in mirror()
- switch (mpi->fmt.bytes[p]) {
- case 1: mirror(p_dst, p_src, 1, w); break;
- case 2: mirror(p_dst, p_src, 2, w); break;
- case 3: mirror(p_dst, p_src, 3, w); break;
- case 4: mirror(p_dst, p_src, 4, w); break;
- default:
- mirror(p_dst, p_src, mpi->fmt.bytes[p], w);
- }
- }
- }
- }
-
- talloc_free(mpi);
- return dmpi;
-}
-
-static int query_format(struct vf_instance *vf, unsigned int fmt)
-{
- struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(fmt);
- if (!(desc.flags & MP_IMGFLAG_BYTE_ALIGNED))
- return 0;
- return vf_next_query_format(vf, fmt);
-}
-
-static int vf_open(vf_instance_t *vf){
- vf->config=config;
- vf->filter=filter;
- vf->query_format=query_format;
- return 1;
+ return vf_lw_set_graph(vf, NULL, NULL, "hflip") >= 0;
}
const vf_info_t vf_info_mirror = {
@@ -109,5 +30,3 @@ const vf_info_t vf_info_mirror = {
.name = "mirror",
.open = vf_open,
};
-
-//===========================================================================//
diff --git a/video/filter/vf_screenshot.c b/video/filter/vf_screenshot.c
deleted file mode 100644
index 57cd9fbb0b..0000000000
--- a/video/filter/vf_screenshot.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "talloc.h"
-
-#include "video/img_format.h"
-#include "video/mp_image.h"
-#include "video/sws_utils.h"
-#include "video/out/vo.h"
-
-#include "vf.h"
-
-struct vf_priv_s {
- struct mp_image *current;
-};
-
-static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
-{
- mp_image_unrefp(&vf->priv->current);
- vf->priv->current = talloc_steal(vf, mp_image_new_ref(mpi));
- return mpi;
-}
-
-static int control (vf_instance_t *vf, int request, void *data)
-{
- if (request == VFCTRL_SCREENSHOT && vf->priv->current) {
- *(struct mp_image **)data = mp_image_new_ref(vf->priv->current);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int query_format(struct vf_instance *vf, unsigned int fmt)
-{
- if (mp_sws_supported_format(fmt))
- return vf_next_query_format(vf, fmt);
- return 0;
-}
-
-static int vf_open(vf_instance_t *vf)
-{
- vf->control = control;
- vf->filter = filter;
- vf->query_format = query_format;
- vf->priv = talloc_zero(vf, struct vf_priv_s);
- return 1;
-}
-
-const vf_info_t vf_info_screenshot = {
- .description = "screenshot to file",
- .name = "screenshot",
- .open = vf_open,
-};
diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c
index db0bce3210..01cacbf742 100644
--- a/video/filter/vf_vapoursynth.c
+++ b/video/filter/vf_vapoursynth.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <inttypes.h>
#include <pthread.h>
+#include <limits.h>
#include <assert.h>
#include <VapourSynth.h>
@@ -167,10 +168,10 @@ static void copy_mp_to_vs_frame_props_map(struct vf_priv_s *p, VSMap *map,
}
if (pict_type)
p->vsapi->propSetData(map, "_PictType", &pict_type, 1, 0);
- p->vsapi->propSetInt(map, "_FieldBased",
- !!(img->fields & MP_IMGFIELD_INTERLACED), 0);
- p->vsapi->propSetInt(map, "_Field",
- !!(img->fields & MP_IMGFIELD_TOP_FIRST), 0);
+ int field = 0;
+ if (img->fields & MP_IMGFIELD_INTERLACED)
+ field = img->fields & MP_IMGFIELD_TOP_FIRST ? 2 : 1;
+ p->vsapi->propSetInt(map, "_FieldBased", field, 0);
}
static int set_vs_frame_props(struct vf_priv_s *p, VSFrameRef *frame,
@@ -407,6 +408,10 @@ static void VS_CC infiltInit(VSMap *in, VSMap *out, void **instanceData,
{
struct vf_instance *vf = *instanceData;
struct vf_priv_s *p = vf->priv;
+ // The number of frames of our input node is obviously unknown. The user
+ // could for example seek any time, randomly "ending" the clip.
+ // This specific value was suggested by the VapourSynth developer.
+ int enough_for_everyone = INT_MAX / 16;
// Note: this is called from createFilter, so no need for locking.
@@ -414,6 +419,7 @@ static void VS_CC infiltInit(VSMap *in, VSMap *out, void **instanceData,
.format = p->vsapi->getFormatPreset(mp_to_vs(p->fmt_in.imgfmt), p->vscore),
.width = p->fmt_in.w,
.height = p->fmt_in.h,
+ .numFrames = enough_for_everyone,
};
if (!fmt.format) {
p->vsapi->setError(out, "Unsupported input format.\n");
diff --git a/video/filter/vf_vdpaupp.c b/video/filter/vf_vdpaupp.c
index 4db6ab9186..26c1eef5ca 100644
--- a/video/filter/vf_vdpaupp.c
+++ b/video/filter/vf_vdpaupp.c
@@ -92,9 +92,7 @@ static bool output_field(struct vf_instance *vf, int pos)
frame->field = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
if (p->opts.deint) {
- int top_field_first = 1;
- if (mpi->fields & MP_IMGFIELD_ORDERED)
- top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
+ int top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
frame->field = top_field_first ^ (pos & 1) ?
VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD:
VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;