Comments (8)
This is probably a side effect of rbsp_to_nal() starting the NAL buffer with a zero byte. I am interpreting the reason for this behaviour to be that the first byte in the resulting NAL is reserved for the NAL header. But write_nal_unit() puts the NAL header first in the RBSP stream before passing it to rbsp_to_nal(), causing the extra zero byte.
If this is the intended behaviour of rbsp_to_nal(), lines 1059-1062 in h264_stream.c which currently do the following:
bs_t* b = bs_new(rbsp_buf, rbsp_size);
/* forbidden_zero_bit */ bs_write_u(b, 1, 0);
bs_write_u(b, 2, nal->nal_ref_idc);
bs_write_u(b, 5, nal->nal_unit_type);
should be changed to instead modify the first byte of the NAL unit resulting from the (later) call to rbsp_to_nal().
from h264bitstream.
@antoneliasson Thank you very much. I manually changed the code as you suggested and it fixed my problem.
from h264bitstream.
Good. Could you please submit a pull request for your change?
from h264bitstream.
@antoneliasson @skirsten This sounds like a serious bug, but I'm not sure I completely understand what the bug is supposed to be.
Per the standard, nals may start with either 0x00 00 00 01 or 0x00 00 01. When writing, h264bitstream always uses the longer form (regardless of what it was when that nal was read in - if it was read in). This is consistent with eg x264 which always writes the longer form.
from h264bitstream.
You are talking about the start code prefix, which can be either 0x00 00 01 or 0x00 00 00 01 (for 16-bit alignment purposes if I remember correctly). The start code prefix must be immediately followed by the NAL Unit header. The bug is that your application inserts a zero byte between the start code prefix and the NAL Unit header.
from h264bitstream.
I wanted to push the changes originally but I deleted the code and forgot about it. Will do now...
Edit: Nevermind I have no clue what I changed...
from h264bitstream.
I stumbled on this too...
I was expecting:
SPS: 00 00 00 01 67 42 00 0a f8 41 a2
PPS: 00 00 00 01 68 ce 38 80
but kept getting:
SPS: 00 67 42 00 0a f8 41 a2
PPS: 00 68 ce 38 80
Anyway, I worked around it by just writing 3 bytes ahead in the buffer then overwriting the first four bytes with the start code. I.e. replace write_nal_unit(stream, buffer, size)
with (write_nal_unit(stream, buffer + 3, size - 3) + 3)
.
from h264bitstream.
I guess there was a confusion between "NAL unit syntax" (7.3.1) and "byte stream NAL unit syntax" (B.1.1). The latter begins with "leading_zero_8bits":
from h264bitstream.
Related Issues (20)
- Exponential golomb encoding fixes HOT 3
- h265bitstream support HOT 6
- libh264bitstream.so.0 file not found HOT 1
- "error while loading shared libraries" when running h264_analyze HOT 1
- No avcc-support
- debug_nal not existent? HOT 1
- Compile command for h264bitstream
- How to recombine base and enhancement layer, splitted using svc_split?
- platform support HOT 1
- Fuzzing with the sample streams leads to lots of crashes HOT 8
- Extract motion vectors HOT 3
- autoreconf: 'configure.ac' or 'configure.in' is require
- Write a h264 stream copy-paste using this library
- SPS scaling list writer assumes 8 and only 8 indices
- segmentation fault in read_slice_layer_rbsp HOT 1
- Missing braces in for loop HOT 1
- Homp
- How do I install & use h264bitstream? HOT 1
- Bug: bs_read_ue compiler-dependent behavior when i==32 HOT 2
- avcc->pps_table is initialised using the SPS count instead of the PPS count HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h264bitstream.