Bump dates to 2011
[x262.git] / encoder / set.c
index 4b0fa51..b02772a 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * set: header writing
  *****************************************************************************
- * Copyright (C) 2003-2010 x264 project
+ * Copyright (C) 2003-2011 x264 project
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Loren Merritt <lorenm@u.washington.edu>
@@ -159,7 +159,7 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
     while( (1 << sps->i_log2_max_frame_num) <= max_frame_num )
         sps->i_log2_max_frame_num++;
 
-    sps->i_poc_type = param->i_bframe ? 0 : 2;
+    sps->i_poc_type = param->i_bframe || param->b_interlaced ? 0 : 2;
     if( sps->i_poc_type == 0 )
     {
         int max_delta_poc = (param->i_bframe + 2) * (!!param->i_bframe_pyramid + 1) * 2;
@@ -192,10 +192,10 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
     sps->b_mb_adaptive_frame_field = param->b_interlaced;
     sps->b_direct8x8_inference = 1;
 
-    sps->crop.i_left   = 0;
-    sps->crop.i_top    = 0;
-    sps->crop.i_right  = sps->i_mb_width*16 - param->i_width;
-    sps->crop.i_bottom = (sps->i_mb_height*16 - param->i_height) >> !sps->b_frame_mbs_only;
+    sps->crop.i_left   = param->crop_rect.i_left;
+    sps->crop.i_top    = param->crop_rect.i_top;
+    sps->crop.i_right  = param->crop_rect.i_right + sps->i_mb_width*16 - param->i_width;
+    sps->crop.i_bottom = (param->crop_rect.i_bottom + sps->i_mb_height*16 - param->i_height) >> !sps->b_frame_mbs_only;
     sps->b_crop = sps->crop.i_left  || sps->crop.i_top ||
                   sps->crop.i_right || sps->crop.i_bottom;
 
@@ -571,8 +571,8 @@ int x264_sei_version_write( x264_t *h, bs_t *s )
 
     memcpy( payload, uuid, 16 );
     sprintf( payload+16, "x264 - core %d%s - H.264/MPEG-4 AVC codec - "
-             "Copyleft 2003-2010 - http://www.videolan.org/x264.html - options: %s",
-             X264_BUILD, X264_VERSION, opts );
+             "Copy%s 2003-2011 - http://www.videolan.org/x264.html - options: %s",
+             X264_BUILD, X264_VERSION, HAVE_GPL?"left":"right", opts );
     length = strlen(payload)+1;
 
     x264_sei_write( s, (uint8_t *)payload, length, SEI_USER_DATA_UNREGISTERED );
@@ -638,6 +638,45 @@ void x264_sei_pic_timing_write( x264_t *h, bs_t *s )
     x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_PIC_TIMING );
 }
 
+void x264_sei_frame_packing_write( x264_t *h, bs_t *s )
+{
+    bs_t q;
+    uint8_t tmp_buf[100];
+    bs_init( &q, tmp_buf, 100 );
+
+    bs_realign( &q );
+
+    bs_write_ue( &q, 0 );                         // frame_packing_arrangement_id
+    bs_write1( &q, 0 );                           // frame_packing_arrangement_cancel_flag
+    bs_write ( &q, 7, h->param.i_frame_packing ); // frame_packing_arrangement_type
+    bs_write1( &q, 0 );                           // quincunx_sampling_flag
+
+    // 0: views are unrelated, 1: left view is on the left, 2: left view is on the right
+    bs_write ( &q, 6, 1 );                        // content_interpretation_type
+
+    bs_write1( &q, 0 );                           // spatial_flipping_flag
+    bs_write1( &q, 0 );                           // frame0_flipped_flag
+    bs_write1( &q, 0 );                           // field_views_flag
+    bs_write1( &q, h->param.i_frame_packing == 5 && !(h->fenc->i_frame&1) ); // current_frame_is_frame0_flag
+    bs_write1( &q, 0 );                           // frame0_self_contained_flag
+    bs_write1( &q, 0 );                           // frame1_self_contained_flag
+    if ( /* quincunx_sampling_flag == 0 && */ h->param.i_frame_packing != 5 )
+    {
+        bs_write( &q, 4, 0 );                     // frame0_grid_position_x
+        bs_write( &q, 4, 0 );                     // frame0_grid_position_y
+        bs_write( &q, 4, 0 );                     // frame1_grid_position_x
+        bs_write( &q, 4, 0 );                     // frame1_grid_position_y
+    }
+    bs_write( &q, 8, 0 );                         // frame_packing_arrangement_reserved_byte
+    bs_write_ue( &q, 1 );                         // frame_packing_arrangement_repetition_period
+    bs_write1( &q, 0 );                           // frame_packing_arrangement_extension_flag
+
+    bs_align_10( &q );
+    bs_flush( &q );
+
+    x264_sei_write( s, tmp_buf, bs_pos( &q ) / 8, SEI_FRAME_PACKING );
+}
+
 void x264_filler_write( x264_t *h, bs_t *s, int filler )
 {
     bs_realign( s );