[x264-devel] Eliminate extra layer of indirection for sps/pps references

Jason Garrett-Glaser git at videolan.org
Sun Jul 10 06:17:54 CEST 2011


x264 | branch: master | Jason Garrett-Glaser <jason at x264.com> | Thu Jun 23 11:54:42 2011 -0700| [eaf95892fd60c8c4b104354c5e18ea5dfd23343e] | committer: Jason Garrett-Glaser

Eliminate extra layer of indirection for sps/pps references
Also remove poc type 1 support (it didn't work anyways) to reduce sps size.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=eaf95892fd60c8c4b104354c5e18ea5dfd23343e
---

 common/common.h   |   10 ++++------
 common/set.h      |    6 ------
 encoder/encoder.c |   17 -----------------
 encoder/set.c     |   27 ---------------------------
 tools/checkasm.c  |    2 --
 5 files changed, 4 insertions(+), 58 deletions(-)

diff --git a/common/common.h b/common/common.h
index 0b146fc..cfee673 100644
--- a/common/common.h
+++ b/common/common.h
@@ -439,9 +439,6 @@ struct x264_t
     uint8_t *nal_buffer;
     int      nal_buffer_size;
 
-    x264_sps_t      *sps;
-    x264_pps_t      *pps;
-
     /**** thread synchronization starts here ****/
 
     /* frame number/poc */
@@ -467,9 +464,6 @@ struct x264_t
     int             b_queued_intra_refresh;
     int64_t         i_last_idr_pts;
 
-    /* We use only one SPS and one PPS */
-    x264_sps_t      sps_array[1];
-    x264_pps_t      pps_array[1];
     int             i_idr_pic_id;
 
     /* quantization matrix for decoding, [cqm][qp%6][coef] */
@@ -494,6 +488,10 @@ struct x264_t
     /* Slice header */
     x264_slice_header_t sh;
 
+    /* SPS / PPS */
+    x264_sps_t      sps[1];
+    x264_pps_t      pps[1];
+
     /* Slice header backup, for SEI_DEC_REF_PIC_MARKING */
     int b_sh_backup;
     x264_slice_header_t sh_backup;
diff --git a/common/set.h b/common/set.h
index fb81c1a..aeeb36c 100644
--- a/common/set.h
+++ b/common/set.h
@@ -69,12 +69,6 @@ typedef struct
     int i_poc_type;
     /* poc 0 */
     int i_log2_max_poc_lsb;
-    /* poc 1 */
-    int b_delta_pic_order_always_zero;
-    int i_offset_for_non_ref_pic;
-    int i_offset_for_top_to_bottom_field;
-    int i_num_ref_frames_in_poc_cycle;
-    int i_offset_for_ref_frame[256];
 
     int i_num_ref_frames;
     int b_gaps_in_frame_num_value_allowed;
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 20b8fcf..3aff596 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -209,12 +209,6 @@ static void x264_slice_header_write( bs_t *s, x264_slice_header_t *sh, int i_nal
         if( sh->pps->b_pic_order && !sh->b_field_pic )
             bs_write_se( s, sh->i_delta_poc_bottom );
     }
-    else if( sh->sps->i_poc_type == 1 && !sh->sps->b_delta_pic_order_always_zero )
-    {
-        bs_write_se( s, sh->i_delta_poc[0] );
-        if( sh->pps->b_pic_order && !sh->b_field_pic )
-            bs_write_se( s, sh->i_delta_poc[1] );
-    }
 
     if( sh->pps->b_redundant_pic_cnt )
         bs_write_ue( s, sh->i_redundant_pic_cnt );
@@ -790,7 +784,6 @@ static int x264_validate_parameters( x264_t *h, int b_open )
             int maxrate_bak = h->param.rc.i_vbv_max_bitrate;
             if( h->param.rc.i_rc_method == X264_RC_ABR && h->param.rc.i_vbv_buffer_size <= 0 )
                 h->param.rc.i_vbv_max_bitrate = h->param.rc.i_bitrate * 2;
-            h->sps = h->sps_array;
             x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
             do h->param.i_level_idc = l->level_idc;
                 while( l[1].level_idc && x264_validate_levels( h, 0 ) && l++ );
@@ -1019,10 +1012,7 @@ x264_t *x264_encoder_open( x264_param_t *param )
         goto fail;
     }
 
-    h->sps = &h->sps_array[0];
     x264_sps_init( h->sps, h->param.i_sps_id, &h->param );
