webrtc-sdk / libwebrtc

A C++ wrapper for binary release, mainly used for flutter-webrtc desktop (windows, linux, embedded).
MIT License
382 stars 78 forks source link

Fix gpu decode #38

Open zjzhang-cn opened 2 years ago

zjzhang-cn commented 2 years ago

修复Intel GPU解码问题

cloudwebrtc commented 2 years ago

LGTM

Meonardo commented 2 years ago

尝试用新的代码进行解码, 渲染发现色度不对, 如下图展示: 左边正常 image

zjzhang-cn commented 2 years ago

根据你的图片,应该YUV格式的问题。 你能帮忙跟踪一下 FourCC的数值吗 image

Meonardo commented 2 years ago

一样的, image

zjzhang-cn commented 2 years ago

谢谢, 找到原因了 ,你替换这行代码 libyuv::NV12ToI420(pData->Y, pData->Pitch, pData->UV, pData->Pitch, i420_buffer->MutableDataY(), i420_buffer->StrideY(), i420_buffer->MutableDataU(), i420_buffer->StrideU(), i420_buffer->MutableDataV(), i420_buffer->StrideV(), frame_info.Width, frame_info.Height);

Meonardo commented 2 years ago

找到原因了 ,你替换这行代码

现在色度是准确的👍, 但是我觉这里用 Pitch / 2 作为 src_stride_uv 是没问题的🤔.

zjzhang-cn commented 2 years ago

nv12的uv分量是交错的,所以每行的字节与y分量是一样的。

Meonardo commented 2 years ago

nv12的uv分量是交错的,所以每行的字节与y分量是一样的。

懂了, 我以为是单个 U / V, 多谢指点!

nikohpng commented 1 year ago

在i5-7200u中, gpu为 intel HD Graphics 620 中,解码没问题,编码出现远端查看只渲染一帧画面就卡死了。 Update:

// Finally init the encoder
  sts = m_pmfx_enc_->Init(&m_mfx_enc_params_);
  if (MFX_WRN_PARTIAL_ACCELERATION == sts) {
    sts = MFX_ERR_NONE;
  } else if (MFX_WRN_INCOMPATIBLE_VIDEO_PARAM == sts) {
    RTC_LOG(LS_ERROR) << "Invalid video param detected.";
  } else if (MFX_ERR_NONE != sts) {
    return WEBRTC_VIDEO_CODEC_ERROR;
  }

错误日志如下:

(video_source_sink_controller.cc:89): Pushing SourceSink restrictions: max_fps=60 max_pixel_count=2147483647 target_pixel_count=null resolutions={1280x720}
(msdkvideoencoder.cc:137): InitEncodeOnEncoderThread: maxBitrate:62914framerate:60targetBitRate:62914frame_height:720frame_width:1280
(msdkvideoencoder.cc:295): Invalid video param detected.