History

Merge pull request #1657 from mstorsjo/clip-bitrate

Make sure the random test bitrate is high enough

sijchen committed 11 years ago

Commit 9a602ca2 parents 397c7ca 887b4f416 files · +705 −79Browse files

Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 16 files). Show all

Unified · Split

codec/decoder/core/src/au_parser.cpp+135−6
@@ -833,6 +833,8 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { · 832 unmodified lines
833#define PPS_PIC_INIT_QP_QS_MAX 51833#define PPS_PIC_INIT_QP_QS_MAX 51
834#define PPS_CHROMA_QP_INDEX_OFFSET_MIN -12834#define PPS_CHROMA_QP_INDEX_OFFSET_MIN -12
835#define PPS_CHROMA_QP_INDEX_OFFSET_MAX 12835#define PPS_CHROMA_QP_INDEX_OFFSET_MAX 12
836#define SCALING_LIST_DELTA_SCALE_MAX 127
837#define SCALING_LIST_DELTA_SCALE_MIN -128
836 838
837/*!839/*!
838 *************************************************************************************840 *************************************************************************************
@@ -935,12 +937,16 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 96 unmodified lines
935 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag937 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
936 pSps->bSeqScalingMatrixPresentFlag = !!uiCode;938 pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
937 939
938 if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME940 if (pSps->bSeqScalingMatrixPresentFlag)// For high profile, it is not used in current application. FIXME
939 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,941
940 "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",942 WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4,
941 pSps->bSeqScalingMatrixPresentFlag);943 pSps->iScalingList8x8));
942 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);944 //if exist, to parse scalinglist matrix value
943 }945
946 // WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
947 // "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
948 // pSps->bSeqScalingMatrixPresentFlag);
949 //return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
944 }950 }
945 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4951 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
946 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",952 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",
@@ -1307,6 +1313,22 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 360 unmodified lines
1307 pPps->bConstainedIntraPredFlag = !!uiCode;1313 pPps->bConstainedIntraPredFlag = !!uiCode;
1308 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag1314 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
1309 pPps->bRedundantPicCntPresentFlag = !!uiCode;1315 pPps->bRedundantPicCntPresentFlag = !!uiCode;
1316//going on to parse high profile syntax, need fix me
1317 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1318 pPps->bTransform_8x8_mode_flag = !!uiCode;
1319 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1320 pPps->bPicScalingMatrixPresentFlag = !!uiCode;
1321 if (pPps->bPicScalingMatrixPresentFlag) {
1322 if (pCtx->bSpsAvailFlags[pPps->iSpsId])
1323 WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag,
1324 pPps->iScalingList4x4, pPps->iScalingList8x8));
1325 else {
1326 pCtx->bSpsLatePps = true;
1327 WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4,
1328 pPps->iScalingList8x8));
1329 }
1330 }
1331
1310 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {1332 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
1311 PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];1333 PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
1312 PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;1334 PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
@@ -1355,6 +1377,113 @@ int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type · 42 unmodified lines
1355 1377
1356 return ERR_NONE;1378 return ERR_NONE;
1357}1379}
1380/*
1381 *************************************************************************************
1382 * \brief to parse scalinglist message payload
1383 *
1384 * \param pps sps scaling list matrix message to be parsed output
1385 * \param pBsAux bitstream reader auxiliary
1386 *
1387 * \return 0 - successed
1388 * 1 - failed
1389 *
1390 * \note Call it in case scaling list matrix present at sps or pps level
1391 *************************************************************************************
1392 */
1393int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* bUseDefaultScalingMatrixFlag,
1394 PBitStringAux pBsAux) { // reserved Sei_Msg type
1395 int iLastScale = 8;
1396 int iNextScale = 8;
1397 int iDeltaScale;
1398 int32_t iCode;
1399 for (int j = 0; j < iScalingListNum; j++) {
1400 if (iNextScale != 0) {
1401 WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode));
1402 WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, SCALING_LIST_DELTA_SCALE_MIN, SCALING_LIST_DELTA_SCALE_MAX, "DeltaScale",
1403 ERR_SCALING_LIST_DELTA_SCALE);
1404 iDeltaScale = iCode;
1405 iNextScale = (iLastScale + iDeltaScale + 256) % 256;
1406 *bUseDefaultScalingMatrixFlag = (j == 0 && iNextScale == 0);
1407 if (*bUseDefaultScalingMatrixFlag)
1408 break;
1409 }
1410 pScalingList[g_kuiZigzagScan[j]] = (iNextScale == 0) ? iLastScale : iNextScale;
1411 iLastScale = pScalingList[g_kuiZigzagScan[j]];
1412 }
1413
1414
1415 return ERR_NONE;
1416}
1417
1418int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, bool* pScalingListPresentFlag,
1419 uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]) {
1420 uint32_t uiScalingListNum;
1421 uint32_t uiCode;
1422 int32_t iRetTmp;
1423 bool bUseDefaultScalingMatrixFlag4x4 = false;
1424 bool bUseDefaultScalingMatrixFlag8x8 = false;
1425 bool bInit = false;
1426 const uint8_t* defaultScaling[4];
1427
1428 if (pSps != NULL) {
1429 uiScalingListNum = (pSps->uiChromaFormatIdc != 3) ? 8 : 12;
1430 bInit = bPPS && pSps->bSeqScalingMatrixPresentFlag;
1431 } else
1432 uiScalingListNum = 12;
1433
1434//Init default_scaling_list value for sps or pps
1435 defaultScaling[0] = bInit ? pSps->iScalingList4x4[0] : g_kuiDequantScaling4x4Default[0];
1436 defaultScaling[1] = bInit ? pSps->iScalingList4x4[3] : g_kuiDequantScaling4x4Default[1];
1437 defaultScaling[2] = bInit ? pSps->iScalingList8x8[0] : g_kuiDequantScaling8x8Default[0];
1438 defaultScaling[3] = bInit ? pSps->iScalingList8x8[1] : g_kuiDequantScaling8x8Default[1];
1439
1440 for (int i = 0; i < uiScalingListNum; i++) {
1441 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
1442 pScalingListPresentFlag[i] = !!uiCode;
1443 if (!!uiCode) {
1444 if (i < 6) {
1445 iRetTmp = SetScalingListValue (iScalingList4x4[i], 16, &bUseDefaultScalingMatrixFlag4x4, pBs);
1446 if (iRetTmp == ERR_NONE) {
1447 if (bUseDefaultScalingMatrixFlag4x4) {
1448 bUseDefaultScalingMatrixFlag4x4 = false;
1449 memcpy (iScalingList4x4[i], g_kuiDequantScaling4x4Default[i / 3], sizeof (uint8_t) * 16);
1450 }
1451 } else
1452 return iRetTmp;
1453
1454 } else {
1455 SetScalingListValue (iScalingList8x8[i - 6], 64, &bUseDefaultScalingMatrixFlag8x8, pBs);
1456 //if(iRetTmp == ERR_NONE)
1457 //{
1458 if (bUseDefaultScalingMatrixFlag8x8) {
1459 bUseDefaultScalingMatrixFlag8x8 = false;
1460 memcpy (iScalingList8x8[i - 6], g_kuiDequantScaling8x8Default[ (i - 6) & 1], sizeof (uint8_t) * 64);
1461 }
1462 // }
1463
1464 //else
1465 // return iRetTmp;
1466 }
1467
1468 } else {
1469 if (i < 6) {
1470 if ((i != 0) && (i != 3))
1471 memcpy (iScalingList4x4[i], iScalingList4x4[i - 1], sizeof (uint8_t) * 16);
1472 else
1473 memcpy (iScalingList4x4[i], defaultScaling[i / 3], sizeof (uint8_t) * 16);
1474
1475 } else {
1476 if ((i == 6) || (i == 7))
1477 memcpy (iScalingList8x8[i - 6], defaultScaling[ (i & 1) + 2], sizeof (uint8_t) * 64);
1478 else
1479 memcpy (iScalingList8x8[i - 6], iScalingList8x8[ (i - 6) / 3], sizeof (uint8_t) * 64);
1480
1481 }
1482 }
1483 }
1484 return ERR_NONE;
1485
1486}
1358 1487
1359/*!1488/*!
1360 *************************************************************************************1489 *************************************************************************************

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t