-
-    h->pps = &h->pps_array[0];
     x264_pps_init( h->pps, h->param.i_sps_id, &h->param, h->sps );
 
     x264_set_aspect_ratio( h, &h->param, 1 );
@@ -1190,9 +1180,6 @@ x264_t *x264_encoder_open( x264_param_t *param )
         else
             h->thread[i]->fdec = h->thread[0]->fdec;
 
-        h->thread[i]->sps = &h->thread[i]->sps_array[0];
-        h->thread[i]->pps = &h->thread[i]->pps_array[0];
-
         CHECKED_MALLOC( h->thread[i]->out.p_bitstream, h->out.i_bitstream );
         /* Start each thread with room for init_nal_count NAL units; it'll realloc later if needed. */
         CHECKED_MALLOC( h->thread[i]->out.nal, init_nal_count*sizeof(x264_nal_t) );
@@ -1953,10 +1940,6 @@ static inline void x264_slice_init( x264_t *h, int i_nal_type, int i_global_qp )
         h->fdec->i_delta_poc[0] = h->sh.i_delta_poc_bottom == -1;
         h->fdec->i_delta_poc[1] = h->sh.i_delta_poc_bottom ==  1;
     }
-    else if( h->sps->i_poc_type == 1 )
-    {
-        /* FIXME TODO FIXME */
-    }
     else
     {
         /* Nothing to do ? */
diff --git a/encoder/set.c b/encoder/set.c
index 362cc5f..d3a5f60 100644
--- a/encoder/set.c
+++ b/encoder/set.c
@@ -165,21 +165,6 @@ void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )
         while( (1 << sps->i_log2_max_poc_lsb) <= max_delta_poc * 2 )
             sps->i_log2_max_poc_lsb++;
     }
-    else if( sps->i_poc_type == 1 )
-    {
-        int i;
-
-        /* FIXME */
-        sps->b_delta_pic_order_always_zero = 1;
-        sps->i_offset_for_non_ref_pic = 0;
-        sps->i_offset_for_top_to_bottom_field = 0;
-        sps->i_num_ref_frames_in_poc_cycle = 0;
-
-        for( i = 0; i < sps->i_num_ref_frames_in_poc_cycle; i++ )
-        {
-            sps->i_offset_for_ref_frame[i] = 0;
-        }
-    }
 
     sps->b_vui = 1;
 
@@ -292,19 +277,7 @@ void x264_sps_write( bs_t *s, x264_sps_t *sps )
     bs_write_ue( s, sps->i_log2_max_frame_num - 4 );
     bs_write_ue( s, sps->i_poc_type );
     if( sps->i_poc_type == 0 )
-    {
         bs_write_ue( s, sps->i_log2_max_poc_lsb - 4 );
-    }
-    else if( sps->i_poc_type == 1 )
-    {
-        bs_write1( s, sps->b_delta_pic_order_always_zero );
-        bs_write_se( s, sps->i_offset_for_non_ref_pic );
-        bs_write_se( s, sps->i_offset_for_top_to_bottom_field );
-        bs_write_ue( s, sps->i_num_ref_frames_in_poc_cycle );
-
-        for( int i = 0; i < sps->i_num_ref_frames_in_poc_cycle; i++ )
-            bs_write_se( s, sps->i_offset_for_ref_frame[i] );
-    }
     bs_write_ue( s, sps->i_num_ref_frames );
     bs_write1( s, sps->b_gaps_in_frame_num_value_allowed );
     bs_write_ue( s, sps->i_mb_width - 1 );
diff --git a/tools/checkasm.c b/tools/checkasm.c
index 73ae49c..d4ebc45 100644
--- a/tools/checkasm.c
+++ b/tools/checkasm.c
@@ -565,7 +565,6 @@ static int check_dct( int cpu_ref, int cpu_new )
     x264_dct_init( cpu_new, &dct_asm );
 
     memset( h, 0, sizeof(*h) );
-    h->pps = h->pps_array;
     x264_param_default( &h->param );
     h->chroma_qp_table = i_chroma_qp_table + 12;
     h->param.analyse.i_luma_deadzone[0] = 0;
@@ -1436,7 +1435,6 @@ static int check_quant( int cpu_ref, int cpu_new )
     x264_t h_buf;
     x264_t *h = &h_buf;
     memset( h, 0, sizeof(*h) );
-    h->pps = h->pps_array;
     x264_param_default( &h->param );
     h->chroma_qp_table = i_chroma_qp_table + 12;
     h->param.analyse.b_transform_8x8 = 1;



More information about the x264-devel mailing list