[MPlayer-dev-eng] [PATCH] new debanding filter "gradfun"
Diego Biurrun
diego at biurrun.de
Tue May 19 09:31:59 CEST 2009
On Tue, May 19, 2009 at 07:01:56AM +0000, Loren Merritt wrote:
> This is a port/optimization of an Avisynth filter by the same name.
> Original discussion: http://forum.doom9.org/showthread.php?t=108681
>
> While the filter works as-is, ideally it should output 16bit yuv which
> would be dithered only in the final conversion of 8bit rgb. But MPlayer
> doesn't have any 16bit depth colorspaces, so I couldn't do that.
>
> --- a/DOCS/man/en/mplayer.1
> +++ b/DOCS/man/en/mplayer.1
> @@ -7336,6 +7336,25 @@ Percentage of the pixels that have to be below the threshold (default: 98).
> .
> +.TP
> +.B gradfun[=strength[:radius]]
> +Fix the banding artifacts that are sometimes introduced into nearly flat
> +regions by truncation to 8bit colordepth. Interpolates the gradients that
> +should go where the bands are, and dithers them.
> +.sp 1
> +This filter was designed for playback only. Do not use it prior to lossy
> +compression, because compression tends to lose the dither and bring back
> +the bands.
> +.RSs
> +.IPs <strength>
> +Maximum amount by which the filter will change any one pixel.
> +Also the threshold for detecting nearly flat regions (default: 1.2).
> +.IPs <radius>
> +Neighborhood to fit the gradient to. Larger radius makes for smoother
> +gradients, but also prevents the filter from modifying pixels near
> +detailed regions (default: 16).
Put new sentences on a new line please, it's a roff syntax requirement.
> --- /dev/null
> +++ b/libmpcodecs/vf_gradfun.c
> @@ -0,0 +1,394 @@
> +
> +#if ARCH_X86
> +#include "libavutil/x86_cpu.h"
> +#endif
The #if is unnecessary, the header just contains a bunch of #defines.
> +static void filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers) {
> + int x;
> + for(x=0; x<width; x++, dc+=x&1) {
Extra good karma for K&R style and reasonably short lines, i.e. { on the
next line for function declarations, space between if/for/while/switch
and (.
Diego
More information about the MPlayer-dev-eng
mailing list