oneam / h264bsd

A simple h264 software decoding library
Other
194 stars 52 forks source link

NAL parcer error #10

Closed alexandrmiee closed 2 years ago

alexandrmiee commented 6 years ago

When decoder parce NAL header, it not skip emulation prevention byte.

Test header 00 00 00 01 67 42 C0 1E D9 00 A0 2F F9 70 11 00
00 03 00 01 00 00 03 00 32 0F 16 2E 48 00 00 00 01

oneam commented 6 years ago

Is the emulation prevention byte will work in the start code prefix (first 4 bytes). It's intended to keep decoders from accidentally adding the start code prefix in a regular byte stream.

I'll look in the decoding of the rest of the NAL unit.

Your test header has two lines. Is it intended to be 2 example byte streams or one long example?

alexandrmiee commented 6 years ago

It is one example. I parce h264 video generated from test data

ffmpeg.exe -i test_640x360.h264 -vf scale=320:240 -profile:v baseline -f h264 vv.h264

When decoder get pVuiParameters->numUnitsInTick in h264bsdDecodeVuiParameters function it not skip emulation prevention. In test example in not skip emulation prevention too, but bytes in example data afte shifting by chance that not exist bit of nalHrdParametersPresentFlag.

oneam commented 6 years ago

I just ran through a test using xCode but I can't repeat the problem. Once the code gets to h264bsdDecodeVuiParameters the input pStrmData points to a buffer with all of the emulation prevention bytes stripped out. The timingInfoPresentFlag is set and the VUI values agree with ffprobe (1/50 in the case of test_640x360.h264)

It looks like you're using Windows. I'll try the same test using Visual Studio and see what it says.