00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "global.h"
00017 #include "conformance.h"
00018
00019
00020
00021 static const unsigned int MaxFs [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 99, 396, 396, 396, 0, 0, 0, 0, 0, 0, 396, 792, 1620, 0, 0, 0, 0, 0, 0, 0,
00022
00023 1620, 3600, 5120, 0, 0, 0, 0, 0, 0, 0, 8192, 8192, 8704, 0, 0, 0, 0, 0, 0, 0, 22080, 36864 };
00024 static const unsigned int MinCR [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0,
00025 2, 4, 4, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2 };
00026 static const unsigned int MaxBR [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,128, 192, 384, 768, 0, 0, 0, 0, 0, 0,2000,4000,4000, 0, 0, 0, 0, 0, 0, 0,
00027 10000,14000,20000, 0, 0, 0, 0, 0, 0, 0,20000,50000,50000, 0, 0, 0, 0, 0, 0, 0,135000,240000 };
00028 static const unsigned int MaxCPB[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0,175,350, 500,1000,2000, 0, 0, 0, 0, 0, 0,2000,4000,4000, 0, 0, 0, 0, 0, 0, 0,
00029 10000,14000,20000, 0, 0, 0, 0, 0, 0, 0,25000,62500,62500, 0, 0, 0, 0, 0, 0, 0,135000,240000 };
00030
00031 static const unsigned int MaxMBPS[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1485, 1485, 3000, 6000, 11880, 0, 0, 0, 0, 0, 0, 11880, 19800, 20250, 0, 0, 0, 0, 0, 0, 0,
00032 40500, 108000, 216000, 0, 0, 0, 0, 0, 0, 0, 245760, 245760, 522240, 0, 0, 0, 0, 0, 0, 0, 589824, 983040 };
00033
00034
00035
00036
00037
00038 static const int LEVELVMVLIMIT[17][6] =
00039 {
00040 { -63, 63, -128, 127, -256, 255},
00041 { -63, 63, -128, 127, -256, 255},
00042 { -127, 127, -256, 255, -512, 511},
00043 { -127, 127, -256, 255, -512, 511},
00044 { -127, 127, -256, 255, -512, 511},
00045 { -127, 127, -256, 255, -512, 511},
00046 { -255, 255, -512, 511, -1024, 1023},
00047 { -255, 255, -512, 511, -1024, 1023},
00048 { -255, 255, -512, 511, -1024, 1023},
00049 { -511, 511, -1024, 1023, -2048, 2047},
00050 { -511, 511, -1024, 1023, -2048, 2047},
00051 { -511, 511, -1024, 1023, -2048, 2047},
00052 { -511, 511, -1024, 1023, -2048, 2047},
00053 { -511, 511, -1024, 1023, -2048, 2047},
00054 { -511, 511, -1024, 1023, -2048, 2047},
00055 { -511, 511, -1024, 1023, -2048, 2047},
00056 { -511, 511, -1024, 1023, -2048, 2047}
00057 };
00058
00059 const int LEVELHMVLIMIT[6] = { -2047, 2047, -4096, 4095, -8192, 8191};
00060
00061
00062
00063
00064
00065
00066
00067 unsigned int getMaxFs (unsigned int levelIdc)
00068 {
00069 unsigned int ret;
00070
00071 if ( (levelIdc < 9) || (levelIdc > 51))
00072 error ("getMaxFs: Unknown LevelIdc", 500);
00073
00074
00075
00076 ret = MaxFs[levelIdc];
00077
00078 if ( 0 == ret )
00079 error ("getMaxFs: Unknown LevelIdc", 500);
00080
00081 return ret;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090 unsigned int getMaxMBPS (unsigned int levelIdc)
00091 {
00092 unsigned int ret;
00093
00094 if ( (levelIdc < 9) || (levelIdc > 51))
00095 error ("getMaxMBPS: Unknown LevelIdc", 500);
00096
00097
00098
00099 ret = MaxMBPS[levelIdc];
00100
00101 if ( 0 == ret )
00102 error ("getMaxMBPS: Unknown LevelIdc", 500);
00103
00104 return ret;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113 unsigned int getMinCR (unsigned int levelIdc)
00114 {
00115 unsigned int ret;
00116
00117 if ( (levelIdc < 9) || (levelIdc > 51))
00118 error ("getMinCR: Unknown LevelIdc", 500);
00119
00120
00121
00122 ret = MinCR[levelIdc];
00123
00124 if ( 0 == ret )
00125 error ("getMinCR: Unknown LevelIdc", 500);
00126
00127 return ret;
00128 }
00129
00130
00131
00132
00133
00134
00135
00136 unsigned int getMaxBR (unsigned int levelIdc)
00137 {
00138 unsigned int ret;
00139
00140 if ( (levelIdc < 9) || (levelIdc > 51))
00141 error ("getMaxBR: Unknown LevelIdc", 500);
00142
00143
00144
00145 ret = MaxBR[levelIdc];
00146
00147 if ( 0 == ret )
00148 error ("getMaxBR: Unknown LevelIdc", 500);
00149
00150 return ret;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159 unsigned int getMaxCPB (unsigned int levelIdc)
00160 {
00161 unsigned int ret;
00162
00163 if ( (levelIdc < 9) || (levelIdc > 51))
00164 error ("getMaxCPB: Unknown LevelIdc", 500);
00165
00166
00167
00168 ret = MaxCPB[levelIdc];
00169
00170 if ( 0 == ret )
00171 error ("getMaxCPB: Unknown LevelIdc", 500);
00172
00173 return ret;
00174 }
00175
00176
00177
00178
00179
00180
00181
00182 void ProfileCheck(InputParameters *p_Inp)
00183 {
00184 if((p_Inp->ProfileIDC != BASELINE ) &&
00185 (p_Inp->ProfileIDC != MAIN ) &&
00186 (p_Inp->ProfileIDC != EXTENDED ) &&
00187 (p_Inp->ProfileIDC != FREXT_HP ) &&
00188 (p_Inp->ProfileIDC != FREXT_Hi10P ) &&
00189 (p_Inp->ProfileIDC != FREXT_Hi422 ) &&
00190 (p_Inp->ProfileIDC != FREXT_Hi444 ) &&
00191 (p_Inp->ProfileIDC != FREXT_CAVLC444 ))
00192 {
00193 snprintf(errortext, ET_SIZE, "Profile must be in\n\n 66 (Baseline),\n 77 (Main),\n 88 (Extended),\n 100 (High),\n 110 (High 10 or High 10 Intra)\n"
00194 " 122 (High 4:2:2 or High 4:2:2 Intra),\n 244 (High 4:4:4 predictive or High 4:4:4 Intra),\n 44 (CAVLC 4:4:4 Intra)\n");
00195 error (errortext, 500);
00196 }
00197
00198 if ((p_Inp->partition_mode) && (p_Inp->symbol_mode==CABAC))
00199 {
00200 snprintf(errortext, ET_SIZE, "Data partitioning and CABAC is not supported in any profile.");
00201 error (errortext, 500);
00202 }
00203
00204 if (p_Inp->redundant_pic_flag)
00205 {
00206 if (p_Inp->ProfileIDC != BASELINE)
00207 {
00208 snprintf(errortext, ET_SIZE, "Redundant pictures are only allowed in Baseline profile (ProfileIDC = 66).");
00209 error (errortext, 500);
00210 }
00211 }
00212
00213 if ((p_Inp->partition_mode) && (p_Inp->ProfileIDC!=EXTENDED))
00214 {
00215 snprintf(errortext, ET_SIZE, "Data partitioning is only allowed in Extended profile (ProfileIDC = 88).");
00216 error (errortext, 500);
00217 }
00218
00219 if (p_Inp->ChromaIntraDisable && p_Inp->FastCrIntraDecision)
00220 {
00221 fprintf( stderr, "\n Warning: ChromaIntraDisable and FastCrIntraDecision cannot be combined together.\n Using only Chroma Intra DC mode.\n");
00222 p_Inp->FastCrIntraDecision=0;
00223 }
00224
00225 if ((p_Inp->sp_periodicity) && (p_Inp->ProfileIDC != EXTENDED ))
00226 {
00227 snprintf(errortext, ET_SIZE, "SP pictures are only allowed in Extended profile (ProfileIDC = 88).");
00228 error (errortext, 500);
00229 }
00230
00231
00232 if (p_Inp->ProfileIDC == BASELINE )
00233 {
00234 if ((p_Inp->NumberBFrames || p_Inp->BRefPictures==2) && p_Inp->PReplaceBSlice == 0)
00235 {
00236 snprintf(errortext, ET_SIZE, "B slices are not allowed in Baseline profile (ProfileIDC = 66).");
00237 error (errortext, 500);
00238 }
00239 if (p_Inp->WeightedPrediction)
00240 {
00241 snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in Baseline profile (ProfileIDC = 66).");
00242 error (errortext, 500);
00243 }
00244 if (p_Inp->WeightedBiprediction)
00245 {
00246 snprintf(errortext, ET_SIZE, "Weighted prediction is not allowed in Baseline profile (ProfileIDC = 66).");
00247 error (errortext, 500);
00248 }
00249 if (p_Inp->symbol_mode == CABAC)
00250 {
00251 snprintf(errortext, ET_SIZE, "CABAC is not allowed in Baseline profile (ProfileIDC = 66).");
00252 error (errortext, 500);
00253 }
00254 if ((p_Inp->PicInterlace) ||(p_Inp->MbInterlace))
00255 {
00256 snprintf(errortext, ET_SIZE, "Interlace tools are not allowed in Baseline profile (ProfileIDC = 66).");
00257 error (errortext, 500);
00258 }
00259 if (p_Inp->GenerateMultiplePPS != 0)
00260 {
00261 snprintf(errortext, ET_SIZE, "GenerateMultiplePPS is not supported for Baseline profile because it requires enabling Weighted prediction.\n");
00262 error (errortext, 400);
00263 }
00264 }
00265
00266
00267 if (p_Inp->ProfileIDC == MAIN )
00268 {
00269 if (p_Inp->num_slice_groups_minus1)
00270 {
00271 snprintf(errortext, ET_SIZE, "num_slice_groups_minus1>0 (FMO) is not allowed in Main profile (ProfileIDC = 77).");
00272 error (errortext, 500);
00273 }
00274 }
00275
00276
00277 if (p_Inp->ProfileIDC == EXTENDED )
00278 {
00279 if (!p_Inp->directInferenceFlag)
00280 {
00281 snprintf(errortext, ET_SIZE, "direct_8x8_inference flag must be equal to 1 in Extended profile (ProfileIDC = 88).");
00282 error (errortext, 500);
00283 }
00284
00285 if (p_Inp->symbol_mode == CABAC)
00286 {
00287 snprintf(errortext, ET_SIZE, "CABAC is not allowed in Extended profile (ProfileIDC = 88).");
00288 error (errortext, 500);
00289 }
00290 }
00291
00292
00293 if ( p_Inp->separate_colour_plane_flag )
00294 {
00295 if( p_Inp->yuv_format!=3 )
00296 {
00297 fprintf( stderr, "\nWarning: SeparateColourPlane has only effect in 4:4:4 chroma mode (YUVFormat=3),\n disabling SeparateColourPlane.");
00298 p_Inp->separate_colour_plane_flag = 0;
00299 }
00300
00301 if ( p_Inp->ChromaMEEnable )
00302 {
00303 snprintf(errortext, ET_SIZE, "\nChromaMEEnable is not allowed when SeparateColourPlane is enabled.");
00304 error (errortext, 500);
00305 }
00306 }
00307
00308
00309 if ( p_Inp->ProfileIDC == FREXT_CAVLC444 )
00310 {
00311 if ( p_Inp->symbol_mode != CAVLC )
00312 {
00313 snprintf(errortext, ET_SIZE, "\nCABAC is not allowed in CAVLC 4:4:4 Intra profile (ProfileIDC = 44).");
00314 error (errortext, 500);
00315 }
00316 if ( !p_Inp->IntraProfile )
00317 {
00318 fprintf (stderr, "\nWarning: ProfileIDC equal to 44 implies an Intra only profile, setting IntraProfile = 1.");
00319 p_Inp->IntraProfile = 1;
00320 }
00321 }
00322
00323
00324 if (p_Inp->IntraProfile && ( p_Inp->ProfileIDC<FREXT_HP && p_Inp->ProfileIDC!=FREXT_CAVLC444 ))
00325 {
00326 snprintf(errortext, ET_SIZE, "\nIntraProfile is allowed only with ProfileIDC %d to %d.", FREXT_HP, FREXT_Hi444);
00327 error (errortext, 500);
00328 }
00329
00330 if (p_Inp->IntraProfile && !p_Inp->idr_period)
00331 {
00332 snprintf(errortext, ET_SIZE, "\nIntraProfile requires IDRPeriod >= 1.");
00333 error (errortext, 500);
00334 }
00335
00336 if (p_Inp->IntraProfile && p_Inp->intra_period != 1)
00337 {
00338 snprintf(errortext, ET_SIZE, "\nIntraProfile requires IntraPeriod equal 1.");
00339 error (errortext, 500);
00340 }
00341
00342 if (p_Inp->IntraProfile && p_Inp->num_ref_frames)
00343 {
00344 fprintf( stderr, "\nWarning: Setting NumberReferenceFrames to 0 in IntraProfile.");
00345 p_Inp->num_ref_frames = 0;
00346 }
00347
00348 if (p_Inp->IntraProfile == 0 && p_Inp->num_ref_frames == 0)
00349 {
00350 snprintf(errortext, ET_SIZE, "\nProfiles other than IntraProfile require NumberReferenceFrames > 0.");
00351 error (errortext, 500);
00352 }
00353 }
00354
00355
00356
00357
00358
00359
00360
00361 void LevelCheck(ImageParameters *p_Img, InputParameters *p_Inp)
00362 {
00363 unsigned int PicSizeInMbs = ( (p_Inp->output.width + p_Img->auto_crop_right) * (p_Inp->output.height + p_Img->auto_crop_bottom) ) >> 8;
00364 unsigned int MBProcessingRate = (unsigned int) (PicSizeInMbs * p_Inp->output.frame_rate + 0.5);
00365
00366 if ( (p_Inp->LevelIDC>=30) && (p_Inp->directInferenceFlag==0))
00367 {
00368 fprintf( stderr, "\nWarning: LevelIDC 3.0 and above require direct_8x8_inference to be set to 1. Please check your settings.\n");
00369 p_Inp->directInferenceFlag=1;
00370 }
00371 if ( ((p_Inp->LevelIDC<21) || (p_Inp->LevelIDC>41)) && (p_Inp->PicInterlace > 0 || p_Inp->MbInterlace > 0) )
00372 {
00373 snprintf(errortext, ET_SIZE, "\nInterlace modes only supported for LevelIDC in the range of 21 and 41. Please check your settings.\n");
00374 error (errortext, 500);
00375 }
00376
00377 if ( PicSizeInMbs > getMaxFs(p_Inp->LevelIDC) )
00378 {
00379 snprintf(errortext, ET_SIZE, "\nPicSizeInMbs exceeds maximum allowed size at specified LevelIdc %.1f\n", (float) p_Inp->LevelIDC / 10.0);
00380 error (errortext, 500);
00381 }
00382
00383 if (p_Inp->IntraProfile && (PicSizeInMbs > 1620) && p_Inp->slice_mode != 1)
00384 {
00385 error ("\nIntraProfile with PicSizeInMbs > 1620 requires SliceMode equal 1.", 500);
00386 }
00387
00388 if (p_Inp->IntraProfile && (PicSizeInMbs > 1620) && ((unsigned int)p_Inp->slice_argument > ( getMaxFs(p_Inp->LevelIDC) >> 2 ) ) )
00389 {
00390
00391 snprintf(errortext, ET_SIZE, "\nIntraProfile requires SliceArgument smaller or equal to 1/4 MaxFs at specified LevelIdc %d.", p_Inp->LevelIDC);
00392 error (errortext, 500);
00393 }
00394
00395 if ( MBProcessingRate > getMaxMBPS(p_Inp->LevelIDC) )
00396 {
00397 snprintf(errortext, ET_SIZE, "\nMB Processing Rate (%d) exceeds maximum allowed processing rate (%d) at specified LevelIdc %.1f\n",
00398 MBProcessingRate, getMaxMBPS(p_Inp->LevelIDC), (float) p_Inp->LevelIDC / 10.0);
00399 error (errortext, 500);
00400 }
00401
00402 if ( p_Inp->bit_rate > (int)(1200 * getMaxBR(p_Inp->LevelIDC)) )
00403 {
00404 snprintf(errortext, ET_SIZE, "\nBit Rate (%d) exceeds maximum allowed bit rate (%d) at specified LevelIdc %.1f for NAL HRD\n",
00405 p_Inp->bit_rate, 1200 * getMaxBR(p_Inp->LevelIDC), (float) p_Inp->LevelIDC / 10.0);
00406 error (errortext, 500);
00407 }
00408 }
00409
00410
00411
00412
00413
00414
00415
00416 void update_mv_limits(ImageParameters *p_Img, InputParameters *p_Inp, byte is_field)
00417 {
00418 memcpy(p_Img->MaxVmvR, LEVELVMVLIMIT[p_Img->LevelIndex], 6 * sizeof(int));
00419 memcpy(p_Img->MaxHmvR, LEVELHMVLIMIT, 6 * sizeof(int));
00420 if (is_field)
00421 {
00422 int i;
00423 for (i = 0; i < 6; i++)
00424 p_Img->MaxVmvR[i] = rshift_rnd(p_Img->MaxVmvR[i], 1);
00425 }
00426 if (p_Inp->UseMVLimits)
00427 {
00428 p_Img->MaxVmvR[0] = imax(p_Img->MaxVmvR[0], -(p_Inp->SetMVYLimit));
00429 p_Img->MaxVmvR[1] = imin(p_Img->MaxVmvR[1], (p_Inp->SetMVYLimit));
00430 p_Img->MaxVmvR[2] = imax(p_Img->MaxVmvR[2], -(p_Inp->SetMVYLimit << 1));
00431 p_Img->MaxVmvR[3] = imin(p_Img->MaxVmvR[3], (p_Inp->SetMVYLimit << 1));
00432 p_Img->MaxVmvR[4] = imax(p_Img->MaxVmvR[4], -(p_Inp->SetMVYLimit << 2));
00433 p_Img->MaxVmvR[5] = imin(p_Img->MaxVmvR[5], (p_Inp->SetMVYLimit << 2));
00434
00435 p_Img->MaxHmvR[0] = imax(p_Img->MaxHmvR[0], -(p_Inp->SetMVXLimit));
00436 p_Img->MaxHmvR[1] = imin(p_Img->MaxHmvR[1], (p_Inp->SetMVXLimit));
00437 p_Img->MaxHmvR[2] = imax(p_Img->MaxHmvR[2], -(p_Inp->SetMVXLimit << 1));
00438 p_Img->MaxHmvR[3] = imin(p_Img->MaxHmvR[3], (p_Inp->SetMVXLimit << 1));
00439 p_Img->MaxHmvR[4] = imax(p_Img->MaxHmvR[4], -(p_Inp->SetMVXLimit << 2));
00440 p_Img->MaxHmvR[5] = imin(p_Img->MaxHmvR[5], (p_Inp->SetMVXLimit << 2));
00441 }
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451 void clip_mv_range(ImageParameters *p_Img, int search_range, MotionVector *mv, int res)
00452 {
00453 res <<= 1;
00454
00455 mv->mv_x = (short) iClip3( p_Img->MaxHmvR[0 + res] + search_range, p_Img->MaxHmvR[1 + res] - search_range, mv->mv_x);
00456 mv->mv_y = (short) iClip3( p_Img->MaxVmvR[0 + res] + search_range, p_Img->MaxVmvR[1 + res] - search_range, mv->mv_y);
00457 }
00458
00459
00460
00461
00462
00463
00464
00465 void test_clip_mvs(ImageParameters *p_Img, short mv[2], Boolean write_mb)
00466 {
00467 if ((mv[0] < p_Img->MaxHmvR[4]) || (mv[0] > p_Img->MaxHmvR[5]) || (mv[1] < p_Img->MaxVmvR[4]) || (mv[1] > p_Img->MaxVmvR[5]))
00468 {
00469 if (write_mb == TRUE)
00470 printf("Warning MVs (%d %d) were out of range x(%d %d) y(%d %d). Clipping mvs before writing\n", mv[0], mv[1], p_Img->MaxHmvR[4], p_Img->MaxHmvR[5], p_Img->MaxVmvR[4], p_Img->MaxVmvR[5]);
00471 mv[0] = (short) iClip3( p_Img->MaxHmvR[4], p_Img->MaxHmvR[5], mv[0]);
00472 mv[1] = (short) iClip3( p_Img->MaxVmvR[4], p_Img->MaxVmvR[5], mv[1]);
00473 }
00474 }
00475
00476
00477
00478
00479
00480
00481
00482 int out_of_bounds_mvs(ImageParameters *p_Img, short mv[2])
00483 {
00484 return ((mv[0] < p_Img->MaxHmvR[4]) || (mv[0] > p_Img->MaxHmvR[5]) || (mv[1] < p_Img->MaxVmvR[4]) || (mv[1] > p_Img->MaxVmvR[5]));
00485 }
00486
00487 int InvalidWeightsForBiPrediction(Slice *currSlice, Block8x8Info* b8x8info, int mode)
00488 {
00489 seq_parameter_set_rbsp_t *active_sps = currSlice->active_sps;
00490 int cur_blk, cur_comp;
00491 int best8x8l0ref, best8x8l1ref;
00492 int weight_sum = 0;
00493 int invalid_mode = 0;
00494 short *wbp0, *wbp1;
00495 for (cur_blk = 0; cur_blk < 4; cur_blk ++)
00496 {
00497 if (b8x8info->best[mode][cur_blk].pdir == 2)
00498 {
00499 best8x8l0ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_0];
00500 best8x8l1ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_1];
00501 wbp0 = &currSlice->wbp_weight[LIST_0][best8x8l0ref][best8x8l1ref][0];
00502 wbp1 = &currSlice->wbp_weight[LIST_1][best8x8l0ref][best8x8l1ref][0];
00503
00504 for (cur_comp = 0; cur_comp < (active_sps->chroma_format_idc == YUV400 ? 1 : 3) ; cur_comp ++)
00505 {
00506 weight_sum = *wbp0++ + *wbp1++;
00507
00508 if (weight_sum < -128 || weight_sum > 127)
00509 {
00510 invalid_mode = 1;
00511 break;
00512 }
00513 }
00514 if (invalid_mode == 1)
00515 break;
00516 }
00517 }
00518 return invalid_mode;
00519 }
00520
00521 int InvalidMotionVectors(ImageParameters *p_Img, Slice *currSlice, Block8x8Info* b8x8info, int mode)
00522 {
00523 int cur_blk;
00524 int l0ref, l1ref;
00525 int invalid_mode = 0;
00526 int i, j;
00527
00528 if (mode > P8x8)
00529 return invalid_mode;
00530
00531
00532 for (cur_blk = 0; cur_blk < 4; cur_blk ++)
00533 {
00534 i = (cur_blk & 0x01) << 1;
00535 j = (cur_blk >> 1) << 1;
00536 switch (b8x8info->best[mode][cur_blk].pdir)
00537 {
00538 case 0:
00539 l0ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_0];
00540 if (out_of_bounds_mvs(p_Img, currSlice->all_mv [LIST_0][l0ref][mode][j][i]))
00541 {
00542 invalid_mode = 1;
00543 return invalid_mode;
00544 }
00545 break;
00546 case 1:
00547 l1ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_1];
00548 if (out_of_bounds_mvs(p_Img, currSlice->all_mv [LIST_1][l1ref][mode][j][i]))
00549 {
00550 invalid_mode = 1;
00551 return invalid_mode;
00552 }
00553 break;
00554 case 2:
00555 l0ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_0];
00556 l1ref = (int) b8x8info->best[mode][cur_blk].ref[LIST_1];
00557 if (out_of_bounds_mvs(p_Img, currSlice->all_mv [LIST_0][l0ref][mode][j][i]))
00558 {
00559 invalid_mode = 1;
00560 return invalid_mode;
00561 }
00562 if (out_of_bounds_mvs(p_Img, currSlice->all_mv [LIST_1][l1ref][mode][j][i]))
00563 {
00564 invalid_mode = 1;
00565 return invalid_mode;
00566 }
00567 break;
00568 default:
00569 break;
00570 }
00571 }
00572
00573 return invalid_mode;
00574 }
00575
00576 Boolean CheckPredictionParams(Macroblock *currMB, Block8x8Info *b8x8info, int mode)
00577 {
00578 Slice *currSlice = currMB->p_slice;
00579
00580 if (mode == P8x8 && currMB->luma_transform_size_8x8_flag == TRUE)
00581 {
00582 int i;
00583
00584 for (i = 0; i < 4; i++)
00585 {
00586 if (b8x8info->best[P8x8][i].mode != 4 && b8x8info->best[P8x8][i].mode != 0)
00587 {
00588 return FALSE;
00589 }
00590 }
00591 }
00592
00593 if (InvalidMotionVectors(currSlice->p_Img, currSlice, b8x8info, mode))
00594 return FALSE;
00595
00596 if (currSlice->slice_type == B_SLICE)
00597 {
00598
00599 if (currSlice->weighted_prediction == 1 && mode < P8x8)
00600 {
00601 if (InvalidWeightsForBiPrediction(currSlice, b8x8info, mode))
00602 return FALSE;
00603 }
00604
00605
00606 if (mode==0)
00607 {
00608 int i, j;
00609 for (j = currMB->block_y; j < currMB->block_y + 4;j++)
00610 {
00611 for (i = currMB->block_x; i < currMB->block_x + 4;i++)
00612 {
00613 if (currSlice->direct_pdir[j][i] < 0)
00614 return FALSE;
00615 }
00616 }
00617 }
00618 }
00619
00620 return TRUE;
00621 }