| 49 | } |
| 50 | |
| 51 | int32_t H264EncoderX264Impl::InitEncode(const VideoCodec* inst, |
| 52 | int32_t number_of_cores, |
| 53 | size_t max_payload_size) { |
| 54 | |
| 55 | if (inst == NULL) { |
| 56 | return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 57 | } |
| 58 | if (inst->maxFramerate < 1) { |
| 59 | return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 60 | } |
| 61 | // allow zero to represent an unspecified maxBitRate |
| 62 | if (inst->maxBitrate > 0 && inst->startBitrate > inst->maxBitrate) { |
| 63 | return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 64 | } |
| 65 | if (inst->width < 1 || inst->height < 1) { |
| 66 | return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 67 | } |
| 68 | if (number_of_cores < 1) { |
| 69 | return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
| 70 | } |
| 71 | |
| 72 | int ret_val = Release(); |
| 73 | if (ret_val < 0) { |
| 74 | return ret_val; |
| 75 | } |
| 76 | codec_settings_ = *inst; |
| 77 | /* Get default params for preset/tuning */ |
| 78 | x264_param_t param; |
| 79 | memset(¶m, 0, sizeof(param)); |
| 80 | x264_param_default(¶m); |
| 81 | ret_val = x264_param_default_preset(¶m, "fast", "zerolatency"); |
| 82 | if (ret_val != 0) { |
| 83 | RTC_LOG(LS_ERROR) << "H264EncoderX264Impl::InitEncode() fails to initialize encoder ret_val " << ret_val; |
| 84 | x264_encoder_close(encoder_); |
| 85 | encoder_ = NULL; |
| 86 | return WEBRTC_VIDEO_CODEC_ERROR; |
| 87 | } |
| 88 | |
| 89 | param.i_log_level = X264_LOG_WARNING; |
| 90 | param.i_threads = 1; |
| 91 | param.i_width = inst->width; |
| 92 | param.i_height = inst->height; |
| 93 | param.i_frame_total = 0; |
| 94 | |
| 95 | param.b_sliced_threads = 0; |
| 96 | //param.i_keyint_min = 5000; |
| 97 | param.i_keyint_max = 60; |
| 98 | |
| 99 | /*param.i_bframe = 0; |
| 100 | param.b_open_gop = 0; |
| 101 | param.i_bframe_pyramid = 0; |
| 102 | param.i_bframe_adaptive = X264_B_ADAPT_TRELLIS; |
| 103 | param.i_nal_hrd = 0; |
| 104 | |
| 105 | param.i_fps_den = 1; |
| 106 | param.i_fps_num = inst->maxFramerate; |
| 107 | param.i_timebase_den = 1; |
| 108 | param.i_timebase_num = inst->maxFramerate; |
nothing calls this directly
no outgoing calls
no test coverage detected