[x264-devel] [Git][videolan/x264][stable] 11 commits: mp4: Add GPAC detection with pkg-config

Anton Mitrofanov gitlab at videolan.org
Sun Jun 13 20:41:32 UTC 2021



Anton Mitrofanov pushed to branch stable at VideoLAN / x264


Commits:
979044a6 by Anton Mitrofanov at 2021-04-13T19:20:26+00:00
mp4: Add GPAC detection with pkg-config

- - - - -
989f618e by Brad Smith at 2021-04-13T20:40:49+00:00
arm: Enable HAVE_SECTION_DATA_REL_RO for OpenBSD

- - - - -
10e1b406 by Brad Smith at 2021-04-13T20:40:49+00:00
Use sysconf(_SC_NPROCESSORS_ONLN) on OpenBSD

On modern versions of OpenBSD, the number of processors online may differ from
the number of processors configured.

- - - - -
c347e7a0 by Anton Mitrofanov at 2021-04-13T20:46:00+00:00
CI: Add macos-arm64 target (cross-compile)

Rename the old macos target to macos-x86_64.

- - - - -
5bc04b8d by Anton Mitrofanov at 2021-05-03T12:29:06+03:00
y4m: Support files with longer sequence header

ffmpeg can now generate y4m files with sequence header length > 80.

- - - - -
5180c07c by Anton Mitrofanov at 2021-05-03T13:54:26+03:00
y4m: Support ffmpeg's color range extension

- - - - -
4459373f by Anton Mitrofanov at 2021-05-05T06:50:25+00:00
Fix parsing of enums

Ignore empty string values for enum.

- - - - -
8719ef8a by Phillip Blucas at 2021-05-05T07:11:57+00:00
Support writing the mastering display color volume SEI message

Use --mastering-display to specify the properties of the reference display.
A formatted string with all 10 values is required: G,B,R primaries and
white point coordinates, plus max/min brightness. Coordinates are in
0.00002 increments. Brightness units are 0.0001 cd/m^2.

For example, a 1000 nit BT.2020 display with a 0.0001 nit black level:
--mastering-display G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)

- - - - -
fa770fd5 by Phillip Blucas at 2021-05-05T07:11:57+00:00
Support writing the content light level information SEI message

Use --cll to specify the maximum content light level (MaxCLL)
and the maximum frame average light level (MaxFALL) as described
by the CTA 861.3 specification.

- - - - -
b684ebe0 by Anton Mitrofanov at 2021-05-05T10:27:24+03:00
Cosmetics: Fix vertical alignment for long_options

- - - - -
5db6aa6c by Anton Mitrofanov at 2021-06-13T15:43:57+03:00
lavf: Fix compilation with new versions of ffmpeg

Add the missing header as avcodec.h is no longer included in avformat.h.

- - - - -


14 changed files:

- .gitlab-ci.yml
- autocomplete.c
- common/arm/asm.S
- common/base.c
- common/base.h
- common/cpu.c
- configure
- encoder/encoder.c
- encoder/set.c
- encoder/set.h
- input/lavf.c
- input/y4m.c
- x264.c
- x264.h


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -35,11 +35,21 @@ stages:
     _PLATFORMSUFFIX: ".exe"
     _WRAPPER: ""
 
-.variables-macos: &variables-macos
+.variables-macos-x86_64: &variables-macos-x86_64
     _TRIPLET: "x86_64-apple-darwin19"
     _PLATFORMSUFFIX: ""
     _WRAPPER: ""
     _CONTRIB_URL: "https://artifacts.videolan.org/vlc/macos-x86_64/"
+    _XCFLAGS: "-arch x86_64"
+    _XLDFLAGS: "-arch x86_64"
+
+.variables-macos-arm64: &variables-macos-arm64
+    _TRIPLET: "aarch64-apple-darwin19"
+    _PLATFORMSUFFIX: ""
+    _WRAPPER: ""
+    _CONTRIB_URL: "https://artifacts.videolan.org/vlc/macos-arm64/"
+    _XCFLAGS: "-arch arm64"
+    _XLDFLAGS: "-arch arm64"
 
 .build:
     stage: build
@@ -133,11 +143,8 @@ build-llvm-mingw-aarch64:
     extends: .build-llvm-mingw
     variables: *variables-win-aarch64
 
-build-macos:
+.build-macos:
     extends: .build
-    tags:
-        - amd64
-        - catalina
     script: |
         set -x
         LOCAL_INSTALL_DIR=`pwd`/${_TRIPLET}
