- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/src/pjmedia-codec/openh264.cpp
r5045 r5513 164 164 struct SLayerPEncCtx 165 165 { 166 pj_int32_t iDLayerQp;167 SSliceConfig sSliceCfg;166 pj_int32_t iDLayerQp; 167 SSliceArgument sSliceArgument; 168 168 }; 169 169 … … 471 471 472 472 /* Init encoder parameters */ 473 pj_bzero(&eprm, sizeof(eprm));474 eprm.i InputCsp = videoFormatI420;473 oh264_data->enc->GetDefaultParams (&eprm); 474 eprm.iComplexityMode = MEDIUM_COMPLEXITY; 475 475 eprm.sSpatialLayers[0].uiProfileIdc = PRO_BASELINE; 476 476 eprm.iPicWidth = param->enc_fmt.det.vid.size.w; 477 eprm.iUsageType = CAMERA_VIDEO_REAL_TIME; 477 478 eprm.iPicHeight = param->enc_fmt.det.vid.size.h; 478 479 eprm.fMaxFrameRate = (param->enc_fmt.det.vid.fps.num * 479 480 1.0f / 480 481 param->enc_fmt.det.vid.fps.denum); 481 eprm.uiFrameToBeCoded = (unsigned int) -1;482 482 eprm.iTemporalLayerNum = 1; 483 483 eprm.uiIntraPeriod = 0; /* I-Frame interval in frames */ 484 eprm.bEnableSpsPpsIdAddition = (oh264_data->whole? false : true); 484 eprm.eSpsPpsIdStrategy = (oh264_data->whole ? CONSTANT_ID : 485 INCREASING_ID); 485 486 eprm.bEnableFrameCroppingFlag = true; 486 487 eprm.iLoopFilterDisableIdc = 0; … … 505 506 pj_bzero(&elayer_ctx, sizeof (SLayerPEncCtx)); 506 507 elayer_ctx.iDLayerQp = 24; 507 elayer_ctx.sSliceCfg.uiSliceMode = (oh264_data->whole ? 508 SM_SINGLE_SLICE : SM_DYN_SLICE); 509 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceSizeConstraint = param->enc_mtu; 510 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceNum = 1; 511 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[0] = 960; 512 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[1] = 0; 513 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[2] = 0; 514 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[3] = 0; 515 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[4] = 0; 516 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[5] = 0; 517 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[6] = 0; 518 elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[7] = 0; 508 elayer_ctx.sSliceArgument.uiSliceMode = (oh264_data->whole ? 509 SM_SINGLE_SLICE : 510 SM_SIZELIMITED_SLICE); 511 512 /* uiSliceSizeConstraint = uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES */ 513 elayer_ctx.sSliceArgument.uiSliceSizeConstraint = param->enc_mtu - 50; 514 elayer_ctx.sSliceArgument.uiSliceNum = 1; 515 elayer_ctx.sSliceArgument.uiSliceMbNum[0] = 960; 516 elayer_ctx.sSliceArgument.uiSliceMbNum[1] = 0; 517 elayer_ctx.sSliceArgument.uiSliceMbNum[2] = 0; 518 elayer_ctx.sSliceArgument.uiSliceMbNum[3] = 0; 519 elayer_ctx.sSliceArgument.uiSliceMbNum[4] = 0; 520 elayer_ctx.sSliceArgument.uiSliceMbNum[5] = 0; 521 elayer_ctx.sSliceArgument.uiSliceMbNum[6] = 0; 522 elayer_ctx.sSliceArgument.uiSliceMbNum[7] = 0; 519 523 520 524 elayer->iVideoWidth = eprm.iPicWidth; … … 524 528 elayer->iSpatialBitrate = eprm.iTargetBitrate; 525 529 elayer->iDLayerQp = elayer_ctx.iDLayerQp; 526 elayer->sSlice Cfg.uiSliceMode = elayer_ctx.sSliceCfg.uiSliceMode;527 528 memcpy ( &elayer->sSliceCfg,529 &elayer_ctx.sSliceCfg,530 sizeof (SSliceConfig));531 memcpy ( &elayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0],532 &elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum[0],533 sizeof (elayer_ctx.sSliceCfg.sSliceArgument.uiSliceMbNum));530 elayer->sSliceArgument.uiSliceMode = elayer_ctx.sSliceArgument.uiSliceMode; 531 532 memcpy ( &elayer->sSliceArgument, 533 &elayer_ctx.sSliceArgument, 534 sizeof (SSliceArgument)); 535 memcpy ( &elayer->sSliceArgument.uiSliceMbNum[0], 536 &elayer_ctx.sSliceArgument.uiSliceMbNum[0], 537 sizeof (elayer_ctx.sSliceArgument.uiSliceMbNum)); 534 538 535 539 /* Init input picture */ … … 553 557 } 554 558 559 int videoFormat = videoFormatI420; 560 rc = oh264_data->enc->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat); 561 if (rc != cmResultSuccess) { 562 PJ_LOG(4,(THIS_FILE, "SVC encoder SetOption videoFormatI420 failed, " 563 "rc=%d", rc)); 564 return PJMEDIA_CODEC_EFAILED; 565 } 566 555 567 /* 556 568 * Decoder 557 569 */ 558 570 sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); 559 sDecParam.iOutputColorFormat = videoFormatI420;560 571 sDecParam.uiTargetDqLayer = (pj_uint8_t) - 1; 561 sDecParam. uiEcActiveFlag = 1;572 sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; 562 573 sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; 563 574 … … 575 586 PJ_LOG(4,(THIS_FILE, "Decoder initialization failed, rc=%d", rc)); 576 587 return PJMEDIA_CODEC_EFAILED; 577 }578 579 pj_int32_t color_fmt = videoFormatI420;580 rc = oh264_data->dec->SetOption (DECODER_OPTION_DATAFORMAT, &color_fmt);581 if (rc) {582 PJ_LOG(4,(THIS_FILE,583 "Warning: SetOption(DECODER_OPTION_DATAFORMAT) failed, rc=%d",584 rc));585 588 } 586 589 … … 662 665 } 663 666 664 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeSkip) {667 if (oh264_data->bsi.eFrameType == videoFrameTypeSkip) { 665 668 output->size = 0; 666 669 output->type = PJMEDIA_FRAME_TYPE_NONE; … … 682 685 /* Find which layer with biggest payload */ 683 686 oh264_data->ilayer = 0; 684 payload_size = oh264_data->bsi.sLayerInfo[0].iNalLengthInByte[0];687 payload_size = oh264_data->bsi.sLayerInfo[0].pNalLengthInByte[0]; 685 688 for (i=0; i < (unsigned)oh264_data->bsi.iLayerNum; ++i) { 686 689 unsigned j; 687 690 pLayerBsInfo = &oh264_data->bsi.sLayerInfo[i]; 688 691 for (j=0; j < (unsigned)pLayerBsInfo->iNalCount; ++j) { 689 if (pLayerBsInfo-> iNalLengthInByte[j] > (int)payload_size) {690 payload_size = pLayerBsInfo->iNalLengthInByte[j];692 if (pLayerBsInfo->pNalLengthInByte[j] > (int)payload_size) { 693 payload_size = pLayerBsInfo->pNalLengthInByte[j]; 691 694 oh264_data->ilayer = i; 692 695 } … … 704 707 payload_size = 0; 705 708 for (int inal = pLayerBsInfo->iNalCount - 1; inal >= 0; --inal) { 706 payload_size += pLayerBsInfo-> iNalLengthInByte[inal];709 payload_size += pLayerBsInfo->pNalLengthInByte[inal]; 707 710 } 708 711 … … 761 764 output->size = payload_len; 762 765 763 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeIDR) {766 if (oh264_data->bsi.eFrameType == videoFrameTypeIDR) { 764 767 output->bit_info |= PJMEDIA_VID_FRM_KEYFRAME; 765 768 } … … 783 786 oh264_data->enc_frame_size = 0; 784 787 for (int inal = pLayerBsInfo->iNalCount - 1; inal >= 0; --inal) { 785 oh264_data->enc_frame_size += pLayerBsInfo-> iNalLengthInByte[inal];788 oh264_data->enc_frame_size += pLayerBsInfo->pNalLengthInByte[inal]; 786 789 } 787 790 … … 810 813 output->size = payload_len; 811 814 812 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeIDR) {815 if (oh264_data->bsi.eFrameType == videoFrameTypeIDR) { 813 816 output->bit_info |= PJMEDIA_VID_FRM_KEYFRAME; 814 817 }
Note: See TracChangeset
for help on using the changeset viewer.