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

Subversion Repositories bluespec-h264

[/] [bluespec-h264/] [trunk/] [test/] [decoder/] [ldecod/] [src/] [errorconcealment.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 errorconcealment.c
5
 *
6
 * \brief
7
 *    Implements error concealment scheme for H.264 decoder
8
 *
9
 * \date
10
 *    6.10.2000
11
 *
12
 * \version
13
 *    1.0
14
 *
15
 * \note
16
 *    This simple error concealment implemented in this decoder uses
17
 *    the existing dependencies of syntax elements.
18
 *    In case that an element is detected as false this elements and all
19
 *    dependend elements are marked as elements to conceal in the ec_flag[]
20
 *    array. If the decoder requests a new element by the function
21
 *    readSyntaxElement_xxxx() this array is checked first if an error concealment has
22
 *    to be applied on this element.
23
 *    In case that an error occured a concealed element is given to the
24
 *    decoding function in macroblock().
25
 *
26
 * \author
27
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
28
 *    - Sebastian Purreiter   <sebastian.purreiter@mch.siemens.de>
29
 ***********************************************************************
30
 */
31
 
32
#include "contributors.h"
33
#include "global.h"
34
#include "elements.h"
35
 
36
static int ec_flag[SE_MAX_ELEMENTS];        //!< array to set errorconcealment
37
/*
38
static char SEtypes[][25] =
39
{
40
    "SE_HEADER",
41
    "SE_PTYPE",
42
    "SE_MBTYPE",
43
    "SE_REFFRAME",
44
    "SE_INTRAPREDMODE",
45
    "SE_MVD",
46
    "SE_CBP_INTRA",
47
    "SE_LUM_DC_INTRA",
48
    "SE_CHR_DC_INTRA",
49
    "SE_LUM_AC_INTRA",
50
    "SE_CHR_AC_INTRA",
51
    "SE_CBP_INTER",
52
    "SE_LUM_DC_INTER",
53
    "SE_CHR_DC_INTER",
54
    "SE_LUM_AC_INTER",
55
    "SE_CHR_AC_INTER",
56
    "SE_DELTA_QUANT_INTER",
57
    "SE_DELTA_QUANT_INTRA",
58
    "SE_BFRAME",
59
    "SE_EOS"
60
};
61
*/
62
 
63
/*!
64
 ***********************************************************************
65
 * \brief
66
 *    set concealment for all elements in same partition
67
 *    and dependend syntax elements
68
 * \return
69
 *    EC_REQ, elements of same type or depending type need error concealment. \n
70
 *    EX_SYNC   sync on next header
71
 ***********************************************************************
72
 */
73
int set_ec_flag(
74
  int se)   //!< type of syntax element to conceal
75
{
76
 
77
  /*
78
  if (ec_flag[se] == NO_EC)
79
    printf("Error concealment on element %s\n",SEtypes[se]);
80
  */
81
  switch (se)
82
  {
83
  case SE_HEADER :
84
    ec_flag[SE_HEADER] = EC_REQ;
85
  case SE_PTYPE :
86
    ec_flag[SE_PTYPE] = EC_REQ;
87
  case SE_MBTYPE :
88
    ec_flag[SE_MBTYPE] = EC_REQ;
89
 
90
  case SE_REFFRAME :
91
    ec_flag[SE_REFFRAME] = EC_REQ;
92
    ec_flag[SE_MVD] = EC_REQ; // set all motion vectors to zero length
93
    se = SE_CBP_INTER;      // conceal also Inter texture elements
94
    break;
95
 
96
  case SE_INTRAPREDMODE :
97
    ec_flag[SE_INTRAPREDMODE] = EC_REQ;
98
    se = SE_CBP_INTRA;      // conceal also Intra texture elements
99
    break;
100
  case SE_MVD :
101
    ec_flag[SE_MVD] = EC_REQ;
102
    se = SE_CBP_INTER;      // conceal also Inter texture elements
103
    break;
104
 
105
  default:
106
    break;
107
  }
108
 
109
  switch (se)
110
  {
111
  case SE_CBP_INTRA :
112
    ec_flag[SE_CBP_INTRA] = EC_REQ;
113
  case SE_LUM_DC_INTRA :
114
    ec_flag[SE_LUM_DC_INTRA] = EC_REQ;
115
  case SE_CHR_DC_INTRA :
116
    ec_flag[SE_CHR_DC_INTRA] = EC_REQ;
117
  case SE_LUM_AC_INTRA :
118
    ec_flag[SE_LUM_AC_INTRA] = EC_REQ;
119
  case SE_CHR_AC_INTRA :
120
    ec_flag[SE_CHR_AC_INTRA] = EC_REQ;
121
    break;
122
 
123
  case SE_CBP_INTER :
124
    ec_flag[SE_CBP_INTER] = EC_REQ;
125
  case SE_LUM_DC_INTER :
126
    ec_flag[SE_LUM_DC_INTER] = EC_REQ;
127
  case SE_CHR_DC_INTER :
128
    ec_flag[SE_CHR_DC_INTER] = EC_REQ;
129
  case SE_LUM_AC_INTER :
130
    ec_flag[SE_LUM_AC_INTER] = EC_REQ;
131
  case SE_CHR_AC_INTER :
132
    ec_flag[SE_CHR_AC_INTER] = EC_REQ;
133
    break;
134
  case SE_DELTA_QUANT_INTER :
135
    ec_flag[SE_DELTA_QUANT_INTER] = EC_REQ;
136
    break;
137
  case SE_DELTA_QUANT_INTRA :
138
    ec_flag[SE_DELTA_QUANT_INTRA] = EC_REQ;
139
    break;
140
  default:
141
    break;
142
 
143
  }
144
  return EC_REQ;
145
}
146
 
147
/*!
148
 ***********************************************************************
149
 * \brief
150
 *    resets EC_Flags called at the start of each slice
151
 *
152
 ***********************************************************************
153
 */
154
void reset_ec_flags()
155
{
156
  int i;
157
  for (i=0; i<SE_MAX_ELEMENTS; i++)
158
    ec_flag[i] = NO_EC;
159
}
160
 
161
 
162
/*!
163
 ***********************************************************************
164
 * \brief
165
 *    get error concealed element in dependence of syntax
166
 *    element se.                                                          \n
167
 *    This function implements the error concealment.
168
 * \return
169
 *    NO_EC if no error concealment required                               \n
170
 *    EC_REQ if element requires error concealment
171
 ***********************************************************************
172
 */
173
int get_concealed_element(SyntaxElement *sym)
174
{
175
  if (ec_flag[sym->type] == NO_EC)
176
    return NO_EC;
177
/*
178
#if TRACE
179
  printf("TRACE: get concealed element for %s!!!\n", SEtypes[sym->type]);
180
#endif
181
*/
182
  switch (sym->type)
183
  {
184
  case SE_HEADER :
185
    sym->len = 31;
186
    sym->inf = 0; // Picture Header
187
    break;
188
 
189
  case SE_PTYPE : // inter_img_1
190
  case SE_MBTYPE : // set COPY_MB
191
  case SE_REFFRAME :
192
    sym->len = 1;
193
    sym->inf = 0;
194
    break;
195
 
196
  case SE_INTRAPREDMODE :
197
  case SE_MVD :
198
    sym->len = 1;
199
    sym->inf = 0;  // set vector to zero length
200
    break;
201
 
202
  case SE_CBP_INTRA :
203
    sym->len = 5;
204
    sym->inf = 0; // codenumber 3 <=> no CBP information for INTRA images
205
    break;
206
 
207
  case SE_LUM_DC_INTRA :
208
  case SE_CHR_DC_INTRA :
209
  case SE_LUM_AC_INTRA :
210
  case SE_CHR_AC_INTRA :
211
    sym->len = 1;
212
    sym->inf = 0;  // return EOB
213
    break;
214
 
215
  case SE_CBP_INTER :
216
    sym->len = 1;
217
    sym->inf = 0; // codenumber 1 <=> no CBP information for INTER images
218
    break;
219
 
220
  case SE_LUM_DC_INTER :
221
  case SE_CHR_DC_INTER :
222
  case SE_LUM_AC_INTER :
223
  case SE_CHR_AC_INTER :
224
    sym->len = 1;
225
    sym->inf = 0;  // return EOB
226
    break;
227
 
228
  case SE_DELTA_QUANT_INTER:
229
    sym->len = 1;
230
    sym->inf = 0;
231
    break;
232
  case SE_DELTA_QUANT_INTRA:
233
    sym->len = 1;
234
    sym->inf = 0;
235
    break;
236
  default:
237
    break;
238
  }
239
 
240
  return EC_REQ;
241
}
242
 

powered by: WebSVN 2.1.0

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