@@ -150,13 +157,26 @@ build-macos:
         sed -i.bak -e "s#@@CONTRIB_PREFIX@@#${LOCAL_INSTALL_DIR}#g" ${PKG_CONFIG_LIBDIR}/*.pc
         git clone --depth 1 --branch master https://github.com/l-smash/l-smash.git lsmash
         cd lsmash
-        ./configure --prefix="${LOCAL_INSTALL_DIR}"
+        ./configure --prefix="${LOCAL_INSTALL_DIR}" --target-os="${_TRIPLET}" --extra-cflags="${_XCFLAGS}" --extra-ldflags="${_XLDFLAGS}"
         make -j$(getconf _NPROCESSORS_ONLN)
         make -j$(getconf _NPROCESSORS_ONLN) install
         cd ..
-        ./configure --enable-pic --enable-strip
+        ./configure --host="${_TRIPLET}" --enable-pic --enable-strip
         make -j$(getconf _NPROCESSORS_ONLN) x264 checkasm
-    variables: *variables-macos
+
+build-macos-x86_64:
+    extends: .build-macos
+    tags:
+        - amd64
+        - catalina
+    variables: *variables-macos-x86_64
+
+build-macos-arm64:
+    extends: .build-macos
+    tags:
+        - amd64
+        - catalina
+    variables: *variables-macos-arm64
 
 .test: &test
     stage: test
@@ -195,12 +215,12 @@ test-win64:
         - build-win64
     variables: *variables-win64
 
-test-macos:
+test-macos-x86_64:
     <<: *test
-    extends: build-macos
+    extends: build-macos-x86_64
     dependencies:
-        - build-macos
-    variables: *variables-macos
+        - build-macos-x86_64
+    variables: *variables-macos-x86_64
 
 .release: &release
     stage: release
@@ -246,9 +266,16 @@ release-win64:
         - build-win64
     variables: *variables-win64
 
-release-macos:
+release-macos-x86_64:
+    <<: *release
+    extends: build-macos-x86_64
+    dependencies:
+        - build-macos-x86_64
+    variables: *variables-macos-x86_64
+
+release-macos-arm64:
     <<: *release
-    extends: build-macos
+    extends: build-macos-arm64
     dependencies:
-        - build-macos
-    variables: *variables-macos
+        - build-macos-arm64
+    variables: *variables-macos-arm64


=====================================
autocomplete.c
=====================================
@@ -115,6 +115,8 @@ static const char * const opts_nosuggest[] =
     "--ipratio",
     "--keyint", "-I",
     "--lookahead-threads",
+    "--mastering-display",
+    "--cll",
     "--merange",
     "--min-keyint", "-i",
     "--mvrange",


=====================================
common/arm/asm.S
=====================================
@@ -74,7 +74,7 @@
 #   define FUNC @
 #endif
 
-#if SYS_LINUX
+#if SYS_LINUX || SYS_OPENBSD
 #define HAVE_SECTION_DATA_REL_RO 1
 #else
 #define HAVE_SECTION_DATA_REL_RO 0


=====================================
common/base.c
=====================================
@@ -814,7 +814,7 @@ REALIGN_STACK int x264_param_apply_profile( x264_param_t *param, const char *pro
 static int parse_enum( const char *arg, const char * const *names, int *dst )
 {
     for( int i = 0; names[i]; i++ )
-        if( !strcasecmp( arg, names[i] ) )
+        if( *names[i] && !strcasecmp( arg, names[i] ) )
         {
             *dst = i;
             return 0;
@@ -1013,6 +1013,32 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
         p->vui.i_chroma_loc = atoi(value);
         b_error = ( p->vui.i_chroma_loc < 0 || p->vui.i_chroma_loc > 5 );
     }
+    OPT("mastering-display")
+    {
+        if( strcasecmp( value, "undef" ) )
+        {
+            b_error |= sscanf( value, "G(%d,%d)B(%d,%d)R(%d,%d)WP(%d,%d)L(%"SCNd64",%"SCNd64")",
+                               &p->mastering_display.i_green_x, &p->mastering_display.i_green_y,
+                               &p->mastering_display.i_blue_x, &p->mastering_display.i_blue_y,
+                               &p->mastering_display.i_red_x, &p->mastering_display.i_red_y,
+                               &p->mastering_display.i_white_x, &p->mastering_display.i_white_y,
+                               &p->mastering_display.i_display_max, &p->mastering_display.i_display_min ) != 10;
+            p->mastering_display.b_mastering_display = !b_error;
+        }
+        else
+            p->mastering_display.b_mastering_display = 0;
+    }
+    OPT("cll")
+    {
+        if( strcasecmp( value, "undef" ) )
+        {
+            b_error |= sscanf( value, "%d,%d",
+                               &p->content_light_level.i_max_cll, &p->content_light_level.i_max_fall ) != 2;
+            p->content_light_level.b_cll = !b_error;
+        }
+        else
+            p->content_light_level.b_cll = 0;
+    }
     OPT("alternative-transfer")
         b_error |= parse_enum( value, x264_transfer_names, &p->i_alternative_transfer );
     OPT("fps")
@@ -1389,7 +1415,7 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha
  ****************************************************************************/
 char *x264_param2string( x264_param_t *p, int b_res )
 {
-    int len = 1000;
+    int len = 2000;
     char *buf, *s;
     if( p->rc.psz_zones )
         len += strlen(p->rc.psz_zones);
@@ -1498,6 +1524,16 @@ char *x264_param2string( x264_param_t *p, int b_res )
     if( p->crop_rect.i_left | p->crop_rect.i_top | p->crop_rect.i_right | p->crop_rect.i_bottom )
         s += sprintf( s, " crop_rect=%d,%d,%d,%d", p->crop_rect.i_left, p->crop_rect.i_top,
                                                    p->crop_rect.i_right, p->crop_rect.i_bottom );
+    if( p->mastering_display.b_mastering_display )
+        s += sprintf( s, " mastering-display=G(%d,%d)B(%d,%d)R(%d,%d)WP(%d,%d)L(%"PRId64",%"PRId64")",
+                      p->mastering_display.i_green_x, p->mastering_display.i_green_y,
+                      p->mastering_display.i_blue_x, p->mastering_display.i_blue_y,
+                      p->mastering_display.i_red_x, p->mastering_display.i_red_y,
+                      p->mastering_display.i_white_x, p->mastering_display.i_white_y,
+                      p->mastering_display.i_display_max, p->mastering_display.i_display_min );
+    if( p->content_light_level.b_cll )
+        s += sprintf( s, " cll=%d,%d",
+                      p->content_light_level.i_max_cll, p->content_light_level.i_max_fall );
     if( p->i_frame_packing >= 0 )
         s += sprintf( s, " frame-packing=%d", p->i_frame_packing );
 


=====================================
common/base.h
=====================================
@@ -128,6 +128,8 @@ enum sei_payload_type_e
     SEI_RECOVERY_POINT         = 6,
     SEI_DEC_REF_PIC_MARKING    = 7,
     SEI_FRAME_PACKING          = 45,
+    SEI_MASTERING_DISPLAY      = 137,
+    SEI_CONTENT_LIGHT_LEVEL    = 144,
     SEI_ALTERNATIVE_TRANSFER   = 147,
 };
 


=====================================
common/cpu.c
=====================================
@@ -433,7 +433,7 @@ int x264_cpu_num_processors( void )
 #elif SYS_WINDOWS
     return x264_pthread_num_processors_np();
 
-#elif SYS_CYGWIN || SYS_SunOS
+#elif SYS_CYGWIN || SYS_SunOS || SYS_OPENBSD
     return sysconf( _SC_NPROCESSORS_ONLN );
 
 #elif SYS_LINUX
@@ -460,15 +460,10 @@ int x264_cpu_num_processors( void )
     get_system_info( &info );
     return info.cpu_count;
 
-#elif SYS_MACOSX || SYS_FREEBSD || SYS_OPENBSD
+#elif SYS_MACOSX || SYS_FREEBSD
     int ncpu;
     size_t length = sizeof( ncpu );
-#if SYS_OPENBSD
-    int mib[2] = { CTL_HW, HW_NCPU };
-    if( sysctl(mib, 2, &ncpu, &length, NULL, 0) )
-#else
     if( sysctlbyname("hw.ncpu", &ncpu, &length, NULL, 0) )
-#endif
     {
         ncpu = 1;
     }


