OpenCores
URL https://opencores.org/ocsvn/bluespec-h264/bluespec-h264/trunk

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [test/] [decoder/] [ldecod/] [src/] [parsetcommon.c] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jamey.hick
 
2
/*!
3
 **************************************************************************************
4
 * \file
5
 *    parset.c
6
 * \brief
7
 *    Picture and Sequence Parameter set generation and handling
8
 *  \date 25 November 2002
9
 * \author
10
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
11
 *      - Stephan Wenger        <stewe@cs.tu-berlin.de>
12
 *
13
 **************************************************************************************
14
 */
15
#include <assert.h>
16
#include <stdio.h>
17
#include <stdlib.h>
18
 
19
#include "parsetcommon.h"
20
#include "memalloc.h"
21
/*!
22
 *************************************************************************************
23
 * \brief
24
 *    Allocates memory for a picture paramater set
25
 *
26
 * \return
27
 *    pointer to a pps
28
 *************************************************************************************
29
 */
30
 
31
pic_parameter_set_rbsp_t *AllocPPS ()
32
 {
33
   pic_parameter_set_rbsp_t *p;
34
 
35
   if ((p=calloc (sizeof (pic_parameter_set_rbsp_t), 1)) == NULL)
36
     no_mem_exit ("AllocPPS: PPS");
37
   if ((p->slice_group_id = calloc (SIZEslice_group_id, 1)) == NULL)
38
     no_mem_exit ("AllocPPS: slice_group_id");
39
   return p;
40
 }
41
 
42
 
43
/*!
44
 *************************************************************************************
45
 * \brief
46
 *    Allocates memory for am sequence paramater set
47
 *
48
 * \return
49
 *    pointer to a sps
50
 *************************************************************************************
51
 */
52
 
53
seq_parameter_set_rbsp_t *AllocSPS ()
54
 {
55
   seq_parameter_set_rbsp_t *p;
56
 
57
   if ((p=calloc (sizeof (seq_parameter_set_rbsp_t), 1)) == NULL)
58
     no_mem_exit ("AllocSPS: SPS");
59
   return p;
60
 }
61
 
62
 
63
/*!
64
 *************************************************************************************
65
 * \brief
66
 *    Frees a picture parameter set
67
 *
68
 * \param pps to be freed
69
 *   Picture parameter set to be freed
70
 *************************************************************************************
71
 */
72
 
73
 void FreePPS (pic_parameter_set_rbsp_t *pps)
74
 {
75
   assert (pps != NULL);
76
   if (pps->slice_group_id != NULL) free (pps->slice_group_id);
77
   free (pps);
78
 }
79
 
80
 
81
 /*!
82
 *************************************************************************************
83
 * \brief
84
 *    Frees a sps
85
 *
86
 * \param sps
87
 *   Sequence parameter set to be freed
88
 *************************************************************************************
89
 */
90
 
91
 void FreeSPS (seq_parameter_set_rbsp_t *sps)
92
 {
93
   assert (sps != NULL);
94
   free (sps);
95
 }
96
 
97
 
98
int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2)
99
{
100
  unsigned i;
101
  int equal = 1;
102
 
103
  if ((!sps1->Valid) || (!sps2->Valid))
104
    return 0;
105
 
106
  equal &= (sps1->profile_idc == sps2->profile_idc);
107
  equal &= (sps1->constrained_set0_flag == sps2->constrained_set0_flag);
108
  equal &= (sps1->constrained_set1_flag == sps2->constrained_set1_flag);
109
  equal &= (sps1->constrained_set2_flag == sps2->constrained_set2_flag);
110
  equal &= (sps1->level_idc == sps2->level_idc);
111
  equal &= (sps1->seq_parameter_set_id == sps2->seq_parameter_set_id);
112
  equal &= (sps1->log2_max_frame_num_minus4 == sps2->log2_max_frame_num_minus4);
113
  equal &= (sps1->pic_order_cnt_type == sps2->pic_order_cnt_type);
114
 
115
  if (!equal) return equal;
116
 
117
  if( sps1->pic_order_cnt_type == 0 )
118
  {
119
    equal &= (sps1->log2_max_pic_order_cnt_lsb_minus4 == sps2->log2_max_pic_order_cnt_lsb_minus4);
120
  }
121
 
122
  else if( sps1->pic_order_cnt_type == 1 )
123
  {
124
    equal &= (sps1->delta_pic_order_always_zero_flag == sps2->delta_pic_order_always_zero_flag);
125
    equal &= (sps1->offset_for_non_ref_pic == sps2->offset_for_non_ref_pic);
126
    equal &= (sps1->offset_for_top_to_bottom_field == sps2->offset_for_top_to_bottom_field);
127
    equal &= (sps1->num_ref_frames_in_pic_order_cnt_cycle == sps2->num_ref_frames_in_pic_order_cnt_cycle);
128
    if (!equal) return equal;
129
 
130
    for ( i = 0 ; i< sps1->num_ref_frames_in_pic_order_cnt_cycle ;i ++)
131
      equal &= (sps1->offset_for_ref_frame[i] == sps2->offset_for_ref_frame[i]);
132
  }
133
 
134
  equal &= (sps1->num_ref_frames == sps2->num_ref_frames);
135
  equal &= (sps1->gaps_in_frame_num_value_allowed_flag == sps2->gaps_in_frame_num_value_allowed_flag);
136
  equal &= (sps1->pic_width_in_mbs_minus1 == sps2->pic_width_in_mbs_minus1);
137
  equal &= (sps1->pic_height_in_map_units_minus1 == sps2->pic_height_in_map_units_minus1);
138
  equal &= (sps1->frame_mbs_only_flag == sps2->frame_mbs_only_flag);
139
 
140
  if (!equal) return equal;
141
  if( !sps1->frame_mbs_only_flag )
142
    equal &= (sps1->mb_adaptive_frame_field_flag == sps2->mb_adaptive_frame_field_flag);
143
 
144
  equal &= (sps1->direct_8x8_inference_flag == sps2->direct_8x8_inference_flag);
145
  equal &= (sps1->frame_cropping_flag == sps2->frame_cropping_flag);
146
  if (!equal) return equal;
147
  if (sps1->frame_cropping_flag)
148
  {
149
    equal &= (sps1->frame_cropping_rect_left_offset == sps2->frame_cropping_rect_left_offset);
150
    equal &= (sps1->frame_cropping_rect_right_offset == sps2->frame_cropping_rect_right_offset);
151
    equal &= (sps1->frame_cropping_rect_top_offset == sps2->frame_cropping_rect_top_offset);
152
    equal &= (sps1->frame_cropping_rect_bottom_offset == sps2->frame_cropping_rect_bottom_offset);
153
  }
154
  equal &= (sps1->vui_parameters_present_flag == sps2->vui_parameters_present_flag);
155
 
156
  return equal;
157
}
158
 
