why info of h264 svc temporal layer in webrtc doesn't match description in RFC6190?

127 views
Skip to first unread message

13000...@qq.com

unread,
Dec 25, 2019, 4:41:59 AM12/25/19
to discuss-webrtc
RFC6190 makes a specification on Scalable Video Coding,  in section 1.1.3 of RFC6190,  it mentions that using a NAL unit header extension to support SVC support(format shown as below)
```
            +---------------+---------------+---------------+
            |0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |R|I|   PRID    |N| DID |  QID  | TID |U|D|O| RR|
            +---------------+---------------+---------------+
```

it seems that 'tid' represent the temporal layer of current NAL,  to verify this,  I use windows to compile and run webrtc; In H264EncoderImpl::InitEncode( ),  I chagne the code for support enable svc temporal layer

```
//h264_encoder_impl.cc

int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,
                                    const VideoEncoder::Settings& settings) {
.....

    //configurations_[i].num_temporal_layers = codec_.simulcastStream[idx].numberOfTemporalLayers;
    configurations_[i].num_temporal_layers = 3;  //enable svc temporal layer to 3

.....

}
```

Since there a object named 'info'  which includes the infomation of temporal layer after frame encode, so I can compare the value of info.temporal_layer with value of 'tid' to validate;so I add a judgement and breakpoint as below (code with highlight)

```
//h264_encoder_impl.cc

static void RtpFragmentize(EncodedImage* encoded_image,
                           const VideoFrameBuffer& frame_buffer,
                           SFrameBSInfo* info,
                           RTPFragmentationHeader* frag_header) {

         .....

          for (int layer = 0; layer < info->iLayerNum; ++layer) {
          const SLayerBSInfo& layerInfo = info->sLayerInfo[layer];
          // Iterate NAL units making up this layer, noting fragments.
          size_t layer_len = 0;
          for (int nal = 0; nal < layerInfo.iNalCount; ++nal, ++frag) {
                  // Because the sum of all layer lengths, |required_capacity|, fits in a
                  // |size_t|, we know that any indices in-between will not overflow.
                  RTC_DCHECK_GE(layerInfo.pNalLengthInByte[nal], 4);
                  RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 0], start_code[0]);
                  RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 1], start_code[1]);
                  RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 2], start_code[2]);
                  RTC_DCHECK_EQ(layerInfo.pBsBuf[layer_len + 3], start_code[3]);
                  frag_header->fragmentationOffset[frag] =
                        encoded_image->size() + layer_len + sizeof(start_code);
                  frag_header->fragmentationLength[frag] =
                layerInfo.pNalLengthInByte[nal] - sizeof(start_code);
                  layer_len += layerInfo.pNalLengthInByte[nal];
          }
          // Copy the entire layer's data (including start codes).
          memcpy(encoded_image->data() + encoded_image->size(), layerInfo.pBsBuf,
                 layer_len);
          encoded_image->set_size(encoded_image->size() + layer_len);

          // add a judgement and breakpoint
          // after frmae encode, try to compare info.temporal_layer with tid
          RTC_LOG(INFO) << "xxxxxxxxxxxxxxxxxxxxxxxxxxxx temporal layer is " << layerInfo.uiTemporalId;
          if (layerInfo.uiTemporalId != 0) {
            int a;
=>        a = 1;  // add breakpoint here
          }

          .....
}

.....
}

```

then brakpoint was triggered,  log says temporal layer is 2 :
```
(h264_encoder_impl.cc:150): xxxxxxxxxxxxxxxxxxxxxxxxxxxx temporal layer is 2
```

but value 'tid' in nal is 0, anything wrong?

Snipaste_2019-12-24_11-21-38.png








Alexandre GOUAILLARD

unread,
Dec 25, 2019, 12:13:35 PM12/25/19
to discuss...@googlegroups.com
I don't think libwebrtc supports H264 SVC.
At best, it would support what google calls k-SVC, which is a mix of simulcast (for spatial resolutions) and SVC (only for temporal resolutions).

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/98c01e52-681c-4aef-90e9-c217b13b4a7f%40googlegroups.com.


--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

Sergey Silkin

unread,
Dec 27, 2019, 7:01:11 AM12/27/19
to discuss-webrtc
Reply all
Reply to author
Forward
0 new messages