=====================================
configure
=====================================
@@ -124,6 +124,7 @@ cl_ldflags() {
         arg=${arg/pthreadGC/pthreadVC}
         [ "$arg" = avifil32.lib ] && arg=vfw32.lib
         [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
+        [ "$arg" = gpac.lib ] && arg=libgpac.lib
         [ "$arg" = x264.lib ] && arg=libx264.lib
 
         [ -n "$arg" ] && echo -n "$arg "
@@ -827,6 +828,11 @@ case $host_cpu in
         if [ "$SYS" = MACOSX ] ; then
             AS="${AS-${CC}}"
             ASFLAGS="$ASFLAGS -DPREFIX -DPIC"
+            if cc_check '' "-arch arm64"; then
+                CFLAGS="$CFLAGS -arch arm64"
+                LDFLAGS="$LDFLAGS -arch arm64"
+                ASFLAGS="$ASFLAGS -arch arm64"
+            fi
         elif [ "$SYS" = WINDOWS ] && [ "$compiler" = CL ] ; then
             AS="${AS-${SRCPATH}/tools/gas-preprocessor.pl -arch aarch64 -as-type armasm -- armasm64 -nologo}"
         else
@@ -1244,15 +1250,32 @@ fi
 
 if [ "$gpac" = "auto" -a "$lsmash" != "yes" ] ; then
     gpac="no"
-    GPAC_LIBS="-lgpac_static"
-    cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz"
-    cc_check "" -ldl && GPAC_LIBS="$GPAC_LIBS -ldl"
-    if [ "$SYS" = "WINDOWS" ] ; then
-        cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32"
-        cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm"
+    if pkg_check gpac ; then
+        GPAC_LIBS_TMP="$GPAC_LIBS $($PKGCONFIG --libs gpac)"
+        GPAC_CFLAGS_TMP="$GPAC_CFLAGS $($PKGCONFIG --cflags gpac)"
+        if cc_check gpac/isomedia.h "$GPAC_CFLAGS_TMP $GPAC_LIBS_TMP" "gf_isom_close(0);" ; then
+            GPAC_LIBS="$GPAC_LIBS_TMP"
+            GPAC_CFLAGS="$GPAC_CFLAGS_TMP"
+        else
+            GPAC_LIBS_TMP="$GPAC_LIBS $($PKGCONFIG --static --libs gpac | sed 's/-lgpac //')"
+            GPAC_CFLAGS_TMP="$GPAC_CFLAGS $($PKGCONFIG --static --cflags gpac)"
+            if cc_check gpac/isomedia.h "$GPAC_CFLAGS_TMP $GPAC_LIBS_TMP" "gf_isom_close(0);" ; then
+                GPAC_LIBS="$GPAC_LIBS_TMP"
+                GPAC_CFLAGS="$GPAC_CFLAGS_TMP"
+            fi
+        fi
+    fi
+    if [ -z "$GPAC_LIBS" ] ; then
+        GPAC_LIBS="-lgpac_static"
+        cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz"
+        cc_check "" -ldl && GPAC_LIBS="$GPAC_LIBS -ldl"
+        if [ "$SYS" = "WINDOWS" ] ; then
+            cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32"
+            cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm"
+        fi
     fi
-    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,0);" ; then
+    if cc_check gpac/isomedia.h "$GPAC_CFLAGS $GPAC_LIBS" "gf_isom_close(0);" ; then
+        if cc_check gpac/isomedia.h "$GPAC_CFLAGS $GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0,0);" ; then
             gpac="yes"
         else
             echo "Warning: gpac is too old, update to v0.8.0 or later"
@@ -1268,6 +1291,7 @@ if [ "$lsmash" = "yes" ] ; then
 elif [ "$gpac" = "yes" ] ; then
     mp4="gpac"
     LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
+    CFLAGS="$CFLAGS $GPAC_CFLAGS"
     define HAVE_GPAC
 fi
 


=====================================
encoder/encoder.c
=====================================
@@ -640,6 +640,41 @@ static int validate_parameters( x264_t *h, int b_open )
         return -1;
     }
 
+    if( h->param.mastering_display.b_mastering_display )
+    {
+        if( h->param.mastering_display.i_green_x > UINT16_MAX || h->param.mastering_display.i_green_x < 0 ||
+            h->param.mastering_display.i_green_y > UINT16_MAX || h->param.mastering_display.i_green_y < 0 ||
+            h->param.mastering_display.i_blue_x > UINT16_MAX || h->param.mastering_display.i_blue_x < 0 ||
+            h->param.mastering_display.i_blue_y > UINT16_MAX || h->param.mastering_display.i_blue_y < 0 ||
+            h->param.mastering_display.i_red_x > UINT16_MAX || h->param.mastering_display.i_red_x < 0 ||
+            h->param.mastering_display.i_red_y > UINT16_MAX || h->param.mastering_display.i_red_y < 0 ||
+            h->param.mastering_display.i_white_x > UINT16_MAX || h->param.mastering_display.i_white_x < 0 ||
+            h->param.mastering_display.i_white_y > UINT16_MAX || h->param.mastering_display.i_white_y < 0 )
+        {
+            x264_log( h, X264_LOG_ERROR, "mastering display xy coordinates out of range [0,%u]\n", UINT16_MAX );
+            return -1;
+        }
+        if( h->param.mastering_display.i_display_max > UINT32_MAX || h->param.mastering_display.i_display_max < 0 ||
+            h->param.mastering_display.i_display_min > UINT32_MAX || h->param.mastering_display.i_display_min < 0 )
+        {
+            x264_log( h, X264_LOG_ERROR, "mastering display brightness out of range [0,%u]\n", UINT32_MAX );
+            return -1;
+        }
+        if( h->param.mastering_display.i_display_min == 50000 && h->param.mastering_display.i_display_max == 50000 )
+        {
+            x264_log( h, X264_LOG_ERROR, "mastering display min and max brightness cannot both be 50000\n" );
+            return -1;
+        }
+    }
+
+    if( h->param.content_light_level.b_cll &&
+        (h->param.content_light_level.i_max_cll > UINT16_MAX || h->param.content_light_level.i_max_cll < 0 ||
+         h->param.content_light_level.i_max_fall > UINT16_MAX || h->param.content_light_level.i_max_fall < 0) )
+    {
+        x264_log( h, X264_LOG_ERROR, "content light levels out of range [0,%u]\n", UINT16_MAX );
+        return -1;
+    }
+
     /* Detect default ffmpeg settings and terminate with an error. */
     if( b_open )
     {
@@ -1818,6 +1853,9 @@ static int encoder_try_reconfig( x264_t *h, x264_param_t *param, int *rc_reconfi
     COPY( i_deblocking_filter_alphac0 );
     COPY( i_deblocking_filter_beta );
     COPY( i_frame_packing );
+    COPY( mastering_display );
+    COPY( content_light_level );
+    COPY( i_alternative_transfer );
     COPY( analyse.inter );
     COPY( analyse.intra );
     COPY( analyse.i_direct_mv_pred );
@@ -3691,6 +3729,33 @@ int     x264_encoder_encode( x264_t *h,
                 return -1;
             overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
         }
+
+        if( h->param.mastering_display.b_mastering_display )
+        {
+            nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
+            x264_sei_mastering_display_write( h, &h->out.bs );
+            if( nal_end( h ) )
+                return -1;
+            overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
+        }
+
+        if( h->param.content_light_level.b_cll )
+        {
+            nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
+            x264_sei_content_light_level_write( h, &h->out.bs );
+            if( nal_end( h ) )
+                return -1;
+            overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
+        }
+
+        if( h->param.i_alternative_transfer != 2 )
+        {
+            nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
+            x264_sei_alternative_transfer_write( h, &h->out.bs );
+            if( nal_end( h ) )
+                return -1;
+            overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
+        }
     }
 
     if( h->param.i_frame_packing >= 0 && (h->fenc->b_keyframe || h->param.i_frame_packing == 5) )
@@ -3702,15 +3767,6 @@ int     x264_encoder_encode( x264_t *h,
         overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
     }
 
-    if( h->param.i_alternative_transfer != 2 )
-    {
-        nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
-        x264_sei_alternative_transfer_write( h, &h->out.bs );
-        if( nal_end( h ) )
-            return -1;
-        overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
-    }
-
     /* generate sei pic timing */
     if( h->sps->vui.b_pic_struct_present || h->sps->vui.b_nal_hrd_parameters_present )
     {


=====================================
encoder/set.c
=====================================
@@ -703,6 +703,48 @@ void x264_sei_frame_packing_write( x264_t *h, bs_t *s )
     x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_FRAME_PACKING );
 }
 
