Skip to content

Instantly share code, notes, and snippets.

@SAPikachu
Created August 8, 2011 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SAPikachu/1131739 to your computer and use it in GitHub Desktop.
Save SAPikachu/1131739 to your computer and use it in GitHub Desktop.
x264: skips depth filter when possible
a68cd9bf80f359d376cce02a295299302ed95d02
filters/video/depth.c | 7 +++++++
input/avs.c | 5 +++++
x264.h | 1 +
3 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/filters/video/depth.c b/filters/video/depth.c
index 25dde25..b6cf1a5 100644
--- a/filters/video/depth.c
+++ b/filters/video/depth.c
@@ -174,6 +174,13 @@ static void free_filter( hnd_t handle )
static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info,
x264_param_t *param, char *opt_string )
{
+ if( info->csp & X264_CSP_SKIP_DEPTH_FILTER )
+ {
+ x264_cli_log( "depth", X264_LOG_INFO, "skipped depth filter\n" );
+ info->csp = (info->csp & X264_CSP_MASK) | X264_CSP_HIGH_DEPTH;
+ return 0;
+ }
+
int ret = 0;
int change_fmt = (info->csp ^ param->i_csp) & X264_CSP_HIGH_DEPTH;
int csp = ~(~info->csp ^ change_fmt);
diff --git a/input/avs.c b/input/avs.c
index 373fa68..89032ca 100644
--- a/input/avs.c
+++ b/input/avs.c
@@ -273,6 +273,11 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
x264_cli_log( "avs", X264_LOG_INFO, "avisynth 16bit hack enabled\n" );
info->csp |= X264_CSP_HIGH_DEPTH;
info->width >>= 1;
+ if( opt->bit_depth == BIT_DEPTH )
+ {
+ /* HACK: totally skips depth filter to prevent dither error */
+ info->csp |= X264_CSP_SKIP_DEPTH_FILTER;
+ }
}
*p_handle = h;
diff --git a/x264.h b/x264.h
index 965d314..c806f2d 100644
--- a/x264.h
+++ b/x264.h
@@ -188,6 +188,7 @@ static const char * const x264_nal_hrd_names[] = { "none", "vbr", "cbr", 0 };
#define X264_CSP_MAX 0x0009 /* end of list */
#define X264_CSP_VFLIP 0x1000 /* the csp is vertically flipped */
#define X264_CSP_HIGH_DEPTH 0x2000 /* the csp has a depth of 16 bits per pixel component */
+#define X264_CSP_SKIP_DEPTH_FILTER 0x0100 /* HACK: totally skips depth filter to prevent dither error */
/* Slice type */
#define X264_TYPE_AUTO 0x0000 /* Let x264 choose the right type */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment