Merge git://git.videolan.org/x264
authorKieran Kunhya <kierank@ob-encoder.com>
Thu, 19 Dec 2013 12:06:51 +0000 (12:06 +0000)
committerKieran Kunhya <kierank@ob-encoder.com>
Thu, 19 Dec 2013 12:06:51 +0000 (12:06 +0000)
Conflicts:
Makefile
common/common.h
common/frame.c
common/set.h
configure
encoder/encoder.c
encoder/set.c

19 files changed:
1  2 
Makefile
common/common.c
common/common.h
common/frame.c
common/frame.h
common/macroblock.c
common/pixel.c
common/set.h
configure
encoder/analyse.c
encoder/encoder.c
encoder/me.c
encoder/ratecontrol.c
encoder/set.c
encoder/set.h
output/matroska.c
tools/checkasm.c
x264.c
x264.h

diff --cc Makefile
+++ b/Makefile
@@@ -71,14 -69,8 +71,13 @@@ ifneq ($(findstring HAVE_GPAC 1, $(CONF
  SRCCLI += output/mp4.c
  endif
  
- # Visualization sources
- ifneq ($(findstring HAVE_VISUALIZE 1, $(CONFIG)),)
- SRCS   += common/visualize.c common/display-x11.c
 +ifeq ($(HAVE_MPEG2),1)
 +SRCS   += common/mpeg2vlc.c encoder/mpeg2vlc.c
 +CLIS   += x262$(EXE)
 +endif
 +
+ ifneq ($(findstring HAVE_LSMASH 1, $(CONFIG)),)
+ SRCCLI += output/mp4_lsmash.c
  endif
  
  # MMX/SSE optims
diff --cc common/common.c
@@@ -1231,34 -1102,9 +1236,34 @@@ static void x264_log_default( void *p_u
              break;
      }
      fprintf( stderr, "x264 [%s]: ", psz_prefix );
-     vfprintf( stderr, psz_fmt, arg );
+     x264_vfprintf( stderr, psz_fmt, arg );
  }
  
 +static void x264_log_mpeg2( void *p_unused, int i_level, const char *psz_fmt, va_list arg )
 +{
 +    char *psz_prefix;
 +    switch( i_level )
 +    {
 +        case X264_LOG_ERROR:
 +            psz_prefix = "error";
 +            break;
 +        case X264_LOG_WARNING:
 +            psz_prefix = "warning";
 +            break;
 +        case X264_LOG_INFO:
 +            psz_prefix = "info";
 +            break;
 +        case X264_LOG_DEBUG:
 +            psz_prefix = "debug";
 +            break;
 +        default:
 +            psz_prefix = "unknown";
 +            break;
 +    }
 +    fprintf( stderr, "x262 [%s]: ", psz_prefix );
 +    vfprintf( stderr, psz_fmt, arg );
 +}
 +
  /****************************************************************************
   * x264_picture_init:
   ****************************************************************************/
diff --cc common/common.h
@@@ -87,10 -109,8 +112,12 @@@ do {
  
  #define NALU_OVERHEAD 5 // startcode + NAL type costs 5 bytes per frame
  #define FILLER_OVERHEAD (NALU_OVERHEAD+1)
+ #define SEI_OVERHEAD (NALU_OVERHEAD - (h->param.b_annexb && !h->param.b_avcintra_compat && (h->out.i_nal-1)))
 +#define STRUCTURE_OVERHEAD 4 // startcode
 +
 +#define LOG2_16(x) (31 - x264_clz((x)|1))
 +
  /****************************************************************************
   * Includes
   ****************************************************************************/
diff --cc common/frame.c
@@@ -84,9 -84,9 +84,10 @@@ static x264_frame_t *x264_frame_new( x2
  #else
      int disalign = 1<<10;
  #endif
 +    int pixel_buffers = MPEG2 ? 1 : 4;
  
      CHECKED_MALLOCZERO( frame, sizeof(x264_frame_t) );
+     PREALLOC_INIT
  
      /* allocate frame data (+64 for extra data for me) */
      i_width  = h->mb.i_mb_width*16;
          if( h->param.analyse.i_subpel_refine && b_fdec )
          {
              /* FIXME: Don't allocate both buffers in non-adaptive MBAFF. */
-             CHECKED_MALLOC( frame->buffer[p], pixel_buffers*luma_plane_size * sizeof(pixel) );
 -            PREALLOC( frame->buffer[p], 4*luma_plane_size * sizeof(pixel) );
++            PREALLOC( frame->buffer[p], pixel_buffers*luma_plane_size * sizeof(pixel) );
              if( PARAM_INTERLACED )
-                 CHECKED_MALLOC( frame->buffer_fld[p], pixel_buffers*luma_plane_size * sizeof(pixel) );
-             for( int i = 0; i < pixel_buffers; i++ )
-             {
-                 frame->filtered[p][i] = frame->buffer[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH;
-                 frame->filtered_fld[p][i] = frame->buffer_fld[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH;
-             }
-             frame->plane[p] = frame->filtered[p][0];
-             frame->plane_fld[p] = frame->filtered_fld[p][0];
 -                PREALLOC( frame->buffer_fld[p], 4*luma_plane_size * sizeof(pixel) );
++                PREALLOC( frame->buffer_fld[p], pixel_buffers*luma_plane_size * sizeof(pixel) );
          }
          else
          {
          if( h->frames.b_have_lowres )
          {
              int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign );
--
-             CHECKED_MALLOC( frame->buffer_lowres[0], pixel_buffers * luma_plane_size * sizeof(pixel) );
-             for( int i = 0; i < pixel_buffers; i++ )
-                 frame->lowres[i] = frame->buffer_lowres[0] + (frame->i_stride_lowres * PADV + PADH) + i * luma_plane_size;
 -            PREALLOC( frame->buffer_lowres[0], 4 * luma_plane_size * sizeof(pixel) );
++            PREALLOC( frame->buffer_lowres[0], pixel_buffers * luma_plane_size * sizeof(pixel) );
  
              for( int j = 0; j <= !!h->param.i_bframe; j++ )
                  for( int i = 0; i <= h->param.i_bframe; i++ )
          }
          if( h->param.rc.i_aq_mode )
          {
-             CHECKED_MALLOC( frame->f_qp_offset, h->mb.i_mb_count * sizeof(float) );
-             CHECKED_MALLOC( frame->f_qp_offset_aq, h->mb.i_mb_count * sizeof(float) );
+             PREALLOC( frame->f_qp_offset, h->mb.i_mb_count * sizeof(float) );
+             PREALLOC( frame->f_qp_offset_aq, h->mb.i_mb_count * sizeof(float) );
              if( h->frames.b_have_lowres )
 -            for( int i = 0; i < 4; i++ )
+                 PREALLOC( frame->i_inv_qscale_factor, (h->mb.i_mb_count+3) * sizeof(uint16_t) );
+         }
+     }
+     PREALLOC_END( frame->base );
+     if( i_csp == X264_CSP_NV12 || i_csp == X264_CSP_NV16 )
+     {
+         int chroma_padv = i_padv >> (i_csp == X264_CSP_NV12);
+         frame->plane[1] = frame->buffer[1] + frame->i_stride[1] * chroma_padv + PADH;
+         if( PARAM_INTERLACED )
+             frame->plane_fld[1] = frame->buffer_fld[1] + frame->i_stride[1] * chroma_padv + PADH;
+     }
+     for( int p = 0; p < luma_plane_count; p++ )
+     {
+         int luma_plane_size = align_plane_size( frame->i_stride[p] * (frame->i_lines[p] + 2*i_padv), disalign );
+         if( h->param.analyse.i_subpel_refine && b_fdec )
+         {
 -            for( int i = 0; i < 4; i++ )
++            for( int i = 0; i < pixel_buffers; i++ )
+             {
+                 frame->filtered[p][i] = frame->buffer[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH;
+                 frame->filtered_fld[p][i] = frame->buffer_fld[p] + i*luma_plane_size + frame->i_stride[p] * i_padv + PADH;
+             }
+             frame->plane[p] = frame->filtered[p][0];
+             frame->plane_fld[p] = frame->filtered_fld[p][0];
+         }
+         else
+         {
+             frame->filtered[p][0] = frame->plane[p] = frame->buffer[p] + frame->i_stride[p] * i_padv + PADH;
+             frame->filtered_fld[p][0] = frame->plane_fld[p] = frame->buffer_fld[p] + frame->i_stride[p] * i_padv + PADH;
+         }
+     }
+     if( b_fdec )
+     {
+         M32( frame->mv16x16[0] ) = 0;
+         frame->mv16x16++;
+         if( h->param.analyse.i_me_method >= X264_ME_ESA )
+             frame->integral = (uint16_t*)frame->buffer[3] + frame->i_stride[0] * i_padv + PADH;
+     }
+     else
+     {
+         if( h->frames.b_have_lowres )
+         {
+             int luma_plane_size = align_plane_size( frame->i_stride_lowres * (frame->i_lines[0]/2 + 2*PADV), disalign );
++            for( int i = 0; i < pixel_buffers; i++ )
+                 frame->lowres[i] = frame->buffer_lowres[0] + (frame->i_stride_lowres * PADV + PADH) + i * luma_plane_size;
+             for( int j = 0; j <= !!h->param.i_bframe; j++ )
+                 for( int i = 0; i <= h->param.i_bframe; i++ )
+                     memset( frame->lowres_mvs[j][i], 0, 2*h->mb.i_mb_count*sizeof(int16_t) );
+             frame->i_intra_cost = frame->lowres_costs[0][0];
+             memset( frame->i_intra_cost, -1, (i_mb_count+3) * sizeof(uint16_t) );
+             if( h->param.rc.i_aq_mode )
                  /* shouldn't really be initialized, just silences a valgrind false-positive in x264_mbtree_propagate_cost_sse2 */
-                 CHECKED_MALLOCZERO( frame->i_inv_qscale_factor, (h->mb.i_mb_count+3) * sizeof(uint16_t) );
+                 memset( frame->i_inv_qscale_factor, 0, (h->mb.i_mb_count+3) * sizeof(uint16_t) );
          }
      }
  
diff --cc common/frame.h
Simple merge
Simple merge
diff --cc common/pixel.c
Simple merge
diff --cc common/set.h
@@@ -253,21 -248,99 +253,113 @@@ static const uint8_t * const x264_cqm_j
      x264_cqm_jvt8i, x264_cqm_jvt8p
  };
  
 +/* matrix is transposed */
 +static const uint8_t x264_cqm_intra_mpeg2[64] =
 +{
 +     8,16,19,22,22,26,26,27,
 +    16,16,22,22,26,27,27,29,
 +    19,22,26,26,27,29,29,35,
 +    22,24,27,27,29,32,34,38,
 +    26,27,29,29,32,35,38,46,
 +    27,29,34,34,35,40,46,56,
 +    29,34,34,37,40,48,56,69,
 +    34,37,38,40,48,58,69,83
 +};
 +
+ // 1080i25_avci50, 1080p25_avci50
+ static const uint8_t x264_cqm_avci50_4ic[16] =
+ {
+     16,22,28,40,
+     22,28,40,44,
+     28,40,44,48,
+     40,44,48,60
+ };
+ //  1080i25_avci50,
+ static const uint8_t x264_cqm_avci50_1080i_8iy[64] =
+ {
+     16,18,19,21,27,33,81,87,
+     18,19,21,24,30,33,81,87,
+     19,21,24,27,30,78,84,90,
+     21,24,27,30,33,78,84,90,
+     24,27,30,33,78,81,84,90,
+     24,27,30,33,78,81,84,93,
+     27,30,33,78,78,81,87,93,
+     30,33,33,78,81,84,87,96
+ };
+ //  1080p25_avci50, 720p25_avci50, 720p50_avci50
+ static const uint8_t x264_cqm_avci50_p_8iy[64] =
+ {
+     16,18,19,21,24,27,30,33,
+     18,19,21,24,27,30,33,78,
+     19,21,24,27,30,33,78,81,
+     21,24,27,30,33,78,81,84,
+     24,27,30,33,78,81,84,87,
+     27,30,33,78,81,84,87,90,
+     30,33,78,81,84,87,90,93,
+     33,78,81,84,87,90,93,96
+ };
+ //  1080i25_avci100, 1080p25_avci100
+ static const uint8_t x264_cqm_avci100_1080_4ic[16] =
+ {
+     16,20,26,32,
+     20,26,32,38,
+     26,32,38,44,
+     32,38,44,50
+ };
+ // 720p25_avci100, 720p50_avci100
+ static const uint8_t x264_cqm_avci100_720p_4ic[16] =
+ {
+     16,21,27,34,
+     21,27,34,41,
+     27,34,41,46,
+     34,41,46,54
+ };
+ //  1080i25_avci100,
+ static const uint8_t x264_cqm_avci100_1080i_8iy[64] =
+ {
+     16,19,20,23,24,26,32,42,
+     18,19,22,24,26,32,36,42,
+     18,20,23,24,26,32,36,63,
+     19,20,23,26,32,36,42,63,
+     20,22,24,26,32,36,59,63,
+     22,23,24,26,32,36,59,68,
+     22,23,24,26,32,42,59,68,
+     22,23,24,26,36,42,59,72
+ };
+ // 1080p25_avci100,
+ static const uint8_t x264_cqm_avci100_1080p_8iy[64] =
+ {
+     16,18,19,20,22,23,24,26,
+     18,19,20,22,23,24,26,32,
+     19,20,22,23,24,26,32,36,
+     20,22,23,24,26,32,36,42,
+     22,23,24,26,32,36,42,59,
+     23,24,26,32,36,42,59,63,
+     24,26,32,36,42,59,63,68,
+     26,32,36,42,59,63,68,72
+ };
+ // 720p25_avci100, 720p50_avci100
+ static const uint8_t x264_cqm_avci100_720p_8iy[64] =
+ {
+     16,18,19,21,22,24,26,32,
+     18,19,19,21,22,24,26,32,
+     19,19,21,22,22,24,26,32,
+     21,21,22,22,23,24,26,34,
+     22,22,22,23,24,25,26,34,
+     24,24,24,24,25,26,34,36,
+     26,26,26,26,26,34,36,38,
+     32,32,32,34,34,36,38,42
+ };
  int  x264_cqm_init( x264_t *h );
 +int  x264_cqm_init_mpeg2( x264_t *h );
  void x264_cqm_delete( x264_t *h );
  int  x264_cqm_parse_file( x264_t *h, const char *filename );
  
diff --cc configure
+++ b/configure
@@@ -289,8 -291,9 +294,8 @@@ cross_prefix="
  EXE=""
  
  # list of all preprocessor HAVE values we can define
- CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F VISUALIZE SWSCALE LAVF FFMS GPAC GF_MALLOC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL MPEG2"
+ CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
 -             LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH"
 -
++             LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH MPEG2"
  # parse options
  
  for opt do
@@@ -1158,7 -1175,7 +1191,7 @@@ EO
  
  if [ $compiler = ICL ]; then
      echo '%.o: %.c' >> config.mak
--    echo '    $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
++    echo '  $(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
  fi
  
  if [ "$cli" = "yes" ]; then
@@@ -899,75 -810,61 +917,77 @@@ static void x264_mb_analyse_intra( x264
      int idx;
      int lambda = a->i_lambda;
  
 +    if( MPEG2 )
 +    {
 +        int i_satd = 0;
 +        for( int i = 0; i < 4; i++ )
 +        {
 +            p_src = &h->mb.pic.p_fenc[0][8 * (i&1) + 8 * (i>>1) * FENC_STRIDE];
 +            p_dst = &h->mb.pic.p_fdec[0][8 * (i&1) + 8 * (i>>1) * FDEC_STRIDE];
 +            h->predict_8x8_mpeg2( p_dst, 0 );
 +            i_satd += h->pixf.mbcmp[PIXEL_8x8]( p_dst, FDEC_STRIDE, p_src, FENC_STRIDE );
 +        }
 +
 +        int quant = h->mb.i_last_qp != a->i_qp && h->mb.i_mb_x;
 +        a->i_satd_i16x16 = i_satd + lambda * x264_i_mb_type[h->sh.i_type][quant].i_size;
 +        return;
 +    }
 +
      /*---------------- Try all mode and calculate their score ---------------*/
+     /* Disabled i16x16 for AVC-Intra compat */
+     if( !h->param.b_avcintra_compat )
+     {
+         const int8_t *predict_mode = predict_16x16_mode_available( h->mb.i_neighbour_intra );
  
-     /* 16x16 prediction selection */
-     const int8_t *predict_mode = predict_16x16_mode_available( h->mb.i_neighbour_intra );
-     /* Not heavily tuned */
-     static const uint8_t i16x16_thresh_lut[11] = { 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4 };
-     int i16x16_thresh = a->b_fast_intra ? (i16x16_thresh_lut[h->mb.i_subpel_refine]*i_satd_inter)>>1 : COST_MAX;
+         /* Not heavily tuned */
+         static const uint8_t i16x16_thresh_lut[11] = { 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4 };
+         int i16x16_thresh = a->b_fast_intra ? (i16x16_thresh_lut[h->mb.i_subpel_refine]*i_satd_inter)>>1 : COST_MAX;
  
-     if( !h->mb.b_lossless && predict_mode[3] >= 0 )
-     {
-         h->pixf.intra_mbcmp_x3_16x16( p_src, p_dst, a->i_satd_i16x16_dir );
-         a->i_satd_i16x16_dir[0] += lambda * bs_size_ue(0);
-         a->i_satd_i16x16_dir[1] += lambda * bs_size_ue(1);
-         a->i_satd_i16x16_dir[2] += lambda * bs_size_ue(2);
-         COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[0], a->i_predict16x16, 0 );
-         COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[1], a->i_predict16x16, 1 );
-         COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[2], a->i_predict16x16, 2 );
-         /* Plane is expensive, so don't check it unless one of the previous modes was useful. */
-         if( a->i_satd_i16x16 <= i16x16_thresh )
+         if( !h->mb.b_lossless && predict_mode[3] >= 0 )
          {
-             h->predict_16x16[I_PRED_16x16_P]( p_dst );
-             a->i_satd_i16x16_dir[I_PRED_16x16_P] = h->pixf.mbcmp[PIXEL_16x16]( p_dst, FDEC_STRIDE, p_src, FENC_STRIDE );
-             a->i_satd_i16x16_dir[I_PRED_16x16_P] += lambda * bs_size_ue(3);
-             COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[I_PRED_16x16_P], a->i_predict16x16, 3 );
+             h->pixf.intra_mbcmp_x3_16x16( p_src, p_dst, a->i_satd_i16x16_dir );
+             a->i_satd_i16x16_dir[0] += lambda * bs_size_ue(0);
+             a->i_satd_i16x16_dir[1] += lambda * bs_size_ue(1);
+             a->i_satd_i16x16_dir[2] += lambda * bs_size_ue(2);
+             COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[0], a->i_predict16x16, 0 );
+             COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[1], a->i_predict16x16, 1 );
+             COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[2], a->i_predict16x16, 2 );
+             /* Plane is expensive, so don't check it unless one of the previous modes was useful. */
+             if( a->i_satd_i16x16 <= i16x16_thresh )
+             {
+                 h->predict_16x16[I_PRED_16x16_P]( p_dst );
+                 a->i_satd_i16x16_dir[I_PRED_16x16_P] = h->pixf.mbcmp[PIXEL_16x16]( p_dst, FDEC_STRIDE, p_src, FENC_STRIDE );
+                 a->i_satd_i16x16_dir[I_PRED_16x16_P] += lambda * bs_size_ue(3);
+                 COPY2_IF_LT( a->i_satd_i16x16, a->i_satd_i16x16_dir[I_PRED_16x16_P], a->i_predict16x16, 3 );
+             }
          }
-     }
-     else
-     {
-         for( ; *predict_mode >= 0; predict_mode++ )
+         else
          {
-             int i_satd;
-             int i_mode = *predict_mode;
+             for( ; *predict_mode >= 0; predict_mode++ )
+             {
+                 int i_satd;
+                 int i_mode = *predict_mode;
  
-             if( h->mb.b_lossless )
-                 x264_predict_lossless_16x16( h, 0, i_mode );
-             else
-                 h->predict_16x16[i_mode]( p_dst );
+                 if( h->mb.b_lossless )
+                     x264_predict_lossless_16x16( h, 0, i_mode );
+                 else
+                     h->predict_16x16[i_mode]( p_dst );
  
-             i_satd = h->pixf.mbcmp[PIXEL_16x16]( p_dst, FDEC_STRIDE, p_src, FENC_STRIDE ) +
-                      lambda * bs_size_ue( x264_mb_pred_mode16x16_fix[i_mode] );
-             COPY2_IF_LT( a->i_satd_i16x16, i_satd, a->i_predict16x16, i_mode );
-             a->i_satd_i16x16_dir[i_mode] = i_satd;
+                 i_satd = h->pixf.mbcmp[PIXEL_16x16]( p_dst, FDEC_STRIDE, p_src, FENC_STRIDE ) +
+                          lambda * bs_size_ue( x264_mb_pred_mode16x16_fix[i_mode] );
+                 COPY2_IF_LT( a->i_satd_i16x16, i_satd, a->i_predict16x16, i_mode );
+                 a->i_satd_i16x16_dir[i_mode] = i_satd;
+             }
          }
-     }
  
