Fix RBSP issue, where 0x03 should be removed. v5.0.178 v6.0.75#3597
Fix RBSP issue, where 0x03 should be removed. v5.0.178 v6.0.75#3597winlinvip merged 12 commits intoossrs:developfrom
Conversation
…represents any 2 bit pattern: 00, 01, 10, or 11)
|
Thank you for the PR. This PR is an enhancement PR.
|
|
Thank you for your reply. I referred to the following code. https://github.com/mirror/x264/blob/master/common/bitstream.c static uint8_t *nal_escape_c( uint8_t *dst, uint8_t *src, uint8_t *end )
{
if( src < end ) *dst++ = *src++;
if( src < end ) *dst++ = *src++;
while( src < end )
{
if( src[0] <= 0x03 && !dst[-2] && !dst[-1] ) // this
*dst++ = 0x03;
*dst++ = *src++;
}
return dst;
} |
|
There indeed is this logic, that is, if the original data in the video is
|
|
Please add the corresponding utest cases. For the various scenarios mentioned in the specifications, test cases need to be added for verification and testing.
|
@feixintianxia I revisited the code logic, it seems I misunderstood it before, this modification should be fine. Could you please help to add some unit tests? Thanks.
|
|
Nice work! Thank you all @feixintianxia @xiaozhihong @chundonglinlin ! 👍 |
|
I added some utests and found that the boundary conditions were not handled correctly, the following case will fail: VOID TEST(KernelCodecTest, VideoFormatRbspEdge)
{
if (true) {
vector<uint8_t> nalu = {0x00, 0x00, 0x03};
vector<uint8_t> expect = {0x00, 0x00, 0x03};
vector<uint8_t> rbsp(nalu.size());
SrsBuffer b((char*)nalu.data(), nalu.size());
int nb_rbsp = srs_rbsp_remove_emulation_bytes(&b, rbsp);
ASSERT_EQ(nb_rbsp, (int)expect.size());
EXPECT_TRUE(srs_bytes_equals(rbsp.data(), expect.data(), nb_rbsp));
}Fixed by 5e6784c
|
This reverts commit 5b12c27.
ISO_IEC_14496-10-AVC-2012.pdf, page 65 7.4.1.1 Encapsulation of an SODB within an RBSP (informative) ... 00 00 03 xx, the 03 byte should be drop where xx represents any 2 bit pattern: 00, 01, 10, or 11. --------- Co-authored-by: john <hondaxiao@tencent.com> Co-authored-by: chundonglinlin <chundonglinlin@163.com> Co-authored-by: winlin <winlin@vip.126.com>
ISO_IEC_14496-10-AVC-2012.pdf, page 65 7.4.1.1 Encapsulation of an SODB within an RBSP (informative) ... 00 00 03 xx, the 03 byte should be drop where xx represents any 2 bit pattern: 00, 01, 10, or 11. --------- Co-authored-by: john <hondaxiao@tencent.com> Co-authored-by: chundonglinlin <chundonglinlin@163.com> Co-authored-by: winlin <winlin@vip.126.com>
ISO_IEC_14496-10-AVC-2012.pdf, page 65 7.4.1.1 Encapsulation of an SODB within an RBSP (informative) ... 00 00 03 xx, the 03 byte should be drop where xx represents any 2 bit pattern: 00, 01, 10, or 11. --------- Co-authored-by: john <hondaxiao@tencent.com> Co-authored-by: chundonglinlin <chundonglinlin@163.com> Co-authored-by: winlin <winlin@vip.126.com>
I came across the code this pr made changes on, and I don't think it is accurate. Specifically, according to the x264 code referred here, wouldn't the emulated bytes of rbsp should be: and if I understand it right, the emulation removing subroutine would also be incorrect regarding bytes encoded by the x264 encoder ? cc @feixintianxia @xiaozhihong @winlinvip @chundonglinlin @gaod |
ISO_IEC_14496-10-AVC-2012.pdf, page 65
7.4.1.1 Encapsulation of an SODB within an RBSP (informative)
... 00 00 03 xx, the 03 byte should be drop where xx represents any 2 bit pattern: 00, 01, 10, or 11.
Co-authored-by: john hondaxiao@tencent.com
Co-authored-by: chundonglinlin chundonglinlin@163.com