159
int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2)
160
{
161
  unsigned i;
162
  int equal = 1;
163
 
164
  if ((!pps1->Valid) || (!pps2->Valid))
165
    return 0;
166
 
167
  equal &= (pps1->pic_parameter_set_id == pps2->pic_parameter_set_id);
168
  equal &= (pps1->seq_parameter_set_id == pps2->seq_parameter_set_id);
169
  equal &= (pps1->entropy_coding_mode_flag == pps2->entropy_coding_mode_flag);
170
  equal &= (pps1->pic_order_present_flag == pps2->pic_order_present_flag);
171
  equal &= (pps1->num_slice_groups_minus1 == pps2->num_slice_groups_minus1);
172
 
173
  if (!equal) return equal;
174
 
175
  if (pps1->num_slice_groups_minus1>0)
176
  {
177
      equal &= (pps1->slice_group_map_type == pps2->slice_group_map_type);
178
      if (!equal) return equal;
179
      if (pps1->slice_group_map_type == 0)
180
      {
181
        for (i=0; i<=pps1->num_slice_groups_minus1; i++)
182
          equal &= (pps1->run_length_minus1[i] == pps2->run_length_minus1[i]);
183
      }
184
      else if( pps1->slice_group_map_type == 2 )
185
      {
186
        for (i=0; i<pps1->num_slice_groups_minus1; i++)
187
        {
188
          equal &= (pps1->top_left[i] == pps2->top_left[i]);
189
          equal &= (pps1->bottom_right[i] == pps2->bottom_right[i]);
190
        }
191
      }
192
      else if( pps1->slice_group_map_type == 3 || pps1->slice_group_map_type==4 || pps1->slice_group_map_type==5 )
193
      {
194
        equal &= (pps1->slice_group_change_direction_flag == pps2->slice_group_change_direction_flag);
195
        equal &= (pps1->slice_group_change_rate_minus1 == pps2->slice_group_change_rate_minus1);
196
      }
197
      else if( pps1->slice_group_map_type == 6 )
198
      {
199
        equal &= (pps1->num_slice_group_map_units_minus1 == pps2->num_slice_group_map_units_minus1);
200
        if (!equal) return equal;
201
        for (i=0; i<=pps1->num_slice_group_map_units_minus1; i++)
202
          equal &= (pps1->slice_group_id[i] == pps2->slice_group_id[i]);
203
      }
204
  }
205
 
206
  equal &= (pps1->num_ref_idx_l0_active_minus1 == pps2->num_ref_idx_l0_active_minus1);
207
  equal &= (pps1->num_ref_idx_l1_active_minus1 == pps2->num_ref_idx_l1_active_minus1);
208
  equal &= (pps1->weighted_pred_flag == pps2->weighted_pred_flag);
209
  equal &= (pps1->weighted_bipred_idc == pps2->weighted_bipred_idc);
210
  equal &= (pps1->pic_init_qp_minus26 == pps2->pic_init_qp_minus26);
211
  equal &= (pps1->pic_init_qs_minus26 == pps2->pic_init_qs_minus26);
212
  equal &= (pps1->chroma_qp_index_offset == pps2->chroma_qp_index_offset);
213
  equal &= (pps1->deblocking_filter_control_present_flag == pps2->deblocking_filter_control_present_flag);
214
  equal &= (pps1->constrained_intra_pred_flag == pps2->constrained_intra_pred_flag);
215
  equal &= (pps1->redundant_pic_cnt_present_flag == pps2->redundant_pic_cnt_present_flag);
216
 
217
  return equal;
218
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.