+void x264_sei_mastering_display_write( x264_t *h, bs_t *s )
+{
+    bs_t q;
+    ALIGNED_4( uint8_t tmp_buf[100] );
+    M32( tmp_buf ) = 0; // shut up gcc
+    bs_init( &q, tmp_buf, 100 );
+
+    bs_realign( &q );
+
+    bs_write( &q, 16, h->param.mastering_display.i_green_x );
+    bs_write( &q, 16, h->param.mastering_display.i_green_y );
+    bs_write( &q, 16, h->param.mastering_display.i_blue_x );
+    bs_write( &q, 16, h->param.mastering_display.i_blue_y );
+    bs_write( &q, 16, h->param.mastering_display.i_red_x );
+    bs_write( &q, 16, h->param.mastering_display.i_red_y );
+    bs_write( &q, 16, h->param.mastering_display.i_white_x );
+    bs_write( &q, 16, h->param.mastering_display.i_white_y );
+    bs_write32( &q, h->param.mastering_display.i_display_max );
+    bs_write32( &q, h->param.mastering_display.i_display_min );
+
+    bs_align_10( &q );
+
+    x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_MASTERING_DISPLAY );
+}
+
+void x264_sei_content_light_level_write( x264_t *h, bs_t *s )
+{
+    bs_t q;
+    ALIGNED_4( uint8_t tmp_buf[100] );
+    M32( tmp_buf ) = 0; // shut up gcc
+    bs_init( &q, tmp_buf, 100 );
+
+    bs_realign( &q );
+
+    bs_write( &q, 16, h->param.content_light_level.i_max_cll );
+    bs_write( &q, 16, h->param.content_light_level.i_max_fall );
+
+    bs_align_10( &q );
+
+    x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_CONTENT_LIGHT_LEVEL );
+}
+
 void x264_sei_alternative_transfer_write( x264_t *h, bs_t *s )
 {
     bs_t q;


=====================================
encoder/set.h
=====================================
@@ -53,6 +53,10 @@ void x264_sei_pic_timing_write( x264_t *h, bs_t *s );
 void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s );
 #define x264_sei_frame_packing_write x264_template(sei_frame_packing_write)
 void x264_sei_frame_packing_write( x264_t *h, bs_t *s );
+#define x264_sei_mastering_display_write x264_template(sei_mastering_display_write)
+void x264_sei_mastering_display_write( x264_t *h, bs_t *s );
+#define x264_sei_content_light_level_write x264_template(sei_content_light_level_write)
+void x264_sei_content_light_level_write( x264_t *h, bs_t *s );
 #define x264_sei_alternative_transfer_write x264_template(sei_alternative_transfer_write)
 void x264_sei_alternative_transfer_write( x264_t *h, bs_t *s );
 #define x264_sei_avcintra_umid_write x264_template(sei_avcintra_umid_write)


=====================================
input/lavf.c
=====================================
@@ -28,6 +28,7 @@
 
 #undef DECLARE_ALIGNED
 #include <libavformat/avformat.h>
+#include <libavcodec/avcodec.h>
 #include <libavutil/dict.h>
 #include <libavutil/error.h>
 #include <libavutil/mem.h>


=====================================
input/y4m.c
=====================================
@@ -42,9 +42,8 @@ typedef struct
 } y4m_hnd_t;
 
 #define Y4M_MAGIC "YUV4MPEG2"
-#define MAX_YUV4_HEADER 80
 #define Y4M_FRAME_MAGIC "FRAME"
-#define MAX_FRAME_HEADER 80
+#define Y4M_MAX_HEADER 256
 
 static int parse_csp_and_depth( char *csp_name, int *bit_depth )
 {
@@ -73,7 +72,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
     y4m_hnd_t *h = calloc( 1, sizeof(y4m_hnd_t) );
     int i;
     uint32_t n, d;
-    char header[MAX_YUV4_HEADER+10];
+    char header[Y4M_MAX_HEADER+10];
     char *tokend, *header_end;
     int colorspace = X264_CSP_NONE;
     int alt_colorspace = X264_CSP_NONE;
@@ -91,7 +90,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
         return -1;
 
     /* Read header */
-    for( i = 0; i < MAX_YUV4_HEADER; i++ )
+    for( i = 0; i < Y4M_MAX_HEADER; i++ )
     {
         header[i] = fgetc( h->fh );
         if( header[i] == '\n' )
@@ -104,7 +103,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
         }
     }
     FAIL_IF_ERROR( strncmp( header, Y4M_MAGIC, sizeof(Y4M_MAGIC)-1 ), "bad sequence header magic\n" );
-    FAIL_IF_ERROR( i == MAX_YUV4_HEADER, "bad sequence header length\n" );
+    FAIL_IF_ERROR( i == Y4M_MAX_HEADER, "bad sequence header length\n" );
 
     /* Scan properties */
     header_end = &header[i+1]; /* Include space */
@@ -173,6 +172,15 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
                     tokstart += 6;
                     alt_colorspace = parse_csp_and_depth( tokstart, &alt_bit_depth );
                 }
+                else if( !strncmp( "COLORRANGE=", tokstart, 11 ) )
+                {
+                    /* ffmpeg's color range extension */
+                    tokstart += 11;
+                    if( !strncmp( "FULL", tokstart, 4 ) )
+                        info->fullrange = 1;
+                    else if( !strncmp( "LIMITED", tokstart, 7 ) )
+                        info->fullrange = 0;
+                }
                 tokstart = strchr( tokstart, 0x20 );
                 break;
         }
@@ -217,9 +225,9 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
 
         /* Find out the length of the frame header */
         size_t len = 1;
-        while( len <= MAX_FRAME_HEADER && fgetc( h->fh ) != '\n' )
+        while( len <= Y4M_MAX_HEADER && fgetc( h->fh ) != '\n' )
             len++;
-        FAIL_IF_ERROR( len > MAX_FRAME_HEADER || len < sizeof(Y4M_FRAME_MAGIC), "bad frame header length\n" );
+        FAIL_IF_ERROR( len > Y4M_MAX_HEADER || len < sizeof(Y4M_FRAME_MAGIC), "bad frame header length\n" );
         h->frame_header_len = len;
         h->frame_size += len;
 
@@ -264,9 +272,9 @@ static int read_frame_internal( cli_pic_t *pic, y4m_hnd_t *h, int bit_depth_uc )
         header = header_buf;
         if( fread( header, 1, slen, h->fh ) != slen )
             return -1;
-        while( i <= MAX_FRAME_HEADER && fgetc( h->fh ) != '\n' )
+        while( i <= Y4M_MAX_HEADER && fgetc( h->fh ) != '\n' )
             i++;
