PageRenderTime 55ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/H264Dec/source/h264bsd_macroblock_layer.c

http://github.com/mbebenita/Broadway
C | 1446 lines | 963 code | 197 blank | 286 comment | 221 complexity | e9c10cbce5b76995d4de7ce068518052 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. * Copyright (C) 2009 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*------------------------------------------------------------------------------
  17. Table of contents
  18. 1. Include headers
  19. 2. External compiler flags
  20. 3. Module defines
  21. 4. Local function prototypes
  22. 5. Functions
  23. h264bsdDecodeMacroblockLayer
  24. h264bsdMbPartPredMode
  25. h264bsdNumMbPart
  26. h264bsdNumSubMbPart
  27. DecodeMbPred
  28. DecodeSubMbPred
  29. DecodeResidual
  30. DetermineNc
  31. CbpIntra16x16
  32. h264bsdPredModeIntra16x16
  33. h264bsdDecodeMacroblock
  34. ProcessResidual
  35. h264bsdSubMbPartMode
  36. ------------------------------------------------------------------------------*/
  37. /*------------------------------------------------------------------------------
  38. 1. Include headers
  39. ------------------------------------------------------------------------------*/
  40. #include "h264bsd_macroblock_layer.h"
  41. #include "h264bsd_slice_header.h"
  42. #include "h264bsd_util.h"
  43. #include "h264bsd_vlc.h"
  44. #include "h264bsd_cavlc.h"
  45. #include "h264bsd_nal_unit.h"
  46. #include "h264bsd_neighbour.h"
  47. #include "h264bsd_transform.h"
  48. #include "h264bsd_intra_prediction.h"
  49. #include "h264bsd_inter_prediction.h"
  50. #ifdef H264DEC_OMXDL
  51. #include "omxtypes.h"
  52. #include "omxVC.h"
  53. #include "armVC.h"
  54. #endif /* H264DEC_OMXDL */
  55. /*------------------------------------------------------------------------------
  56. 2. External compiler flags
  57. --------------------------------------------------------------------------------
  58. --------------------------------------------------------------------------------
  59. 3. Module defines
  60. ------------------------------------------------------------------------------*/
  61. #ifdef H264DEC_OMXDL
  62. static const u32 chromaIndex[8] = { 256, 260, 288, 292, 320, 324, 352, 356 };
  63. static const u32 lumaIndex[16] = { 0, 4, 64, 68,
  64. 8, 12, 72, 76,
  65. 128, 132, 192, 196,
  66. 136, 140, 200, 204 };
  67. #endif
  68. /* mapping of dc coefficients array to luma blocks */
  69. static const u32 dcCoeffIndex[16] =
  70. {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15};
  71. /*------------------------------------------------------------------------------
  72. 4. Local function prototypes
  73. ------------------------------------------------------------------------------*/
  74. static u32 DecodeMbPred(strmData_t *pStrmData, mbPred_t *pMbPred,
  75. mbType_e mbType, u32 numRefIdxActive);
  76. static u32 DecodeSubMbPred(strmData_t *pStrmData, subMbPred_t *pSubMbPred,
  77. mbType_e mbType, u32 numRefIdxActive);
  78. static u32 DecodeResidual(strmData_t *pStrmData, residual_t *pResidual,
  79. mbStorage_t *pMb, mbType_e mbType, u32 codedBlockPattern);
  80. #ifdef H264DEC_OMXDL
  81. static u32 DetermineNc(mbStorage_t *pMb, u32 blockIndex, u8 *pTotalCoeff);
  82. #else
  83. static u32 DetermineNc(mbStorage_t *pMb, u32 blockIndex, i16 *pTotalCoeff);
  84. #endif
  85. static u32 CbpIntra16x16(mbType_e mbType);
  86. #ifdef H264DEC_OMXDL
  87. static u32 ProcessIntra4x4Residual(mbStorage_t *pMb, u8 *data, u32 constrainedIntraPred,
  88. macroblockLayer_t *mbLayer, const u8 **pSrc, image_t *image);
  89. static u32 ProcessChromaResidual(mbStorage_t *pMb, u8 *data, const u8 **pSrc );
  90. static u32 ProcessIntra16x16Residual(mbStorage_t *pMb, u8 *data, u32 constrainedIntraPred,
  91. u32 intraChromaPredMode, const u8 **pSrc, image_t *image);
  92. #else
  93. static u32 ProcessResidual(mbStorage_t *pMb, i32 residualLevel[][16], u32 *);
  94. #endif
  95. /*------------------------------------------------------------------------------
  96. Function name: h264bsdDecodeMacroblockLayer
  97. Functional description:
  98. Parse macroblock specific information from bit stream.
  99. Inputs:
  100. pStrmData pointer to stream data structure
  101. pMb pointer to macroblock storage structure
  102. sliceType type of the current slice
  103. numRefIdxActive maximum reference index
  104. Outputs:
  105. pMbLayer stores the macroblock data parsed from stream
  106. Returns:
  107. HANTRO_OK success
  108. HANTRO_NOK end of stream or error in stream
  109. ------------------------------------------------------------------------------*/
  110. u32 h264bsdDecodeMacroblockLayer(strmData_t *pStrmData,
  111. macroblockLayer_t *pMbLayer, mbStorage_t *pMb, u32 sliceType,
  112. u32 numRefIdxActive)
  113. {
  114. /* Variables */
  115. u32 tmp, i, value;
  116. i32 itmp;
  117. mbPartPredMode_e partMode;
  118. /* Code */
  119. ASSERT(pStrmData);
  120. ASSERT(pMbLayer);
  121. #ifdef H264DEC_NEON
  122. h264bsdClearMbLayer(pMbLayer, ((sizeof(macroblockLayer_t) + 63) & ~0x3F));
  123. #else
  124. H264SwDecMemset(pMbLayer, 0, sizeof(macroblockLayer_t));
  125. #endif
  126. tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
  127. if (IS_I_SLICE(sliceType))
  128. {
  129. if ((value + 6) > 31 || tmp != HANTRO_OK)
  130. return(HANTRO_NOK);
  131. pMbLayer->mbType = (mbType_e)(value + 6);
  132. }
  133. else
  134. {
  135. if ((value + 1) > 31 || tmp != HANTRO_OK)
  136. return(HANTRO_NOK);
  137. pMbLayer->mbType = (mbType_e)(value + 1);
  138. }
  139. if (pMbLayer->mbType == I_PCM)
  140. {
  141. i32 *level;
  142. while( !h264bsdIsByteAligned(pStrmData) )
  143. {
  144. /* pcm_alignment_zero_bit */
  145. tmp = h264bsdGetBits(pStrmData, 1);
  146. if (tmp)
  147. return(HANTRO_NOK);
  148. }
  149. level = pMbLayer->residual.level[0];
  150. for (i = 0; i < 384; i++)
  151. {
  152. value = h264bsdGetBits(pStrmData, 8);
  153. if (value == END_OF_STREAM)
  154. return(HANTRO_NOK);
  155. *level++ = (i32)value;
  156. }
  157. }
  158. else
  159. {
  160. partMode = h264bsdMbPartPredMode(pMbLayer->mbType);
  161. if ( (partMode == PRED_MODE_INTER) &&
  162. (h264bsdNumMbPart(pMbLayer->mbType) == 4) )
  163. {
  164. tmp = DecodeSubMbPred(pStrmData, &pMbLayer->subMbPred,
  165. pMbLayer->mbType, numRefIdxActive);
  166. }
  167. else
  168. {
  169. tmp = DecodeMbPred(pStrmData, &pMbLayer->mbPred,
  170. pMbLayer->mbType, numRefIdxActive);
  171. }
  172. if (tmp != HANTRO_OK)
  173. return(tmp);
  174. if (partMode != PRED_MODE_INTRA16x16)
  175. {
  176. tmp = h264bsdDecodeExpGolombMapped(pStrmData, &value,
  177. (u32)(partMode == PRED_MODE_INTRA4x4));
  178. if (tmp != HANTRO_OK)
  179. return(tmp);
  180. pMbLayer->codedBlockPattern = value;
  181. }
  182. else
  183. {
  184. pMbLayer->codedBlockPattern = CbpIntra16x16(pMbLayer->mbType);
  185. }
  186. if ( pMbLayer->codedBlockPattern ||
  187. (partMode == PRED_MODE_INTRA16x16) )
  188. {
  189. tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
  190. if (tmp != HANTRO_OK || (itmp < -26) || (itmp > 25) )
  191. return(HANTRO_NOK);
  192. pMbLayer->mbQpDelta = itmp;
  193. tmp = DecodeResidual(pStrmData, &pMbLayer->residual, pMb,
  194. pMbLayer->mbType, pMbLayer->codedBlockPattern);
  195. pStrmData->strmBuffReadBits =
  196. (u32)(pStrmData->pStrmCurrPos - pStrmData->pStrmBuffStart) * 8 +
  197. pStrmData->bitPosInWord;
  198. if (tmp != HANTRO_OK)
  199. return(tmp);
  200. }
  201. }
  202. return(HANTRO_OK);
  203. }
  204. /*------------------------------------------------------------------------------
  205. Function: h264bsdMbPartPredMode
  206. Functional description:
  207. Returns the prediction mode of a macroblock type
  208. ------------------------------------------------------------------------------*/
  209. mbPartPredMode_e h264bsdMbPartPredMode(mbType_e mbType)
  210. {
  211. /* Variables */
  212. /* Code */
  213. ASSERT(mbType <= 31);
  214. if ((mbType <= P_8x8ref0))
  215. return(PRED_MODE_INTER);
  216. else if (mbType == I_4x4)
  217. return(PRED_MODE_INTRA4x4);
  218. else
  219. return(PRED_MODE_INTRA16x16);
  220. }
  221. /*------------------------------------------------------------------------------
  222. Function: h264bsdNumMbPart
  223. Functional description:
  224. Returns the amount of macroblock partitions in a macroblock type
  225. ------------------------------------------------------------------------------*/
  226. u32 h264bsdNumMbPart(mbType_e mbType)
  227. {
  228. /* Variables */
  229. /* Code */
  230. ASSERT(h264bsdMbPartPredMode(mbType) == PRED_MODE_INTER);
  231. switch (mbType)
  232. {
  233. case P_L0_16x16:
  234. case P_Skip:
  235. return(1);
  236. case P_L0_L0_16x8:
  237. case P_L0_L0_8x16:
  238. return(2);
  239. /* P_8x8 or P_8x8ref0 */
  240. default:
  241. return(4);
  242. }
  243. }
  244. /*------------------------------------------------------------------------------
  245. Function: h264bsdNumSubMbPart
  246. Functional description:
  247. Returns the amount of sub-partitions in a sub-macroblock type
  248. ------------------------------------------------------------------------------*/
  249. u32 h264bsdNumSubMbPart(subMbType_e subMbType)
  250. {
  251. /* Variables */
  252. /* Code */
  253. ASSERT(subMbType <= P_L0_4x4);
  254. switch (subMbType)
  255. {
  256. case P_L0_8x8:
  257. return(1);
  258. case P_L0_8x4:
  259. case P_L0_4x8:
  260. return(2);
  261. /* P_L0_4x4 */
  262. default:
  263. return(4);
  264. }
  265. }
  266. /*------------------------------------------------------------------------------
  267. Function: DecodeMbPred
  268. Functional description:
  269. Parse macroblock prediction information from bit stream and store
  270. in 'pMbPred'.
  271. ------------------------------------------------------------------------------*/
  272. u32 DecodeMbPred(strmData_t *pStrmData, mbPred_t *pMbPred, mbType_e mbType,
  273. u32 numRefIdxActive)
  274. {
  275. /* Variables */
  276. u32 tmp, i, j, value;
  277. i32 itmp;
  278. /* Code */
  279. ASSERT(pStrmData);
  280. ASSERT(pMbPred);
  281. switch (h264bsdMbPartPredMode(mbType))
  282. {
  283. case PRED_MODE_INTER: /* PRED_MODE_INTER */
  284. if (numRefIdxActive > 1)
  285. {
  286. for (i = h264bsdNumMbPart(mbType), j = 0; i--; j++)
  287. {
  288. tmp = h264bsdDecodeExpGolombTruncated(pStrmData, &value,
  289. (u32)(numRefIdxActive > 2));
  290. if (tmp != HANTRO_OK || value >= numRefIdxActive)
  291. return(HANTRO_NOK);
  292. pMbPred->refIdxL0[j] = value;
  293. }
  294. }
  295. for (i = h264bsdNumMbPart(mbType), j = 0; i--; j++)
  296. {
  297. tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
  298. if (tmp != HANTRO_OK)
  299. return(tmp);
  300. pMbPred->mvdL0[j].hor = (i16)itmp;
  301. tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
  302. if (tmp != HANTRO_OK)
  303. return(tmp);
  304. pMbPred->mvdL0[j].ver = (i16)itmp;
  305. }
  306. break;
  307. case PRED_MODE_INTRA4x4:
  308. for (itmp = 0, i = 0; itmp < 2; itmp++)
  309. {
  310. value = h264bsdShowBits32(pStrmData);
  311. tmp = 0;
  312. for (j = 8; j--; i++)
  313. {
  314. pMbPred->prevIntra4x4PredModeFlag[i] =
  315. value & 0x80000000 ? HANTRO_TRUE : HANTRO_FALSE;
  316. value <<= 1;
  317. if (!pMbPred->prevIntra4x4PredModeFlag[i])
  318. {
  319. pMbPred->remIntra4x4PredMode[i] = value>>29;
  320. value <<= 3;
  321. tmp++;
  322. }
  323. }
  324. if (h264bsdFlushBits(pStrmData, 8 + 3*tmp) == END_OF_STREAM)
  325. return(HANTRO_NOK);
  326. }
  327. /* fall-through */
  328. case PRED_MODE_INTRA16x16:
  329. tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
  330. if (tmp != HANTRO_OK || value > 3)
  331. return(HANTRO_NOK);
  332. pMbPred->intraChromaPredMode = value;
  333. break;
  334. }
  335. return(HANTRO_OK);
  336. }
  337. /*------------------------------------------------------------------------------
  338. Function: DecodeSubMbPred
  339. Functional description:
  340. Parse sub-macroblock prediction information from bit stream and
  341. store in 'pMbPred'.
  342. ------------------------------------------------------------------------------*/
  343. u32 DecodeSubMbPred(strmData_t *pStrmData, subMbPred_t *pSubMbPred,
  344. mbType_e mbType, u32 numRefIdxActive)
  345. {
  346. /* Variables */
  347. u32 tmp, i, j, value;
  348. i32 itmp;
  349. /* Code */
  350. ASSERT(pStrmData);
  351. ASSERT(pSubMbPred);
  352. ASSERT(h264bsdMbPartPredMode(mbType) == PRED_MODE_INTER);
  353. for (i = 0; i < 4; i++)
  354. {
  355. tmp = h264bsdDecodeExpGolombUnsigned(pStrmData, &value);
  356. if (tmp != HANTRO_OK || value > 3)
  357. return(HANTRO_NOK);
  358. pSubMbPred->subMbType[i] = (subMbType_e)value;
  359. }
  360. if ( (numRefIdxActive > 1) && (mbType != P_8x8ref0) )
  361. {
  362. for (i = 0; i < 4; i++)
  363. {
  364. tmp = h264bsdDecodeExpGolombTruncated(pStrmData, &value,
  365. (u32)(numRefIdxActive > 2));
  366. if (tmp != HANTRO_OK || value >= numRefIdxActive)
  367. return(HANTRO_NOK);
  368. pSubMbPred->refIdxL0[i] = value;
  369. }
  370. }
  371. for (i = 0; i < 4; i++)
  372. {
  373. j = 0;
  374. for (value = h264bsdNumSubMbPart(pSubMbPred->subMbType[i]);
  375. value--; j++)
  376. {
  377. tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
  378. if (tmp != HANTRO_OK)
  379. return(tmp);
  380. pSubMbPred->mvdL0[i][j].hor = (i16)itmp;
  381. tmp = h264bsdDecodeExpGolombSigned(pStrmData, &itmp);
  382. if (tmp != HANTRO_OK)
  383. return(tmp);
  384. pSubMbPred->mvdL0[i][j].ver = (i16)itmp;
  385. }
  386. }
  387. return(HANTRO_OK);
  388. }
  389. #ifdef H264DEC_OMXDL
  390. /*------------------------------------------------------------------------------
  391. Function: DecodeResidual
  392. Functional description:
  393. Parse residual information from bit stream and store in 'pResidual'.
  394. ------------------------------------------------------------------------------*/
  395. u32 DecodeResidual(strmData_t *pStrmData, residual_t *pResidual,
  396. mbStorage_t *pMb, mbType_e mbType, u32 codedBlockPattern)
  397. {
  398. /* Variables */
  399. u32 i, j;
  400. u32 blockCoded;
  401. u32 blockIndex;
  402. u32 is16x16;
  403. OMX_INT nc;
  404. OMXResult omxRes;
  405. OMX_U8 *pPosCoefBuf;
  406. /* Code */
  407. ASSERT(pStrmData);
  408. ASSERT(pResidual);
  409. pPosCoefBuf = pResidual->posCoefBuf;
  410. /* luma DC is at index 24 */
  411. if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTRA16x16)
  412. {
  413. nc = (OMX_INT)DetermineNc(pMb, 0, pResidual->totalCoeff);
  414. #ifndef H264DEC_NEON
  415. omxRes = omxVCM4P10_DecodeCoeffsToPairCAVLC(
  416. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  417. (OMX_S32*) (&pStrmData->bitPosInWord),
  418. &pResidual->totalCoeff[24],
  419. &pPosCoefBuf,
  420. nc,
  421. 16);
  422. #else
  423. omxRes = armVCM4P10_DecodeCoeffsToPair(
  424. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  425. (OMX_S32*) (&pStrmData->bitPosInWord),
  426. &pResidual->totalCoeff[24],
  427. &pPosCoefBuf,
  428. nc,
  429. 16);
  430. #endif
  431. if (omxRes != OMX_Sts_NoErr)
  432. return(HANTRO_NOK);
  433. is16x16 = HANTRO_TRUE;
  434. }
  435. else
  436. is16x16 = HANTRO_FALSE;
  437. for (i = 4, blockIndex = 0; i--;)
  438. {
  439. /* luma cbp in bits 0-3 */
  440. blockCoded = codedBlockPattern & 0x1;
  441. codedBlockPattern >>= 1;
  442. if (blockCoded)
  443. {
  444. for (j = 4; j--; blockIndex++)
  445. {
  446. nc = (OMX_INT)DetermineNc(pMb,blockIndex,pResidual->totalCoeff);
  447. if (is16x16)
  448. {
  449. #ifndef H264DEC_NEON
  450. omxRes = omxVCM4P10_DecodeCoeffsToPairCAVLC(
  451. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  452. (OMX_S32*) (&pStrmData->bitPosInWord),
  453. &pResidual->totalCoeff[blockIndex],
  454. &pPosCoefBuf,
  455. nc,
  456. 15);
  457. #else
  458. omxRes = armVCM4P10_DecodeCoeffsToPair(
  459. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  460. (OMX_S32*) (&pStrmData->bitPosInWord),
  461. &pResidual->totalCoeff[blockIndex],
  462. &pPosCoefBuf,
  463. nc,
  464. 15);
  465. #endif
  466. }
  467. else
  468. {
  469. #ifndef H264DEC_NEON
  470. omxRes = omxVCM4P10_DecodeCoeffsToPairCAVLC(
  471. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  472. (OMX_S32*) (&pStrmData->bitPosInWord),
  473. &pResidual->totalCoeff[blockIndex],
  474. &pPosCoefBuf,
  475. nc,
  476. 16);
  477. #else
  478. omxRes = armVCM4P10_DecodeCoeffsToPair(
  479. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  480. (OMX_S32*) (&pStrmData->bitPosInWord),
  481. &pResidual->totalCoeff[blockIndex],
  482. &pPosCoefBuf,
  483. nc,
  484. 16);
  485. #endif
  486. }
  487. if (omxRes != OMX_Sts_NoErr)
  488. return(HANTRO_NOK);
  489. }
  490. }
  491. else
  492. blockIndex += 4;
  493. }
  494. /* chroma DC block are at indices 25 and 26 */
  495. blockCoded = codedBlockPattern & 0x3;
  496. if (blockCoded)
  497. {
  498. #ifndef H264DEC_NEON
  499. omxRes = omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC(
  500. (const OMX_U8**) (&pStrmData->pStrmCurrPos),
  501. (OMX_S32*) (&pStrmData->bitPosInWord),
  502. &pResidual->totalCoeff[25],
  503. &pPosCoefBuf);
  504. #else
  505. omxRes = armVCM4P10_DecodeCoeffsToPair(
  506. (const OMX_U8**) (&pStrmData->pStrmCurrPos),
  507. (OMX_S32*) (&pStrmData->bitPosInWord),
  508. &pResidual->totalCoeff[25],
  509. &pPosCoefBuf,
  510. 17,
  511. 4);
  512. #endif
  513. if (omxRes != OMX_Sts_NoErr)
  514. return(HANTRO_NOK);
  515. #ifndef H264DEC_NEON
  516. omxRes = omxVCM4P10_DecodeChromaDcCoeffsToPairCAVLC(
  517. (const OMX_U8**) (&pStrmData->pStrmCurrPos),
  518. (OMX_S32*) (&pStrmData->bitPosInWord),
  519. &pResidual->totalCoeff[26],
  520. &pPosCoefBuf);
  521. #else
  522. omxRes = armVCM4P10_DecodeCoeffsToPair(
  523. (const OMX_U8**) (&pStrmData->pStrmCurrPos),
  524. (OMX_S32*) (&pStrmData->bitPosInWord),
  525. &pResidual->totalCoeff[26],
  526. &pPosCoefBuf,
  527. 17,
  528. 4);
  529. #endif
  530. if (omxRes != OMX_Sts_NoErr)
  531. return(HANTRO_NOK);
  532. }
  533. /* chroma AC */
  534. blockCoded = codedBlockPattern & 0x2;
  535. if (blockCoded)
  536. {
  537. for (i = 8; i--;blockIndex++)
  538. {
  539. nc = (OMX_INT)DetermineNc(pMb, blockIndex, pResidual->totalCoeff);
  540. #ifndef H264DEC_NEON
  541. omxRes = omxVCM4P10_DecodeCoeffsToPairCAVLC(
  542. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  543. (OMX_S32*) (&pStrmData->bitPosInWord),
  544. &pResidual->totalCoeff[blockIndex],
  545. &pPosCoefBuf,
  546. nc,
  547. 15);
  548. #else
  549. omxRes = armVCM4P10_DecodeCoeffsToPair(
  550. (const OMX_U8 **) (&pStrmData->pStrmCurrPos),
  551. (OMX_S32*) (&pStrmData->bitPosInWord),
  552. &pResidual->totalCoeff[blockIndex],
  553. &pPosCoefBuf,
  554. nc,
  555. 15);
  556. #endif
  557. if (omxRes != OMX_Sts_NoErr)
  558. return(HANTRO_NOK);
  559. }
  560. }
  561. return(HANTRO_OK);
  562. }
  563. #else
  564. /*------------------------------------------------------------------------------
  565. Function: DecodeResidual
  566. Functional description:
  567. Parse residual information from bit stream and store in 'pResidual'.
  568. ------------------------------------------------------------------------------*/
  569. u32 DecodeResidual(strmData_t *pStrmData, residual_t *pResidual,
  570. mbStorage_t *pMb, mbType_e mbType, u32 codedBlockPattern)
  571. {
  572. /* Variables */
  573. u32 i, j, tmp;
  574. i32 nc;
  575. u32 blockCoded;
  576. u32 blockIndex;
  577. u32 is16x16;
  578. i32 (*level)[16];
  579. /* Code */
  580. ASSERT(pStrmData);
  581. ASSERT(pResidual);
  582. level = pResidual->level;
  583. /* luma DC is at index 24 */
  584. if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTRA16x16)
  585. {
  586. nc = (i32)DetermineNc(pMb, 0, pResidual->totalCoeff);
  587. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData, level[24], nc, 16);
  588. if ((tmp & 0xF) != HANTRO_OK)
  589. return(tmp);
  590. pResidual->totalCoeff[24] = (tmp >> 4) & 0xFF;
  591. is16x16 = HANTRO_TRUE;
  592. }
  593. else
  594. is16x16 = HANTRO_FALSE;
  595. for (i = 4, blockIndex = 0; i--;)
  596. {
  597. /* luma cbp in bits 0-3 */
  598. blockCoded = codedBlockPattern & 0x1;
  599. codedBlockPattern >>= 1;
  600. if (blockCoded)
  601. {
  602. for (j = 4; j--; blockIndex++)
  603. {
  604. nc = (i32)DetermineNc(pMb, blockIndex, pResidual->totalCoeff);
  605. if (is16x16)
  606. {
  607. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData,
  608. level[blockIndex] + 1, nc, 15);
  609. pResidual->coeffMap[blockIndex] = tmp >> 15;
  610. }
  611. else
  612. {
  613. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData,
  614. level[blockIndex], nc, 16);
  615. pResidual->coeffMap[blockIndex] = tmp >> 16;
  616. }
  617. if ((tmp & 0xF) != HANTRO_OK)
  618. return(tmp);
  619. pResidual->totalCoeff[blockIndex] = (tmp >> 4) & 0xFF;
  620. }
  621. }
  622. else
  623. blockIndex += 4;
  624. }
  625. /* chroma DC block are at indices 25 and 26 */
  626. blockCoded = codedBlockPattern & 0x3;
  627. if (blockCoded)
  628. {
  629. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData, level[25], -1, 4);
  630. if ((tmp & 0xF) != HANTRO_OK)
  631. return(tmp);
  632. pResidual->totalCoeff[25] = (tmp >> 4) & 0xFF;
  633. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData, level[25]+4, -1, 4);
  634. if ((tmp & 0xF) != HANTRO_OK)
  635. return(tmp);
  636. pResidual->totalCoeff[26] = (tmp >> 4) & 0xFF;
  637. }
  638. /* chroma AC */
  639. blockCoded = codedBlockPattern & 0x2;
  640. if (blockCoded)
  641. {
  642. for (i = 8; i--;blockIndex++)
  643. {
  644. nc = (i32)DetermineNc(pMb, blockIndex, pResidual->totalCoeff);
  645. tmp = h264bsdDecodeResidualBlockCavlc(pStrmData,
  646. level[blockIndex] + 1, nc, 15);
  647. if ((tmp & 0xF) != HANTRO_OK)
  648. return(tmp);
  649. pResidual->totalCoeff[blockIndex] = (tmp >> 4) & 0xFF;
  650. pResidual->coeffMap[blockIndex] = (tmp >> 15);
  651. }
  652. }
  653. return(HANTRO_OK);
  654. }
  655. #endif
  656. /*------------------------------------------------------------------------------
  657. Function: DetermineNc
  658. Functional description:
  659. Returns the nC of a block.
  660. ------------------------------------------------------------------------------*/
  661. #ifdef H264DEC_OMXDL
  662. u32 DetermineNc(mbStorage_t *pMb, u32 blockIndex, u8 *pTotalCoeff)
  663. #else
  664. u32 DetermineNc(mbStorage_t *pMb, u32 blockIndex, i16 *pTotalCoeff)
  665. #endif
  666. {
  667. /*lint -e702 */
  668. /* Variables */
  669. u32 tmp;
  670. i32 n;
  671. const neighbour_t *neighbourA, *neighbourB;
  672. u8 neighbourAindex, neighbourBindex;
  673. /* Code */
  674. ASSERT(blockIndex < 24);
  675. /* if neighbour block belongs to current macroblock totalCoeff array
  676. * mbStorage has not been set/updated yet -> use pTotalCoeff */
  677. neighbourA = h264bsdNeighbour4x4BlockA(blockIndex);
  678. neighbourB = h264bsdNeighbour4x4BlockB(blockIndex);
  679. neighbourAindex = neighbourA->index;
  680. neighbourBindex = neighbourB->index;
  681. if (neighbourA->mb == MB_CURR && neighbourB->mb == MB_CURR)
  682. {
  683. n = (pTotalCoeff[neighbourAindex] +
  684. pTotalCoeff[neighbourBindex] + 1)>>1;
  685. }
  686. else if (neighbourA->mb == MB_CURR)
  687. {
  688. n = pTotalCoeff[neighbourAindex];
  689. if (h264bsdIsNeighbourAvailable(pMb, pMb->mbB))
  690. {
  691. n = (n + pMb->mbB->totalCoeff[neighbourBindex] + 1) >> 1;
  692. }
  693. }
  694. else if (neighbourB->mb == MB_CURR)
  695. {
  696. n = pTotalCoeff[neighbourBindex];
  697. if (h264bsdIsNeighbourAvailable(pMb, pMb->mbA))
  698. {
  699. n = (n + pMb->mbA->totalCoeff[neighbourAindex] + 1) >> 1;
  700. }
  701. }
  702. else
  703. {
  704. n = tmp = 0;
  705. if (h264bsdIsNeighbourAvailable(pMb, pMb->mbA))
  706. {
  707. n = pMb->mbA->totalCoeff[neighbourAindex];
  708. tmp = 1;
  709. }
  710. if (h264bsdIsNeighbourAvailable(pMb, pMb->mbB))
  711. {
  712. if (tmp)
  713. n = (n + pMb->mbB->totalCoeff[neighbourBindex] + 1) >> 1;
  714. else
  715. n = pMb->mbB->totalCoeff[neighbourBindex];
  716. }
  717. }
  718. return((u32)n);
  719. /*lint +e702 */
  720. }
  721. /*------------------------------------------------------------------------------
  722. Function: CbpIntra16x16
  723. Functional description:
  724. Returns the coded block pattern for intra 16x16 macroblock.
  725. ------------------------------------------------------------------------------*/
  726. u32 CbpIntra16x16(mbType_e mbType)
  727. {
  728. /* Variables */
  729. u32 cbp;
  730. u32 tmp;
  731. /* Code */
  732. ASSERT(mbType >= I_16x16_0_0_0 && mbType <= I_16x16_3_2_1);
  733. if (mbType >= I_16x16_0_0_1)
  734. cbp = 15;
  735. else
  736. cbp = 0;
  737. /* tmp is 0 for I_16x16_0_0_0 mb type */
  738. /* ignore lint warning on arithmetic on enum's */
  739. tmp = /*lint -e(656)*/(mbType - I_16x16_0_0_0) >> 2;
  740. if (tmp > 2)
  741. tmp -= 3;
  742. cbp += tmp << 4;
  743. return(cbp);
  744. }
  745. /*------------------------------------------------------------------------------
  746. Function: h264bsdPredModeIntra16x16
  747. Functional description:
  748. Returns the prediction mode for intra 16x16 macroblock.
  749. ------------------------------------------------------------------------------*/
  750. u32 h264bsdPredModeIntra16x16(mbType_e mbType)
  751. {
  752. /* Variables */
  753. u32 tmp;
  754. /* Code */
  755. ASSERT(mbType >= I_16x16_0_0_0 && mbType <= I_16x16_3_2_1);
  756. /* tmp is 0 for I_16x16_0_0_0 mb type */
  757. /* ignore lint warning on arithmetic on enum's */
  758. tmp = /*lint -e(656)*/(mbType - I_16x16_0_0_0);
  759. return(tmp & 0x3);
  760. }
  761. /*------------------------------------------------------------------------------
  762. Function: h264bsdDecodeMacroblock
  763. Functional description:
  764. Decode one macroblock and write into output image.
  765. Inputs:
  766. pMb pointer to macroblock specific information
  767. mbLayer pointer to current macroblock data from stream
  768. currImage pointer to output image
  769. dpb pointer to decoded picture buffer
  770. qpY pointer to slice QP
  771. mbNum current macroblock number
  772. constrainedIntraPred flag specifying if neighbouring inter
  773. macroblocks are used in intra prediction
  774. Outputs:
  775. pMb structure is updated with current macroblock
  776. currImage decoded macroblock is written into output image
  777. Returns:
  778. HANTRO_OK success
  779. HANTRO_NOK error in macroblock decoding
  780. ------------------------------------------------------------------------------*/
  781. u32 h264bsdDecodeMacroblock(mbStorage_t *pMb, macroblockLayer_t *pMbLayer,
  782. image_t *currImage, dpbStorage_t *dpb, i32 *qpY, u32 mbNum,
  783. u32 constrainedIntraPredFlag, u8* data)
  784. {
  785. /* Variables */
  786. u32 i, tmp;
  787. mbType_e mbType;
  788. #ifdef H264DEC_OMXDL
  789. const u8 *pSrc;
  790. #endif
  791. /* Code */
  792. ASSERT(pMb);
  793. ASSERT(pMbLayer);
  794. ASSERT(currImage);
  795. ASSERT(qpY && *qpY < 52);
  796. ASSERT(mbNum < currImage->width*currImage->height);
  797. mbType = pMbLayer->mbType;
  798. pMb->mbType = mbType;
  799. pMb->decoded++;
  800. h264bsdSetCurrImageMbPointers(currImage, mbNum);
  801. if (mbType == I_PCM)
  802. {
  803. u8 *pData = (u8*)data;
  804. #ifdef H264DEC_OMXDL
  805. u8 *tot = pMb->totalCoeff;
  806. #else
  807. i16 *tot = pMb->totalCoeff;
  808. #endif
  809. i32 *lev = pMbLayer->residual.level[0];
  810. pMb->qpY = 0;
  811. /* if decoded flag > 1 -> mb has already been successfully decoded and
  812. * written to output -> do not write again */
  813. if (pMb->decoded > 1)
  814. {
  815. for (i = 24; i--;)
  816. *tot++ = 16;
  817. return HANTRO_OK;
  818. }
  819. for (i = 24; i--;)
  820. {
  821. *tot++ = 16;
  822. for (tmp = 16; tmp--;)
  823. *pData++ = (u8)(*lev++);
  824. }
  825. h264bsdWriteMacroblock(currImage, (u8*)data);
  826. return(HANTRO_OK);
  827. }
  828. else
  829. {
  830. #ifdef H264DEC_OMXDL
  831. if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTER)
  832. {
  833. tmp = h264bsdInterPrediction(pMb, pMbLayer, dpb, mbNum,
  834. currImage, (u8*)data);
  835. if (tmp != HANTRO_OK) return (tmp);
  836. }
  837. #endif
  838. if (mbType != P_Skip)
  839. {
  840. H264SwDecMemcpy(pMb->totalCoeff,
  841. pMbLayer->residual.totalCoeff,
  842. 27*sizeof(*pMb->totalCoeff));
  843. /* update qpY */
  844. if (pMbLayer->mbQpDelta)
  845. {
  846. *qpY = *qpY + pMbLayer->mbQpDelta;
  847. if (*qpY < 0) *qpY += 52;
  848. else if (*qpY >= 52) *qpY -= 52;
  849. }
  850. pMb->qpY = (u32)*qpY;
  851. #ifdef H264DEC_OMXDL
  852. pSrc = pMbLayer->residual.posCoefBuf;
  853. if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTER)
  854. {
  855. OMXResult res;
  856. u8 *p;
  857. u8 *totalCoeff = pMb->totalCoeff;
  858. for (i = 0; i < 16; i++, totalCoeff++)
  859. {
  860. p = data + lumaIndex[i];
  861. if (*totalCoeff)
  862. {
  863. res = omxVCM4P10_DequantTransformResidualFromPairAndAdd(
  864. &pSrc, p, 0, p, 16, 16, *qpY, *totalCoeff);
  865. if (res != OMX_Sts_NoErr)
  866. return (HANTRO_NOK);
  867. }
  868. }
  869. }
  870. else if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTRA4x4)
  871. {
  872. tmp = ProcessIntra4x4Residual(pMb,
  873. data,
  874. constrainedIntraPredFlag,
  875. pMbLayer,
  876. &pSrc,
  877. currImage);
  878. if (tmp != HANTRO_OK)
  879. return (tmp);
  880. }
  881. else if (h264bsdMbPartPredMode(mbType) == PRED_MODE_INTRA16x16)
  882. {
  883. tmp = ProcessIntra16x16Residual(pMb,
  884. data,
  885. constrainedIntraPredFlag,
  886. pMbLayer->mbPred.intraChromaPredMode,
  887. &pSrc,
  888. currImage);
  889. if (tmp != HANTRO_OK)
  890. return (tmp);
  891. }
  892. tmp = ProcessChromaResidual(pMb, data, &pSrc);
  893. #else
  894. tmp = ProcessResidual(pMb, pMbLayer->residual.level,
  895. pMbLayer->residual.coeffMap);
  896. #endif
  897. if (tmp != HANTRO_OK)
  898. return (tmp);
  899. }
  900. else
  901. {
  902. H264SwDecMemset(pMb->totalCoeff, 0, 27*sizeof(*pMb->totalCoeff));
  903. pMb->qpY = (u32)*qpY;
  904. }
  905. #ifdef H264DEC_OMXDL
  906. /* if decoded flag > 1 -> mb has already been successfully decoded and
  907. * written to output -> do not write again */
  908. if (pMb->decoded > 1)
  909. return HANTRO_OK;
  910. h264bsdWriteMacroblock(currImage, data);
  911. #else
  912. if (h264bsdMbPartPredMode(mbType) != PRED_MODE_INTER)
  913. {
  914. tmp = h264bsdIntraPrediction(pMb, pMbLayer, currImage, mbNum,
  915. constrainedIntraPredFlag, (u8*)data);
  916. if (tmp != HANTRO_OK) return (tmp);
  917. }
  918. else
  919. {
  920. tmp = h264bsdInterPrediction(pMb, pMbLayer, dpb, mbNum,
  921. currImage, (u8*)data);
  922. if (tmp != HANTRO_OK) return (tmp);
  923. }
  924. #endif
  925. }
  926. return HANTRO_OK;
  927. }
  928. #ifdef H264DEC_OMXDL
  929. /*------------------------------------------------------------------------------
  930. Function: ProcessChromaResidual
  931. Functional description:
  932. Process the residual data of chroma with
  933. inverse quantization and inverse transform.
  934. ------------------------------------------------------------------------------*/
  935. u32 ProcessChromaResidual(mbStorage_t *pMb, u8 *data, const u8 **pSrc )
  936. {
  937. u32 i;
  938. u32 chromaQp;
  939. i16 *pDc;
  940. i16 dc[4 + 4] = {0,0,0,0,0,0,0,0};
  941. u8 *totalCoeff;
  942. OMXResult result;
  943. u8 *p;
  944. /* chroma DC processing. First chroma dc block is block with index 25 */
  945. chromaQp =
  946. h264bsdQpC[CLIP3(0, 51, (i32)pMb->qpY + pMb->chromaQpIndexOffset)];
  947. if (pMb->totalCoeff[25])
  948. {
  949. pDc = dc;
  950. result = omxVCM4P10_TransformDequantChromaDCFromPair(
  951. pSrc,
  952. pDc,
  953. (i32)chromaQp);
  954. if (result != OMX_Sts_NoErr)
  955. return (HANTRO_NOK);
  956. }
  957. if (pMb->totalCoeff[26])
  958. {
  959. pDc = dc+4;
  960. result = omxVCM4P10_TransformDequantChromaDCFromPair(
  961. pSrc,
  962. pDc,
  963. (i32)chromaQp);
  964. if (result != OMX_Sts_NoErr)
  965. return (HANTRO_NOK);
  966. }
  967. pDc = dc;
  968. totalCoeff = pMb->totalCoeff + 16;
  969. for (i = 0; i < 8; i++, pDc++, totalCoeff++)
  970. {
  971. /* chroma prediction */
  972. if (*totalCoeff || *pDc)
  973. {
  974. p = data + chromaIndex[i];
  975. result = omxVCM4P10_DequantTransformResidualFromPairAndAdd(
  976. pSrc,
  977. p,
  978. pDc,
  979. p,
  980. 8,
  981. 8,
  982. (i32)chromaQp,
  983. *totalCoeff);
  984. if (result != OMX_Sts_NoErr)
  985. return (HANTRO_NOK);
  986. }
  987. }
  988. return(HANTRO_OK);
  989. }
  990. /*------------------------------------------------------------------------------
  991. Function: ProcessIntra16x16Residual
  992. Functional description:
  993. Process the residual data of luma with
  994. inverse quantization and inverse transform.
  995. ------------------------------------------------------------------------------*/
  996. u32 ProcessIntra16x16Residual(mbStorage_t *pMb,
  997. u8 *data,
  998. u32 constrainedIntraPred,
  999. u32 intraChromaPredMode,
  1000. const u8** pSrc,
  1001. image_t *image)
  1002. {
  1003. u32 i;
  1004. i16 *pDc;
  1005. i16 dc[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  1006. u8 *totalCoeff;
  1007. OMXResult result;
  1008. u8 *p;
  1009. totalCoeff = pMb->totalCoeff;
  1010. if (totalCoeff[24])
  1011. {
  1012. pDc = dc;
  1013. result = omxVCM4P10_TransformDequantLumaDCFromPair(
  1014. pSrc,
  1015. pDc,
  1016. (i32)pMb->qpY);
  1017. if (result != OMX_Sts_NoErr)
  1018. return (HANTRO_NOK);
  1019. }
  1020. /* Intra 16x16 pred */
  1021. if (h264bsdIntra16x16Prediction(pMb, data, image->luma,
  1022. image->width*16, constrainedIntraPred) != HANTRO_OK)
  1023. return(HANTRO_NOK);
  1024. for (i = 0; i < 16; i++, totalCoeff++)
  1025. {
  1026. p = data + lumaIndex[i];
  1027. pDc = &dc[dcCoeffIndex[i]];
  1028. if (*totalCoeff || *pDc)
  1029. {
  1030. result = omxVCM4P10_DequantTransformResidualFromPairAndAdd(
  1031. pSrc,
  1032. p,
  1033. pDc,
  1034. p,
  1035. 16,
  1036. 16,
  1037. (i32)pMb->qpY,
  1038. *totalCoeff);
  1039. if (result != OMX_Sts_NoErr)
  1040. return (HANTRO_NOK);
  1041. }
  1042. }
  1043. if (h264bsdIntraChromaPrediction(pMb, data + 256,
  1044. image,
  1045. intraChromaPredMode,
  1046. constrainedIntraPred) != HANTRO_OK)
  1047. return(HANTRO_NOK);
  1048. return HANTRO_OK;
  1049. }
  1050. /*------------------------------------------------------------------------------
  1051. Function: ProcessIntra4x4Residual
  1052. Functional description:
  1053. Process the residual data of luma with
  1054. inverse quantization and inverse transform.
  1055. ------------------------------------------------------------------------------*/
  1056. u32 ProcessIntra4x4Residual(mbStorage_t *pMb,
  1057. u8 *data,
  1058. u32 constrainedIntraPred,
  1059. macroblockLayer_t *mbLayer,
  1060. const u8 **pSrc,
  1061. image_t *image)
  1062. {
  1063. u32 i;
  1064. u8 *totalCoeff;
  1065. OMXResult result;
  1066. u8 *p;
  1067. totalCoeff = pMb->totalCoeff;
  1068. for (i = 0; i < 16; i++, totalCoeff++)
  1069. {
  1070. p = data + lumaIndex[i];
  1071. if (h264bsdIntra4x4Prediction(pMb, p, mbLayer, image->luma,
  1072. image->width*16, constrainedIntraPred, i) != HANTRO_OK)
  1073. return(HANTRO_NOK);
  1074. if (*totalCoeff)
  1075. {
  1076. result = omxVCM4P10_DequantTransformResidualFromPairAndAdd(
  1077. pSrc,
  1078. p,
  1079. NULL,
  1080. p,
  1081. 16,
  1082. 16,
  1083. (i32)pMb->qpY,
  1084. *totalCoeff);
  1085. if (result != OMX_Sts_NoErr)
  1086. return (HANTRO_NOK);
  1087. }
  1088. }
  1089. if (h264bsdIntraChromaPrediction(pMb, data + 256,
  1090. image,
  1091. mbLayer->mbPred.intraChromaPredMode,
  1092. constrainedIntraPred) != HANTRO_OK)
  1093. return(HANTRO_NOK);
  1094. return HANTRO_OK;
  1095. }
  1096. #else /* H264DEC_OMXDL */
  1097. /*------------------------------------------------------------------------------
  1098. Function: ProcessResidual
  1099. Functional description:
  1100. Process the residual data of one macroblock with
  1101. inverse quantization and inverse transform.
  1102. ------------------------------------------------------------------------------*/
  1103. u32 ProcessResidual(mbStorage_t *pMb, i32 residualLevel[][16], u32 *coeffMap)
  1104. {
  1105. /* Variables */
  1106. u32 i;
  1107. u32 chromaQp;
  1108. i32 (*blockData)[16];
  1109. i32 (*blockDc)[16];
  1110. i16 *totalCoeff;
  1111. i32 *chromaDc;
  1112. const u32 *dcCoeffIdx;
  1113. /* Code */
  1114. ASSERT(pMb);
  1115. ASSERT(residualLevel);
  1116. /* set pointers to DC coefficient blocks */
  1117. blockDc = residualLevel + 24;
  1118. blockData = residualLevel;
  1119. totalCoeff = pMb->totalCoeff;
  1120. if (h264bsdMbPartPredMode(pMb->mbType) == PRED_MODE_INTRA16x16)
  1121. {
  1122. if (totalCoeff[24])
  1123. {
  1124. h264bsdProcessLumaDc(*blockDc, pMb->qpY);
  1125. }
  1126. dcCoeffIdx = dcCoeffIndex;
  1127. for (i = 16; i--; blockData++, totalCoeff++, coeffMap++)
  1128. {
  1129. /* set dc coefficient of luma block */
  1130. (*blockData)[0] = (*blockDc)[*dcCoeffIdx++];
  1131. if ((*blockData)[0] || *totalCoeff)
  1132. {
  1133. if (h264bsdProcessBlock(*blockData, pMb->qpY, 1, *coeffMap) !=
  1134. HANTRO_OK)
  1135. return(HANTRO_NOK);
  1136. }
  1137. else
  1138. MARK_RESIDUAL_EMPTY(*blockData);
  1139. }
  1140. }
  1141. else
  1142. {
  1143. for (i = 16; i--; blockData++, totalCoeff++, coeffMap++)
  1144. {
  1145. if (*totalCoeff)
  1146. {
  1147. if (h264bsdProcessBlock(*blockData, pMb->qpY, 0, *coeffMap) !=
  1148. HANTRO_OK)
  1149. return(HANTRO_NOK);
  1150. }
  1151. else
  1152. MARK_RESIDUAL_EMPTY(*blockData);
  1153. }
  1154. }
  1155. /* chroma DC processing. First chroma dc block is block with index 25 */
  1156. chromaQp =
  1157. h264bsdQpC[CLIP3(0, 51, (i32)pMb->qpY + pMb->chromaQpIndexOffset)];
  1158. if (pMb->totalCoeff[25] || pMb->totalCoeff[26])
  1159. h264bsdProcessChromaDc(residualLevel[25], chromaQp);
  1160. chromaDc = residualLevel[25];
  1161. for (i = 8; i--; blockData++, totalCoeff++, coeffMap++)
  1162. {
  1163. /* set dc coefficient of chroma block */
  1164. (*blockData)[0] = *chromaDc++;
  1165. if ((*blockData)[0] || *totalCoeff)
  1166. {
  1167. if (h264bsdProcessBlock(*blockData, chromaQp, 1,*coeffMap) !=
  1168. HANTRO_OK)
  1169. return(HANTRO_NOK);
  1170. }
  1171. else
  1172. MARK_RESIDUAL_EMPTY(*blockData);
  1173. }
  1174. return(HANTRO_OK);
  1175. }
  1176. #endif /* H264DEC_OMXDL */
  1177. /*------------------------------------------------------------------------------
  1178. Function: h264bsdSubMbPartMode
  1179. Functional description:
  1180. Returns the macroblock's sub-partition mode.
  1181. ------------------------------------------------------------------------------*/
  1182. subMbPartMode_e h264bsdSubMbPartMode(subMbType_e subMbType)
  1183. {
  1184. /* Variables */
  1185. /* Code */
  1186. ASSERT(subMbType < 4);
  1187. return((subMbPartMode_e)subMbType);
  1188. }