-     if( h->sh.i_type == SLICE_TYPE_B )
-         /* cavlc mb type prefix */
-         a->i_satd_i16x16 += lambda * i_mb_b_cost_table[I_16x16];
+         if( h->sh.i_type == SLICE_TYPE_B )
+             /* cavlc mb type prefix */
+             a->i_satd_i16x16 += lambda * i_mb_b_cost_table[I_16x16];
  
-     if( a->i_satd_i16x16 > i16x16_thresh )
-         return;
+         if( a->i_satd_i16x16 > i16x16_thresh )
+             return;
+     }
  
      uint16_t *cost_i4x4_mode = (uint16_t*)ALIGN((intptr_t)x264_cost_i4x4_mode,64) + a->i_qp*32 + 8;
      /* 8x8 prediction selection */
@@@ -351,27 -347,22 +347,30 @@@ static void x264_slice_header_write( bs
      }
  }
  
 +static void x264_slice_header_write_mpeg2( x264_t *h, bs_t *s, int i_mb_y )
 +{
 +    if( h->param.i_height > 2800 )
 +       bs_write( s, 3, 0 ); // FIXME
 +    bs_write( s, 5, h->mb.i_qp ); // quantiser_scale_code
 +    bs_write1( s, 0 ); // extra_bit_slice
 +}
 +
  /* If we are within a reasonable distance of the end of the memory allocated for the bitstream, */
  /* reallocate, adding an arbitrary amount of space. */