-        FAIL_IF_ERROR( i > MAX_FRAME_HEADER, "bad frame header length\n" );
+        FAIL_IF_ERROR( i > Y4M_MAX_HEADER, "bad frame header length\n" );
     }
     FAIL_IF_ERROR( memcmp( header, Y4M_FRAME_MAGIC, slen ), "bad frame header magic\n" );
 


=====================================
x264.c
=====================================
@@ -66,7 +66,7 @@
 #endif
 
 #if HAVE_GPAC
-#include <gpac/version.h>
+#include <gpac/isomedia.h>
 #endif
 
 #if HAVE_LSMASH
@@ -415,7 +415,7 @@ REALIGN_STACK int main( int argc, char **argv )
 static char const *strtable_lookup( const char * const table[], int idx )
 {
     int i = 0; while( table[i] ) i++;
-    return ( ( idx >= 0 && idx < i ) ? table[ idx ] : "???" );
+    return ( idx >= 0 && idx < i && *table[idx] ) ? table[idx] : "???";
 }
 
 static char *stringify_names( char *buf, const char * const names[] )
@@ -423,11 +423,12 @@ static char *stringify_names( char *buf, const char * const names[] )
     int i = 0;
     char *p = buf;
     for( p[0] = 0; names[i]; i++ )
-    {
-        p += sprintf( p, "%s", names[i] );
-        if( names[i+1] )
-            p += sprintf( p, ", " );
-    }
+        if( *names[i] )
+        {
+            if( p != buf )
+                p += sprintf( p, ", " );
+            p += sprintf( p, "%s", names[i] );
+        }
     return buf;
 }
 
@@ -478,7 +479,7 @@ static void print_csp_names( int longhelp )
 
 static void help( x264_param_t *defaults, int longhelp )
 {
-    char buf[50];
+    char buf[200];
 #define H0 printf
 #define H1 if( longhelp >= 1 ) printf
 #define H2 if( longhelp == 2 ) printf
@@ -711,7 +712,7 @@ static void help( x264_param_t *defaults, int longhelp )
     H0( "      --bff                   Enable interlaced mode (bottom field first)\n" );
     H2( "      --constrained-intra     Enable constrained intra prediction.\n" );
     H0( "      --pulldown <string>     Use soft pulldown to change frame rate\n"
-        "                                  - none, 22, 32, 64, double, triple, euro (requires cfr input)\n" );
+        "                                  - %s (requires cfr input)\n", stringify_names( buf, x264_pulldown_names ) );
     H2( "      --fake-interlaced       Flag stream as interlaced but encode progressive.\n"
         "                              Makes it possible to encode 25p and 30p Blu-Ray\n"
         "                              streams. Ignored in interlaced mode.\n" );
@@ -873,6 +874,10 @@ static void help( x264_param_t *defaults, int longhelp )
                                        strtable_lookup( x264_colmatrix_names, defaults->vui.i_colmatrix ) );
     H2( "      --chromaloc <integer>   Specify chroma sample location (0 to 5) [%d]\n",
                                        defaults->vui.i_chroma_loc );
