Changeset 5405 for pjproject/trunk/pjmedia/src/pjmedia-codec/openh264.cpp
- Timestamp:
- Aug 3, 2016 7:08:07 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/openh264.cpp
r5045 r5405 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 elayer_ctx.sSliceArgument.uiSliceSizeConstraint = param->enc_mtu; 512 elayer_ctx.sSliceArgument.uiSliceNum = 1; 513 elayer_ctx.sSliceArgument.uiSliceMbNum[0] = 960; 514 elayer_ctx.sSliceArgument.uiSliceMbNum[1] = 0; 515 elayer_ctx.sSliceArgument.uiSliceMbNum[2] = 0; 516 elayer_ctx.sSliceArgument.uiSliceMbNum[3] = 0; 517 elayer_ctx.sSliceArgument.uiSliceMbNum[4] = 0; 518 elayer_ctx.sSliceArgument.uiSliceMbNum[5] = 0; 519 elayer_ctx.sSliceArgument.uiSliceMbNum[6] = 0; 520 elayer_ctx.sSliceArgument.uiSliceMbNum[7] = 0; 519 521 520 522 elayer->iVideoWidth = eprm.iPicWidth; … … 524 526 elayer->iSpatialBitrate = eprm.iTargetBitrate; 525 527 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));528 elayer->sSliceArgument.uiSliceMode = elayer_ctx.sSliceArgument.uiSliceMode; 529 530 memcpy ( &elayer->sSliceArgument, 531 &elayer_ctx.sSliceArgument, 532 sizeof (SSliceArgument)); 533 memcpy ( &elayer->sSliceArgument.uiSliceMbNum[0], 534 &elayer_ctx.sSliceArgument.uiSliceMbNum[0], 535 sizeof (elayer_ctx.sSliceArgument.uiSliceMbNum)); 534 536 535 537 /* Init input picture */ … … 553 555 } 554 556 557 int videoFormat = videoFormatI420; 558 rc = oh264_data->enc->SetOption (ENCODER_OPTION_DATAFORMAT, &videoFormat); 559 if (rc != cmResultSuccess) { 560 PJ_LOG(4,(THIS_FILE, "SVC encoder SetOption videoFormatI420 failed, " 561 "rc=%d", rc)); 562 return PJMEDIA_CODEC_EFAILED; 563 } 564 555 565 /* 556 566 * Decoder 557 567 */ 558 568 sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty); 559 sDecParam.iOutputColorFormat = videoFormatI420;560 569 sDecParam.uiTargetDqLayer = (pj_uint8_t) - 1; 561 sDecParam. uiEcActiveFlag = 1;570 sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY; 562 571 sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; 563 572 … … 575 584 PJ_LOG(4,(THIS_FILE, "Decoder initialization failed, rc=%d", rc)); 576 585 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 586 } 586 587 … … 662 663 } 663 664 664 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeSkip) {665 if (oh264_data->bsi.eFrameType == videoFrameTypeSkip) { 665 666 output->size = 0; 666 667 output->type = PJMEDIA_FRAME_TYPE_NONE; … … 682 683 /* Find which layer with biggest payload */ 683 684 oh264_data->ilayer = 0; 684 payload_size = oh264_data->bsi.sLayerInfo[0].iNalLengthInByte[0];685 payload_size = oh264_data->bsi.sLayerInfo[0].pNalLengthInByte[0]; 685 686 for (i=0; i < (unsigned)oh264_data->bsi.iLayerNum; ++i) { 686 687 unsigned j; 687 688 pLayerBsInfo = &oh264_data->bsi.sLayerInfo[i]; 688 689 for (j=0; j < (unsigned)pLayerBsInfo->iNalCount; ++j) { 689 if (pLayerBsInfo-> iNalLengthInByte[j] > (int)payload_size) {690 payload_size = pLayerBsInfo->iNalLengthInByte[j];690 if (pLayerBsInfo->pNalLengthInByte[j] > (int)payload_size) { 691 payload_size = pLayerBsInfo->pNalLengthInByte[j]; 691 692 oh264_data->ilayer = i; 692 693 } … … 704 705 payload_size = 0; 705 706 for (int inal = pLayerBsInfo->iNalCount - 1; inal >= 0; --inal) { 706 payload_size += pLayerBsInfo-> iNalLengthInByte[inal];707 payload_size += pLayerBsInfo->pNalLengthInByte[inal]; 707 708 } 708 709 … … 761 762 output->size = payload_len; 762 763 763 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeIDR) {764 if (oh264_data->bsi.eFrameType == videoFrameTypeIDR) { 764 765 output->bit_info |= PJMEDIA_VID_FRM_KEYFRAME; 765 766 } … … 783 784 oh264_data->enc_frame_size = 0; 784 785 for (int inal = pLayerBsInfo->iNalCount - 1; inal >= 0; --inal) { 785 oh264_data->enc_frame_size += pLayerBsInfo-> iNalLengthInByte[inal];786 oh264_data->enc_frame_size += pLayerBsInfo->pNalLengthInByte[inal]; 786 787 } 787 788 … … 810 811 output->size = payload_len; 811 812 812 if (oh264_data->bsi.e OutputFrameType == videoFrameTypeIDR) {813 if (oh264_data->bsi.eFrameType == videoFrameTypeIDR) { 813 814 output->bit_info |= PJMEDIA_VID_FRM_KEYFRAME; 814 815 }
Note: See TracChangeset
for help on using the changeset viewer.