Coder Social home page Coder Social logo

Comments (3)

nikohpng avatar nikohpng commented on May 20, 2024

I have same issue.

from libwebrtc.

Meonardo avatar Meonardo commented on May 20, 2024

Hi @nikohpng Can you test this code block below for your case?
I can get the yuv data buffer successfully but still have rendering issue...

I found the MSDK produces NV12(see intel media-sdk manual) pixel format, the mfxFrameData stores the yuv data (see the mfxFrameData definition), change these code to code below see if you can retrieve yuv data.

mfxFrameData frame_data = pOutputSurface->Data;
mfxMemId dxMemId = frame_data.MemId;
mfxFrameInfo frame_info = pOutputSurface->Info;

m_pmfx_allocator_->LockFrame(dxMemId, &frame_data);

// always nv12
int w = frame_info.Width;
int h = frame_info.Height;
int stride_uv = (w + 1) / 2;
uint8_t* data_y = frame_data.Y;
uint8_t* data_u = frame_data.U;
uint8_t* data_v = frame_data.V;

rtc::scoped_refptr<NV12Buffer> nv12_buffer = webrtc::NV12Buffer::Create(w, h);
if (nv12_buffer.get()) {
  libyuv::I420ToNV12(data_y, w, data_u, stride_uv, data_v, stride_uv,
                     nv12_buffer->MutableDataY(),
                     nv12_buffer->StrideY(),
                     nv12_buffer->MutableDataUV(),
                     nv12_buffer->StrideUV(), w, h);

  rtc::scoped_refptr<VideoFrameBuffer> buffer = std::move(nv12_buffer);

  if (callback_) {
    webrtc::VideoFrame decoded_frame(buffer, inputImage.Timestamp(), 0,
                                     webrtc::kVideoRotation_0);
    decoded_frame.set_ntp_time_ms(inputImage.ntp_time_ms_);
    decoded_frame.set_timestamp(inputImage.Timestamp());
    callback_->Decoded(decoded_frame);
  }
}

m_pmfx_allocator_->UnlockFrame(dxMemId, &frame_data);

from libwebrtc.

Meonardo avatar Meonardo commented on May 20, 2024

After calling m_pmfx_allocator_->LockFrame(dxMemId, &frame_data);, the yuv data can be retrieved, but the code above for converting i420ToNV12 is WRONG, please see the correct way for coverting nv12 -> i420.

from libwebrtc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.