+    H2( "      --mastering-display <string> Specify 'G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)'\n"
+        "                              for primaries, white point, and display brightness\n" );
+    H2( "      --cll <string>          Specify 'max_content,max_frame_average' content\n"
+        "                              light levels\n" );
     H2( "      --alternative-transfer <string> Specify an alternative transfer\n"
         "                              characteristics [\"%s\"]\n"
         "                                  - same values as --transfer\n",
@@ -1006,173 +1011,175 @@ typedef enum
 static char short_options[] = "8A:B:b:f:hI:i:m:o:p:q:r:t:Vvw";
 static struct option long_options[] =
 {
-    { "help",              no_argument, NULL, 'h' },
-    { "longhelp",          no_argument, NULL, OPT_LONGHELP },
-    { "fullhelp",          no_argument, NULL, OPT_FULLHELP },
-    { "version",           no_argument, NULL, 'V' },
-    { "profile",     required_argument, NULL, OPT_PROFILE },
-    { "preset",      required_argument, NULL, OPT_PRESET },
-    { "tune",        required_argument, NULL, OPT_TUNE },
-    { "slow-firstpass",    no_argument, NULL, OPT_SLOWFIRSTPASS },
-    { "bitrate",     required_argument, NULL, 'B' },
-    { "bframes",     required_argument, NULL, 'b' },
-    { "b-adapt",     required_argument, NULL, 0 },
-    { "no-b-adapt",        no_argument, NULL, 0 },
-    { "b-bias",      required_argument, NULL, 0 },
-    { "b-pyramid",   required_argument, NULL, 0 },
-    { "open-gop",          no_argument, NULL, 0 },
-    { "bluray-compat",     no_argument, NULL, 0 },
-    { "avcintra-class", required_argument, NULL, 0 },
-    { "avcintra-flavor", required_argument, NULL, 0 },
-    { "min-keyint",  required_argument, NULL, 'i' },
-    { "keyint",      required_argument, NULL, 'I' },
-    { "intra-refresh",     no_argument, NULL, 0 },
-    { "scenecut",    required_argument, NULL, 0 },
-    { "no-scenecut",       no_argument, NULL, 0 },
-    { "nf",                no_argument, NULL, 0 },
-    { "no-deblock",        no_argument, NULL, 0 },
-    { "filter",      required_argument, NULL, 0 },
-    { "deblock",     required_argument, NULL, 'f' },
-    { "interlaced",        no_argument, NULL, OPT_INTERLACED },
-    { "tff",               no_argument, NULL, OPT_INTERLACED },
-    { "bff",               no_argument, NULL, OPT_INTERLACED },
-    { "no-interlaced",     no_argument, NULL, OPT_INTERLACED },
-    { "constrained-intra", no_argument, NULL, 0 },
-    { "cabac",             no_argument, NULL, 0 },
-    { "no-cabac",          no_argument, NULL, 0 },
-    { "qp",          required_argument, NULL, 'q' },
-    { "qpmin",       required_argument, NULL, 0 },
-    { "qpmax",       required_argument, NULL, 0 },
-    { "qpstep",      required_argument, NULL, 0 },
-    { "crf",         required_argument, NULL, 0 },
-    { "rc-lookahead",required_argument, NULL, 0 },
-    { "ref",         required_argument, NULL, 'r' },
-    { "asm",         required_argument, NULL, 0 },
-    { "no-asm",            no_argument, NULL, 0 },
-    { "opencl",            no_argument, NULL, 1 },
-    { "opencl-clbin",required_argument, NULL, 0 },
-    { "opencl-device",required_argument, NULL, 0 },
-    { "sar",         required_argument, NULL, 0 },
-    { "fps",         required_argument, NULL, OPT_FPS },
-    { "frames",      required_argument, NULL, OPT_FRAMES },
-    { "seek",        required_argument, NULL, OPT_SEEK },
-    { "output",      required_argument, NULL, 'o' },
-    { "muxer",       required_argument, NULL, OPT_MUXER },
-    { "demuxer",     required_argument, NULL, OPT_DEMUXER },
-    { "stdout",      required_argument, NULL, OPT_MUXER },
-    { "stdin",       required_argument, NULL, OPT_DEMUXER },
-    { "index",       required_argument, NULL, OPT_INDEX },
-    { "analyse",     required_argument, NULL, 0 },
-    { "partitions",  required_argument, NULL, 'A' },
-    { "direct",      required_argument, NULL, 0 },
-    { "weightb",           no_argument, NULL, 'w' },
-    { "no-weightb",        no_argument, NULL, 0 },
-    { "weightp",     required_argument, NULL, 0 },
-    { "me",          required_argument, NULL, 0 },
-    { "merange",     required_argument, NULL, 0 },
-    { "mvrange",     required_argument, NULL, 0 },
-    { "mvrange-thread", required_argument, NULL, 0 },
-    { "subme",       required_argument, NULL, 'm' },
-    { "psy-rd",      required_argument, NULL, 0 },
-    { "no-psy",            no_argument, NULL, 0 },
-    { "psy",               no_argument, NULL, 0 },
-    { "mixed-refs",        no_argument, NULL, 0 },
-    { "no-mixed-refs",     no_argument, NULL, 0 },
-    { "no-chroma-me",      no_argument, NULL, 0 },
-    { "8x8dct",            no_argument, NULL, '8' },
-    { "no-8x8dct",         no_argument, NULL, 0 },
-    { "trellis",     required_argument, NULL, 't' },
-    { "fast-pskip",        no_argument, NULL, 0 },
-    { "no-fast-pskip",     no_argument, NULL, 0 },
-    { "no-dct-decimate",   no_argument, NULL, 0 },
-    { "aq-strength", required_argument, NULL, 0 },
-    { "aq-mode",     required_argument, NULL, 0 },
-    { "deadzone-inter", required_argument, NULL, 0 },
-    { "deadzone-intra", required_argument, NULL, 0 },
-    { "level",       required_argument, NULL, 0 },
-    { "ratetol",     required_argument, NULL, 0 },
-    { "vbv-maxrate", required_argument, NULL, 0 },
-    { "vbv-bufsize", required_argument, NULL, 0 },
-    { "vbv-init",    required_argument, NULL, 0 },
-    { "crf-max",     required_argument, NULL, 0 },
-    { "ipratio",     required_argument, NULL, 0 },
-    { "pbratio",     required_argument, NULL, 0 },
-    { "chroma-qp-offset", required_argument, NULL, 0 },
-    { "pass",        required_argument, NULL, 'p' },
-    { "stats",       required_argument, NULL, 0 },
-    { "qcomp",       required_argument, NULL, 0 },
-    { "mbtree",            no_argument, NULL, 0 },
-    { "no-mbtree",         no_argument, NULL, 0 },
-    { "qblur",       required_argument, NULL, 0 },
-    { "cplxblur",    required_argument, NULL, 0 },
-    { "zones",       required_argument, NULL, 0 },
-    { "qpfile",      required_argument, NULL, OPT_QPFILE },
-    { "threads",     required_argument, NULL, 0 },
-    { "lookahead-threads", required_argument, NULL, 0 },
-    { "sliced-threads",    no_argument, NULL, 0 },
-    { "no-sliced-threads", no_argument, NULL, 0 },
-    { "slice-max-size",    required_argument, NULL, 0 },
-    { "slice-max-mbs",     required_argument, NULL, 0 },
-    { "slice-min-mbs",     required_argument, NULL, 0 },
-    { "slices",            required_argument, NULL, 0 },
-    { "slices-max",        required_argument, NULL, 0 },
-    { "thread-input",      no_argument, NULL, OPT_THREAD_INPUT },
-    { "sync-lookahead",    required_argument, NULL, 0 },
-    { "non-deterministic", no_argument, NULL, 0 },
-    { "cpu-independent",   no_argument, NULL, 0 },
-    { "psnr",              no_argument, NULL, 0 },
-    { "ssim",              no_argument, NULL, 0 },
-    { "quiet",             no_argument, NULL, OPT_QUIET },
-    { "verbose",           no_argument, NULL, 'v' },
-    { "log-level",   required_argument, NULL, OPT_LOG_LEVEL },
-    { "no-progress",       no_argument, NULL, OPT_NOPROGRESS },
-    { "dump-yuv",    required_argument, NULL, 0 },
-    { "sps-id",      required_argument, NULL, 0 },
-    { "aud",               no_argument, NULL, 0 },
-    { "nr",          required_argument, NULL, 0 },
-    { "cqm",         required_argument, NULL, 0 },
-    { "cqmfile",     required_argument, NULL, 0 },
-    { "cqm4",        required_argument, NULL, 0 },
-    { "cqm4i",       required_argument, NULL, 0 },
-    { "cqm4iy",      required_argument, NULL, 0 },
-    { "cqm4ic",      required_argument, NULL, 0 },
-    { "cqm4p",       required_argument, NULL, 0 },
-    { "cqm4py",      required_argument, NULL, 0 },
-    { "cqm4pc",      required_argument, NULL, 0 },
-    { "cqm8",        required_argument, NULL, 0 },
-    { "cqm8i",       required_argument, NULL, 0 },
-    { "cqm8p",       required_argument, NULL, 0 },
-    { "overscan",    required_argument, NULL, 0 },
-    { "videoformat", required_argument, NULL, 0 },
-    { "range",       required_argument, NULL, OPT_RANGE },
-    { "colorprim",   required_argument, NULL, 0 },
-    { "transfer",    required_argument, NULL, 0 },
-    { "colormatrix", required_argument, NULL, 0 },
-    { "chromaloc",   required_argument, NULL, 0 },
-    { "force-cfr",         no_argument, NULL, 0 },
-    { "tcfile-in",   required_argument, NULL, OPT_TCFILE_IN },
-    { "tcfile-out",  required_argument, NULL, OPT_TCFILE_OUT },
-    { "timebase",    required_argument, NULL, OPT_TIMEBASE },
-    { "pic-struct",        no_argument, NULL, 0 },
-    { "crop-rect",   required_argument, NULL, 0 },
-    { "nal-hrd",     required_argument, NULL, 0 },
-    { "pulldown",    required_argument, NULL, OPT_PULLDOWN },
-    { "fake-interlaced",   no_argument, NULL, 0 },
-    { "frame-packing",     required_argument, NULL, 0 },
+    { "help",                 no_argument,       NULL, 'h' },
+    { "longhelp",             no_argument,       NULL, OPT_LONGHELP },
+    { "fullhelp",             no_argument,       NULL, OPT_FULLHELP },
+    { "version",              no_argument,       NULL, 'V' },
+    { "profile",              required_argument, NULL, OPT_PROFILE },
+    { "preset",               required_argument, NULL, OPT_PRESET },
+    { "tune",                 required_argument, NULL, OPT_TUNE },
+    { "slow-firstpass",       no_argument,       NULL, OPT_SLOWFIRSTPASS },
+    { "bitrate",              required_argument, NULL, 'B' },
+    { "bframes",              required_argument, NULL, 'b' },
+    { "b-adapt",              required_argument, NULL, 0 },
+    { "no-b-adapt",           no_argument,       NULL, 0 },
+    { "b-bias",               required_argument, NULL, 0 },
+    { "b-pyramid",            required_argument, NULL, 0 },
+    { "open-gop",             no_argument,       NULL, 0 },
+    { "bluray-compat",        no_argument,       NULL, 0 },
+    { "avcintra-class",       required_argument, NULL, 0 },
+    { "avcintra-flavor",      required_argument, NULL, 0 },
+    { "min-keyint",           required_argument, NULL, 'i' },
+    { "keyint",               required_argument, NULL, 'I' },
+    { "intra-refresh",        no_argument,       NULL, 0 },
+    { "scenecut",             required_argument, NULL, 0 },
+    { "no-scenecut",          no_argument,       NULL, 0 },
+    { "nf",                   no_argument,       NULL, 0 },
+    { "no-deblock",           no_argument,       NULL, 0 },
+    { "filter",               required_argument, NULL, 0 },
+    { "deblock",              required_argument, NULL, 'f' },
+    { "interlaced",           no_argument,       NULL, OPT_INTERLACED },
+    { "tff",                  no_argument,       NULL, OPT_INTERLACED },
+    { "bff",                  no_argument,       NULL, OPT_INTERLACED },
+    { "no-interlaced",        no_argument,       NULL, OPT_INTERLACED },
+    { "constrained-intra",    no_argument,       NULL, 0 },
+    { "cabac",                no_argument,       NULL, 0 },
+    { "no-cabac",             no_argument,       NULL, 0 },
+    { "qp",                   required_argument, NULL, 'q' },
+    { "qpmin",                required_argument, NULL, 0 },
+    { "qpmax",                required_argument, NULL, 0 },
+    { "qpstep",               required_argument, NULL, 0 },
+    { "crf",                  required_argument, NULL, 0 },
+    { "rc-lookahead",         required_argument, NULL, 0 },
+    { "ref",                  required_argument, NULL, 'r' },
+    { "asm",                  required_argument, NULL, 0 },
+    { "no-asm",               no_argument,       NULL, 0 },
+    { "opencl",               no_argument,       NULL, 1 },
+    { "opencl-clbin",         required_argument, NULL, 0 },
+    { "opencl-device",        required_argument, NULL, 0 },
+    { "sar",                  required_argument, NULL, 0 },
+    { "fps",                  required_argument, NULL, OPT_FPS },
+    { "frames",               required_argument, NULL, OPT_FRAMES },
+    { "seek",                 required_argument, NULL, OPT_SEEK },
+    { "output",               required_argument, NULL, 'o' },
+    { "muxer",                required_argument, NULL, OPT_MUXER },
+    { "demuxer",              required_argument, NULL, OPT_DEMUXER },
+    { "stdout",               required_argument, NULL, OPT_MUXER },
+    { "stdin",                required_argument, NULL, OPT_DEMUXER },
+    { "index",                required_argument, NULL, OPT_INDEX },
+    { "analyse",              required_argument, NULL, 0 },
+    { "partitions",           required_argument, NULL, 'A' },
+    { "direct",               required_argument, NULL, 0 },
+    { "weightb",              no_argument,       NULL, 'w' },
+    { "no-weightb",           no_argument,       NULL, 0 },
+    { "weightp",              required_argument, NULL, 0 },
+    { "me",                   required_argument, NULL, 0 },
+    { "merange",              required_argument, NULL, 0 },
+    { "mvrange",              required_argument, NULL, 0 },
+    { "mvrange-thread",       required_argument, NULL, 0 },
+    { "subme",                required_argument, NULL, 'm' },
+    { "psy-rd",               required_argument, NULL, 0 },
+    { "no-psy",               no_argument,       NULL, 0 },
+    { "psy",                  no_argument,       NULL, 0 },
+    { "mixed-refs",           no_argument,       NULL, 0 },
+    { "no-mixed-refs",        no_argument,       NULL, 0 },
+    { "no-chroma-me",         no_argument,       NULL, 0 },
+    { "8x8dct",               no_argument,       NULL, '8' },
+    { "no-8x8dct",            no_argument,       NULL, 0 },
+    { "trellis",              required_argument, NULL, 't' },
+    { "fast-pskip",           no_argument,       NULL, 0 },
+    { "no-fast-pskip",        no_argument,       NULL, 0 },
+    { "no-dct-decimate",      no_argument,       NULL, 0 },
+    { "aq-strength",          required_argument, NULL, 0 },
+    { "aq-mode",              required_argument, NULL, 0 },
+    { "deadzone-inter",       required_argument, NULL, 0 },
+    { "deadzone-intra",       required_argument, NULL, 0 },
+    { "level",                required_argument, NULL, 0 },
+    { "ratetol",              required_argument, NULL, 0 },
+    { "vbv-maxrate",          required_argument, NULL, 0 },
+    { "vbv-bufsize",          required_argument, NULL, 0 },
+    { "vbv-init",             required_argument, NULL, 0 },
+    { "crf-max",              required_argument, NULL, 0 },
+    { "ipratio",              required_argument, NULL, 0 },
+    { "pbratio",              required_argument, NULL, 0 },
+    { "chroma-qp-offset",     required_argument, NULL, 0 },
+    { "pass",                 required_argument, NULL, 'p' },
+    { "stats",                required_argument, NULL, 0 },
+    { "qcomp",                required_argument, NULL, 0 },
+    { "mbtree",               no_argument,       NULL, 0 },
+    { "no-mbtree",            no_argument,       NULL, 0 },
+    { "qblur",                required_argument, NULL, 0 },
+    { "cplxblur",             required_argument, NULL, 0 },
+    { "zones",                required_argument, NULL, 0 },
+    { "qpfile",               required_argument, NULL, OPT_QPFILE },
+    { "threads",              required_argument, NULL, 0 },
+    { "lookahead-threads",    required_argument, NULL, 0 },
+    { "sliced-threads",       no_argument,       NULL, 0 },
+    { "no-sliced-threads",    no_argument,       NULL, 0 },
+    { "slice-max-size",       required_argument, NULL, 0 },
+    { "slice-max-mbs",        required_argument, NULL, 0 },
+    { "slice-min-mbs",        required_argument, NULL, 0 },
+    { "slices",               required_argument, NULL, 0 },
+    { "slices-max",           required_argument, NULL, 0 },
+    { "thread-input",         no_argument,       NULL, OPT_THREAD_INPUT },
+    { "sync-lookahead",       required_argument, NULL, 0 },
+    { "non-deterministic",    no_argument,       NULL, 0 },
+    { "cpu-independent",      no_argument,       NULL, 0 },
+    { "psnr",                 no_argument,       NULL, 0 },
+    { "ssim",                 no_argument,       NULL, 0 },
+    { "quiet",                no_argument,       NULL, OPT_QUIET },
+    { "verbose",              no_argument,       NULL, 'v' },
+    { "log-level",            required_argument, NULL, OPT_LOG_LEVEL },
+    { "no-progress",          no_argument,       NULL, OPT_NOPROGRESS },
+    { "dump-yuv",             required_argument, NULL, 0 },
+    { "sps-id",               required_argument, NULL, 0 },
+    { "aud",                  no_argument,       NULL, 0 },
+    { "nr",                   required_argument, NULL, 0 },
+    { "cqm",                  required_argument, NULL, 0 },
+    { "cqmfile",              required_argument, NULL, 0 },
+    { "cqm4",                 required_argument, NULL, 0 },
+    { "cqm4i",                required_argument, NULL, 0 },
+    { "cqm4iy",               required_argument, NULL, 0 },
+    { "cqm4ic",               required_argument, NULL, 0 },
+    { "cqm4p",                required_argument, NULL, 0 },
+    { "cqm4py",               required_argument, NULL, 0 },
+    { "cqm4pc",               required_argument, NULL, 0 },
+    { "cqm8",                 required_argument, NULL, 0 },
+    { "cqm8i",                required_argument, NULL, 0 },
+    { "cqm8p",                required_argument, NULL, 0 },
+    { "overscan",             required_argument, NULL, 0 },
+    { "videoformat",          required_argument, NULL, 0 },
+    { "range",                required_argument, NULL, OPT_RANGE },
+    { "colorprim",            required_argument, NULL, 0 },
+    { "transfer",             required_argument, NULL, 0 },
+    { "colormatrix",          required_argument, NULL, 0 },
+    { "chromaloc",            required_argument, NULL, 0 },
+    { "force-cfr",            no_argument,       NULL, 0 },
+    { "tcfile-in",            required_argument, NULL, OPT_TCFILE_IN },
+    { "tcfile-out",           required_argument, NULL, OPT_TCFILE_OUT },
+    { "timebase",             required_argument, NULL, OPT_TIMEBASE },
+    { "pic-struct",           no_argument,       NULL, 0 },
+    { "crop-rect",            required_argument, NULL, 0 },
+    { "nal-hrd",              required_argument, NULL, 0 },
+    { "pulldown",             required_argument, NULL, OPT_PULLDOWN },
+    { "fake-interlaced",      no_argument,       NULL, 0 },
+    { "frame-packing",        required_argument, NULL, 0 },
+    { "mastering-display",    required_argument, NULL, 0 },
+    { "cll",                  required_argument, NULL, 0 },
     { "alternative-transfer", required_argument, NULL, 0 },
-    { "vf",          required_argument, NULL, OPT_VIDEO_FILTER },
-    { "video-filter", required_argument, NULL, OPT_VIDEO_FILTER },
-    { "input-fmt",   required_argument, NULL, OPT_INPUT_FMT },
-    { "input-res",   required_argument, NULL, OPT_INPUT_RES },
-    { "input-csp",   required_argument, NULL, OPT_INPUT_CSP },
-    { "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
-    { "output-depth", required_argument, NULL, OPT_OUTPUT_DEPTH },
-    { "dts-compress",      no_argument, NULL, OPT_DTS_COMPRESSION },
-    { "output-csp",  required_argument, NULL, OPT_OUTPUT_CSP },
-    { "input-range", required_argument, NULL, OPT_INPUT_RANGE },
-    { "stitchable",        no_argument, NULL, 0 },
-    { "filler",            no_argument, NULL, 0 },
-    {0, 0, 0, 0}
+    { "vf",                   required_argument, NULL, OPT_VIDEO_FILTER },
+    { "video-filter",         required_argument, NULL, OPT_VIDEO_FILTER },
+    { "input-fmt",            required_argument, NULL, OPT_INPUT_FMT },
+    { "input-res",            required_argument, NULL, OPT_INPUT_RES },
+    { "input-csp",            required_argument, NULL, OPT_INPUT_CSP },
+    { "input-depth",          required_argument, NULL, OPT_INPUT_DEPTH },
+    { "output-depth",         required_argument, NULL, OPT_OUTPUT_DEPTH },
+    { "dts-compress",         no_argument,       NULL, OPT_DTS_COMPRESSION },
+    { "output-csp",           required_argument, NULL, OPT_OUTPUT_CSP },
+    { "input-range",          required_argument, NULL, OPT_INPUT_RANGE },
+    { "stitchable",           no_argument,       NULL, 0 },
+    { "filler",               no_argument,       NULL, 0 },
+    { NULL,                   0,                 NULL, 0 }
 };
 
 static int select_output( const char *muxer, char *filename, x264_param_t *param )
@@ -1357,7 +1364,7 @@ static int init_vid_filters( char *sequence, hnd_t *handle, video_info_t *info,
 static int parse_enum_name( const char *arg, const char * const *names, const char **dst )
 {
     for( int i = 0; names[i]; i++ )
-        if( !strcasecmp( arg, names[i] ) )
+        if( *names[i] && !strcasecmp( arg, names[i] ) )
         {
             *dst = names[i];
             return 0;
@@ -1368,7 +1375,7 @@ static int parse_enum_name( const char *arg, const char * const *names, const ch
 static int parse_enum_value( const char *arg, const char * const *names, int *dst )
 {
     for( int i = 0; names[i]; i++ )
-        if( !strcasecmp( arg, names[i] ) )
+        if( *names[i] && !strcasecmp( arg, names[i] ) )
         {
             *dst = i;
             return 0;


=====================================
x264.h
=====================================
@@ -45,7 +45,7 @@ extern "C" {
 
 #include "x264_config.h"
 
-#define X264_BUILD 161
+#define X264_BUILD 163
 
 #ifdef _WIN32
 #   define X264_DLL_IMPORT __declspec(dllimport)
@@ -485,6 +485,31 @@ typedef struct x264_param_t
     /* frame packing arrangement flag */
     int i_frame_packing;
 
+    /* mastering display SEI: Primary and white point chromaticity coordinates
+       in 0.00002 increments. Brightness units are 0.0001 cd/m^2. */
+    struct
+    {
+        int b_mastering_display;    /* enable writing this SEI */
+        int i_green_x;
+        int i_green_y;
+        int i_blue_x;
+        int i_blue_y;
+        int i_red_x;
+        int i_red_y;
+        int i_white_x;
+        int i_white_y;
+        int64_t i_display_max;
+        int64_t i_display_min;
+    } mastering_display;
+
+    /* content light level SEI */
+    struct
+    {
+        int b_cll;                  /* enable writing this SEI */
+        int i_max_cll;
+        int i_max_fall;
+    } content_light_level;
+
     /* alternative transfer SEI */
     int i_alternative_transfer;
 



View it on GitLab: https://code.videolan.org/videolan/x264/-/compare/55d517bc4569272a2c9a367a4106c234aba2ffbc...5db6aa6cab1b146e07b60cc1736a01f21da01154

-- 
View it on GitLab: https://code.videolan.org/videolan/x264/-/compare/55d517bc4569272a2c9a367a4106c234aba2ffbc...5db6aa6cab1b146e07b60cc1736a01f21da01154
You're receiving this email because of your account on code.videolan.org.




More information about the x264-devel mailing list