[MPlayer-dev-eng] [PATCH] libavcodec skip decoding options
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Jul 15 12:00:02 CEST 2005
Hi,
the attached patch adds support for libavcodecs skip* options, esp.
skiploopfilter can give a big speedup with h264 at little cost.
I need a bit of help with the man page entry though, I'll give the text
here, somebody else please put the formattings in (I don't know
how to make sub-subsections, and no I don't want to learn :-) )
under lavdopts:
skip options
all these accept a value that specifies when this processing step
should be skipped:
none
never skip
default
skip when it is useless (e.g. 0 size packets in AVI)
nonref
skip for frames that are not referenced (i.e. not used for decoding
other frames, the error can not "build up")
bidir
skip for B-Frames
nonkey
skip for all frames except keyframes
all
skip for all frames
skiploopfilter=<skipvalue> (H.264 only)
Skips the loop filter (aka deblocking) during H.264 decoding.
Since the filtered frame is supposed to be used as reference
for decoding dependant frames this has a worse effect on quality
than not doing deblocking on e.g. MPEG2 video.
But at least for high bitrate HDTV this provides a bit speedup with
no visible quality loss.
skipidct=<skipvalue> (MPEG1/2 only)
Skips the IDCT step. This looses a lot of quality in almost all cases.
skipframe=<skipvalue>
Skips decoding of frames completely.
Big speedup, but jerky motion and sometimes bad artefacts.
I intend to apply the code part tomorrow and leave the man page to
whoever will do it *g*
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.149
diff -u -r1.149 vd_ffmpeg.c
--- libmpcodecs/vd_ffmpeg.c 26 Jun 2005 20:28:12 -0000 1.149
+++ libmpcodecs/vd_ffmpeg.c 15 Jul 2005 09:34:56 -0000
@@ -106,6 +106,11 @@
static int lavc_param_fast=0;
static int lavc_param_lowres=0;
static char *lavc_param_lowres_str=NULL;
+#if LIBAVCODEC_BUILD >= 4758
+static char *lavc_param_skip_loop_filter_str = NULL;
+static char *lavc_param_skip_idct_str = NULL;
+static char *lavc_param_skip_frame_str = NULL;
+#endif
m_option_t lavc_decode_opts_conf[]={
{"bug", &lavc_param_workaround_bugs, CONF_TYPE_INT, CONF_RANGE, -1, 999999, NULL},
@@ -122,9 +127,35 @@
{"fast", &lavc_param_fast, CONF_TYPE_FLAG, 0, 0, CODEC_FLAG2_FAST, NULL},
#endif
{"lowres", &lavc_param_lowres_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#if LIBAVCODEC_BUILD >= 4758
+ {"skiploopfilter", &lavc_param_skip_loop_filter_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"skipidct", &lavc_param_skip_idct_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"skipframe", &lavc_param_skip_frame_str, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#endif
{NULL, NULL, 0, 0, 0, 0, NULL}
};
+#if LIBAVCODEC_BUILD >= 4758
+static enum AVDiscard str2AVDiscard(char *str) {
+ if (!str)
+ return AVDISCARD_DEFAULT;
+ if (strcasecmp(str, "none") == 0)
+ return AVDISCARD_NONE;
+ if (strcasecmp(str, "default") == 0)
+ return AVDISCARD_DEFAULT;
+ if (strcasecmp(str, "nonref") == 0)
+ return AVDISCARD_NONREF;
+ if (strcasecmp(str, "bidir") == 0)
+ return AVDISCARD_BIDIR;
+ if (strcasecmp(str, "nonkey") == 0)
+ return AVDISCARD_NONKEY;
+ if (strcasecmp(str, "all") == 0)
+ return AVDISCARD_ALL;
+ mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Unknown discard value %s\n", str);
+ return AVDISCARD_DEFAULT;
+}
+#endif
+
// to set/get/query special features/parameters
static int control(sh_video_t *sh,int cmd,void* arg,...){
vd_ffmpeg_ctx *ctx = sh->context;
@@ -271,6 +302,11 @@
avctx->lowres = lavc_param_lowres;
}
#endif
+#if LIBAVCODEC_BUILD >= 4758
+ avctx->skip_loop_filter = str2AVDiscard(lavc_param_skip_loop_filter_str);
+ avctx->skip_idct = str2AVDiscard(lavc_param_skip_idct_str);
+ avctx->skip_frame = str2AVDiscard(lavc_param_skip_frame_str);
+#endif
mp_dbg(MSGT_DECVIDEO,MSGL_DBG2,"libavcodec.size: %d x %d\n",avctx->width,avctx->height);
/* AVRn stores huffman table in AVI header */
/* Pegasus MJPEG stores it also in AVI header, but it uses the common
More information about the MPlayer-dev-eng
mailing list