summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-28 04:29:17 +0000
committerrfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-04-28 04:29:17 +0000
commit46ca153401ef3852b8870f491c0358b74c6c108b (patch)
tree6b7958f85c8e24586de5997acff29fc21d356f94
parentb7e594f57db070ef36927e83e498734cf9fcaad1 (diff)
downloadmpv-46ca153401ef3852b8870f491c0358b74c6c108b.tar.bz2
mpv-46ca153401ef3852b8870f491c0358b74c6c108b.tar.xz
soft skipping for mencoder. rather than skipping decoding/filtering
frames that will be skipped, mencoded tells vf_softskip (if present) that it should drop the next frame. this allows filters that need to see every input frame (inverse telecine, denoise3d, ...) to see skipped frames before they get dropped. in principle, a smarter softskip filter could be written that would buffer frames and choose to drop the one with least change, rather than strictly dropping the next one. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12338 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/Makefile2
-rw-r--r--libmpcodecs/vf.c2
-rw-r--r--libmpcodecs/vf.h1
-rw-r--r--libmpcodecs/vf_softskip.c85
-rw-r--r--mencoder.c6
5 files changed, 93 insertions, 3 deletions
diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile
index fb4f504516..0721f2168c 100644
--- a/libmpcodecs/Makefile
+++ b/libmpcodecs/Makefile
@@ -14,7 +14,7 @@ VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_raw.c vd_hmblck.c vd_fli.c vd_qtrle.c v
VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_zrmjpeg.c vd_xanim.c vd_xvid.c vd_xvid4.c vd_libdv.c vd_qtvideo.c vd_theora.c
VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT)
-VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_noformat.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c vf_rgbtest.c vf_qp.c vf_phase.c vf_divtc.c vf_harddup.c
+VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_noformat.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c vf_rgbtest.c vf_qp.c vf_phase.c vf_divtc.c vf_harddup.c vf_softskip.c
ifeq ($(HAVE_FFPOSTPROCESS),yes)
VFILTER_SRCS += vf_pp.c
endif
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 511d1b1c2a..bb7d57b9a2 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -90,6 +90,7 @@ extern vf_info_t vf_info_qp;
extern vf_info_t vf_info_phase;
extern vf_info_t vf_info_divtc;
extern vf_info_t vf_info_harddup;
+extern vf_info_t vf_info_softskip;
// list of available filters:
static vf_info_t* filter_list[]={
@@ -173,6 +174,7 @@ static vf_info_t* filter_list[]={
&vf_info_phase,
&vf_info_divtc,
&vf_info_harddup,
+ &vf_info_softskip,
NULL
};
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index 6200ef0cad..e14a9cc174 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -65,6 +65,7 @@ typedef struct vf_seteq_s
#define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */
#define VFCTRL_FLIP_PAGE 10 /* Tell the vo to flip pages */
#define VFCTRL_DUPLICATE_FRAME 11 /* For encoding - encode zero-change frame */
+#define VFCTRL_SKIP_NEXT_FRAME 12 /* For encoding - drop the next frame that passes thru */
#include "vfcap.h"
diff --git a/libmpcodecs/vf_softskip.c b/libmpcodecs/vf_softskip.c
new file mode 100644
index 0000000000..1ef864f73f
--- /dev/null
+++ b/libmpcodecs/vf_softskip.c
@@ -0,0 +1,85 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../config.h"
+#include "../mp_msg.h"
+
+#include "img_format.h"
+#include "mp_image.h"
+#include "vf.h"
+
+#include "../libvo/fastmemcpy.h"
+
+struct vf_priv_s {
+ int skipflag;
+};
+
+static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
+{
+ mp_image_t *dmpi;
+
+ if (vf->priv->skipflag)
+ return vf->priv->skipflag = 0;
+
+ dmpi = vf_get_image(vf->next, mpi->imgfmt,
+ MP_IMGTYPE_EXPORT, 0, mpi->width, mpi->height);
+
+ dmpi->planes[0] = mpi->planes[0];
+ dmpi->stride[0] = mpi->stride[0];
+ if (dmpi->flags&MP_IMGFLAG_PLANAR) {
+ dmpi->planes[1] = mpi->planes[1];
+ dmpi->stride[1] = mpi->stride[1];
+ dmpi->planes[2] = mpi->planes[2];
+ dmpi->stride[2] = mpi->stride[2];
+ }
+
+ return vf_next_put_image(vf, dmpi);
+}
+
+static int control(struct vf_instance_s* vf, int request, void* data)
+{
+ switch (request) {
+ case VFCTRL_SKIP_NEXT_FRAME:
+ vf->priv->skipflag = 1;
+ return CONTROL_TRUE;
+ }
+ return vf_next_control(vf, request, data);
+}
+
+static int query_format(struct vf_instance_s* vf, unsigned int fmt)
+{
+ /* FIXME - figure out which other formats work */
+ switch (fmt) {
+ case IMGFMT_YV12:
+ case IMGFMT_IYUV:
+ case IMGFMT_I420:
+ return vf_next_query_format(vf, fmt);
+ }
+ return 0;
+}
+
+static void uninit(struct vf_instance_s* vf)
+{
+ free(vf->priv);
+}
+
+static int open(vf_instance_t *vf, char* args)
+{
+ vf->put_image = put_image;
+ vf->control = control;
+ vf->uninit = uninit;
+ vf->priv = calloc(1, sizeof(struct vf_priv_s));
+ return 1;
+}
+
+vf_info_t vf_info_softskip = {
+ "soft (post-filter) frame skipping for encoding",
+ "softskip",
+ "Rich Felker",
+ "",
+ open,
+ NULL
+};
+
+
diff --git a/mencoder.c b/mencoder.c
index 0a347f3ba8..069235652c 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -1289,14 +1289,16 @@ case VCODEC_FRAMENO:
break;
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
- blit_frame=decode_video(sh_video,start,in_size,(skip_flag>0)?1:0);
+ blit_frame=decode_video(sh_video,start,in_size,
+ skip_flag>0 && vf_next_control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE);
if(!blit_frame){
badframes++;
if(skip_flag<=0){
// unwanted skipping of a frame, what to do?
if(skip_limit==0){
// skipping not allowed -> write empty frame:
- muxer_write_chunk(mux_v,0,0);
+ if (!encode_duplicates || vf_next_control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
+ muxer_write_chunk(mux_v,0,0);
} else {
// skipping allowed -> skip it and distriubute timer error:
v_timer_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;