Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From dc5f7f4f60a1caaff14133bbfedf076813f45a43 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Thu, 17 Aug 2017 23:46:23 +0300
- Subject: [PATCH 1/7] flv: Split FrameType and CodecID values
- ---
- output/flv.c | 4 ++--
- output/flv_bytestream.h | 4 ++--
- 2 files changed, 4 insertions(+), 4 deletions(-)
- diff --git a/output/flv.c b/output/flv.c
- index 63ecbddc..8c127128 100644
- --- a/output/flv.c
- +++ b/output/flv.c
- @@ -199,7 +199,7 @@ static int write_headers( hnd_t handle, x264_nal_t *p_nal )
- flv_put_be24( c, 0 ); // StreamID - Always 0
- p_flv->start = c->d_cur; // needed for overwriting length
- - flv_put_byte( c, 7 | FLV_FRAME_KEY ); // Frametype and CodecID
- + flv_put_byte( c, FLV_FRAME_KEY | FLV_CODECID_H264 ); // FrameType and CodecID
- flv_put_byte( c, 0 ); // AVC sequence header
- flv_put_be24( c, 0 ); // composition time
- @@ -282,7 +282,7 @@ static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_
- flv_put_be24( c, 0 );
- p_flv->start = c->d_cur;
- - flv_put_byte( c, p_picture->b_keyframe ? FLV_FRAME_KEY : FLV_FRAME_INTER );
- + flv_put_byte( c, (p_picture->b_keyframe ? FLV_FRAME_KEY : FLV_FRAME_INTER) | FLV_CODECID_H264 );
- flv_put_byte( c, 1 ); // AVC NALU
- flv_put_be24( c, offset );
- diff --git a/output/flv_bytestream.h b/output/flv_bytestream.h
- index 5da56960..d3f89ca4 100644
- --- a/output/flv_bytestream.h
- +++ b/output/flv_bytestream.h
- @@ -92,8 +92,8 @@ enum
- enum
- {
- - FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET | 7,
- - FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET | 7,
- + FLV_FRAME_KEY = 1 << FLV_VIDEO_FRAMETYPE_OFFSET,
- + FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET,
- };
- typedef enum
- --
- 2.13.0.windows.1
- From 2ac159b201e4500732e13fcae293bc5bc7d23882 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Thu, 17 Aug 2017 23:51:14 +0300
- Subject: [PATCH 2/7] flv: Fix one frame video total duration
- ---
- output/flv.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
- diff --git a/output/flv.c b/output/flv.c
- index 8c127128..b7827f99 100644
- --- a/output/flv.c
- +++ b/output/flv.c
- @@ -325,7 +325,12 @@ static int close_file( hnd_t handle, int64_t largest_pts, int64_t second_largest
- CHECK( flv_flush_data( c ) );
- - double total_duration = (2 * largest_pts - second_largest_pts) * p_flv->d_timebase;
- + double total_duration;
- + /* duration algorithm fails with one frame */
- + if( p_flv->i_framenum == 1 )
- + total_duration = p_flv->i_fps_num ? (double)p_flv->i_fps_den / p_flv->i_fps_num : 0;
- + else
- + total_duration = (2 * largest_pts - second_largest_pts) * p_flv->d_timebase;
- if( x264_is_regular_file( c->fp ) && total_duration > 0 )
- {
- --
- 2.13.0.windows.1
- From 131f30940b970b3c3b642a194ca0ebd04e96d1fd Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Fri, 22 Sep 2017 16:20:15 +0300
- Subject: [PATCH 3/7] Fix compilation with mp4 output (gpac)
- ---
- input/input.h | 5 -----
- output/flv.c | 1 -
- output/flv_bytestream.c | 1 -
- output/matroska_ebml.c | 1 -
- output/mp4_lsmash.c | 1 -
- output/raw.c | 1 -
- x264.c | 1 -
- x264cli.h | 1 +
- 8 files changed, 1 insertion(+), 11 deletions(-)
- diff --git a/input/input.h b/input/input.h
- index 816ee32c..3b33be4a 100644
- --- a/input/input.h
- +++ b/input/input.h
- @@ -28,13 +28,8 @@
- #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/output/flv.c b/output/flv.c
- index b7827f99..606842fb 100644
- --- a/output/flv.c
- +++ b/output/flv.c
- @@ -27,7 +27,6 @@
- #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 c18f38c1..b57a63ca 100644
- --- a/output/flv_bytestream.c
- +++ b/output/flv_bytestream.c
- @@ -25,7 +25,6 @@
- #include "output.h"
- #include "flv_bytestream.h"
- -#include "common/osdep.h"
- uint64_t flv_dbl2int( double value )
- {
- diff --git a/output/matroska_ebml.c b/output/matroska_ebml.c
- index 0fb47ca0..ef246cbf 100644
- --- a/output/matroska_ebml.c
- +++ b/output/matroska_ebml.c
- @@ -27,7 +27,6 @@
- #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 b8af7a35..30bded00 100644
- --- a/output/mp4_lsmash.c
- +++ b/output/mp4_lsmash.c
- @@ -29,7 +29,6 @@
- #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 02bfc201..47e33539 100644
- --- a/output/raw.c
- +++ b/output/raw.c
- @@ -25,7 +25,6 @@
- *****************************************************************************/
- #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 90e0a0b7..06d15897 100644
- --- a/x264.c
- +++ b/x264.c
- @@ -44,7 +44,6 @@
- #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
- diff --git a/x264cli.h b/x264cli.h
- index 6ae500e2..0920d7b4 100644
- --- a/x264cli.h
- +++ b/x264cli.h
- @@ -31,6 +31,7 @@
- #include <stdlib.h>
- #include <string.h>
- #include "x264.h"
- +#include "common/osdep.h"
- /* In microseconds */
- #define UPDATE_INTERVAL 250000
- --
- 2.13.0.windows.1
- From a0c87fcd2b10dc3aac864e97b052ae1ce3e7d9d3 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Fri, 22 Sep 2017 16:59:13 +0300
- Subject: [PATCH 4/7] configure: Improvements
- Log result of pkg-config checks to config.log.
- Fix lavf support detection for pkg-config fallback case.
- Fix detection of linking dependencies errors for lavf/lsmash/gpac.
- Cosmetics.
- ---
- configure | 48 +++++++++++++++++++++++++++++++++---------------
- 1 file changed, 33 insertions(+), 15 deletions(-)
- diff --git a/configure b/configure
- index de809f12..dc32a3f3 100755
- --- a/configure
- +++ b/configure
- @@ -253,6 +253,24 @@ rc_check() {
- return $res
- }
- +pkg_check() {
- + log_check "for packages: $1"
- + pkg_cmd="$PKGCONFIG --exists $1"
- + if $pkg_cmd >conftest.log 2>&1; then
- + res=$?
- + log_ok
- + else
- + res=$?
- + log_fail
- + log_msg "Failed commandline was:"
- + log_msg "--------------------------------------------------"
- + log_msg "$pkg_cmd"
- + cat conftest.log >> config.log
- + log_msg "--------------------------------------------------"
- + fi
- + return $res
- +}
- +
- define() {
- echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
- }
- @@ -978,7 +996,7 @@ fi
- if [ "$cli_libx264" = "system" -a "$shared" != "yes" ] ; then
- [ "$static" = "yes" ] && die "Option --system-libx264 can not be used together with --enable-static"
- - if $PKGCONFIG --exists x264 2>/dev/null; then
- + if pkg_check x264 ; then
- X264_LIBS="$($PKGCONFIG --libs x264)"
- X264_INCLUDE_DIR="${X264_INCLUDE_DIR-$($PKGCONFIG --variable=includedir x264)}"
- configure_system_override "$X264_INCLUDE_DIR" || die "Detection of system libx264 configuration failed"
- @@ -1040,7 +1058,7 @@ if [ "$thread" = "posix" ]; then
- fi
- [ "$thread" != "no" ] && define HAVE_THREAD
- -if cc_check "math.h" "-Werror" "return log2f(2);" ; then
- +if cc_check 'math.h' '' 'log2f(2);' ; then
- define HAVE_LOG2F
- fi
- @@ -1068,7 +1086,7 @@ fi
- if [ "$swscale" = "auto" ] ; then
- swscale="no"
- - if $PKGCONFIG --exists libswscale 2>/dev/null; then
- + if pkg_check 'libswscale libavutil' ; then
- SWSCALE_LIBS="$SWSCALE_LIBS $($PKGCONFIG --libs libswscale libavutil)"
- SWSCALE_CFLAGS="$SWSCALE_CFLAGS $($PKGCONFIG --cflags libswscale libavutil)"
- fi
- @@ -1085,18 +1103,18 @@ fi
- if [ "$lavf" = "auto" ] ; then
- lavf="no"
- - if $PKGCONFIG --exists libavformat libavcodec libswscale 2>/dev/null; then
- - LAVF_LIBS="$LAVF_LIBS $($PKGCONFIG --libs libavformat libavcodec libavutil libswscale)"
- - LAVF_CFLAGS="$LAVF_CFLAGS $($PKGCONFIG --cflags libavformat libavcodec libavutil libswscale)"
- + if pkg_check 'libavformat libavcodec libavutil' ; then
- + LAVF_LIBS="$LAVF_LIBS $($PKGCONFIG --libs libavformat libavcodec libavutil)"
- + LAVF_CFLAGS="$LAVF_CFLAGS $($PKGCONFIG --cflags libavformat libavcodec libavutil)"
- fi
- - if [ -z "$LAVF_LIBS" -a -z "$LAVF_CFLAGS" ]; then
- + if [ -z "$LAVF_LIBS" ] && cc_check '' -lavformat ; then
- LAVF_LIBS="-lavformat"
- - for lib in -lpostproc -lavcodec -lswscale -lavutil -lm -lz -lbz2 $libpthread -lavifil32 -lws2_32; do
- + for lib in -lavcodec -lavresample -lswresample -lavutil -lbz2 -lz $libpthread -lole32 -luser32 -lws2_32 -lsecur32 ; do
- cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
- done
- fi
- - LAVF_LIBS="-L. $LAVF_LIBS"
- - if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "av_frame_free(0);" ; then
- +
- + if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "av_register_all();" ; then
- if [ "$swscale" = "yes" ]; then
- lavf="yes"
- else
- @@ -1109,7 +1127,7 @@ if [ "$ffms" = "auto" ] ; then
- ffms_major="2"; ffms_minor="21"; ffms_micro="0"; ffms_bump="0"
- ffms="no"
- - if $PKGCONFIG --exists ffms2 2>/dev/null; then
- + if pkg_check ffms2 ; then
- FFMS2_LIBS="$FFMS2_LIBS $($PKGCONFIG --libs ffms2)"
- FFMS2_CFLAGS="$FFMS2_CFLAGS $($PKGCONFIG --cflags ffms2)"
- fi
- @@ -1151,13 +1169,13 @@ fi
- if [ "$lsmash" = "auto" ] ; then
- lsmash="no"
- - if $PKGCONFIG --exists liblsmash 2>/dev/null; then
- + if pkg_check liblsmash ; then
- LSMASH_LIBS="$LSMASH_LIBS $($PKGCONFIG --libs liblsmash)"
- LSMASH_CFLAGS="$LSMASH_CFLAGS $($PKGCONFIG --cflags liblsmash)"
- fi
- [ -z "$LSMASH_LIBS" ] && LSMASH_LIBS="-llsmash"
- - if cc_check lsmash.h "$LSMASH_CFLAGS $LSMASH_LIBS" ; then
- + if cc_check lsmash.h "$LSMASH_CFLAGS $LSMASH_LIBS" "lsmash_destroy_root(0);" ; then
- if cpp_check lsmash.h "$LSMASH_CFLAGS" "LSMASH_VERSION_MAJOR > 1 || (LSMASH_VERSION_MAJOR == 1 && LSMASH_VERSION_MINOR >= 5)" ; then
- lsmash="yes"
- else
- @@ -1174,7 +1192,7 @@ if [ "$gpac" = "auto" -a "$lsmash" != "yes" ] ; then
- cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32"
- cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm"
- fi
- - if cc_check gpac/isomedia.h "$GPAC_LIBS" ; then
- + if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_close(0);" ; then
- if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
- gpac="yes"
- else
- @@ -1190,8 +1208,8 @@ if [ "$lsmash" = "yes" ] ; then
- define HAVE_LSMASH
- elif [ "$gpac" = "yes" ] ; then
- mp4="gpac"
- - define HAVE_GPAC
- LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
- + define HAVE_GPAC
- fi
- if [ "$avs" = "auto" ] ; then
- --
- 2.13.0.windows.1
- From 8a3f8a1cffde234fd474addfcbd2edc646733bc6 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Fri, 22 Sep 2017 17:05:06 +0300
- Subject: [PATCH 5/7] Fix thread safety of x264_threading_init() and use of
- X264_PTHREAD_MUTEX_INITIALIZER with win32thread
- ---
- common/osdep.c | 22 ++++++++++++++++++----
- common/threadpool.c | 3 +++
- common/win32thread.c | 10 +++++++++-
- 3 files changed, 30 insertions(+), 5 deletions(-)
- diff --git a/common/osdep.c b/common/osdep.c
- index e5615dcf..42b5aaa9 100644
- --- a/common/osdep.c
- +++ b/common/osdep.c
- @@ -72,11 +72,8 @@ static void threading_destroy( void )
- #endif
- }
- -int x264_threading_init( void )
- +static int threading_init( void )
- {
- - /* if already init, then do nothing */
- - if( InterlockedCompareExchange( &x264_threading_is_init, 1, 0 ) )
- - return 0;
- #if PTW32_STATIC_LIB
- /* if static pthread-win32 is already initialized, then do nothing */
- if( ptw32_processInitialized )
- @@ -89,7 +86,24 @@ int x264_threading_init( void )
- #endif
- /* register cleanup to run at process termination */
- atexit( threading_destroy );
- + return 0;
- +}
- +int x264_threading_init( void )
- +{
- + LONG state;
- + while( (state = InterlockedCompareExchange( &x264_threading_is_init, -1, 0 )) != 0 )
- + {
- + /* if already init, then do nothing */
- + if( state > 0 )
- + return 0;
- + }
- + if( threading_init() < 0 )
- + {
- + InterlockedExchange( &x264_threading_is_init, 0 );
- + return -1;
- + }
- + InterlockedExchange( &x264_threading_is_init, 1 );
- return 0;
- }
- #endif
- diff --git a/common/threadpool.c b/common/threadpool.c
- index 61d75ce0..f707cfdd 100644
- --- a/common/threadpool.c
- +++ b/common/threadpool.c
- @@ -78,6 +78,9 @@ int x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
- if( threads <= 0 )
- return -1;
- + if( x264_threading_init() < 0 )
- + return -1;
- +
- x264_threadpool_t *pool;
- CHECKED_MALLOCZERO( pool, sizeof(x264_threadpool_t) );
- *p_pool = pool;
- diff --git a/common/win32thread.c b/common/win32thread.c
- index 8f878d94..76940d3f 100644
- --- a/common/win32thread.c
- +++ b/common/win32thread.c
- @@ -95,7 +95,15 @@ int x264_pthread_mutex_lock( x264_pthread_mutex_t *mutex )
- {
- static const x264_pthread_mutex_t init = X264_PTHREAD_MUTEX_INITIALIZER;
- if( !memcmp( mutex, &init, sizeof(x264_pthread_mutex_t) ) )
- - *mutex = static_mutex;
- + {
- + int ret = 0;
- + EnterCriticalSection( &static_mutex );
- + if( !memcmp( mutex, &init, sizeof(x264_pthread_mutex_t) ) )
- + ret = x264_pthread_mutex_init( mutex, NULL );
- + LeaveCriticalSection( &static_mutex );
- + if( ret )
- + return ret;
- + }
- EnterCriticalSection( mutex );
- return 0;
- }
- --
- 2.13.0.windows.1
- From e907e2ffc2fbc3907c6ac842ccf9fa33334f1af1 Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Fri, 22 Sep 2017 17:18:55 +0300
- Subject: [PATCH 6/7] Make ref and i4x4_mode costs global instead of static
- Fixes some thread safety doubts and makes code cleaner.
- Downside: slightly higher memory usage when calling multiple encoders from the same application.
- ---
- common/common.h | 7 ++++++-
- encoder/analyse.c | 16 +++++-----------
- encoder/encoder.c | 2 ++
- 3 files changed, 13 insertions(+), 12 deletions(-)
- diff --git a/common/common.h b/common/common.h
- index 279babf1..32485b56 100644
- --- a/common/common.h
- +++ b/common/common.h
- @@ -501,9 +501,14 @@ struct x264_t
- udctcoef (*quant8_bias0[4])[64]; /* [4][QP_MAX_SPEC+1][64] */
- udctcoef (*nr_offset_emergency)[4][64];
- - /* mv/ref cost arrays. */
- + /* mv/ref/mode cost arrays. */
- uint16_t *cost_mv[QP_MAX+1];
- uint16_t *cost_mv_fpel[QP_MAX+1][4];
- + struct
- + {
- + uint16_t ref[QP_MAX+1][3][33];
- + ALIGNED_64( uint16_t i4x4_mode[(QP_MAX+2)*32] );
- + } *cost_table;
- const uint8_t *chroma_qp_table; /* includes both the nonlinear luma->chroma mapping and chroma_qp_offset */
- diff --git a/encoder/analyse.c b/encoder/analyse.c
- index 2e9ad6b8..d077a75c 100644
- --- a/encoder/analyse.c
- +++ b/encoder/analyse.c
- @@ -191,10 +191,6 @@ static const uint8_t i_sub_mb_p_cost_table[4] =
- static void analyse_update_cache( x264_t *h, x264_mb_analysis_t *a );
- -static uint16_t x264_cost_ref[QP_MAX+1][3][33];
- -static UNUSED x264_pthread_mutex_t cost_ref_mutex = X264_PTHREAD_MUTEX_INITIALIZER;
- -static uint16_t x264_cost_i4x4_mode[(QP_MAX+2)*32];
- -
- static int init_costs( x264_t *h, float *logs, int qp )
- {
- if( h->cost_mv[qp] )
- @@ -210,11 +206,9 @@ static int init_costs( x264_t *h, float *logs, int qp )
- h->cost_mv[qp][-i] =
- h->cost_mv[qp][i] = X264_MIN( (int)(lambda * logs[i] + .5f), UINT16_MAX );
- }
- - x264_pthread_mutex_lock( &cost_ref_mutex );
- for( int i = 0; i < 3; i++ )
- for( int j = 0; j < 33; j++ )
- - x264_cost_ref[qp][i][j] = i ? X264_MIN( lambda * bs_size_te( i, j ), UINT16_MAX ) : 0;
- - x264_pthread_mutex_unlock( &cost_ref_mutex );
- + h->cost_table->ref[qp][i][j] = i ? X264_MIN( lambda * bs_size_te( i, j ), UINT16_MAX ) : 0;
- if( h->param.analyse.i_me_method >= X264_ME_ESA && !h->cost_mv_fpel[qp][0] )
- {
- for( int j = 0; j < 4; j++ )
- @@ -225,7 +219,7 @@ static int init_costs( x264_t *h, float *logs, int qp )
- h->cost_mv_fpel[qp][j][i] = h->cost_mv[qp][i*4+j];
- }
- }
- - uint16_t *cost_i4x4_mode = (uint16_t*)ALIGN((intptr_t)x264_cost_i4x4_mode,64) + qp*32;
- + uint16_t *cost_i4x4_mode = (uint16_t*)h->cost_table->i4x4_mode + qp*32;
- for( int i = 0; i < 17; i++ )
- cost_i4x4_mode[i] = 3*lambda*(i!=8);
- return 0;
- @@ -303,8 +297,8 @@ void x264_analyse_weight_frame( x264_t *h, int end )
- static void mb_analyse_load_costs( x264_t *h, x264_mb_analysis_t *a )
- {
- a->p_cost_mv = h->cost_mv[a->i_qp];
- - a->p_cost_ref[0] = x264_cost_ref[a->i_qp][x264_clip3(h->sh.i_num_ref_idx_l0_active-1,0,2)];
- - a->p_cost_ref[1] = x264_cost_ref[a->i_qp][x264_clip3(h->sh.i_num_ref_idx_l1_active-1,0,2)];
- + a->p_cost_ref[0] = h->cost_table->ref[a->i_qp][x264_clip3(h->sh.i_num_ref_idx_l0_active-1,0,2)];
- + a->p_cost_ref[1] = h->cost_table->ref[a->i_qp][x264_clip3(h->sh.i_num_ref_idx_l1_active-1,0,2)];
- }
- static void mb_analyse_init_qp( x264_t *h, x264_mb_analysis_t *a, int qp )
- @@ -800,7 +794,7 @@ static void mb_analyse_intra( x264_t *h, x264_mb_analysis_t *a, int i_satd_inter
- return;
- }
- - uint16_t *cost_i4x4_mode = (uint16_t*)ALIGN((intptr_t)x264_cost_i4x4_mode,64) + a->i_qp*32 + 8;
- + uint16_t *cost_i4x4_mode = (uint16_t*)h->cost_table->i4x4_mode + a->i_qp*32 + 8;
- /* 8x8 prediction selection */
- if( flags & X264_ANALYSE_I8x8 )
- {
- diff --git a/encoder/encoder.c b/encoder/encoder.c
- index f6e593c9..b3abc168 100644
- --- a/encoder/encoder.c
- +++ b/encoder/encoder.c
- @@ -1521,6 +1521,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
- h->frames.i_largest_pts = h->frames.i_second_largest_pts = -1;
- h->frames.i_poc_last_open_gop = -1;
- + CHECKED_MALLOCZERO( h->cost_table, sizeof(*h->cost_table) );
- CHECKED_MALLOCZERO( h->frames.unused[0], (h->frames.i_delay + 3) * sizeof(x264_frame_t *) );
- /* Allocate room for max refs plus a few extra just in case. */
- CHECKED_MALLOCZERO( h->frames.unused[1], (h->i_thread_frames + X264_REF_MAX + 4) * sizeof(x264_frame_t *) );
- @@ -4358,6 +4359,7 @@ void x264_encoder_close ( x264_t *h )
- x264_free( h->nal_buffer );
- x264_free( h->reconfig_h );
- x264_analyse_free_costs( h );
- + x264_free( h->cost_table );
- if( h->i_thread_frames > 1 )
- h = h->thread[h->i_thread_phase];
- --
- 2.13.0.windows.1
- From 91031f71beb94c97abb0fcc40116347f9f4e66fc Mon Sep 17 00:00:00 2001
- From: Anton Mitrofanov <BugMaster@narod.ru>
- Date: Fri, 22 Sep 2017 17:28:18 +0300
- Subject: [PATCH 7/7] Don't force fast-intra for subme < 3
- It have caused significant quality hit without any meaningful (if any) speed up.
- ---
- encoder/analyse.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
- diff --git a/encoder/analyse.c b/encoder/analyse.c
- index d077a75c..871670bb 100644
- --- a/encoder/analyse.c
- +++ b/encoder/analyse.c
- @@ -494,14 +494,12 @@ static void mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int qp )
- /* Fast intra decision */
- if( a->b_early_terminate && h->mb.i_mb_xy - h->sh.i_first_mb > 4 )
- {
- - /* Always run in fast-intra mode for subme < 3 */
- - if( h->mb.i_subpel_refine > 2 &&
- - ( IS_INTRA( h->mb.i_mb_type_left[0] ) ||
- + if( IS_INTRA( h->mb.i_mb_type_left[0] ) ||
- IS_INTRA( h->mb.i_mb_type_top ) ||
- IS_INTRA( h->mb.i_mb_type_topleft ) ||
- IS_INTRA( h->mb.i_mb_type_topright ) ||
- (h->sh.i_type == SLICE_TYPE_P && IS_INTRA( h->fref[0][0]->mb_type[h->mb.i_mb_xy] )) ||
- - (h->mb.i_mb_xy - h->sh.i_first_mb < 3*(h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_8x8] + h->stat.frame.i_mb_count[I_16x16])) ) )
- + (h->mb.i_mb_xy - h->sh.i_first_mb < 3*(h->stat.frame.i_mb_count[I_4x4] + h->stat.frame.i_mb_count[I_8x8] + h->stat.frame.i_mb_count[I_16x16])) )
- { /* intra is likely */ }
- else
- {
- --
- 2.13.0.windows.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement