[x264-devel] x264-devel Digest, Vol 117, Issue 8
klchoi123
klchoi123 at gmail.com
Thu Feb 2 16:34:43 CET 2017
Unsubscribe
On Feb 2, 2017 1:08 AM, <x264-devel-request at videolan.org> wrote:
> Send x264-devel mailing list submissions to
> x264-devel at videolan.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://mailman.videolan.org/listinfo/x264-devel
> or, via email, send a message with subject or body 'help' to
> x264-devel-request at videolan.org
>
> You can reach the person managing the list at
> x264-devel-owner at videolan.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of x264-devel digest..."
>
>
> Today's Topics:
>
> 1. [PATCH 15/29] Adjust headers to make x264cli independent of
> common.h (Vittorio Giovara)
> 2. [PATCH 16/29] Add API to set bitdepth at runtime
> (Vittorio Giovara)
> 3. [PATCH 17/29] Templatize the public API (Vittorio Giovara)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 2 Feb 2017 10:05:27 +0100
> From: Vittorio Giovara <vittorio.giovara at gmail.com>
> To: x264-devel at videolan.org
> Subject: [x264-devel] [PATCH 15/29] Adjust headers to make x264cli
> independent of common.h
> Message-ID: <20170202090541.22994-16-vittorio.giovara at gmail.com>
>
> ---
> filters/filters.c | 2 ++
> filters/video/cache.c | 2 ++
> filters/video/depth.c | 2 ++
> filters/video/fix_vfr_pts.c | 1 +
> filters/video/resize.c | 2 ++
> filters/video/select_every.c | 2 ++
> input/input.c | 1 +
> input/input.h | 5 +++++
> input/lavf.c | 2 ++
> input/thread.c | 2 ++
> input/timecode.c | 3 +++
> input/y4m.c | 2 ++
> output/flv.c | 3 +++
> output/flv_bytestream.c | 1 +
> output/flv_bytestream.h | 2 ++
> output/matroska_ebml.c | 3 +++
> output/mp4_lsmash.c | 1 +
> output/raw.c | 1 +
> x264.c | 10 +++++++++-
> x264cli.h | 5 ++++-
> 20 files changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/filters/filters.c b/filters/filters.c
> index 9212a3e..9479cd1 100644
> --- a/filters/filters.c
> +++ b/filters/filters.c
> @@ -26,6 +26,8 @@
> ************************************************************
> *****************/
>
> #include "filters.h"
> +#include <assert.h>
> +
> #define RETURN_IF_ERROR( cond, ... ) RETURN_IF_ERR( cond, "options",
> NULL, __VA_ARGS__ )
>
> char **x264_split_options( const char *opt_str, const char * const
> *options )
> diff --git a/filters/video/cache.c b/filters/video/cache.c
> index 552e1b4..17acb3d 100644
> --- a/filters/video/cache.c
> +++ b/filters/video/cache.c
> @@ -25,6 +25,8 @@
>
> #include "video.h"
> #include "internal.h"
> +#include "common/common.h"
> +
> #define NAME "cache"
> #define LAST_FRAME (h->first_frame + h->cur_size - 1)
>
> diff --git a/filters/video/depth.c b/filters/video/depth.c
> index 72eb288..2e09fe4 100644
> --- a/filters/video/depth.c
> +++ b/filters/video/depth.c
> @@ -23,6 +23,8 @@
> * For more information, contact us at licensing at x264.com.
> ************************************************************
> *****************/
>
> +#include "common/common.h"
> +
> #include "video.h"
> #define NAME "depth"
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
> diff --git a/filters/video/fix_vfr_pts.c b/filters/video/fix_vfr_pts.c
> index e7e9346..0eaf566 100644
> --- a/filters/video/fix_vfr_pts.c
> +++ b/filters/video/fix_vfr_pts.c
> @@ -25,6 +25,7 @@
>
> #include "video.h"
> #include "internal.h"
> +#include "common/mathematics.h"
>
> /* This filter calculates and store the frame's duration to the frame data
> * (if it is not already calculated when the frame arrives to this point)
> diff --git a/filters/video/resize.c b/filters/video/resize.c
> index 4e95f31..2a1c82d 100644
> --- a/filters/video/resize.c
> +++ b/filters/video/resize.c
> @@ -24,6 +24,8 @@
> ************************************************************
> *****************/
>
> #include "video.h"
> +#include "common/mathematics.h"
> +
> #define NAME "resize"
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
>
> diff --git a/filters/video/select_every.c b/filters/video/select_every.c
> index f5b6750..dab2771 100644
> --- a/filters/video/select_every.c
> +++ b/filters/video/select_every.c
> @@ -24,6 +24,8 @@
> ************************************************************
> *****************/
>
> #include "video.h"
> +#include "common/mathematics.h"
> +
> #define NAME "select_every"
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, NAME, __VA_ARGS__ )
>
> diff --git a/input/input.c b/input/input.c
> index faadd4d..84a014c 100644
> --- a/input/input.c
> +++ b/input/input.c
> @@ -25,6 +25,7 @@
> ************************************************************
> *****************/
>
> #include "input.h"
> +#include "common/mem.h"
>
> #ifdef _WIN32
> #include <io.h>
> diff --git a/input/input.h b/input/input.h
> index a66752d..084c3e3 100644
> --- a/input/input.h
> +++ b/input/input.h
> @@ -28,8 +28,13 @@
> #ifndef X264_INPUT_H
> #define X264_INPUT_H
>
> +#include <stdio.h>
> +
> +#include "config.h"
> #include "x264cli.h"
>
> +#include "common/osdep.h"
> +
> #ifdef _WIN32
> #include <windows.h>
> #endif
> diff --git a/input/lavf.c b/input/lavf.c
> index c0024a5..5067a3e 100644
> --- a/input/lavf.c
> +++ b/input/lavf.c
> @@ -25,6 +25,8 @@
> ************************************************************
> *****************/
>
> #include "input.h"
> +#include "common/mathematics.h"
> +
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "lavf", __VA_ARGS__
> )
> #undef DECLARE_ALIGNED
> #include <libavformat/avformat.h>
> diff --git a/input/thread.c b/input/thread.c
> index 3d83bfa..d9622b7 100644
> --- a/input/thread.c
> +++ b/input/thread.c
> @@ -25,6 +25,8 @@
> ************************************************************
> *****************/
>
> #include "input.h"
> +#include "common/threadpool.h"
> +#include "common/mathematics.h"
>
> typedef struct
> {
> diff --git a/input/timecode.c b/input/timecode.c
> index 25f924c..d1fbfe3 100644
> --- a/input/timecode.c
> +++ b/input/timecode.c
> @@ -24,6 +24,9 @@
> ************************************************************
> *****************/
>
> #include "input.h"
> +#include <math.h>
> +#include <inttypes.h>
> +
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "timecode",
> __VA_ARGS__ )
>
> typedef struct
> diff --git a/input/y4m.c b/input/y4m.c
> index 8948f68..901faaa 100644
> --- a/input/y4m.c
> +++ b/input/y4m.c
> @@ -25,6 +25,8 @@
> ************************************************************
> *****************/
>
> #include "input.h"
> +#include "common/mathematics.h"
> +
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "y4m", __VA_ARGS__ )
>
> typedef struct
> diff --git a/output/flv.c b/output/flv.c
> index dfe4d48..63ecbdd 100644
> --- a/output/flv.c
> +++ b/output/flv.c
> @@ -23,8 +23,11 @@
> * For more information, contact us at licensing at x264.com.
> ************************************************************
> *****************/
>
> +#include <inttypes.h>
> +
> #include "output.h"
> #include "flv_bytestream.h"
> +#include "common/osdep.h"
>
> #define CHECK(x)\
> do {\
> diff --git a/output/flv_bytestream.c b/output/flv_bytestream.c
> index b57a63c..c18f38c 100644
> --- a/output/flv_bytestream.c
> +++ b/output/flv_bytestream.c
> @@ -25,6 +25,7 @@
>
> #include "output.h"
> #include "flv_bytestream.h"
> +#include "common/osdep.h"
>
> uint64_t flv_dbl2int( double value )
> {
> diff --git a/output/flv_bytestream.h b/output/flv_bytestream.h
> index af22b09..5da5696 100644
> --- a/output/flv_bytestream.h
> +++ b/output/flv_bytestream.h
> @@ -26,6 +26,8 @@
> #ifndef X264_FLV_BYTESTREAM_H
> #define X264_FLV_BYTESTREAM_H
>
> +#include <stdio.h>
> +
> /* offsets for packed values */
> #define FLV_AUDIO_SAMPLESSIZE_OFFSET 1
> #define FLV_AUDIO_SAMPLERATE_OFFSET 2
> diff --git a/output/matroska_ebml.c b/output/matroska_ebml.c
> index b92a23e..0fb47ca 100644
> --- a/output/matroska_ebml.c
> +++ b/output/matroska_ebml.c
> @@ -23,8 +23,11 @@
> * For more information, contact us at licensing at x264.com.
> ************************************************************
> *****************/
>
> +#include <stdlib.h>
> +
> #include "output.h"
> #include "matroska_ebml.h"
> +#include "common/osdep.h"
>
> #define CLSIZE 1048576
> #define CHECK(x)\
> diff --git a/output/mp4_lsmash.c b/output/mp4_lsmash.c
> index 30bded0..b8af7a3 100644
> --- a/output/mp4_lsmash.c
> +++ b/output/mp4_lsmash.c
> @@ -29,6 +29,7 @@
>
> #include "output.h"
> #include <lsmash.h>
> +#include "common/osdep.h"
>
> #define H264_NALU_LENGTH_SIZE 4
>
> diff --git a/output/raw.c b/output/raw.c
> index 47e3353..02bfc20 100644
> --- a/output/raw.c
> +++ b/output/raw.c
> @@ -25,6 +25,7 @@
> ************************************************************
> *****************/
>
> #include "output.h"
> +#include "common/osdep.h"
>
> static int open_file( char *psz_filename, hnd_t *p_handle,
> cli_output_opt_t *opt )
> {
> diff --git a/x264.c b/x264.c
> index 016047a..15f0020 100644
> --- a/x264.c
> +++ b/x264.c
> @@ -39,11 +39,19 @@
>
> #include <signal.h>
> #include <getopt.h>
> -#include "common/common.h"
> #include "x264cli.h"
> #include "input/input.h"
> #include "output/output.h"
> #include "filters/filters.h"
> +#include "common/cpu.h"
> +#include "common/osdep.h"
> +#include "common/mathematics.h"
> +
> +#define MAX_BIT_DEPTH 10
> +#define QP_BD_OFFSET (6*(MAX_BIT_DEPTH-8))
> +#define QP_MAX_SPEC (51+QP_BD_OFFSET)
> +#define QP_MAX (QP_MAX_SPEC+18)
> +#define QP_MAX_MAX (51+2*6+18)
>
> #define FAIL_IF_ERROR( cond, ... ) FAIL_IF_ERR( cond, "x264", __VA_ARGS__
> )
>
> diff --git a/x264cli.h b/x264cli.h
> index 9b5d31e..6ae500e 100644
> --- a/x264cli.h
> +++ b/x264cli.h
> @@ -27,7 +27,10 @@
> #ifndef X264_CLI_H
> #define X264_CLI_H
>
> -#include "common/common.h"
> +#include <stdint.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include "x264.h"
>
> /* In microseconds */
> #define UPDATE_INTERVAL 250000
> --
> 2.10.0
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 2 Feb 2017 10:05:28 +0100
> From: Vittorio Giovara <vittorio.giovara at gmail.com>
> To: x264-devel at videolan.org
> Subject: [x264-devel] [PATCH 16/29] Add API to set bitdepth at runtime
> Message-ID: <20170202090541.22994-17-vittorio.giovara at gmail.com>
>
> Replace the constant symbol where needed.
> ---
> common/frame.c | 16 +---------------
> common/param.c | 11 +++++------
> common/set.h | 1 +
> encoder/encoder.c | 6 +++---
> encoder/set.c | 7 ++++---
> x264.h | 1 +
> 6 files changed, 15 insertions(+), 27 deletions(-)
>
> diff --git a/common/frame.c b/common/frame.c
> index e0b85b8..42af602 100644
> --- a/common/frame.c
> +++ b/common/frame.c
> @@ -370,21 +370,7 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t
> *dst, x264_picture_t *src )
> return -1;
> }
>
> -#if HIGH_BIT_DEPTH
> - if( !(src->img.i_csp & X264_CSP_HIGH_DEPTH) )
> - {
> - x264_log( h, X264_LOG_ERROR, "This build of x264 requires high
> depth input. Rebuild to support 8-bit input.\n" );
> - return -1;
> - }
> -#else
> - if( src->img.i_csp & X264_CSP_HIGH_DEPTH )
> - {
> - x264_log( h, X264_LOG_ERROR, "This build of x264 requires 8-bit
> input. Rebuild to support high depth input.\n" );
> - return -1;
> - }
> -#endif
> -
> - if( BIT_DEPTH != 10 && i_csp == X264_CSP_V210 )
> + if( h->param.i_bitdepth != 10 && i_csp == X264_CSP_V210 )
> {
> x264_log( h, X264_LOG_ERROR, "v210 input is only compatible with
> bit-depth of 10 bits\n" );
> return -1;
> diff --git a/common/param.c b/common/param.c
> index 1c35d5e..fb536e8 100644
> --- a/common/param.c
> +++ b/common/param.c
> @@ -24,8 +24,6 @@
> * For more information, contact us at licensing at x264.com.
> ************************************************************
> *****************/
>
> -#include "common.h"
> -
> #include <ctype.h>
> #include "osdep.h"
> #include "x264.h"
> @@ -449,6 +447,7 @@ int x264_param_apply_profile( x264_param_t *param,
> const char *profile )
> if( !profile )
> return 0;
>
> + const int qp_bd_offset = 6 * (param->i_bitdepth-8);
> int p = profile_string_to_int( profile );
> if( p < 0 )
> {
> @@ -456,7 +455,7 @@ int x264_param_apply_profile( x264_param_t *param,
> const char *profile )
> return -1;
> }
> if( p < PROFILE_HIGH444_PREDICTIVE && ((param->rc.i_rc_method ==
> X264_RC_CQP && param->rc.i_qp_constant <= 0) ||
> - (param->rc.i_rc_method == X264_RC_CRF &&
> (int)(param->rc.f_rf_constant + QP_BD_OFFSET) <= 0)) )
> + (param->rc.i_rc_method == X264_RC_CRF &&
> (int)(param->rc.f_rf_constant + qp_bd_offset) <= 0)) )
> {
> x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support
> lossless\n", profile );
> return -1;
> @@ -471,9 +470,9 @@ int x264_param_apply_profile( x264_param_t *param,
> const char *profile )
> x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support
> 4:2:2\n", profile );
> return -1;
> }
> - if( p < PROFILE_HIGH10 && BIT_DEPTH > 8 )
> + if( p < PROFILE_HIGH10 && param->i_bitdepth > 8 )
> {
> - x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support a
> bit depth of %d\n", profile, BIT_DEPTH );
> + x264_log_internal( X264_LOG_ERROR, "%s profile doesn't support a
> bit depth of %d\n", profile, param->i_bitdepth );
> return -1;
> }
>
> @@ -1081,7 +1080,7 @@ char *x264_param2string( x264_param_t *p, int b_res )
> s += sprintf( s, "%dx%d ", p->i_width, p->i_height );
> s += sprintf( s, "fps=%u/%u ", p->i_fps_num, p->i_fps_den );
> s += sprintf( s, "timebase=%u/%u ", p->i_timebase_num,
> p->i_timebase_den );
> - s += sprintf( s, "bitdepth=%d ", BIT_DEPTH );
> + s += sprintf( s, "bitdepth=%d ", p->i_bitdepth );
> }
>
> if( p->b_opencl )
> diff --git a/common/set.h b/common/set.h
> index 5760f33..c28b902 100644
> --- a/common/set.h
> +++ b/common/set.h
> @@ -157,6 +157,7 @@ typedef struct
>
> int b_qpprime_y_zero_transform_bypass;
> int i_chroma_format_idc;
> + int i_bitdepth;
>
> } x264_sps_t;
>
> diff --git a/encoder/encoder.c b/encoder/encoder.c
> index 935f137..cc6217a 100644
> --- a/encoder/encoder.c
> +++ b/encoder/encoder.c
> @@ -3795,9 +3795,9 @@ static int encoder_frame_end( x264_t *h, x264_t
> *thread_current,
> pic_out->opaque = h->fenc->opaque;
>
> pic_out->img.i_csp = h->fdec->i_csp;
> -#if HIGH_BIT_DEPTH
> - pic_out->img.i_csp |= X264_CSP_HIGH_DEPTH;
> -#endif
> + if( h->param.i_bitdepth > 8 )
> + pic_out->img.i_csp |= X264_CSP_HIGH_DEPTH;
> +
> pic_out->img.i_plane = h->fdec->i_plane;
> for( int i = 0; i < pic_out->img.i_plane; i++ )
> {
> diff --git a/encoder/set.c b/encoder/set.c
> index 07cb4c4..51b91f8 100644
> --- a/encoder/set.c
> +++ b/encoder/set.c
> @@ -107,13 +107,14 @@ void x264_sps_init( x264_sps_t *sps, int i_id,
> x264_param_t *param )
> sps->i_mb_height= ( param->i_height + 15 ) / 16;
> sps->i_chroma_format_idc = csp >= X264_CSP_I444 ? CHROMA_444 :
> csp >= X264_CSP_I422 ? CHROMA_422 :
> CHROMA_420;
> + sps->i_bitdepth = param->i_bitdepth;
>
> sps->b_qpprime_y_zero_transform_bypass = param->rc.i_rc_method ==
> X264_RC_CQP && param->rc.i_qp_constant == 0;
> if( sps->b_qpprime_y_zero_transform_bypass ||
> sps->i_chroma_format_idc == CHROMA_444 )
> sps->i_profile_idc = PROFILE_HIGH444_PREDICTIVE;
> else if( sps->i_chroma_format_idc == CHROMA_422 )
> sps->i_profile_idc = PROFILE_HIGH422;
> - else if( BIT_DEPTH > 8 )
> + else if( param->i_bitdepth > 8 )
> sps->i_profile_idc = PROFILE_HIGH10;
> else if( param->analyse.b_transform_8x8 || param->i_cqm_preset !=
> X264_CQM_FLAT )
> sps->i_profile_idc = PROFILE_HIGH;
> @@ -287,8 +288,8 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps )
> bs_write_ue( s, sps->i_chroma_format_idc );
> if( sps->i_chroma_format_idc == CHROMA_444 )
> bs_write1( s, 0 ); // separate_colour_plane_flag
> - bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_luma_minus8
> - bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_chroma_minus8
> + bs_write_ue( s, sps->i_bitdepth-8 ); // bit_depth_luma_minus8
> + bs_write_ue( s, sps->i_bitdepth-8 ); // bit_depth_chroma_minus8
> bs_write1( s, sps->b_qpprime_y_zero_transform_bypass );
> bs_write1( s, 0 ); // seq_scaling_matrix_present_flag
> }
> diff --git a/x264.h b/x264.h
> index b73e479..72ea253 100644
> --- a/x264.h
> +++ b/x264.h
> @@ -293,6 +293,7 @@ typedef struct x264_param_t
> int i_width;
> int i_height;
> int i_csp; /* CSP of encoded bitstream */
> + int i_bitdepth;
> int i_level_idc;
> int i_frame_total; /* number of frames to encode if known,
> else 0 */
>
> --
> 2.10.0
>
>
>
> ------------------------------
>
> Message: 3
> Date: Thu, 2 Feb 2017 10:05:29 +0100
> From: Vittorio Giovara <vittorio.giovara at gmail.com>
> To: x264-devel at videolan.org
> Subject: [x264-devel] [PATCH 17/29] Templatize the public API
> Message-ID: <20170202090541.22994-18-vittorio.giovara at gmail.com>
>
> Include an implementation file to wrap the appropriate calls. The
> current API calls are renamed according to the compiled bitdepth value.
> This file allocates an internal structure and calls the main API entry
> points.
>
> In upcoming commits more functions will be renamed and this file will
> support and use the correct function depending on bitdepth value set at
> runtime.
> ---
> Makefile | 2 +-
> common/api.c | 165 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> common/common.h | 15 +++++
> common/osdep.h | 5 ++
> encoder/encoder.c | 3 +
> 5 files changed, 189 insertions(+), 1 deletion(-)
> create mode 100644 common/api.c
>
> diff --git a/Makefile b/Makefile
> index f039fcc..d93ce95 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -19,7 +19,7 @@ SRCS = common/mc.c common/predict.c common/pixel.c
> common/macroblock.c \
> common/set.c common/quant.c common/deblock.c common/vlc.c \
> common/mvpred.c common/bitstream.c \
> common/log.c common/mem.c common/picture.c common/mathematics.c \
> - common/param.c common/tables.c \
> + common/param.c common/tables.c common/api.c \
> encoder/analyse.c encoder/me.c encoder/ratecontrol.c \
> encoder/set.c encoder/macroblock.c encoder/cabac.c \
> encoder/cavlc.c encoder/encoder.c encoder/lookahead.c
> diff --git a/common/api.c b/common/api.c
> new file mode 100644
> index 0000000..4a08d1e
> --- /dev/null
> +++ b/common/api.c
> @@ -0,0 +1,165 @@
> +/**********************************************************
> *******************
> + * api.c: bitdepth-independent interface
> + ************************************************************
> *****************
> + * Copyright (C) 2003-2017 x264 project
> + *
> + * Authors: Vittorio Giovara <vittorio.giovara at gmail.com>
> + * Luca Barbato <lu_zero at gentoo.org>
> + *
> + * This program 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.
> + *
> + * This program 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 this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111,
> USA.
> + *
> + * This program is also available under a commercial proprietary license.
> + * For more information, contact us at licensing at x264.com.
> + ************************************************************
> *****************/
> +
> +#include <stdint.h>
> +#include <stdlib.h>
> +
> +#include "x264.h"
> +
> +x264_t *x264_8_encoder_open( x264_param_t * );
> +void x264_8_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
> +int x264_8_encoder_reconfig( x264_t *, x264_param_t * );
> +void x264_8_encoder_parameters( x264_t *, x264_param_t * );
> +int x264_8_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
> +int x264_8_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal,
> x264_picture_t *pic_in, x264_picture_t *pic_out );
> +void x264_8_encoder_close( x264_t * );
> +int x264_8_encoder_delayed_frames( x264_t * );
> +int x264_8_encoder_maximum_delayed_frames( x264_t *h );
> +void x264_8_encoder_intra_refresh( x264_t * );
> +int x264_8_encoder_invalidate_reference( x264_t *, int64_t pts );
> +
> +typedef struct x264_api_t {
> + /* Internal reference to x264_t data */
> + void *x264;
> +
> + /* API entry points */
> + void (*x264_nal_encode) ( x264_t *h, uint8_t *dst, x264_nal_t *nal );
> + int (*x264_encoder_reconfig) ( x264_t *, x264_param_t * );
> + void (*x264_encoder_parameters) ( x264_t *, x264_param_t * );
> + int (*x264_encoder_headers) ( x264_t *, x264_nal_t **pp_nal, int
> *pi_nal );
> + int (*x264_encoder_encode) ( x264_t *, x264_nal_t **pp_nal, int
> *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
> + void (*x264_encoder_close) ( x264_t * );
> + int (*x264_encoder_delayed_frames) ( x264_t * );
> + int (*x264_encoder_maximum_delayed_frames) ( x264_t *h );
> + void (*x264_encoder_intra_refresh) ( x264_t * );
> + int (*x264_encoder_invalidate_reference) ( x264_t *, int64_t pts );
> +} x264_api_t;
> +
> +x264_t *x264_encoder_open( x264_param_t *param )
> +{
> + x264_api_t *api;
> +
> + api = calloc( 1, sizeof(x264_api_t) );
> + if( !api )
> + return NULL;
> +
> + if( param->i_bitdepth == 0 || param->i_bitdepth == 8 ) {
> + api->x264_encoder_reconfig = x264_8_encoder_reconfig;
> + api->x264_encoder_parameters = x264_8_encoder_parameters;
> + api->x264_encoder_headers = x264_8_encoder_headers;
> + api->x264_encoder_encode = x264_8_encoder_encode;
> + api->x264_encoder_close = x264_8_encoder_close;
> + api->x264_encoder_delayed_frames = x264_8_encoder_delayed_frames;
> + api->x264_encoder_maximum_delayed_frames =
> x264_8_encoder_maximum_delayed_frames;
> + api->x264_encoder_intra_refresh = x264_8_encoder_intra_refresh;
> + api->x264_encoder_invalidate_reference =
> x264_8_encoder_invalidate_reference;
> +
> + api->x264 = x264_8_encoder_open( param );
> + } else if( param->i_bitdepth == 10 ) {
> + x264_log_internal( NULL, "Not yet implemented\n");
> + }
> +
> + if( !api->x264 ) {
> + x264_encoder_close( (x264_t *) api );
> + return NULL;
> + }
> +
> + /* x264_t is opaque */
> + return (x264_t *) api;
> +}
> +
> +void x264_encoder_close( x264_t *h )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + if( api->x264_encoder_close && api->x264 )
> + api->x264_encoder_close( api->x264 );
> +
> + free( h );
> +}
> +
> +void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + api->x264_nal_encode( api->x264, dst, nal );
> +}
> +
> +int x264_encoder_reconfig( x264_t *h, x264_param_t *param)
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_reconfig( api->x264, param );
> +}
> +
> +void x264_encoder_parameters( x264_t *h, x264_param_t *param )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + api->x264_encoder_parameters( api->x264, param );
> +}
> +
> +int x264_encoder_headers( x264_t *h, x264_nal_t **pp_nal, int *pi_nal )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_headers( api->x264, pp_nal, pi_nal );
> +}
> +
> +int x264_encoder_encode( x264_t *h, x264_nal_t **pp_nal, int *pi_nal,
> x264_picture_t *pic_in, x264_picture_t *pic_out )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_encode( api->x264, pp_nal, pi_nal, pic_in,
> pic_out );
> +}
> +
> +int x264_encoder_delayed_frames( x264_t *h )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_delayed_frames( api->x264 );
> +}
> +
> +int x264_encoder_maximum_delayed_frames( x264_t *h )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_maximum_delayed_frames( api->x264 );
> +}
> +
> +void x264_encoder_intra_refresh( x264_t *h )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + api->x264_encoder_intra_refresh( api->x264 );
> +}
> +
> +int x264_encoder_invalidate_reference( x264_t *h, int64_t pts )
> +{
> + x264_api_t *api = (x264_api_t *)h;
> +
> + return api->x264_encoder_invalidate_reference( api->x264, pts );
> +}
> diff --git a/common/common.h b/common/common.h
> index db5c47b..dd9f136 100644
> --- a/common/common.h
> +++ b/common/common.h
> @@ -117,6 +117,21 @@ do {\
> #include <assert.h>
> #include <limits.h>
>
> +/**********************************************************
> ******************
> + * API Templates
> + ************************************************************
> ****************/
> +#define x264_encoder_open x264_template(encoder_open)
> +#define x264_nal_encode x264_template(nal_encode)
> +#define x264_encoder_reconfig x264_template(encoder_reconfig)
> +#define x264_encoder_parameters x264_template(encoder_parameters)
> +#define x264_encoder_headers x264_template(encoder_headers)
> +#define x264_encoder_encode x264_template(encoder_encode)
> +#define x264_encoder_close x264_template(encoder_close)
> +#define x264_encoder_delayed_frames x264_template(encoder_delayed_frames)
> +#define x264_encoder_maximum_delayed_frames
> x264_template(encoder_maximum_delayed_frames)
> +#define x264_encoder_intra_refresh x264_template(encoder_intra_refresh)
> +#define x264_encoder_invalidate_reference x264_template(encoder_
> invalidate_reference)
> +
> #if HAVE_INTERLACED
> # define MB_INTERLACED h->mb.b_interlaced
> # define SLICE_MBAFF h->sh.b_mbaff
> diff --git a/common/osdep.h b/common/osdep.h
> index 9544401..9a6978a 100644
> --- a/common/osdep.h
> +++ b/common/osdep.h
> @@ -103,6 +103,11 @@ int x264_is_pipe( const char *path );
> #define x264_is_pipe(x) 0
> #endif
>
> +/* Macros for templating function calls according to bitdepth */
> +#define x264_glue3_expand(x,y,z) x##_##y##_##z
> +#define x264_glue3(x,y,z) x264_glue3_expand(x,y,z)
> +#define x264_template(w) x264_glue3(x264,BIT_DEPTH,w)
> +
> #ifdef _MSC_VER
> #define DECLARE_ALIGNED( var, n ) __declspec(align(n)) var
> #else
> diff --git a/encoder/encoder.c b/encoder/encoder.c
> index cc6217a..7edd671 100644
> --- a/encoder/encoder.c
> +++ b/encoder/encoder.c
> @@ -40,6 +40,9 @@
>
> #define bs_write_ue bs_write_ue_big
>
> +// forward declaration need for template usage
> +void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
> +
> static int encoder_frame_end( x264_t *h, x264_t *thread_current,
> x264_nal_t **pp_nal, int *pi_nal,
> x264_picture_t *pic_out );
> --
> 2.10.0
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> x264-devel mailing list
> x264-devel at videolan.org
> https://mailman.videolan.org/listinfo/x264-devel
>
>
> ------------------------------
>
> End of x264-devel Digest, Vol 117, Issue 8
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20170202/9d059308/attachment-0001.html>
More information about the x264-devel
mailing list