MCPcopy Create free account
hub / github.com/cisco/openh264 / DumpDependencyRec

Function DumpDependencyRec

codec/encoder/core/src/encoder.cpp:413–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411 */
412
413extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend,
414 SDqLayer* pDqLayer, bool bSimulCastAVC) {
415 WelsFileHandle* pDumpRecFile = NULL;
416 int32_t iWrittenSize = 0;
417 const char* openMode = bAppend ? "ab" : "wb";
418 SWelsSPS* pSpsTmp = NULL;
419 if (bSimulCastAVC || (kiDid == BASE_DEPENDENCY_ID)) {
420 pSpsTmp = pDqLayer->sLayerInfo.pSpsP;
421 } else {
422 pSpsTmp = & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps);
423 }
424 bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag;
425 SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop;
426
427 if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)
428 return;
429 if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage
430 pDumpRecFile = WelsFopen (kpFileName, openMode);
431 else {
432 char sDependencyRecFileName[16] = {0};
433 WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage
434 pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode);
435 }
436 if (NULL != pDumpRecFile && bAppend)
437 WelsFseek (pDumpRecFile, 0, SEEK_END);
438
439 if (NULL != pDumpRecFile) {
440 int32_t i = 0;
441 int32_t j = 0;
442 const int32_t kiStrideY = pCurPicture->iLineSize[0];
443 const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft +
444 pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel;
445 const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop +
446 pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel;
447 const int32_t kiChromaWidth = kiLumaWidth >> 1;
448 const int32_t kiChromaHeight = kiLumaHeight >> 1;
449 uint8_t* pSrc = NULL;
450 pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) +
451 (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0];
452 for (j = 0; j < kiLumaHeight; ++ j) {
453 iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile);
454 assert (iWrittenSize == kiLumaWidth);
455 if (iWrittenSize < kiLumaWidth) {
456 assert (0); // make no sense for us if writing failed
457 WelsFclose (pDumpRecFile);
458 return;
459 }
460 }
461 for (i = 1; i < I420_PLANES; ++ i) {
462 const int32_t kiStrideUV = pCurPicture->iLineSize[i];
463 pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) :
464 pCurPicture->pData[i];
465 for (j = 0; j < kiChromaHeight; ++ j) {
466 iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile);
467 assert (iWrittenSize == kiChromaWidth);
468 if (iWrittenSize < kiChromaWidth) {
469 assert (0); // make no sense for us if writing failed
470 WelsFclose (pDumpRecFile);

Callers 1

WelsEncoderEncodeExtFunction · 0.85

Calls 5

WelsFopenFunction · 0.85
WelsSnprintfFunction · 0.85
WelsFseekFunction · 0.85
WelsFwriteFunction · 0.85
WelsFcloseFunction · 0.85

Tested by

no test coverage detected