Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 9 files). Show all
Unified · Split
| @@ -1005,7 +1005,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 1004 unmodified lines | |||
| 1005 | pSps->bSeqScalingMatrixPresentFlag = !!uiCode; | 1005 | pSps->bSeqScalingMatrixPresentFlag = !!uiCode; |
| 1006 | 1006 | ||
| 1007 | if (pSps->bSeqScalingMatrixPresentFlag) { | 1007 | if (pSps->bSeqScalingMatrixPresentFlag) { |
| 1008 | WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4, | 1008 | WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4, |
| 1009 | pSps->iScalingList8x8)); | 1009 | pSps->iScalingList8x8)); |
| 1010 | } | 1010 | } |
| 1011 | } | 1011 | } |
| @@ -1134,9 +1134,18 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 122 unmodified lines | |||
| 1134 | } | 1134 | } |
| 1135 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag | 1135 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag |
| 1136 | pSps->bVuiParamPresentFlag = !!uiCode; | 1136 | pSps->bVuiParamPresentFlag = !!uiCode; |
| 1137 | if (pSps->bVuiParamPresentFlag && !kbUseSubsetFlag) { //parse Part of Vui Parameters in avc sps only | 1137 | if (pSps->bVuiParamPresentFlag) { |
| 1138 | WELS_READ_VERIFY (ParseVui (pCtx, pSps, pBsAux)); | 1138 | int iRetVui = ParseVui (pCtx, pSps, pBsAux); |
| 1139 | if (iRetVui == GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_VUI_HRD)) { | ||
| 1140 | if (kbUseSubsetFlag) { //Currently do no support VUI with HRD enable in subsetSPS | ||
| 1141 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "hrd parse in vui of subsetSPS is not supported!"); | ||
| 1142 | return iRetVui; | ||
| 1143 | } | ||
| 1144 | } else { | ||
| 1145 | WELS_READ_VERIFY (iRetVui); | ||
| 1146 | } | ||
| 1139 | } | 1147 | } |
| 1148 | |||
| 1140 | if (pCtx->pParam->bParseOnly) { | 1149 | if (pCtx->pParam->bParseOnly) { |
| 1141 | if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds! | 1150 | if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //sps bs exceeds! |
| 1142 | pCtx->iErrorCode |= dsOutOfMemory; | 1151 | pCtx->iErrorCode |= dsOutOfMemory; |
| @@ -1408,12 +1417,12 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 265 unmodified lines | |||
| 1408 | pPps->bPicScalingMatrixPresentFlag = !!uiCode; | 1417 | pPps->bPicScalingMatrixPresentFlag = !!uiCode; |
| 1409 | if (pPps->bPicScalingMatrixPresentFlag) { | 1418 | if (pPps->bPicScalingMatrixPresentFlag) { |
| 1410 | if (pCtx->bSpsAvailFlags[pPps->iSpsId]) { | 1419 | if (pCtx->bSpsAvailFlags[pPps->iSpsId]) { |
| 1411 | WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag, | 1420 | WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag, |
| 1412 | pPps->iScalingList4x4, pPps->iScalingList8x8)); | 1421 | pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, pPps->iScalingList8x8)); |
| 1413 | } else { | 1422 | } else { |
| 1414 | pCtx->bSpsLatePps = true; | 1423 | pCtx->bSpsLatePps = true; |
| 1415 | WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, | 1424 | WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bTransform8x8ModeFlag, pPps->bPicScalingListPresentFlag, |
| 1416 | pPps->iScalingList8x8)); | 1425 | pPps->iScalingList4x4, pPps->iScalingList8x8)); |
| 1417 | } | 1426 | } |
| 1418 | } | 1427 | } |
| 1419 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //second_chroma_qp_index_offset | 1428 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //second_chroma_qp_index_offset |
| @@ -1459,6 +1468,15 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 39 unmodified lines | |||
| 1459 | } | 1468 | } |
| 1460 | return ERR_NONE; | 1469 | return ERR_NONE; |
| 1461 | } | 1470 | } |
| 1471 | |||
| 1472 | #define VUI_MAX_CHROMA_LOG_TYPE_TOP_BOTTOM_FIELD_MAX 5 | ||
| 1473 | #define VUI_NUM_UNITS_IN_TICK_MIN 1 | ||
| 1474 | #define VUI_TIME_SCALE_MIN 1 | ||
| 1475 | #define VUI_MAX_BYTES_PER_PIC_DENOM_MAX 16 | ||
| 1476 | #define VUI_MAX_BITS_PER_MB_DENOM_MAX 16 | ||
| 1477 | #define VUI_LOG2_MAX_MV_LENGTH_HOR_MAX 16 | ||
| 1478 | #define VUI_LOG2_MAX_MV_LENGTH_VER_MAX 16 | ||
| 1479 | #define VUI_MAX_DEC_FRAME_BUFFERING_MAX 16 | ||
| 1462 | int32_t ParseVui (PWelsDecoderContext pCtx, PSps pSps, PBitStringAux pBsAux) { | 1480 | int32_t ParseVui (PWelsDecoderContext pCtx, PSps pSps, PBitStringAux pBsAux) { |
| 1463 | uint32_t uiCode; | 1481 | uint32_t uiCode; |
| 1464 | PVui pVui = &pSps->sVui; | 1482 | PVui pVui = &pSps->sVui; |
| @@ -1506,11 +1524,11 @@ int32_t ParseVui (PWelsDecoderContext pCtx, PSps pSps, PBitStringAux pBsAux) { · 41 unmodified lines | |||
| 1506 | if (pVui->bChromaLocInfoPresentFlag) { | 1524 | if (pVui->bChromaLocInfoPresentFlag) { |
| 1507 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //chroma_sample_loc_type_top_field | 1525 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //chroma_sample_loc_type_top_field |
| 1508 | pVui->uiChromaSampleLocTypeTopField = uiCode; | 1526 | pVui->uiChromaSampleLocTypeTopField = uiCode; |
| 1509 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiChromaSampleLocTypeTopField, VUI_MAX_CHROMA_LOG_TYPE_TOP_BOTTOM_FIELD, | 1527 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiChromaSampleLocTypeTopField, VUI_MAX_CHROMA_LOG_TYPE_TOP_BOTTOM_FIELD_MAX, |
| 1510 | "chroma_sample_loc_type_top_field"); | 1528 | "chroma_sample_loc_type_top_field"); |
| 1511 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //chroma_sample_loc_type_bottom_field | 1529 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //chroma_sample_loc_type_bottom_field |
| 1512 | pVui->uiChromaSampleLocTypeBottomField = uiCode; | 1530 | pVui->uiChromaSampleLocTypeBottomField = uiCode; |
| 1513 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiChromaSampleLocTypeBottomField, VUI_MAX_CHROMA_LOG_TYPE_TOP_BOTTOM_FIELD, | 1531 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiChromaSampleLocTypeBottomField, VUI_MAX_CHROMA_LOG_TYPE_TOP_BOTTOM_FIELD_MAX, |
| 1514 | "chroma_sample_loc_type_bottom_field"); | 1532 | "chroma_sample_loc_type_bottom_field"); |
| 1515 | } | 1533 | } |
| 1516 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //timing_info_present_flag | 1534 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //timing_info_present_flag |
| @@ -1522,17 +1540,60 @@ int32_t ParseVui (PWelsDecoderContext pCtx, PSps pSps, PBitStringAux pBsAux) { · 5 unmodified lines | |||
| 1522 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick | 1540 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //num_units_in_tick |
| 1523 | uiTmp |= uiCode; | 1541 | uiTmp |= uiCode; |
| 1524 | pVui->uiNumUnitsInTick = uiTmp; | 1542 | pVui->uiNumUnitsInTick = uiTmp; |
| 1525 | WELS_CHECK_SE_LOWER_WARNING (pVui->uiNumUnitsInTick, 1, "num_units_in_tick"); | 1543 | WELS_CHECK_SE_LOWER_WARNING (pVui->uiNumUnitsInTick, VUI_NUM_UNITS_IN_TICK_MIN, "num_units_in_tick"); |
| 1526 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale | 1544 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale |
| 1527 | uiTmp = (uiCode << 16); | 1545 | uiTmp = (uiCode << 16); |
| 1528 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale | 1546 | WELS_READ_VERIFY (BsGetBits (pBsAux, 16, &uiCode)); //time_scale |
| 1529 | uiTmp |= uiCode; | 1547 | uiTmp |= uiCode; |
| 1530 | pVui->uiTimeScale = uiTmp; | 1548 | pVui->uiTimeScale = uiTmp; |
| 1549 | WELS_CHECK_SE_LOWER_WARNING (pVui->uiNumUnitsInTick, VUI_TIME_SCALE_MIN, "time_scale"); | ||
| 1531 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //fixed_frame_rate_flag | 1550 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //fixed_frame_rate_flag |
| 1532 | pVui->bFixedFrameRateFlag = !!uiCode; | 1551 | pVui->bFixedFrameRateFlag = !!uiCode; |
| 1533 | } | 1552 | } |
| 1534 | //following HRD related parameters, omitted | 1553 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //nal_hrd_parameters_present_flag |
| 1535 | 1554 | pVui->bNalHrdParamPresentFlag = !!uiCode; | |
| 1555 | if (pVui->bNalHrdParamPresentFlag) { //HRD parse not supported | ||
| 1556 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "nal_hrd_parameters_present_flag = 1 not supported."); | ||
| 1557 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_VUI_HRD); | ||
| 1558 | } | ||
| 1559 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //vcl_hrd_parameters_present_flag | ||
| 1560 | pVui->bVclHrdParamPresentFlag = !!uiCode; | ||
| 1561 | if (pVui->bVclHrdParamPresentFlag) { //HRD parse not supported | ||
| 1562 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "vcl_hrd_parameters_present_flag = 1 not supported."); | ||
| 1563 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_VUI_HRD); | ||
| 1564 | } | ||
| 1565 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_struct_present_flag | ||
| 1566 | pVui->bPicStructPresentFlag = !!uiCode; | ||
| 1567 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //bitstream_restriction_flag | ||
| 1568 | pVui->bBitstreamRestrictionFlag = !!uiCode; | ||
| 1569 | if (pVui->bBitstreamRestrictionFlag) { | ||
| 1570 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //motion_vectors_over_pic_boundaries_flag | ||
| 1571 | pVui->bMotionVectorsOverPicBoundariesFlag = !!uiCode; | ||
| 1572 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //max_bytes_per_pic_denom | ||
| 1573 | pVui->uiMaxBytesPerPicDenom = uiCode; | ||
| 1574 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiMaxBytesPerPicDenom, VUI_MAX_BYTES_PER_PIC_DENOM_MAX, | ||
| 1575 | "max_bytes_per_pic_denom"); | ||
| 1576 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //max_bits_per_mb_denom | ||
| 1577 | pVui->uiMaxBitsPerMbDenom = uiCode; | ||
| 1578 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiMaxBitsPerMbDenom, VUI_MAX_BITS_PER_MB_DENOM_MAX, | ||
| 1579 | "max_bits_per_mb_denom"); | ||
| 1580 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //log2_max_mv_length_horizontal | ||
| 1581 | pVui->uiLog2MaxMvLengthHorizontal = uiCode; | ||
| 1582 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiLog2MaxMvLengthHorizontal, VUI_LOG2_MAX_MV_LENGTH_HOR_MAX, | ||
| 1583 | "log2_max_mv_length_horizontal"); | ||
| 1584 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //log2_max_mv_length_vertical | ||
| 1585 | pVui->uiLog2MaxMvLengthVertical = uiCode; | ||
| 1586 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiLog2MaxMvLengthVertical, VUI_LOG2_MAX_MV_LENGTH_VER_MAX, | ||
| 1587 | "log2_max_mv_length_vertical"); | ||
| 1588 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //max_num_reorder_frames | ||
| 1589 | pVui->uiMaxNumReorderFrames = uiCode; | ||
| 1590 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiMaxNumReorderFrames, VUI_MAX_DEC_FRAME_BUFFERING_MAX, | ||
| 1591 | "max_num_reorder_frames"); | ||
| 1592 | WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //max_dec_frame_buffering | ||
| 1593 | pVui->uiMaxDecFrameBuffering = uiCode; | ||
| 1594 | WELS_CHECK_SE_UPPER_WARNING (pVui->uiMaxDecFrameBuffering, VUI_MAX_DEC_FRAME_BUFFERING_MAX, | ||
| 1595 | "max_num_reorder_frames"); | ||
| 1596 | } | ||
| 1536 | return ERR_NONE; | 1597 | return ERR_NONE; |
| 1537 | } | 1598 | } |
| 1538 | /*! | 1599 | /*! |
| @@ -1593,8 +1654,8 @@ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* b · 54 unmodified lines | |||
| 1593 | return ERR_NONE; | 1654 | return ERR_NONE; |
| 1594 | } | 1655 | } |
| 1595 | 1656 | ||
| 1596 | int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, bool* pScalingListPresentFlag, | 1657 | int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, const bool kbTrans8x8ModeFlag, |
| 1597 | uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]) { | 1658 | bool* pScalingListPresentFlag, uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]) { |
| 1598 | uint32_t uiScalingListNum; | 1659 | uint32_t uiScalingListNum; |
| 1599 | uint32_t uiCode; | 1660 | uint32_t uiCode; |
| 1600 | 1661 | ||
| @@ -1603,11 +1664,15 @@ int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, bool* pScalin · 2 unmodified lines | |||
| 1603 | bool bInit = false; | 1664 | bool bInit = false; |
| 1604 | const uint8_t* defaultScaling[4]; | 1665 | const uint8_t* defaultScaling[4]; |
| 1605 | 1666 | ||
| 1606 | if (pSps != NULL) { | 1667 | if (!bPPS) { //sps scaling_list |
| 1607 | uiScalingListNum = (pSps->uiChromaFormatIdc != 3) ? 8 : 12; | 1668 | if (pSps != NULL) { |
| 1608 | bInit = bPPS && pSps->bSeqScalingMatrixPresentFlag; | 1669 | uiScalingListNum = (pSps->uiChromaFormatIdc != 3) ? 8 : 12; |
| 1609 | } else | 1670 | bInit = bPPS && pSps->bSeqScalingMatrixPresentFlag; |
| 1610 | uiScalingListNum = 12; | 1671 | } else |
| 1672 | uiScalingListNum = 12; | ||
| 1673 | } else { //pps scaling_list | ||
| 1674 | uiScalingListNum = 6 + (int32_t) kbTrans8x8ModeFlag * ((pSps->uiChromaFormatIdc != 3) ? 2 : 6); | ||
| 1675 | } | ||
| 1611 | 1676 | ||
| 1612 | //Init default_scaling_list value for sps or pps | 1677 | //Init default_scaling_list value for sps or pps |
| 1613 | defaultScaling[0] = bInit ? pSps->iScalingList4x4[0] : g_kuiDequantScaling4x4Default[0]; | 1678 | defaultScaling[0] = bInit ? pSps->iScalingList4x4[0] : g_kuiDequantScaling4x4Default[0]; |