- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All:
Now i am doing a project, using Intel QSV H264 encoder, the encoded data will be transmitted to webrtc,
webrtc will change the bitrate according to the coding quality(and other factors).
but, In CBR mode, The h264 Per-slice QP (Quantizer Parameter) is always zero. QP in each macroblock.
webrtc can't read per-MB's QP. webrtc can only read QP in slice header.
I need to packet QP into slice header, In CBR mode. what should i do?
- Tags:
- Development Tools
- Graphics
- Intel® Media SDK
- Intel® Media Server Studio
- Media Processing
- Optimization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry for slow reply, I missed your update above.
You can ignore info posted at https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#example-3-external-brc-pseudo-code. In the first step, please instead just do something like:
mfxExtCodingOption2 co2;
co2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
co2.Header.BufferSz = sizeof(mfxExtCodingOption2);
co2.ExtBRC = MFX_CODINGOPTION_ON;
You can test it quickly by running sample_encode with "-extbrc:implicit" option:
This ExtBRC feature means that BRC is done on SW level (not inside HW as it's done in regular cases). And this ExtBRC feature in fact has two implementations: one is inside MediaSDK run-time library (libmfxhw64.dll) ,the other one is on application level (on sample_encode level as an example of how applications can write their own BRC). Applications which are fine with MSDK internal implementation of ExtBRC can just do "co2.ExtBRC = MFX_CODINGOPTION_ON;" (it matches -extbrc:implicit), if application wants to introduce own BRC implementation (which actually can be copy/paste code from sample_encode's BRC with some tuning), it needs to follow https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#example-3-external-brc-pseudo-code (it matches "-extbrc:on").
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As far as I remember MB QP is not enabled by default. Can you please :
1) share encoder init parameters( ideally, collected by mediasdk tracer)
2) share example of encoded bitstream
3) try to reproduce the issue with sample_encode? I mean will you be able to get a stream with macroblock QPs changing within one frame.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my sdk version is "Intel(R) Media SDK 2019 R1"
1), sample code as attachment "simple_encode.cpp"
2), sample bitstream as attachment "2.h264"
3), yes. i was use simple_encode.
this is In CBR Mode.
QP of each macroblock is different, and i can only get the slice header qp(slice_qp_delta), but it is always 0.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which HW and driver version do you have?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's clear about HW versions, thanks. But you described MSDK developer package version, not driver. Please send driver version (from Device Manager).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i7-5500U CPU@2.40GHz--------6.1.7600.16385
Intel (R) HD Graphics 5500 ---------10.18.14.4206
and
i3-7100 CPU@3.90GHz----------10.0.18362.693
Intel (R) HD Graphics 630--------26.20.100.7262
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We've done an analysis. First of all, my assumption that MBBRC is enabled in this case was wrong. All MB in frames have the same QP. Let's just ignore it because it won't help you.
Indeed, WebRTC has such limitation that it can't read QP in MB:
- Encoded bitstream is sent to ParseBitstream() function (line 495) as shown in file h264_encoder.impl.cc (this will be replaced with mediasdk based encoder) https://webrtc.googlesource.com/src/+/refs/heads/master/modules/video_coding/codecs/h264/h264_encoder_impl.cc
- The ParseBistream is implemented in below file where they try to read the slice header and find the slice_qp_delta https://webrtc.googlesource.com/src/+/refs/heads/master/common_video/h264/h264_bitstream_parser.cc
- And slice QP is calculated using following formula: 26 + init_qp_minus26 (from PPS info) + qp_delta(from above step): int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
From MediaSDK perspective we can't change the logic that qp_offset==0 in slice header.
But there is still a way to resolve your issue. Please use mfxExtBRC feature: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtBRC
You just need to turn mfxExtCodingOption2::ExtBRC option ON . This feature means MediaSDK owns BRC on software level, not inside HW. So MediaSDK writes actual QP into slice header.
Regards,
Dmitry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dmitry E. (Intel) wrote:Hi,
We've done an analysis. First of all, my assumption that MBBRC is enabled in this case was wrong. All MB in frames have the same QP. Let's just ignore it because it won't help you.
Indeed, WebRTC has such limitation that it can't read QP in MB:
- Encoded bitstream is sent to ParseBitstream() function (line 495) as shown in file h264_encoder.impl.cc (this will be replaced with mediasdk based encoder) https://webrtc.googlesource.com/src/+/refs/heads/master/modules/video_co...
- The ParseBistream is implemented in below file where they try to read the slice header and find the slice_qp_delta https://webrtc.googlesource.com/src/+/refs/heads/master/common_video/h26...
- And slice QP is calculated using following formula: 26 + init_qp_minus26 (from PPS info) + qp_delta(from above step): int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
From MediaSDK perspective we can't change the logic that qp_offset==0 in slice header.
But there is still a way to resolve your issue. Please use mfxExtBRC feature: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man...
You just need to turn mfxExtCodingOption2::ExtBRC option ON . This feature means MediaSDK owns BRC on software level, not inside HW. So MediaSDK writes actual QP into slice header.
Regards,
Dmitry
thank you very much.
the mb qp logic is:
[ the first MB QP0=pic_init_qp+26+slice_qp_delta+mb_qp_delta
others MB QPn=(QPm+mb_qp_delta+52)%52 ]
this also means that the logic slice_qp_delta==0 can't be change
And , Now I need a more detailed example about ExtBRC. i want to test if it can work well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dmitry E. (Intel) wrote:Hi,
We've done an analysis. First of all, my assumption that MBBRC is enabled in this case was wrong. All MB in frames have the same QP. Let's just ignore it because it won't help you.
Indeed, WebRTC has such limitation that it can't read QP in MB:
- Encoded bitstream is sent to ParseBitstream() function (line 495) as shown in file h264_encoder.impl.cc (this will be replaced with mediasdk based encoder) https://webrtc.googlesource.com/src/+/refs/heads/master/modules/video_co...
- The ParseBistream is implemented in below file where they try to read the slice header and find the slice_qp_delta https://webrtc.googlesource.com/src/+/refs/heads/master/common_video/h26...
- And slice QP is calculated using following formula: 26 + init_qp_minus26 (from PPS info) + qp_delta(from above step): int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
From MediaSDK perspective we can't change the logic that qp_offset==0 in slice header.
But there is still a way to resolve your issue. Please use mfxExtBRC feature: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man...
You just need to turn mfxExtCodingOption2::ExtBRC option ON . This feature means MediaSDK owns BRC on software level, not inside HW. So MediaSDK writes actual QP into slice header.
Regards,
Dmitry
Hi, I read the doc from
which has the line "frame->QP = <decrease QP>;" .
I still not understand how to do it. can you give a runnable code sample, please ?
thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dmitry E. (Intel) wrote:Hi, I read the doc,
which has line "frame->QP = <increase QP>" that I does not know how to do it.
Can you give a `runnable` code sample, please ?
Thanks in adanvce !
We've done an analysis. First of all, my assumption that MBBRC is enabled in this case was wrong. All MB in frames have the same QP. Let's just ignore it because it won't help you.
Indeed, WebRTC has such limitation that it can't read QP in MB:
- Encoded bitstream is sent to ParseBitstream() function (line 495) as shown in file h264_encoder.impl.cc (this will be replaced with mediasdk based encoder) https://webrtc.googlesource.com/src/+/refs/heads/master/modules/video_co...
- The ParseBistream is implemented in below file where they try to read the slice header and find the slice_qp_delta https://webrtc.googlesource.com/src/+/refs/heads/master/common_video/h26...
- And slice QP is calculated using following formula: 26 + init_qp_minus26 (from PPS info) + qp_delta(from above step): int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
From MediaSDK perspective we can't change the logic that qp_offset==0 in slice header.
But there is still a way to resolve your issue. Please use mfxExtBRC feature: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man...
You just need to turn mfxExtCodingOption2::ExtBRC option ON . This feature means MediaSDK owns BRC on software level, not inside HW. So MediaSDK writes actual QP into slice header.
Regards,
Dmitry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry for slow reply, I missed your update above.
You can ignore info posted at https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#example-3-external-brc-pseudo-code. In the first step, please instead just do something like:
mfxExtCodingOption2 co2;
co2.Header.BufferId = MFX_EXTBUFF_CODING_OPTION2;
co2.Header.BufferSz = sizeof(mfxExtCodingOption2);
co2.ExtBRC = MFX_CODINGOPTION_ON;
You can test it quickly by running sample_encode with "-extbrc:implicit" option:
This ExtBRC feature means that BRC is done on SW level (not inside HW as it's done in regular cases). And this ExtBRC feature in fact has two implementations: one is inside MediaSDK run-time library (libmfxhw64.dll) ,the other one is on application level (on sample_encode level as an example of how applications can write their own BRC). Applications which are fine with MSDK internal implementation of ExtBRC can just do "co2.ExtBRC = MFX_CODINGOPTION_ON;" (it matches -extbrc:implicit), if application wants to introduce own BRC implementation (which actually can be copy/paste code from sample_encode's BRC with some tuning), it needs to follow https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#example-3-external-brc-pseudo-code (it matches "-extbrc:on").
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank u vevry much!!!
if i want to calc the slice_qp. which one is more acurate?
1,average value of all macroblock.
2,median value of all macroblock.
3, weighted average value of all macroblock. and how?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page