Simplify bitstream and pixel format handling #154
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This series of commits modifies and simplifies the bitstream. Since xdec, ydec, bit depth and number of planes is derived from the pixel format (e.g. "yuv420p" -> 8 bits/pixel, xdec = ydec = {0,1,1}, planes = 3) it's much simpler to simply send out a single unsigned integer describing the pixel format code.
Granted, this limits the total amount of pixel formats ever supported to 254 (255 is used as an error return code), however it's unlikely that any encoder can support 254 completely different formats.
An array was used to look up and store all different parameters of a pixel format, with it's order taken from the example_encoder file which looks up the pixel format of a raw y4m file.
This commit reduces the total amount of data that needs to get sent for the header by 7 bytes. While this is unlikely to have a big impact on filesize, even at low bitrates, this will make the job of parsing the bitstream easier.