Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Thread Tools Search this Thread Display Modes
Old 30th August 2012, 14:01   #1  |  Link
Registered User
Join Date: Dec 2008
Posts: 2
Weird last bit in Slice NAL Unit ...

i'm devolopping a transcoder using an encoder / decoder source code,
it's work fine on several stream,
but i found several .h264 file in which i found slices with a really strange bit.

At the end of each slice, the last bit of the last byte is always set to 1 and i don't see any reason for that!
It looks like this bit is never parsed and doesn't contribute in the decoding processing

i see the last MB cabac data, the slice terminating bit, and the end cabac, some stuffing bit (0) and always a 1.....

Have you an idea of what this 1 is ?
alex.buisson is offline   Reply With Quote
Old 30th August 2012, 14:21   #2  |  Link
Join Date: Jan 2002
Posts: 21,922
Can you post a link to a small sample please?
Guest is offline   Reply With Quote
Old 31st August 2012, 07:14   #3  |  Link
Dust Signs
Registered User
Join Date: Jun 2004
Location: Salzburg, Austria
Posts: 219
If you have an Annex B stream, it is very likely that this is part of the trailing bits at the end of the NALU (so that it ends at a whole byte position). If present, it consists of a one bit, followed by as many zero bits as needed to reach a whole byte position. For further information, see 7.4.1, syntax element "rbsp_byte[ i ]", the paragraphs belonging to "rbsp_trailing_bits( )", especially:
Originally Posted by H.264
ii) The next bit consists of a single rbsp_stop_one_bit equal to 1.
iii) When the rbsp_stop_one_bit is not the last bit of a byte-aligned byte, one or more
rbsp_alignment_zero_bit is present to result in byte alignment.
Best regards
Dust Signs
The number you dialed is imaginary. Please turn your phone by 90 and try again
Dust Signs is offline   Reply With Quote
Old 31st August 2012, 08:58   #4  |  Link
Registered User
Join Date: Dec 2008
Posts: 2
A Sample...

i put a sample in https://docs.google.com/open?id=0BxpKFXPCGGNNNWZWSkR2dlpyaDA

at 0x599 in that file you should see "34 21 00 00 00 01 01"
The end of a nalu/slice and the start code of the next nalu.
When i transcode this sample, the encoder rewrite everything bit-exact except the 0x21....
it look like the 0x20 (100000) is the correct value to finish the slice encoding .... the 1 is the end-of-cabac bit ! all others 0 are stuffing.

So why the original stream contain 100001 ?
alex.buisson is offline   Reply With Quote

h264, nalu, slice, syntax

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 00:01.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.