00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "global.h"
00023 #include "memalloc.h"
00024 #include "refbuf.h"
00025 #include "image.h"
00026 #include "errdo.h"
00027 #include "errdo_mc_prediction.h"
00028 #include "md_common.h"
00029
00030 static StorablePicture* find_nearest_ref_picture(DecodedPictureBuffer *p_Dpb, int poc);
00031 static void copy_conceal_mb (Macroblock *currMB, StorablePicture *enc_pic, int decoder, int mb_error, StorablePicture* refPic);
00032 static void get_predicted_mb(Macroblock *currMB, StorablePicture *enc_pic, int decoder);
00033 static void add_residue (Macroblock *currMB, StorablePicture *enc_pic, int decoder, int pl, int block8x8, int x_size, int y_size);
00034 static void Build_Status_Map(ImageParameters *p_Img, InputParameters *p_Inp, byte **s_map);
00035
00036 extern void DeblockFrame(ImageParameters *p_Img, imgpel **, imgpel ***);
00037
00038
00039
00040
00041
00042
00043
00044 int allocate_errdo_mem(ImageParameters *p_Img, InputParameters *p_Inp)
00045 {
00046 int memory_size = 0;
00047
00048 p_Img->p_decs = (Decoders *) malloc(sizeof(Decoders));
00049
00050 p_Img->p_decs->dec_mb_pred = NULL;
00051 p_Img->p_decs->dec_mbY_best = NULL;
00052 p_Img->p_decs->dec_mb_pred_best8x8 = NULL;
00053 p_Img->p_decs->dec_mbY_best8x8 = NULL;
00054 p_Img->p_decs->res_img = NULL;
00055 memory_size += get_mem3Dpel(&p_Img->p_decs->dec_mb_pred, p_Inp->NoOfDecoders, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00056 memory_size += get_mem3Dpel(&p_Img->p_decs->dec_mbY_best, p_Inp->NoOfDecoders, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00057 memory_size += get_mem4Dpel(&p_Img->p_decs->dec_mbY_best8x8, 2, p_Inp->NoOfDecoders, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00058 memory_size += get_mem4Dpel(&p_Img->p_decs->dec_mb_pred_best8x8, 2, p_Inp->NoOfDecoders, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00059 memory_size += get_mem3Dint(&p_Img->p_decs->res_img, MAX_PLANE, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00060
00061 return memory_size;
00062 }
00063
00064
00065
00066
00067
00068
00069
00070 void free_errdo_mem(ImageParameters *p_Img)
00071 {
00072 if (p_Img->p_decs->res_img)
00073 {
00074 free_mem3Dint(p_Img->p_decs->res_img);
00075 }
00076 if (p_Img->p_decs->dec_mb_pred)
00077 {
00078 free_mem3Dpel(p_Img->p_decs->dec_mb_pred);
00079 }
00080 if (p_Img->p_decs->dec_mbY_best)
00081 {
00082 free_mem3Dpel(p_Img->p_decs->dec_mbY_best);
00083 }
00084 if (p_Img->p_decs->dec_mbY_best8x8)
00085 {
00086 free_mem4Dpel(p_Img->p_decs->dec_mbY_best8x8);
00087 }
00088 if (p_Img->p_decs->dec_mb_pred_best8x8)
00089 {
00090 free_mem4Dpel(p_Img->p_decs->dec_mb_pred_best8x8);
00091 }
00092
00093 if ( p_Img->p_decs != NULL )
00094 free( p_Img->p_decs );
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 void decode_one_mb (Macroblock* currMB, StorablePicture *enc_pic, int decoder)
00109 {
00110 int i0, j;
00111 Slice *currSlice = currMB->p_slice;
00112 ImageParameters *p_Img = currMB->p_Img;
00113 imgpel** curComp;
00114 imgpel** oldComp;
00115
00116
00117 if (currMB->mb_type > P8x8)
00118 {
00119 curComp = &enc_pic->p_dec_img[0][decoder][currMB->pix_y];
00120 oldComp = &enc_pic->p_curr_img[currMB->pix_y];
00121 i0 = currMB->pix_x;
00122 copy_image_data_16x16(curComp, oldComp, i0, i0);
00123 }
00124 else if ((currMB->mb_type == 0) && (currSlice->slice_type != B_SLICE))
00125 {
00126 get_predicted_mb(currMB, enc_pic, decoder);
00127 curComp = &enc_pic->p_dec_img[0][decoder][currMB->pix_y];
00128 for(j = 0; j < p_Img->mb_size[0][1]; j++)
00129 {
00130 memcpy(&(curComp[j][currMB->pix_x]), &(p_Img->p_decs->dec_mb_pred[decoder][j][0]), p_Img->mb_size[0][0] * sizeof(imgpel));
00131 }
00132 }
00133 else
00134 {
00135 get_predicted_mb(currMB, enc_pic, decoder);
00136 add_residue(currMB, enc_pic, decoder, PLANE_Y, 0, MB_BLOCK_SIZE, MB_BLOCK_SIZE);
00137 }
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147 static void get_predicted_mb(Macroblock *currMB, StorablePicture *enc_pic, int decoder)
00148 {
00149 Slice *currSlice = currMB->p_slice;
00150 int i,j,k;
00151 int block_size_x, block_size_y;
00152 int mv_mode, pred_dir;
00153 static const byte decode_block_scan[16] = {0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15};
00154 int block8x8;
00155 int k_start, k_end, k_inc;
00156
00157 if (currSlice->slice_type == P_SLICE && !currMB->mb_type)
00158 {
00159 block_size_x = MB_BLOCK_SIZE;
00160 block_size_y = MB_BLOCK_SIZE;
00161 perform_mc(currMB, decoder, PLANE_Y, enc_pic, LIST_0, 0, 0, enc_pic->motion.ref_idx, 0, 0, block_size_x, block_size_y, 0);
00162 }
00163 else if (currMB->mb_type == 1)
00164 {
00165 block_size_x = MB_BLOCK_SIZE;
00166 block_size_y = MB_BLOCK_SIZE;
00167 pred_dir = currMB->b8x8[0].pdir;
00168 perform_mc(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 1, 1, enc_pic->motion.ref_idx, 0, 0, block_size_x, block_size_y, currMB->b8x8[0].bipred);
00169 }
00170 else if (currMB->mb_type == 2)
00171 {
00172 block_size_x = MB_BLOCK_SIZE;
00173 block_size_y = 8;
00174
00175 for (block8x8 = 0; block8x8 < 4; block8x8 += 2)
00176 {
00177 pred_dir = currMB->b8x8[block8x8].pdir;
00178 perform_mc(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 2, 2, enc_pic->motion.ref_idx, 0, block8x8, block_size_x, block_size_y, currMB->b8x8[block8x8].bipred);
00179 }
00180 }
00181 else if (currMB->mb_type == 3)
00182 {
00183 block_size_x = 8;
00184 block_size_y = 16;
00185
00186 for (block8x8 = 0; block8x8 < 2; block8x8++)
00187 {
00188 i = block8x8<<1;
00189 j = 0;
00190 pred_dir = currMB->b8x8[block8x8].pdir;
00191 perform_mc(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 3, 3, enc_pic->motion.ref_idx, i, j, block_size_x, block_size_y, currMB->b8x8[block8x8].bipred);
00192 }
00193 }
00194 else
00195 {
00196 for (block8x8 = 0; block8x8 < 4; block8x8++)
00197 {
00198 mv_mode = currMB->b8x8[block8x8].mode;
00199 pred_dir = currMB->b8x8[block8x8].pdir;
00200
00201 k_start = (block8x8 << 2);
00202 k_inc = (mv_mode == 5) ? 2 : 1;
00203
00204 if (mv_mode == 0)
00205 {
00206 k_end = k_start + 1;
00207 block_size_x = 8;
00208 block_size_y = 8;
00209 }
00210 else
00211 {
00212 k_end = (mv_mode == 4) ? k_start + 1 : ((mv_mode == 7) ? k_start + 4 : k_start + k_inc + 1);
00213 block_size_x = ( mv_mode == 5 || mv_mode == 4 ) ? 8 : 4;
00214 block_size_y = ( mv_mode == 6 || mv_mode == 4 ) ? 8 : 4;
00215 }
00216
00217 for (k = k_start; k < k_end; k += k_inc)
00218 {
00219 i = (decode_block_scan[k] & 3);
00220 j = ((decode_block_scan[k] >> 2) & 3);
00221 perform_mc(currMB, decoder, PLANE_Y, enc_pic, pred_dir, mv_mode, mv_mode, enc_pic->motion.ref_idx, i, j, block_size_x, block_size_y, currMB->b8x8[block8x8].bipred);
00222 }
00223 }
00224 }
00225 }
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 void decode_one_b8block (Macroblock* currMB, StorablePicture *enc_pic, int decoder, int block8x8, short mv_mode, int pred_dir)
00240 {
00241 int i,j,k;
00242 int block_size_x, block_size_y;
00243 int i0 = (block8x8 & 0x01)<<3;
00244 int j0 = (block8x8 >> 1)<<3, j1 = j0+8;
00245 char*** ref_idx_buf = enc_pic->motion.ref_idx;
00246 imgpel **curComp;
00247 imgpel **oldComp;
00248 int k_start, k_end, k_inc;
00249 static const byte decode_block_scan[16] = {0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15};
00250 Slice *currSlice = currMB->p_slice;
00251
00252 if (mv_mode > 8)
00253 {
00254 for(j = j0; j < j1; j++)
00255 {
00256 curComp = &enc_pic->p_dec_img[0][decoder][currMB->pix_y];
00257 oldComp = &enc_pic->p_curr_img[currMB->pix_y];
00258 memcpy(&(curComp[j][i0]), &(oldComp[j][i0]), sizeof(imgpel)*8);
00259 }
00260 }
00261 else
00262 {
00263 k_start = (block8x8 << 2);
00264
00265 if (mv_mode == 0)
00266 {
00267 k_inc = 1;
00268 k_end = k_start+1;
00269 block_size_x = 8;
00270 block_size_y = 8;
00271 ref_idx_buf = currSlice->direct_ref_idx;
00272 }
00273 else
00274 {
00275 k_inc = (mv_mode == 5) ? 2 : 1;
00276 k_end = (mv_mode == 4) ? k_start + 1 : ((mv_mode == 7) ? k_start + 4 : k_start + k_inc + 1);
00277
00278 block_size_x = ( mv_mode == 5 || mv_mode == 4 ) ? 8 : 4;
00279 block_size_y = ( mv_mode == 6 || mv_mode == 4 ) ? 8 : 4;
00280 }
00281
00282 for (k = k_start; k < k_end; k += k_inc)
00283 {
00284 i = (decode_block_scan[k] & 3);
00285 j = ((decode_block_scan[k] >> 2) & 3);
00286 perform_mc(currMB, decoder, PLANE_Y, enc_pic, pred_dir, mv_mode, mv_mode, ref_idx_buf, i, j, block_size_x, block_size_y, currMB->b8x8[block8x8].bipred);
00287 }
00288
00289 add_residue(currMB, enc_pic, decoder, PLANE_Y, block8x8, 8, 8);
00290 }
00291 }
00292
00293
00294
00295
00296
00297
00298
00299 static void add_residue (Macroblock *currMB, StorablePicture *enc_pic, int decoder, int pl, int block8x8, int x_size, int y_size)
00300 {
00301 ImageParameters *p_Img = currMB->p_Img;
00302 int max_pel_value = currMB->p_Img->max_pel_value_comp[pl];
00303 int i,j;
00304 int i0 = (block8x8 & 0x01)<<3, i1 = i0 + x_size;
00305 int j0 = (block8x8 >> 1)<<3, j1 = j0 + y_size;
00306
00307 imgpel **p_dec_img = &enc_pic->p_dec_img[pl][decoder][currMB->pix_y];
00308 int **res_img = p_Img->p_decs->res_img[0];
00309 imgpel** mpr = p_Img->p_decs->dec_mb_pred[decoder];
00310
00311 for (j = j0; j < j1; j++)
00312 {
00313 for (i = i0; i < i1; i++)
00314 {
00315 p_dec_img[j][currMB->pix_x + i] = (imgpel) iClip3(0, max_pel_value, (mpr[j][i] + res_img[j][i]));
00316 }
00317 }
00318 }
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328 void UpdateDecoders(ImageParameters *p_Img, InputParameters *p_Inp, StorablePicture *enc_pic)
00329 {
00330 int k;
00331 for (k = 0; k < p_Inp->NoOfDecoders; k++)
00332 {
00333 Build_Status_Map(p_Img, p_Inp, enc_pic->mb_error_map[k]);
00334 p_Img->error_conceal_picture(p_Img, enc_pic, k);
00335 DeblockFrame (p_Img, enc_pic->p_dec_img[0][k], NULL);
00336 }
00337 }
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 void init_error_conceal(ImageParameters *p_Img, int concealment_type)
00349 {
00350 p_Img->error_conceal_picture = copy_conceal_picture;
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 static void get_predicted_concealment_mb(Macroblock* currMB, StorablePicture* enc_pic, int decoder)
00363 {
00364 Slice *currSlice = currMB->p_slice;
00365 int i,j,k;
00366 int block_size_x, block_size_y;
00367 int mv_mode, pred_dir;
00368 static const byte decode_block_scan[16] = {0,1,4,5,2,3,6,7,8,9,12,13,10,11,14,15};
00369 int block8x8;
00370 int k_start, k_end, k_inc;
00371
00372 if (currSlice->slice_type == P_SLICE && !currMB->mb_type)
00373 {
00374 block_size_x = MB_BLOCK_SIZE;
00375 block_size_y = MB_BLOCK_SIZE;
00376 perform_mc_concealment(currMB, decoder, PLANE_Y, enc_pic, LIST_0, 0, 0, enc_pic->motion.ref_idx, 0, 0, block_size_x, block_size_y);
00377 }
00378 else if (currMB->mb_type == 1)
00379 {
00380 block_size_x = MB_BLOCK_SIZE;
00381 block_size_y = MB_BLOCK_SIZE;
00382 pred_dir = currMB->b8x8[0].pdir;
00383 perform_mc_concealment(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 1, 1, enc_pic->motion.ref_idx, 0, 0, block_size_x, block_size_y);
00384 }
00385 else if (currMB->mb_type == 2)
00386 {
00387 block_size_x = MB_BLOCK_SIZE;
00388 block_size_y = 8;
00389
00390 for (block8x8 = 0; block8x8 < 4; block8x8 += 2)
00391 {
00392 pred_dir = currMB->b8x8[block8x8].pdir;
00393 perform_mc_concealment(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 2, 2, enc_pic->motion.ref_idx, 0, block8x8, block_size_x, block_size_y);
00394 }
00395 }
00396 else if (currMB->mb_type == 3)
00397 {
00398 block_size_x = 8;
00399 block_size_y = 16;
00400
00401 for (block8x8 = 0; block8x8 < 2; block8x8++)
00402 {
00403 i = block8x8<<1;
00404 j = 0;
00405 pred_dir = currMB->b8x8[block8x8].pdir;
00406 perform_mc_concealment(currMB, decoder, PLANE_Y, enc_pic, pred_dir, 3, 3, enc_pic->motion.ref_idx, i, j, block_size_x, block_size_y);
00407 }
00408 }
00409 else
00410 {
00411 for (block8x8 = 0; block8x8 < 4; block8x8++)
00412 {
00413 mv_mode = currMB->b8x8[block8x8].mode;
00414 pred_dir = currMB->b8x8[block8x8].pdir;
00415
00416 k_start = (block8x8 << 2);
00417 k_inc = (mv_mode == 5) ? 2 : 1;
00418
00419 if (mv_mode == 0)
00420 {
00421 k_end = k_start + 1;
00422 block_size_x = 8;
00423 block_size_y = 8;
00424 }
00425 else
00426 {
00427 k_end = (mv_mode == 4) ? k_start + 1 : ((mv_mode == 7) ? k_start + 4 : k_start + k_inc + 1);
00428 block_size_x = ( mv_mode == 5 || mv_mode == 4 ) ? 8 : 4;
00429 block_size_y = ( mv_mode == 6 || mv_mode == 4 ) ? 8 : 4;
00430 }
00431
00432 for (k = k_start; k < k_end; k += k_inc)
00433 {
00434 i = (decode_block_scan[k] & 3);
00435 j = ((decode_block_scan[k] >> 2) & 3);
00436 perform_mc_concealment(currMB, decoder, PLANE_Y, enc_pic, pred_dir, mv_mode, mv_mode, enc_pic->motion.ref_idx, i, j, block_size_x, block_size_y);
00437 }
00438 }
00439 }
00440 }
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 void copy_conceal_picture(ImageParameters *p_Img, StorablePicture *enc_pic, int decoder)
00453 {
00454 unsigned int mb;
00455 Macroblock* currMB;
00456 int mb_error;
00457 byte** mb_error_map = enc_pic->mb_error_map[decoder];
00458 StorablePicture* refPic;
00459
00460 refPic = find_nearest_ref_picture(p_Img->p_Dpb, enc_pic->poc);
00461
00462 for (mb = 0; mb < p_Img->PicSizeInMbs; mb++)
00463 {
00464 currMB = &p_Img->mb_data[mb];
00465 currMB->mb_x = PicPos[mb][0];
00466 currMB->mb_y = PicPos[mb][1];
00467 mb_error = mb_error_map[currMB->mb_y][currMB->mb_x];
00468 if (mb_error)
00469 {
00470 currMB->block_x = currMB ->mb_x << 2;
00471 currMB->block_y = currMB->mb_y << 2;
00472 currMB->pix_x = currMB->block_x << 2;
00473 currMB->pix_y = currMB->block_y << 2;
00474 copy_conceal_mb(currMB, enc_pic, decoder, mb_error, refPic);
00475 }
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484
00485 static void copy_conceal_mb(Macroblock* currMB, StorablePicture *enc_pic, int decoder, int mb_error, StorablePicture* refPic)
00486 {
00487 Slice *currSlice = currMB->p_slice;
00488 int j, i0 = currMB->pix_x;
00489 imgpel** concealed_img = &(enc_pic->p_dec_img[0][decoder][currMB->pix_y]);
00490 imgpel** ref_img;
00491
00492 if (mb_error == 1 || (mb_error != 3 && currMB->mb_type > P8x8))
00493 {
00494 if (refPic != NULL)
00495 {
00496 ref_img = &(refPic->p_dec_img[0][decoder][currMB->pix_y]);
00497 for (j = 0; j < MB_BLOCK_SIZE; j++)
00498 {
00499 memcpy(&(concealed_img[j][i0]), &(ref_img[j][i0]), sizeof(imgpel)*MB_BLOCK_SIZE);
00500 }
00501 }
00502 else
00503 {
00504 for (j = 0; j < MB_BLOCK_SIZE; j++)
00505 {
00506 memset(&(concealed_img[j][i0]), 128, sizeof(imgpel)*MB_BLOCK_SIZE);
00507 }
00508 }
00509 }
00510 else if (mb_error != 2 && currSlice->slice_type != I_SLICE && currMB->mb_type < P8x8)
00511 {
00512 ImageParameters *p_Img = currMB->p_Img;
00513 get_predicted_concealment_mb(currMB, enc_pic, decoder);
00514 for(j = 0; j < MB_BLOCK_SIZE; j++)
00515 {
00516 memcpy(&(concealed_img[j][i0]), &(p_Img->p_decs->dec_mb_pred[decoder][j][0]), MB_BLOCK_SIZE * sizeof(imgpel));
00517 }
00518 }
00519 }
00520
00521
00522
00523
00524
00525
00526
00527 static StorablePicture* find_nearest_ref_picture(DecodedPictureBuffer *p_Dpb, int poc)
00528 {
00529 unsigned int i;
00530 int min_poc_diff = 1000;
00531 int poc_diff;
00532 StorablePicture* refPic = NULL;
00533
00534 for (i = 0; i < p_Dpb->ref_frames_in_buffer; i++)
00535 {
00536 if (p_Dpb->fs_ref[i]->is_used==3)
00537 {
00538 if ((p_Dpb->fs_ref[i]->frame->used_for_reference)&&(!p_Dpb->fs_ref[i]->frame->is_long_term))
00539 {
00540 poc_diff = iabs(p_Dpb->fs_ref[i]->frame->poc - poc);
00541 if (poc_diff < min_poc_diff)
00542 {
00543 refPic = p_Dpb->fs_ref[i]->frame;
00544 min_poc_diff = poc_diff;
00545 }
00546 }
00547 }
00548 }
00549 return refPic;
00550 }
00551
00552
00553
00554
00555
00556
00557
00558 void compute_residue_block (Macroblock *currMB, imgpel **imgY, int **res_img, imgpel **mb_pred, int b8block, int block_size)
00559 {
00560 int i,j;
00561 int i0 = (b8block & 0x01)<<3, i1 = i0+block_size;
00562 int j0 = (b8block >> 1)<<3, j1 = j0+block_size;
00563
00564 for (i = i0; i < i1; i++)
00565 {
00566 for (j = j0; j < j1; j++)
00567 {
00568 res_img[j][i] = (int)imgY[j][currMB->pix_x + i] - mb_pred[j][i];
00569 }
00570 }
00571 }
00572
00573
00574
00575
00576
00577
00578
00579 void errdo_store_best_block(InputParameters *p_Inp, imgpel*** mbY, imgpel*** dec_img, int block_i, int block_j, int img_i, int img_j, int block_size)
00580
00581 {
00582 int j, k;
00583 int j1 = block_j + block_size;
00584
00585 for (k = 0; k < p_Inp->NoOfDecoders; k++)
00586 {
00587 for (j = block_j; j < j1; j++)
00588 {
00589 memcpy(&mbY[k][j][block_i], &dec_img[k][img_j+j][img_i], block_size * sizeof(imgpel));
00590 }
00591 }
00592 }
00593
00594
00595
00596
00597
00598
00599
00600 void errdo_get_best_block(Macroblock *currMB, imgpel*** dec_img, imgpel*** mbY, int j0, int block_size)
00601 {
00602 int j, k;
00603 int j1 = j0 + block_size;
00604
00605 for (k = 0; k < currMB->p_Inp->NoOfDecoders; k++)
00606 {
00607 for (j = j0; j < j1; j++)
00608 {
00609 memcpy(&dec_img[k][currMB->pix_y + j][currMB->pix_x], mbY[k][j], block_size * sizeof(imgpel));
00610 }
00611 }
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628 static void Build_Status_Map(ImageParameters *p_Img, InputParameters *p_Inp, byte **s_map)
00629 {
00630 int i,j,slice=-1,mb=0,jj,ii;
00631 byte packet_lost=0;
00632
00633 jj = p_Img->height/MB_BLOCK_SIZE;
00634 ii = p_Img->width/MB_BLOCK_SIZE;
00635
00636 for (j = 0; j < jj; j++)
00637 {
00638 for (i = 0; i < ii; i++)
00639 {
00640 if (!p_Inp->slice_mode || p_Img->mb_data[mb].slice_nr != slice)
00641 {
00642 packet_lost=0;
00643 if ((double)rand()/(double)RAND_MAX*100 < p_Inp->LossRateC) packet_lost += 3;
00644 if ((double)rand()/(double)RAND_MAX*100 < p_Inp->LossRateB) packet_lost += 2;
00645 if ((double)rand()/(double)RAND_MAX*100 < p_Inp->LossRateA) packet_lost = 1;
00646 slice++;
00647 }
00648 if (!packet_lost)
00649 {
00650 s_map[j][i]=0;
00651 }
00652 else
00653 {
00654 s_map[j][i] = packet_lost;
00655 if(p_Inp->partition_mode == 0) s_map[j][i]=1;
00656 }
00657 mb++;
00658 }
00659 }
00660 }
00661