- static int x264_bitstream_check_buffer( x264_t *h )
+ static int x264_bitstream_check_buffer_internal( x264_t *h, int size, int b_cabac, int i_nal )
  {
-     uint8_t *bs_bak = h->out.p_bitstream;
-     int max_row_size = (2500 << SLICE_MBAFF) * h->mb.i_mb_width;
-     if( (h->param.b_cabac && (h->cabac.p_end - h->cabac.p < max_row_size)) ||
-         (h->out.bs.p_end - h->out.bs.p < max_row_size) )
+     if( (b_cabac && (h->cabac.p_end - h->cabac.p < size)) ||
+         (h->out.bs.p_end - h->out.bs.p < size) )
      {
-         h->out.i_bitstream += max_row_size;
-         CHECKED_MALLOC( h->out.p_bitstream, h->out.i_bitstream );
-         h->mc.memcpy_aligned( h->out.p_bitstream, bs_bak, (h->out.i_bitstream - max_row_size) & ~15 );
-         intptr_t delta = h->out.p_bitstream - bs_bak;
+         int buf_size = h->out.i_bitstream + size;
+         uint8_t *buf = x264_malloc( buf_size );
+         if( !buf )
+             return -1;
+         int aligned_size = h->out.i_bitstream & ~15;
+         h->mc.memcpy_aligned( buf, h->out.p_bitstream, aligned_size );
+         memcpy( buf + aligned_size, h->out.p_bitstream + aligned_size, h->out.i_bitstream - aligned_size );
+         intptr_t delta = buf - h->out.p_bitstream;
  
          h->out.bs.p_start += delta;
          h->out.bs.p += delta;
@@@ -1183,11 -1231,10 +1350,13 @@@ static int x264_validate_parameters( x2
      BOOLIFY( b_fake_interlaced );
      BOOLIFY( b_open_gop );
      BOOLIFY( b_bluray_compat );
 +    BOOLIFY( b_nonlinear_quant );
 +    BOOLIFY( b_alt_intra_vlc );
 +    BOOLIFY( b_alternate_scan );
+     BOOLIFY( b_stitchable );
      BOOLIFY( b_full_recon );
      BOOLIFY( b_opencl );
+     BOOLIFY( b_avcintra_compat );
      BOOLIFY( analyse.b_transform_8x8 );
      BOOLIFY( analyse.b_weighted_bipred );
      BOOLIFY( analyse.b_chroma_me );
@@@ -1330,14 -1337,10 +1500,13 @@@ static void x264_set_aspect_ratio( x264
                  x264_log( h, X264_LOG_WARNING, "cannot create valid sample aspect ratio\n" );
              else
              {
 -                x264_log( h, initial?X264_LOG_INFO:X264_LOG_DEBUG, "using SAR=%d/%d\n", i_w, i_h );
 +                // MPEG-2 Table 6-3 references DAR for 4:3, 16:9, and 2.21
 +                char s = MPEG2 && param->vui.i_aspect_ratio_information > 1 ? 'D' : 'S';
 +                x264_log( h, initial?X264_LOG_INFO:X264_LOG_DEBUG, "using %cAR=%d/%d\n", s, i_w, i_h );
                  h->param.vui.i_sar_width = i_w;
                  h->param.vui.i_sar_height = i_h;
 +                h->param.vui.i_aspect_ratio_information = param->vui.i_aspect_ratio_information;
              }
-             x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
          }
      }
  }
@@@ -1391,11 -1394,11 +1560,11 @@@ x264_t *x264_encoder_open( x264_param_
          goto fail;
      }
  
+     x264_set_aspect_ratio( h, &h->param, 1 );
      x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
 -    x264_pps_init( h->pps, h->param.i_sps_id, &h->param, h->sps );
 +    x264_pps_init( h, h->pps, h->param.i_sps_id, &h->param, h->sps );
  
-     x264_set_aspect_ratio( h, &h->param, 1 );
      x264_validate_levels( h, 1 );
  
      h->chroma_qp_table = i_chroma_qp_table + 12 + h->pps->i_chroma_qp_index_offset;
@@@ -3629,19 -3469,15 +3840,19 @@@ int     x264_encoder_encode( x264_t *h
          }
      }
  
 -    /* write extra sei */
 +    /* write extra sei (H.264) / user data (MPEG-2) */
      for( int i = 0; i < h->fenc->extra_sei.num_payloads; i++ )
      {
 -        x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
 -        x264_sei_write( &h->out.bs, h->fenc->extra_sei.payloads[i].payload, h->fenc->extra_sei.payloads[i].payload_size,
 -                        h->fenc->extra_sei.payloads[i].payload_type );
 +        x264_nal_start( h, MPEG2 ? MPEG2_USER_DATA : NAL_SEI, NAL_PRIORITY_DISPOSABLE );
 +        if( MPEG2 )
 +            x264_user_data_write_mpeg2( &h->out.bs, h->fenc->extra_sei.payloads[i].payload, h->fenc->extra_sei.payloads[i].payload_size );
 +        else
 +            x264_sei_write( &h->out.bs, h->fenc->extra_sei.payloads[i].payload, h->fenc->extra_sei.payloads[i].payload_size,
 +                            h->fenc->extra_sei.payloads[i].payload_type );
          if( x264_nal_end( h ) )
              return -1;
-         overhead += h->out.nal[h->out.i_nal-1].i_payload +
-                     ( MPEG2 ? STRUCTURE_OVERHEAD : NALU_OVERHEAD - (h->param.b_annexb && h->out.i_nal-1) );
 -        overhead += h->out.nal[h->out.i_nal-1].i_payload + SEI_OVERHEAD;
++
++        overhead += h->out.nal[h->out.i_nal-1].i_payload + ( MPEG2 ? STRUCTURE_OVERHEAD : SEI_OVERHEAD );
          if( h->fenc->extra_sei.sei_free )
          {
              h->fenc->extra_sei.sei_free( h->fenc->extra_sei.payloads[i].payload );
          h->fenc->extra_sei.sei_free = NULL;
      }
  
 -    if( h->fenc->b_keyframe )
 +    if( h->fenc->b_keyframe && !MPEG2 )
      {
-         if( h->param.b_repeat_headers && h->fenc->i_frame == 0 )
+         /* Avid's decoder strictly wants two SEIs for AVC-Intra so we can't insert the x264 SEI */
+         if( h->param.b_repeat_headers && h->fenc->i_frame == 0 && !h->param.b_avcintra_compat )
          {
              /* identify ourself */
              x264_nal_start( h, NAL_SEI, NAL_PRIORITY_DISPOSABLE );
diff --cc encoder/me.c
Simple merge
Simple merge
diff --cc encoder/set.c
@@@ -783,338 -726,49 +784,381 @@@ void x264_sei_dec_ref_pic_marking_write
      x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_DEC_REF_PIC_MARKING );
  }
  
 +/* MPEG-2 */
 +static void x264_write_cqm_mpeg2( x264_t *h, bs_t *s, int chroma )
 +{
 +    uint8_t temp[64];
 +    int b_keyframe = h->fenc ? h->fenc->b_keyframe : 1;
 +
 +    if( chroma )
 +    {
 +        // load_chroma_intra_quantiser_matrix
 +        if( b_keyframe &&
 +            memcmp( h->pps->scaling_list[CQM_8IC],
 +                    h->pps->scaling_list[CQM_8IY], 64*sizeof(uint8_t) ) )
 +        {
 +            bs_write1( s, 1 );
 +            zigzag_scan_8x8_cqm( temp, h->pps->scaling_list[CQM_8IC] );
 +            bs_write( s, 8, 8 ); // first value must be 8
 +            for( int i = 1; i < 64; i++ )
 +                bs_write( s, 8, temp[i] );
 +        }
 +        else
 +            bs_write1( s, 0 );
 +
 +        // load_chroma_non_intra_quantiser_matrix
 +        if( memcmp( h->pps->scaling_list[CQM_8PC],
 +                    h->pps->scaling_list[CQM_8PY], 64*sizeof(uint8_t) ) )
 +        {
 +            bs_write1( s, 1 );
 +            zigzag_scan_8x8_cqm( temp, h->pps->scaling_list[CQM_8PC] );
 +            for( int i = 0; i < 64; i++ )
 +                bs_write( s, 8, temp[i] );
 +        }
 +        else
 +            bs_write1( s, 0 );
 +    }
 +    else
 +    {
 +        // load_intra_quantiser_matrix
 +        if( b_keyframe &&
 +            memcmp( h->pps->scaling_list[CQM_8IY], x264_cqm_intra_mpeg2, 64*sizeof(uint8_t) ) )
 +        {
 +            bs_write1( s, 1 );
 +            zigzag_scan_8x8_cqm( temp, h->pps->scaling_list[CQM_8IY] );
 +            bs_write( s, 8, 8 ); // first value must be 8
 +            for( int i = 1; i < 64; i++ )
 +                bs_write( s, 8, temp[i] );
 +        }
 +        else
 +            bs_write1( s, 0 );
 +
 +        // load_non_intra_quantiser_matrix
 +        if( memcmp( h->pps->scaling_list[CQM_8PY], x264_cqm_flat16, 64*sizeof(uint8_t) ) )
 +        {
 +            bs_write1( s, 1 );
 +            zigzag_scan_8x8_cqm( temp, h->pps->scaling_list[CQM_8PY] );
 +            for( int i = 0; i < 64; i++ )
 +                bs_write( s, 8, temp[i] );
 +        }
 +        else
 +            bs_write1( s, 0 );
 +    }
 +}
 +
 +void x264_seq_header_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    int i;
 +    bs_realign( s );
 +
 +    bs_write( s, 12, h->param.i_width & 0xfff );  // horizontal_size_value
 +    bs_write( s, 12, h->param.i_height & 0xfff ); // vertical_size_value
 +    bs_write( s, 4, h->param.vui.i_aspect_ratio_information ); // aspect_ratio_information
 +    bs_write( s, 4, h->sps->i_frame_rate_code ); // frame_rate_code
 +
 +    /* If vbv parameters are not set, choose a common value. */
 +    if( h->param.rc.i_vbv_max_bitrate > 0 )
 +        i = ((h->param.rc.i_vbv_max_bitrate * 1000 + 399) / 400) & 0x3ffff;
 +    else if( h->param.i_width > 720 )
 +        i = 48500; // ATSC A/53, (19400 * 1000 + 399) / 400
 +    else
 +        i = 24500; // DVD, (9800 * 1000 + 399) / 400
 +    bs_write( s, 18, i ); // bit_rate_value
 +
 +    bs_write1( s, 1 ); // marker_bit
 +
 +    if( h->param.rc.i_vbv_buffer_size > 0 )
 +        i = ((h->param.rc.i_vbv_buffer_size * 1000 + 16383) / 16384) & 0x3ff;
 +    else if( h->param.i_width > 720 )
 +        i = 488; // ATSC A/53, (7995 * 1000 + 16383) / 16384
 +    else
 +        i = 112; // DVD, (1835 * 1000 + 16383) / 16384
 +    bs_write( s, 10, i ); // vbv_buffer_size_value
 +
 +    bs_write1( s, 0 ); // constrained_parameters_flag
 +
 +    x264_write_cqm_mpeg2( h, s, 0 );
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_seq_extension_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    x264_sps_t *sps = h->sps;
 +    bs_realign( s );
 +
 +    bs_write( s, 4, MPEG2_SEQ_EXT_ID );   // extension_start_code_identifier
 +    bs_write1( s, sps->i_profile_idc == MPEG2_PROFILE_422 ); // escape bit
 +    bs_write( s, 3, sps->i_profile_idc ); // profile identification
 +
 +    int level;
 +    if( sps->i_profile_idc == MPEG2_PROFILE_422 )
 +        level = sps->i_level_idc == X264_MPEG2_LEVEL_HIGH ? 2 : 5;
 +    else
 +        level = sps->i_level_idc;
 +    bs_write( s, 4, level ); // level identification
 +
 +    bs_write1( s, !( PARAM_INTERLACED || h->param.b_fake_interlaced ||
 +                     h->param.b_pulldown ) ); // progressive_sequence
 +    bs_write( s, 2, sps->i_chroma_format_idc ); // chroma_format
 +    bs_write( s, 2, (h->param.i_width >> 12) & 0x3 );  // horizontal_size_extension
 +    bs_write( s, 2, (h->param.i_height >> 12) & 0x3 ); // vertical_size_extension
 +    bs_write( s, 12, (h->param.rc.i_vbv_max_bitrate * 1000 + 399) / 400 >> 18 & 0xfff );   // bit_rate_extension
 +    bs_write1( s, 1 );   // marker_bit
 +    bs_write( s, 8, (h->param.rc.i_vbv_buffer_size * 1000 + 16383) / 16384 >> 10 & 0xff ); // vbv_buffer_size_extension
 +    bs_write1( s, !h->param.i_bframe ); // low_delay
 +    bs_write( s, 2, 0 ); // frame_rate_extension_n
 +    bs_write( s, 5, 0 ); // frame_rate_extension_d
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_seq_disp_extension_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    x264_sps_t *sps = h->sps;
 +    bs_realign( s );
 +
 +    bs_write( s, 4, MPEG2_SEQ_DISPLAY_EXT_ID ); // extension_start_code_identifier
 +    bs_write( s, 3, sps->vui.i_vidformat );    // video_format
 +    bs_write1( s, sps->vui.b_color_description_present ); // colour_description
 +    if( sps->vui.b_color_description_present )
 +    {
 +        bs_write( s, 8, sps->vui.i_colorprim );
 +        bs_write( s, 8, sps->vui.i_transfer );
 +        bs_write( s, 8, sps->vui.i_colmatrix );
 +    }
 +    bs_write( s, 14, h->param.i_width - h->param.crop_rect.i_left - h->param.crop_rect.i_right ); // display_horizontal_size
 +    bs_write1( s, 1 ); // marker_bit
 +    bs_write( s, 14, h->param.i_height - h->param.crop_rect.i_top - h->param.crop_rect.i_bottom ); // display_vertical_size
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_gop_header_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    bs_realign( s );
 +
 +    int hrs, min, sec;
 +    int frames = h->i_frame;
 +    int fps = h->param.i_fps_num > 60 ? h->param.i_fps_num / 1000 : h->param.i_fps_num;
 +
 +    hrs = frames  / ( 60 * 60 * fps );
 +    frames -= hrs * ( 60 * 60 * fps );
 +    min = frames  / ( 60 * fps );
 +    frames -= min * ( 60 * fps );
 +    sec = frames  / ( fps );
 +    frames -= sec * ( fps );
 +
 +    // timecode
 +    bs_write1( s, 0 );   // drop_frame_flag
 +    bs_write( s, 5, hrs % 24 ); // time_code_hours
 +    bs_write( s, 6, min ); // time_code_minutes
 +    bs_write1( s, 1 );   // marker_bit
 +    bs_write( s, 6, sec ); // time_code_seconds
 +    bs_write( s, 6, frames ); // time_code_pictures
 +
 +    bs_write1( s, h->fenc->i_frame == h->fenc->i_coded ); // closed_gop
 +    bs_write1( s, 0 );   // broken_link
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_pic_header_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    bs_realign( s );
 +
 +    int temporal_ref;
 +    if( IS_X264_TYPE_I( h->fenc->i_type ) )
 +        temporal_ref = h->fenc->i_frame - h->fenc->i_coded;
 +    else
 +        temporal_ref = h->fenc->i_frame - h->frames.i_last_temporal_ref;
 +    bs_write( s, 10, temporal_ref % 1024 ); // temporal_reference
 +    bs_write( s, 3, IS_X264_TYPE_I( h->fenc->i_type ) ? 1 : h->fenc->i_type == X264_TYPE_P ? 2 : 3 ); // picture_coding_type
 +    bs_write( s, 16, 0xffff ); // vbv_delay FIXME
 +    if( !IS_X264_TYPE_I( h->fenc->i_type ) )
 +    {
 +        bs_write1( s, 0 );   // full_pel_forward_vector
 +        bs_write( s, 3, 7 ); // forward_f_code
 +
 +        if( h->fenc->i_type == X264_TYPE_B )
 +        {
 +            bs_write1( s, 0 );   // full_pel_forward_vector
 +            bs_write( s, 3, 7 ); // forward_f_code
 +        }
 +    }
 +    bs_write1( s, 0 ); // extra_bit_picture
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_pic_coding_extension_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    x264_param_t *param = &h->param;
 +
 +    bs_realign( s );
 +
 +    bs_write( s, 4, MPEG2_PIC_CODING_EXT_ID ); // extension_start_code_identifier
 +
 +    // FIXME decide fcodes during lookahead
 +    int fcode_max[2];
 +    switch( param->i_level_idc )
 +    {
 +    case X264_MPEG2_LEVEL_LOW:
 +        fcode_max[0] = 7;
 +        fcode_max[1] = 4;
 +        break;
 +    case X264_MPEG2_LEVEL_MAIN:
 +        fcode_max[0] = 8;
 +        fcode_max[1] = 5;
 +        break;
 +    default:
 +        fcode_max[0] = 9;
 +        fcode_max[1] = 5;
 +    }
 +    h->fenc->mv_fcode[0][0] = h->fenc->mv_fcode[1][0] = fcode_max[0];
 +    h->fenc->mv_fcode[0][1] = h->fenc->mv_fcode[1][1] = fcode_max[1];
 +
 +    // f_code[s][t]
 +    if( IS_X264_TYPE_I( h->fenc->i_type ) )
 +        bs_write( s, 16, 0xffff );
 +    else if( h->fenc->i_type == X264_TYPE_P )
 +    {
 +        for( int i = 0; i < 2; i++ )
 +            bs_write( s, 4, h->fenc->mv_fcode[0][i] );
 +        bs_write( s, 8, 0xff );
 +    }
 +    else
 +    {
 +        for( int j = 0; j < 2; j++ )
 +            for( int i = 0; i < 2; i++ )
 +                bs_write( s, 4, h->fenc->mv_fcode[j][i] );
 +    }
 +    bs_write( s, 2, param->i_intra_dc_precision ); // intra_dc_precision
 +    bs_write( s, 2, 3 ); // picture_structure (support for frame pictures only)
 +    bs_write1( s, ( PARAM_INTERLACED || param->b_fake_interlaced  || param->b_pulldown ) ? h->fenc->b_tff : 0 ); // top_field_first
 +    bs_write1( s, !( PARAM_INTERLACED || param->b_fake_interlaced ) ); // frame_pred_frame_dct
 +    bs_write1( s, 0 ); // concealment_motion_vectors
 +    bs_write1( s, param->b_nonlinear_quant ); // q_scale_type
 +    bs_write1( s, param->b_alt_intra_vlc );   // intra_vlc_format
 +    bs_write1( s, param->b_alternate_scan );  // alternate_scan
 +    bs_write1( s, h->fenc->b_rff ); // repeat_first_field
 +    bs_write1( s, CHROMA_FORMAT == CHROMA_420 ? !( PARAM_INTERLACED || param->b_fake_interlaced ) : 0 ); // chroma_420_type
 +    bs_write1( s, !( PARAM_INTERLACED || param->b_fake_interlaced ) ); // progressive_frame
 +    bs_write1( s, 0 ); // composite_display_flag
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_quant_matrix_extension_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    bs_realign( s );
 +
 +    bs_write( s, 4, MPEG2_QUANT_MATRIX_EXT_ID ); // extension_start_code_identifier
 +
 +    if( !h->fenc->b_keyframe )
 +        x264_write_cqm_mpeg2( h, s, 0 );
 +    else
 +    {
 +        bs_write1( s, 0 ); // load_intra_quantiser_matrix
 +        bs_write1( s, 0 ); // load_non_intra_quantiser_matrix
 +    }
 +
 +    if( CHROMA_FORMAT == CHROMA_422 )
 +        x264_write_cqm_mpeg2( h, s, 1 );
 +    else
 +    {
 +        bs_write1( s, 0 ); // load_chroma_intra_quantiser_matrix
 +        bs_write1( s, 0 ); // load_chroma_non_intra_quantiser_matrix
 +    }
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_pic_display_extension_write_mpeg2( x264_t *h, bs_t *s )
 +{
 +    bs_realign( s );
 +
 +    bs_write( s, 4, MPEG2_PIC_DISPLAY_EXT_ID ); // extension_start_code_identifier
 +
 +    int progressive_sequence = !( PARAM_INTERLACED || h->param.b_fake_interlaced || h->param.b_pulldown );
 +    int offsets = progressive_sequence ? h->fenc->b_rff ? h->fenc->b_tff ? 3 : 2 : 1 :
 +                  h->fenc->b_rff ? 3 : 2;
 +
 +    int cx = h->param.i_width / 2;
 +    int cy = h->param.i_height / 2;
 +    for( int i = 0; i < offsets; i++ )
 +    {
 +        bs_write( s, 16, ( cx - h->param.crop_rect.i_left ) * 16 ); // frame_centre_horizontal_offset
 +        bs_write1( s, 1 ); // marker_bit
 +        bs_write( s, 16, ( cy - h->param.crop_rect.i_top ) * 16 ); // frame_centre_vertical_offset
 +        bs_write1( s, 1 ); // marker_bit
 +    }
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
 +void x264_user_data_write_mpeg2( bs_t *s, uint8_t *payload, int payload_size )
 +{
 +    bs_realign( s );
 +
 +    for( int i = 0; i < payload_size; i++ ) // payload cannot contain a start code
 +        bs_write( s, 8, payload[i] );
 +
 +    bs_align_0( s );
 +    bs_flush( s );
 +}
 +
+ int x264_sei_avcintra_umid_write( x264_t *h, bs_t *s )
+ {
+     uint8_t data[512];
+     const char *msg = "UMID";
+     const int len = 497;
+     memset( data, 0xff, len );
+     memcpy( data, avcintra_uuid, sizeof(avcintra_uuid) );
+     memcpy( data+16, msg, strlen(msg) );
+     data[20] = 0x13;
+     /* These bytes appear to be some sort of frame/seconds counter in certain applications,
+      * but others jump around, so leave them as zero for now */
+     data[21] = data[22] = 0;
+     data[28] = 0x14;
+     data[36] = 0x60;
+     data[41] = 0x22; /* Believed to be some sort of end of basic UMID identifier */
+     x264_sei_write( &h->out.bs, data, len, SEI_USER_DATA_UNREGISTERED );
+     return 0;
+ }
+ int x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len )
+ {
+     uint8_t data[6000];
+     const char *msg = "VANC";
+     if( len > sizeof(data) )
+     {
+         x264_log( h, X264_LOG_ERROR, "AVC-Intra SEI is too large (%d)\n", len );
+         return -1;
+     }
+     memset( data, 0xff, len );
+     memcpy( data, avcintra_uuid, sizeof(avcintra_uuid) );
+     memcpy( data+16, msg, strlen(msg) );
+     x264_sei_write( &h->out.bs, data, len, SEI_USER_DATA_UNREGISTERED );
+     return 0;
+ }
  const x264_level_t x264_levels[] =
  {
      { 10,    1485,    99,    396,     64,    175,  64, 64,  0, 2, 0, 0, 1 },
diff --cc encoder/set.h
Simple merge
Simple merge
Simple merge
diff --cc x264.c
--- 1/x264.c
--- 2/x264.c
+++ b/x264.c
   * For more information, contact us at licensing@x264.com.
   *****************************************************************************/
  
+ #ifdef _WIN32
+ /* The following two defines must be located before the inclusion of any system header files. */
+ #define WINVER       0x0500
+ #define _WIN32_WINNT 0x0500
+ #include <windows.h>
+ #include <io.h>       /* _setmode() */
+ #include <fcntl.h>    /* _O_BINARY */
+ #endif
  #include <signal.h>
 +#include <libgen.h>
  #define _GNU_SOURCE
  #include <getopt.h>
  #include "common/common.h"
@@@ -860,10 -933,7 +949,9 @@@ typedef enu
      OPT_THREAD_INPUT,
      OPT_QUIET,
      OPT_NOPROGRESS,
-     OPT_VISUALIZE,
      OPT_LONGHELP,
 +    OPT_MPEG2,
 +    OPT_NO_MPEG2,
      OPT_PROFILE,
      OPT_PRESET,
      OPT_TUNE,
diff --cc x264.h
Simple merge