From gitlab at videolan.org Sun Jun 13 20:20:13 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:20:13 +0200 Subject: [x264-devel] [Git][videolan/x264][master] lavf: Fix compilation with new versions of ffmpeg Message-ID: <60c6687d385ab_93731ca60ab01158105c@gitlab.mail> Anton Mitrofanov pushed to branch master at VideoLAN / x264 Commits: 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. - - - - - 1 changed file: - input/lavf.c Changes: ===================================== input/lavf.c ===================================== @@ -28,6 +28,7 @@ #undef DECLARE_ALIGNED #include +#include #include #include #include View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/5db6aa6cab1b146e07b60cc1736a01f21da01154 -- View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/5db6aa6cab1b146e07b60cc1736a01f21da01154 You're receiving this email because of your account on code.videolan.org. From gitlab at videolan.org Sun Jun 13 20:24:10 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:24:10 +0200 Subject: [x264-devel] [Git][videolan/x264][master] 2 commits: Fix gcc warnings Message-ID: <60c6696a58179_93731c04e1bc115833ef@gitlab.mail> Anton Mitrofanov pushed to branch master at VideoLAN / x264 Commits: 1a15eaf7 by Anton Mitrofanov at 2021-06-13T20:20:52+00:00 Fix gcc warnings - - - - - df075e15 by Anton Mitrofanov at 2021-06-13T20:20:52+00:00 Fix undefined behavior: left shift of negative value Compilers are good at optimizing multiplication by shift. - - - - - 13 changed files: - common/base.c - common/cabac.c - common/deblock.c - common/macroblock.c - common/macroblock.h - common/mc.c - common/mvpred.c - common/quant.c - common/x86/mc-c.c - encoder/encoder.c - encoder/macroblock.c - encoder/me.c - tools/checkasm.c Changes: ===================================== common/base.c ===================================== @@ -207,7 +207,7 @@ typedef struct { void *ptr[]; } strdup_buffer; -#define BUFFER_OFFSET offsetof(strdup_buffer, ptr) +#define BUFFER_OFFSET (int)offsetof(strdup_buffer, ptr) #define BUFFER_DEFAULT_SIZE 16 char *x264_param_strdup( x264_param_t *param, const char *src ) @@ -922,7 +922,7 @@ REALIGN_STACK int x264_param_parse( x264_param_t *p, const char *name, const cha if( 0 ); OPT("asm") { - p->cpu = isdigit(value[0]) ? atoi(value) : + p->cpu = isdigit(value[0]) ? (uint32_t)atoi(value) : !strcasecmp(value, "auto") || atobool(value) ? x264_cpu_detect() : 0; if( b_error ) { ===================================== common/cabac.c ===================================== @@ -143,7 +143,7 @@ void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val ) { uint32_t v = val + (1<> 3, -tc, tc ); + delta = x264_clip3( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-1*xstride] = x264_clip_pixel( p0 + delta ); /* p0' */ pix[ 0*xstride] = x264_clip_pixel( q0 - delta ); /* q0' */ } @@ -143,7 +143,7 @@ static ALWAYS_INLINE void deblock_edge_chroma_c( pixel *pix, intptr_t xstride, i if( abs( p0 - q0 ) < alpha && abs( p1 - p0 ) < beta && abs( q1 - q0 ) < beta ) { - int delta = x264_clip3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); + int delta = x264_clip3( (((q0 - p0 ) * 4) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-1*xstride] = x264_clip_pixel( p0 + delta ); /* p0' */ pix[ 0*xstride] = x264_clip_pixel( q0 - delta ); /* q0' */ } @@ -315,10 +315,10 @@ static ALWAYS_INLINE void deblock_edge( x264_t *h, pixel *pix, intptr_t i_stride if( !M32(bS) || !alpha || !beta ) return; - tc[0] = (tc0_table(index_a)[bS[0]] << (BIT_DEPTH-8)) + b_chroma; - tc[1] = (tc0_table(index_a)[bS[1]] << (BIT_DEPTH-8)) + b_chroma; - tc[2] = (tc0_table(index_a)[bS[2]] << (BIT_DEPTH-8)) + b_chroma; - tc[3] = (tc0_table(index_a)[bS[3]] << (BIT_DEPTH-8)) + b_chroma; + tc[0] = (tc0_table(index_a)[bS[0]] * (1 << (BIT_DEPTH-8))) + b_chroma; + tc[1] = (tc0_table(index_a)[bS[1]] * (1 << (BIT_DEPTH-8))) + b_chroma; + tc[2] = (tc0_table(index_a)[bS[2]] * (1 << (BIT_DEPTH-8))) + b_chroma; + tc[3] = (tc0_table(index_a)[bS[3]] * (1 << (BIT_DEPTH-8))) + b_chroma; pf_inter( pix, i_stride, alpha, beta, tc ); } ===================================== common/macroblock.c ===================================== @@ -1249,7 +1249,7 @@ static ALWAYS_INLINE void macroblock_cache_load( x264_t *h, int mb_x, int mb_y, if( h->mb.cache.varref[l][index] >= 0 )\ {\ h->mb.cache.varref[l][index] >>= 1;\ - h->mb.cache.varmv[l][index][1] <<= 1;\ + h->mb.cache.varmv[l][index][1] *= 2;\ h->mb.cache.mvd[l][index][1] <<= 1;\ } MAP_MVS ===================================== common/macroblock.h ===================================== @@ -395,9 +395,9 @@ static ALWAYS_INLINE uint32_t pack8to32( uint32_t a, uint32_t b, uint32_t c, uin static ALWAYS_INLINE uint32_t pack16to32_mask( int a, int b ) { #if WORDS_BIGENDIAN - return (b&0xFFFF) + (a<<16); + return (b&0xFFFF) + ((uint32_t)a<<16); #else - return (a&0xFFFF) + (b<<16); + return (a&0xFFFF) + ((uint32_t)b<<16); #endif } static ALWAYS_INLINE uint64_t pack32to64( uint32_t a, uint32_t b ) ===================================== common/mc.c ===================================== @@ -116,7 +116,7 @@ static void weight_cache( x264_t *h, x264_weight_t *w ) static void mc_weight( pixel *dst, intptr_t i_dst_stride, pixel *src, intptr_t i_src_stride, const x264_weight_t *weight, int i_width, int i_height ) { - int offset = weight->i_offset << (BIT_DEPTH-8); + int offset = weight->i_offset * (1 << (BIT_DEPTH-8)); int scale = weight->i_scale; int denom = weight->i_denom; if( denom >= 1 ) ===================================== common/mvpred.c ===================================== @@ -257,13 +257,13 @@ static int mb_predict_mv_direct16x16_temporal( x264_t *h ) int i_part_8x8 = i_mb_8x8 + x8 + (ypart>>1) * h->mb.i_b8_stride; int i_ref1_ref = h->fref[1][0]->ref[0][i_part_8x8]; - int i_ref = (map_col_to_list0(i_ref1_ref>>preshift) << postshift) + (offset&i_ref1_ref&MB_INTERLACED); + int i_ref = (map_col_to_list0(i_ref1_ref>>preshift) * (1 << postshift)) + (offset&i_ref1_ref&MB_INTERLACED); if( i_ref >= 0 ) { int dist_scale_factor = h->mb.dist_scale_factor[i_ref][0]; int16_t *mv_col = h->fref[1][0]->mv[0][i_mb_4x4 + 3*x8 + ypart * h->mb.i_b4_stride]; - int16_t mv_y = (mv_col[1]<> 8; int l0y = ( dist_scale_factor * mv_y + 128 ) >> 8; if( h->param.i_threads > 1 && (l0y > h->mb.mv_max_spel[1] || l0y-mv_y > h->mb.mv_max_spel[1]) ) @@ -533,7 +533,7 @@ void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[ int shift = 1 + MB_INTERLACED - h->mb.field[xy]; \ int16_t *mvp = h->mb.mvr[i_list][i_ref<<1>>shift][xy]; \ mvc[i][0] = mvp[0]; \ - mvc[i][1] = mvp[1]<<1>>shift; \ + mvc[i][1] = mvp[1]*2>>shift; \ i++; \ } ===================================== common/quant.c ===================================== @@ -101,7 +101,7 @@ static int quant_2x2_dc( dctcoef dct[4], int mf, int bias ) } #define DEQUANT_SHL( x ) \ - dct[x] = ( dct[x] * dequant_mf[i_mf][x] ) << i_qbits + dct[x] = ( dct[x] * dequant_mf[i_mf][x] ) * (1 << i_qbits) #define DEQUANT_SHR( x ) \ dct[x] = ( dct[x] * dequant_mf[i_mf][x] + f ) >> (-i_qbits) ===================================== common/x86/mc-c.c ===================================== @@ -499,13 +499,13 @@ static void weight_cache_mmx2( x264_t *h, x264_weight_t *w ) else w->weightfn = h->mc.offsetadd; for( int i = 0; i < 8; i++ ) - w->cachea[i] = abs(w->i_offset<<(BIT_DEPTH-8)); + w->cachea[i] = abs(w->i_offset * (1 << (BIT_DEPTH-8))); return; } w->weightfn = h->mc.weight; int den1 = 1<i_denom; int den2 = w->i_scale<<1; - int den3 = 1+(w->i_offset<<(BIT_DEPTH-8+1)); + int den3 = 1+(w->i_offset * (1 << (BIT_DEPTH-8+1))); for( int i = 0; i < 8; i++ ) { w->cachea[i] = den1; @@ -537,7 +537,7 @@ static void weight_cache_mmx2( x264_t *h, x264_weight_t *w ) return; } w->weightfn = h->mc.weight; - den1 = w->i_offset << w->i_denom | (w->i_denom ? 1 << (w->i_denom - 1) : 0); + den1 = (w->i_offset * (1<i_denom)) | (w->i_denom ? 1 << (w->i_denom - 1) : 0); for( i = 0; i < 8; i++ ) { w->cachea[i] = w->i_scale; ===================================== encoder/encoder.c ===================================== @@ -206,8 +206,8 @@ static void slice_header_init( x264_t *h, x264_slice_header_t *sh, sh->i_disable_deblocking_filter_idc = param->b_sliced_threads ? 2 : 0; else sh->i_disable_deblocking_filter_idc = 1; - sh->i_alpha_c0_offset = param->i_deblocking_filter_alphac0 << 1; - sh->i_beta_offset = param->i_deblocking_filter_beta << 1; + sh->i_alpha_c0_offset = param->i_deblocking_filter_alphac0 * 2; + sh->i_beta_offset = param->i_deblocking_filter_beta * 2; } static void slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal_ref_idc ) ===================================== encoder/macroblock.c ===================================== @@ -1044,7 +1044,7 @@ static ALWAYS_INLINE int macroblock_probe_skip_internal( x264_t *h, int b_bidir, if( M32( mvp ) ) h->mc.mc_chroma( h->mb.pic.p_fdec[1], h->mb.pic.p_fdec[2], FDEC_STRIDE, h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1], - mvp[0], mvp[1]<mc.load_deinterleave_chroma_fdec( h->mb.pic.p_fdec[1], h->mb.pic.p_fref[0][0][4], h->mb.pic.i_stride[1], chroma422?16:8 ); ===================================== encoder/me.c ===================================== @@ -58,7 +58,7 @@ static const int8_t square1[9][2] = {{0,0}, {0,-1}, {0,1}, {-1,0}, {1,0}, {-1,-1 static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_iters, int *p_halfpel_thresh, int b_refine_qpel ); #define BITS_MVD( mx, my )\ - (p_cost_mvx[(mx)<<2] + p_cost_mvy[(my)<<2]) + (p_cost_mvx[(mx)*4] + p_cost_mvy[(my)*4]) #define COST_MV( mx, my )\ do\ @@ -132,9 +132,9 @@ do\ p_fref_w + (m1x) + (m1y)*stride,\ p_fref_w + (m2x) + (m2y)*stride,\ stride, costs );\ - costs[0] += p_cost_mvx[(m0x)<<2]; /* no cost_mvy */\ - costs[1] += p_cost_mvx[(m1x)<<2];\ - costs[2] += p_cost_mvx[(m2x)<<2];\ + costs[0] += p_cost_mvx[(m0x)*4]; /* no cost_mvy */\ + costs[1] += p_cost_mvx[(m1x)*4];\ + costs[2] += p_cost_mvx[(m2x)*4];\ COPY3_IF_LT( bcost, costs[0], bmx, m0x, bmy, m0y );\ COPY3_IF_LT( bcost, costs[1], bmx, m1x, bmy, m1y );\ COPY3_IF_LT( bcost, costs[2], bmx, m2x, bmy, m2y );\ @@ -176,7 +176,7 @@ do\ } #define FPEL(mv) (((mv)+2)>>2) /* Convert subpel MV to fullpel with rounding... */ -#define SPEL(mv) ((mv)<<2) /* ... and the reverse. */ +#define SPEL(mv) ((mv)*4) /* ... and the reverse. */ #define SPELx2(mv) (SPEL(mv)&0xFFFCFFFC) /* for two packed MVs */ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_halfpel_thresh ) @@ -201,7 +201,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int mv_x_max = h->mb.mv_limit_fpel[1][0]; int mv_y_max = h->mb.mv_limit_fpel[1][1]; /* Special version of pack to allow shortcuts in CHECK_MVRANGE */ -#define pack16to32_mask2(mx,my) ((mx<<16)|(my&0x7FFF)) +#define pack16to32_mask2(mx,my) (((uint32_t)(mx)<<16)|((uint32_t)(my)&0x7FFF)) uint32_t mv_min = pack16to32_mask2( -mv_x_min, -mv_y_min ); uint32_t mv_max = pack16to32_mask2( mv_x_max, mv_y_max )|0x8000; uint32_t pmv, bpred_mv = 0; @@ -333,8 +333,8 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, COPY1_IF_LT( bcost, (costs[3]<<4)+12 ); if( !(bcost&15) ) break; - bmx -= (bcost<<28)>>30; - bmy -= (bcost<<30)>>30; + bmx -= (int32_t)((uint32_t)bcost<<28)>>30; + bmy -= (int32_t)((uint32_t)bcost<<30)>>30; bcost &= ~15; } while( --i && CHECK_MVRANGE(bmx, bmy) ); bcost >>= 4; @@ -606,7 +606,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, if( dir ) { bmx = omx + i*(dir>>4); - bmy = omy + i*((dir<<28)>>28); + bmy = omy + i*((int32_t)((uint32_t)dir<<28)>>28); } } } while( ++i <= i_me_range>>2 ); @@ -661,7 +661,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, for( int my = min_y; my <= max_y; my++ ) { int i; - int ycost = p_cost_mvy[my<<2]; + int ycost = p_cost_mvy[my*4]; if( bsad <= ycost ) continue; bsad -= ycost; @@ -753,7 +753,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, for( int my = min_y; my <= max_y; my++ ) { int i; - int ycost = p_cost_mvy[my<<2]; + int ycost = p_cost_mvy[my*4]; if( bcost <= ycost ) continue; bcost -= ycost; @@ -776,7 +776,7 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, uint32_t bmv_spel = SPELx2(bmv); if( h->mb.i_subpel_refine < 3 ) { - m->cost_mv = p_cost_mvx[bmx<<2] + p_cost_mvy[bmy<<2]; + m->cost_mv = p_cost_mvx[bmx*4] + p_cost_mvy[bmy*4]; m->cost = bcost; /* compute the real cost */ if( bmv == pmv ) m->cost += m->cost_mv; @@ -915,8 +915,8 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite COPY1_IF_LT( bcost, (costs[3]<<6)+48 ); if( !(bcost&63) ) break; - bmx -= (bcost<<26)>>29; - bmy -= (bcost<<29)>>29; + bmx -= (int32_t)((uint32_t)bcost<<26)>>29; + bmy -= (int32_t)((uint32_t)bcost<<29)>>29; bcost &= ~63; } bcost >>= 6; @@ -980,8 +980,8 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite COPY1_IF_LT( bcost, (costs[1]<<4)+3 ); COPY1_IF_LT( bcost, (costs[2]<<4)+4 ); COPY1_IF_LT( bcost, (costs[3]<<4)+12 ); - bmx -= (bcost<<28)>>30; - bmy -= (bcost<<30)>>30; + bmx -= (int32_t)((uint32_t)bcost<<28)>>30; + bmy -= (int32_t)((uint32_t)bcost<<30)>>30; bcost >>= 4; } ===================================== tools/checkasm.c ===================================== @@ -2383,7 +2383,7 @@ static int check_quant( uint32_t cpu_ref, uint32_t cpu_new ) { \ int nnz = 0; \ int max = rand() & (size-1); \ - memset( dct1, 0, size*sizeof(dctcoef) ); \ + memset( dct1, 0, 64*sizeof(dctcoef) ); \ for( int idx = ac; idx < max; idx++ ) \ nnz |= dct1[idx] = !(rand()&3) + (!(rand()&15))*rand(); \ if( !nnz ) \ @@ -2417,7 +2417,7 @@ static int check_quant( uint32_t cpu_ref, uint32_t cpu_new ) x264_run_level_t runlevel_c, runlevel_a; \ int nnz = 0; \ int max = rand() & (size-1); \ - memset( dct1, 0, size*sizeof(dctcoef) ); \ + memset( dct1, 0, 64*sizeof(dctcoef) ); \ memcpy( &runlevel_a, buf1+i, sizeof(x264_run_level_t) ); \ memcpy( &runlevel_c, buf1+i, sizeof(x264_run_level_t) ); \ for( int idx = ac; idx < max; idx++ ) \ View it on GitLab: https://code.videolan.org/videolan/x264/-/compare/5db6aa6cab1b146e07b60cc1736a01f21da01154...df075e152dd5435e2090eaa73fec5c4c72bbc3b8 -- View it on GitLab: https://code.videolan.org/videolan/x264/-/compare/5db6aa6cab1b146e07b60cc1736a01f21da01154...df075e152dd5435e2090eaa73fec5c4c72bbc3b8 You're receiving this email because of your account on code.videolan.org. From gitlab at videolan.org Sun Jun 13 20:28:27 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:28:27 +0200 Subject: [x264-devel] [Git][videolan/x264][master] Fix --tcfile-in support Message-ID: <60c66a6b2438a_93731aea5d841159096@gitlab.mail> Anton Mitrofanov pushed to branch master at VideoLAN / x264 Commits: 88fab191 by Anton Mitrofanov at 2021-06-13T20:25:24+00:00 Fix --tcfile-in support Accept files created by MKVToolNix version 17.0.0 or newer. - - - - - 1 changed file: - input/timecode.c Changes: ===================================== input/timecode.c ===================================== @@ -100,8 +100,9 @@ static int parse_tcfile( FILE *tcfile_in, timecode_hnd_t *h, video_info_t *info double *timecodes = NULL; double *fpss = NULL; - ret = fscanf( tcfile_in, "# timecode format v%d", &tcfv ); - FAIL_IF_ERROR( ret != 1 || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ); + ret = fgets( buff, sizeof(buff), tcfile_in ) != NULL && + (sscanf( buff, "# timecode format v%d", &tcfv ) == 1 || sscanf( buff, "# timestamp format v%d", &tcfv ) == 1); + FAIL_IF_ERROR( !ret || (tcfv != 1 && tcfv != 2), "unsupported timecode format\n" ); #define NO_TIMECODE_LINE (buff[0] == '#' || buff[0] == '\n' || buff[0] == '\r') if( tcfv == 1 ) { View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/88fab191002fa4af4a574395d7dbc4eaa82b657c -- View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/88fab191002fa4af4a574395d7dbc4eaa82b657c You're receiving this email because of your account on code.videolan.org. From gitlab at videolan.org Sun Jun 13 20:31:53 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:31:53 +0200 Subject: [x264-devel] [Git][videolan/x264][master] Cosmetics: Add missing backslashes inside #defines Message-ID: <60c66b39d564f_93731bb13e18115967ec@gitlab.mail> Anton Mitrofanov pushed to branch master at VideoLAN / x264 Commits: e0fee7b2 by Ziemowit Zabawa at 2021-06-13T20:29:21+00:00 Cosmetics: Add missing backslashes inside #defines - - - - - 2 changed files: - common/x86/predict-c.c - encoder/rdo.c Changes: ===================================== common/x86/predict-c.c ===================================== @@ -62,7 +62,7 @@ ALIGNED_8( static const int8_t pb_m32101234[8] ) = {-3,-2,-1,0,1,2,3,4}; int b = ( 5 * H + 32 ) >> 6;\ int c = ( 5 * V + 32 ) >> 6;\ int i00 = a - b * 7 - c * 7 + 16;\ - /* b*15 + c*15 can overflow: it's easier to just branch away in this rare case + /* b*15 + c*15 can overflow: it's easier to just branch away in this rare case\ * than to try to consider it in the asm. */\ if( BIT_DEPTH > 8 && (i00 > 0x7fff || abs(b) > 1092 || abs(c) > 1092) )\ x264_predict_16x16_p_c( src );\ ===================================== encoder/rdo.c ===================================== @@ -767,7 +767,7 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct, if( !quant_coefs[i] )\ {\ /* no need to calculate ssd of 0s: it's the same in all nodes.\ - * no need to modify level_tree for ctx=0: it starts with an infinite loop of 0s. + * no need to modify level_tree for ctx=0: it starts with an infinite loop of 0s.\ * subtracting from one score is equivalent to adding to the rest. */\ if( !ctx_hi )\ {\ View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/e0fee7b2ff057bf1823e50c458d76d6964ab7b21 -- View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/e0fee7b2ff057bf1823e50c458d76d6964ab7b21 You're receiving this email because of your account on code.videolan.org. From gitlab at videolan.org Sun Jun 13 20:39:32 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:39:32 +0200 Subject: [x264-devel] [Git][videolan/x264][master] Add support for Sony XAVC Class 300 and 480 Message-ID: <60c66d04e6ce8_93731b74176811601849@gitlab.mail> Anton Mitrofanov pushed to branch master at VideoLAN / x264 Commits: ae03d92b by Phillip Blucas at 2021-06-13T20:32:44+00:00 Add support for Sony XAVC Class 300 and 480 This allows for 2160p UHD at up to 960 Mbit/s. - - - - - 7 changed files: - common/set.h - common/tables.c - common/tables.h - encoder/encoder.c - encoder/set.c - x264.c - x264.h Changes: ===================================== common/set.h ===================================== @@ -140,7 +140,8 @@ typedef struct int b_qpprime_y_zero_transform_bypass; int i_chroma_format_idc; - int b_avcintra; + int b_avcintra_hd; + int b_avcintra_4k; int i_cqm_preset; const uint8_t *scaling_list[8]; /* could be 12, but we don't allow separate Cb/Cr lists */ ===================================== common/tables.c ===================================== @@ -243,7 +243,7 @@ const uint8_t * const x264_cqm_jvt[8] = x264_cqm_jvt8i, x264_cqm_jvt8p }; -// 1080i25_avci50, 1080p25_avci50 +// 720p_avci50, 1080i_avci50, 1080p_avci50 const uint8_t x264_cqm_avci50_4ic[16] = { 16,22,28,40, @@ -252,7 +252,7 @@ const uint8_t x264_cqm_avci50_4ic[16] = 40,44,48,60 }; -// 1080p25_avci50, 720p25_avci50, 720p50_avci50 +// 720p_avci50, 1080p_avci50 const uint8_t x264_cqm_avci50_p_8iy[64] = { 16,18,19,21,24,27,30,33, @@ -265,7 +265,7 @@ const uint8_t x264_cqm_avci50_p_8iy[64] = 33,78,81,84,87,90,93,96 }; -// 1080i25_avci50, +// 1080i_avci50 const uint8_t x264_cqm_avci50_1080i_8iy[64] = { 16,18,19,21,27,33,81,87, @@ -278,7 +278,7 @@ const uint8_t x264_cqm_avci50_1080i_8iy[64] = 30,33,33,78,81,84,87,96 }; -// 720p25_avci100, 720p50_avci100 +// 720p_avci100 const uint8_t x264_cqm_avci100_720p_4ic[16] = { 16,21,27,34, @@ -287,7 +287,7 @@ const uint8_t x264_cqm_avci100_720p_4ic[16] = 34,41,46,54 }; -// 720p25_avci100, 720p50_avci100 +// 720p_avci100 const uint8_t x264_cqm_avci100_720p_8iy[64] = { 16,18,19,21,22,24,26,32, @@ -300,7 +300,7 @@ const uint8_t x264_cqm_avci100_720p_8iy[64] = 32,32,32,34,34,36,38,42 }; -// 1080i25_avci100, 1080p25_avci100 +// 1080i_avci100, 1080p_avci100 const uint8_t x264_cqm_avci100_1080_4ic[16] = { 16,20,26,32, @@ -309,7 +309,7 @@ const uint8_t x264_cqm_avci100_1080_4ic[16] = 32,38,44,50 }; -// 1080i25_avci100, +// 1080i_avci100 const uint8_t x264_cqm_avci100_1080i_8iy[64] = { 16,19,20,23,24,26,32,42, @@ -322,7 +322,7 @@ const uint8_t x264_cqm_avci100_1080i_8iy[64] = 22,23,24,26,36,42,59,72 }; -// 1080p25_avci100, +// 1080p_avci100 const uint8_t x264_cqm_avci100_1080p_8iy[64] = { 16,18,19,20,22,23,24,26, @@ -335,6 +335,37 @@ const uint8_t x264_cqm_avci100_1080p_8iy[64] = 26,32,36,42,59,63,68,72 }; +// 2160p_avci300 +const uint8_t x264_cqm_avci300_2160p_4iy[16] = +{ + 12,16,19,20, + 16,19,20,24, + 19,20,24,33, + 20,24,33,39 +}; + +// 2160p_avci300 +const uint8_t x264_cqm_avci300_2160p_4ic[16] = +{ + 28,39,56,67, + 39,56,67,77, + 56,67,77,104, + 67,77,104,133 +}; + +// 2160p_avci300 +const uint8_t x264_cqm_avci300_2160p_8iy[64] = +{ + 12,14,16,17,19,20,20,24, + 14,16,17,19,20,20,24,30, + 16,17,19,20,20,24,30,42, + 17,19,20,20,24,30,42,56, + 19,20,20,24,30,42,56,72, + 20,20,24,30,42,56,72,76, + 20,24,30,42,56,72,76,80, + 24,30,42,56,72,76,80,84 +}; + /***************************************************************************** * QUANT *****************************************************************************/ ===================================== common/tables.h ===================================== @@ -63,6 +63,9 @@ extern const uint8_t x264_cqm_avci100_720p_8iy[64]; extern const uint8_t x264_cqm_avci100_1080_4ic[16]; extern const uint8_t x264_cqm_avci100_1080i_8iy[64]; extern const uint8_t x264_cqm_avci100_1080p_8iy[64]; +extern const uint8_t x264_cqm_avci300_2160p_4iy[16]; +extern const uint8_t x264_cqm_avci300_2160p_4ic[16]; +extern const uint8_t x264_cqm_avci300_2160p_8iy[64]; extern const uint8_t x264_decimate_table4[16]; extern const uint8_t x264_decimate_table8[64]; ===================================== encoder/encoder.c ===================================== @@ -717,7 +717,9 @@ static int validate_parameters( x264_t *h, int b_open ) return -1; } - int type = h->param.i_avcintra_class == 200 ? 2 : + int type = h->param.i_avcintra_class == 480 ? 4 : + h->param.i_avcintra_class == 300 ? 3 : + h->param.i_avcintra_class == 200 ? 2 : h->param.i_avcintra_class == 100 ? 1 : h->param.i_avcintra_class == 50 ? 0 : -1; if( type < 0 ) @@ -725,63 +727,88 @@ static int validate_parameters( x264_t *h, int b_open ) x264_log( h, X264_LOG_ERROR, "Invalid AVC-Intra class\n" ); return -1; } + else if( type > 2 && h->param.i_avcintra_flavor != X264_AVCINTRA_FLAVOR_SONY ) + { + x264_log( h, X264_LOG_ERROR, "AVC-Intra %d only supported by Sony XAVC flavor\n", h->param.i_avcintra_class ); + return -1; + } - /* [50/100/200][res][fps] */ + /* [50/100/200/300/480][res][fps] */ static const struct { uint16_t fps_num; uint16_t fps_den; uint8_t interlaced; uint16_t frame_size; + const uint8_t *cqm_4iy; const uint8_t *cqm_4ic; const uint8_t *cqm_8iy; - } avcintra_lut[3][2][7] = - { - {{{ 60000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 50, 1, 0, 1100, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 30000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 25, 1, 0, 1100, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 24000, 1001, 0, 912, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}, - {{ 30000, 1001, 1, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, - { 25, 1, 1, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, - { 60000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 30000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 50, 1, 0, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 25, 1, 0, 2196, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, - { 24000, 1001, 0, 1820, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}}, - {{{ 60000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, - { 50, 1, 0, 2224, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, - { 30000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, - { 25, 1, 0, 2224, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, - { 24000, 1001, 0, 1848, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, - {{ 30000, 1001, 1, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, - { 25, 1, 1, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, - { 60000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 30000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 50, 1, 0, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 25, 1, 0, 4444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 24000, 1001, 0, 3692, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, - {{{ 60000, 1001, 0, 3724, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, - { 50, 1, 0, 4472, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, - {{ 30000, 1001, 1, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, - { 25, 1, 1, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, - { 60000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 30000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 50, 1, 0, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 25, 1, 0, 8940, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, - { 24000, 1001, 0, 7444, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}} + } avcintra_lut[5][2][7] = + { + {{{ 60000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 50, 1, 0, 1100, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 30000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 25, 1, 0, 1100, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 24000, 1001, 0, 912, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}, + {{ 30000, 1001, 1, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, + { 25, 1, 1, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_1080i_8iy }, + { 60000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 30000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 50, 1, 0, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 25, 1, 0, 2196, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }, + { 24000, 1001, 0, 1820, x264_cqm_jvt4i, x264_cqm_avci50_4ic, x264_cqm_avci50_p_8iy }}}, + {{{ 60000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, + { 50, 1, 0, 2224, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, + { 30000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, + { 25, 1, 0, 2224, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, + { 24000, 1001, 0, 1848, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, + {{ 30000, 1001, 1, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, + { 25, 1, 1, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, + { 60000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 30000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 50, 1, 0, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 25, 1, 0, 4444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 24000, 1001, 0, 3692, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, + {{{ 60000, 1001, 0, 3724, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }, + { 50, 1, 0, 4472, x264_cqm_jvt4i, x264_cqm_avci100_720p_4ic, x264_cqm_avci100_720p_8iy }}, + {{ 30000, 1001, 1, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, + { 25, 1, 1, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080i_8iy }, + { 60000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 30000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 50, 1, 0, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 25, 1, 0, 8940, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }, + { 24000, 1001, 0, 7444, x264_cqm_jvt4i, x264_cqm_avci100_1080_4ic, x264_cqm_avci100_1080p_8iy }}}, + {{{ 60000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 50, 1, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 30000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 25, 1, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 24000, 1001, 0, 9844, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }}}, + {{{ 60000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 50, 1, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 30000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 25, 1, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }, + { 24000, 1001, 0, 15700, x264_cqm_avci300_2160p_4iy, x264_cqm_avci300_2160p_4ic, x264_cqm_avci300_2160p_8iy }}} }; int res = -1; if( i_csp >= X264_CSP_I420 && i_csp < X264_CSP_I422 && !type ) { - if( h->param.i_width == 1440 && h->param.i_height == 1080 ) res = 1; - else if( h->param.i_width == 960 && h->param.i_height == 720 ) res = 0; + if( h->param.i_width == 1440 && h->param.i_height == 1080 ) res = 1; + else if( h->param.i_width == 960 && h->param.i_height == 720 ) res = 0; } else if( i_csp >= X264_CSP_I422 && i_csp < X264_CSP_I444 && type ) { - if( h->param.i_width == 1920 && h->param.i_height == 1080 ) res = 1; - else if( h->param.i_width == 1280 && h->param.i_height == 720 ) res = 0; + if( type < 3 ) + { + if( h->param.i_width == 1920 && h->param.i_height == 1080 ) res = 1; + else if( h->param.i_width == 2048 && h->param.i_height == 1080 ) res = 1; + else if( h->param.i_width == 1280 && h->param.i_height == 720 ) res = 0; + } + else + { + if( h->param.i_width == 3840 && h->param.i_height == 2160 ) res = 0; + else if( h->param.i_width == 4096 && h->param.i_height == 2160 ) res = 0; + } } else { @@ -822,8 +849,8 @@ static int validate_parameters( x264_t *h, int b_open ) } if( i == 7 ) { - x264_log( h, X264_LOG_ERROR, "FPS %d/%d%c not compatible with AVC-Intra\n", - h->param.i_fps_num, h->param.i_fps_den, PARAM_INTERLACED ? 'i' : 'p' ); + x264_log( h, X264_LOG_ERROR, "FPS %d/%d%c not compatible with AVC-Intra %d\n", + h->param.i_fps_num, h->param.i_fps_den, PARAM_INTERLACED ? 'i' : 'p', h->param.i_avcintra_class ); return -1; } @@ -843,7 +870,7 @@ static int validate_parameters( x264_t *h, int b_open ) h->param.b_pic_struct = 0; h->param.analyse.b_transform_8x8 = 1; h->param.analyse.intra = X264_ANALYSE_I8x8; - h->param.analyse.i_chroma_qp_offset = res && type ? 3 : 4; + h->param.analyse.i_chroma_qp_offset = type > 2 ? -4 : res && type ? 3 : 4; h->param.b_cabac = !type; h->param.rc.i_vbv_buffer_size = avcintra_lut[type][res][i].frame_size; h->param.rc.i_vbv_max_bitrate = @@ -852,7 +879,7 @@ static int validate_parameters( x264_t *h, int b_open ) h->param.rc.f_vbv_buffer_init = 1.0; h->param.rc.b_filler = 1; h->param.i_cqm_preset = X264_CQM_CUSTOM; - memcpy( h->param.cqm_4iy, x264_cqm_jvt4i, sizeof(h->param.cqm_4iy) ); + memcpy( h->param.cqm_4iy, avcintra_lut[type][res][i].cqm_4iy, sizeof(h->param.cqm_4iy) ); memcpy( h->param.cqm_4ic, avcintra_lut[type][res][i].cqm_4ic, sizeof(h->param.cqm_4ic) ); memcpy( h->param.cqm_8iy, avcintra_lut[type][res][i].cqm_8iy, sizeof(h->param.cqm_8iy) ); @@ -1545,7 +1572,7 @@ x264_t *x264_encoder_open( x264_param_t *param, void *api ) h->i_frame_num = 0; if( h->param.i_avcintra_class ) - h->i_idr_pic_id = 5; + h->i_idr_pic_id = h->param.i_avcintra_class > 200 ? 4 : 5; else h->i_idr_pic_id = 0; @@ -3665,7 +3692,7 @@ int x264_encoder_encode( x264_t *h, int total_len = 256; /* Sony XAVC uses an oversized PPS instead of SEI padding */ if( h->param.i_avcintra_flavor == X264_AVCINTRA_FLAVOR_SONY ) - total_len += h->param.i_height == 1080 ? 18*512 : 10*512; + total_len += h->param.i_height >= 1080 ? 18*512 : 10*512; h->out.nal[h->out.i_nal-1].i_padding = total_len - h->out.nal[h->out.i_nal-1].i_payload - NALU_OVERHEAD; } overhead += h->out.nal[h->out.i_nal-1].i_payload + h->out.nal[h->out.i_nal-1].i_padding + NALU_OVERHEAD; ===================================== encoder/set.c ===================================== @@ -241,7 +241,8 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param ) sps->vui.i_log2_max_mv_length_vertical = (int)log2f( X264_MAX( 1, param->analyse.i_mv_range*4-1 ) ) + 1; } - sps->b_avcintra = !!param->i_avcintra_class; + sps->b_avcintra_hd = param->i_avcintra_class && param->i_avcintra_class <= 200; + sps->b_avcintra_4k = param->i_avcintra_class > 200; sps->i_cqm_preset = param->i_cqm_preset; } @@ -325,8 +326,8 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps ) bs_write_ue( s, BIT_DEPTH-8 ); // bit_depth_chroma_minus8 bs_write1( s, sps->b_qpprime_y_zero_transform_bypass ); /* Exactly match the AVC-Intra bitstream */ - bs_write1( s, sps->b_avcintra ); // seq_scaling_matrix_present_flag - if( sps->b_avcintra ) + bs_write1( s, sps->b_avcintra_hd ); // seq_scaling_matrix_present_flag + if( sps->b_avcintra_hd ) { scaling_list_write( s, sps, CQM_4IY ); scaling_list_write( s, sps, CQM_4IC ); @@ -524,7 +525,7 @@ void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps ) bs_write1( s, pps->b_constrained_intra_pred ); bs_write1( s, pps->b_redundant_pic_cnt ); - int b_scaling_list = !sps->b_avcintra && sps->i_cqm_preset != X264_CQM_FLAT; + int b_scaling_list = !sps->b_avcintra_hd && sps->i_cqm_preset != X264_CQM_FLAT; if( pps->b_transform_8x8_mode || b_scaling_list ) { bs_write1( s, pps->b_transform_8x8_mode ); @@ -533,14 +534,27 @@ void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps ) { scaling_list_write( s, sps, CQM_4IY ); scaling_list_write( s, sps, CQM_4IC ); - bs_write1( s, 0 ); // Cr = Cb - scaling_list_write( s, sps, CQM_4PY ); - scaling_list_write( s, sps, CQM_4PC ); - bs_write1( s, 0 ); // Cr = Cb + if( sps->b_avcintra_4k ) + { + scaling_list_write( s, sps, CQM_4IC ); + bs_write1( s, 0 ); // no inter + bs_write1( s, 0 ); // no inter + bs_write1( s, 0 ); // no inter + } + else + { + bs_write1( s, 0 ); // Cr = Cb + scaling_list_write( s, sps, CQM_4PY ); + scaling_list_write( s, sps, CQM_4PC ); + bs_write1( s, 0 ); // Cr = Cb + } if( pps->b_transform_8x8_mode ) { scaling_list_write( s, sps, CQM_8IY+4 ); - scaling_list_write( s, sps, CQM_8PY+4 ); + if( sps->b_avcintra_4k ) + bs_write1( s, 0 ); // no inter + else + scaling_list_write( s, sps, CQM_8PY+4 ); if( sps->i_chroma_format_idc == CHROMA_444 ) { scaling_list_write( s, sps, CQM_8IC+4 ); ===================================== x264.c ===================================== @@ -140,7 +140,7 @@ static cli_output_t cli_output; /* video filter operation struct */ static cli_vid_filter_t filter; -const char * const x264_avcintra_class_names[] = { "50", "100", "200", 0 }; +const char * const x264_avcintra_class_names[] = { "50", "100", "200", "300", "480", 0 }; const char * const x264_cqm_names[] = { "flat", "jvt", 0 }; const char * const x264_log_level_names[] = { "none", "error", "warning", "info", "debug", 0 }; const char * const x264_partition_names[] = { "p8x8", "p4x4", "b8x8", "i8x8", "i4x4", "none", "all", 0 }; ===================================== x264.h ===================================== @@ -45,7 +45,7 @@ extern "C" { #include "x264_config.h" -#define X264_BUILD 163 +#define X264_BUILD 164 #ifdef _WIN32 # define X264_DLL_IMPORT __declspec(dllimport) View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/ae03d92b52bb7581df2e75d571989cb1ecd19cbd -- View it on GitLab: https://code.videolan.org/videolan/x264/-/commit/ae03d92b52bb7581df2e75d571989cb1ecd19cbd You're receiving this email because of your account on code.videolan.org. From gitlab at videolan.org Sun Jun 13 20:41:32 2021 From: gitlab at videolan.org (Anton Mitrofanov) Date: Sun, 13 Jun 2021 22:41:32 +0200 Subject: [x264-devel] [Git][videolan/x264][stable] 11 commits: mp4: Add GPAC detection with pkg-config Message-ID: <60c66d7c6fa66_93731c58cfd411602019@gitlab.mail> 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 +#include #include #include #include ===================================== 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 +#include #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 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 Specify chroma sample location (0 to 5) [%d]\n", defaults->vui.i_chroma_loc ); + H2( " --mastering-display 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 Specify 'max_content,max_frame_average' content\n" + " light levels\n" ); H2( " --alternative-transfer 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.