mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
nal: Add the writing of an additional zero_byte before the start code.
Enables the output of spec-compliant byte streams, as the specification notes that an additional zero_byte has to be added under certain circuimstances.
This commit is contained in:
parent
d69f97cb90
commit
4ffdb358ed
|
@ -304,7 +304,7 @@ void encode_one_frame(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_VPS_NUT, 0);
|
encoder->stream->buffer_pos, 0, NAL_VPS_NUT, 0, 1);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
|
|
||||||
// Sequence Parameter Set (SPS)
|
// Sequence Parameter Set (SPS)
|
||||||
|
@ -312,7 +312,7 @@ void encode_one_frame(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_SPS_NUT, 0);
|
encoder->stream->buffer_pos, 0, NAL_SPS_NUT, 0, 1);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
|
|
||||||
// Picture Parameter Set (PPS)
|
// Picture Parameter Set (PPS)
|
||||||
|
@ -320,7 +320,7 @@ void encode_one_frame(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_PPS_NUT, 0);
|
encoder->stream->buffer_pos, 0, NAL_PPS_NUT, 0, 1);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
|
|
||||||
// First slice is IDR
|
// First slice is IDR
|
||||||
|
@ -337,7 +337,7 @@ void encode_one_frame(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_IDR_W_RADL, 0);
|
encoder->stream->buffer_pos, 0, NAL_IDR_W_RADL, 0, 0);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
} else {
|
} else {
|
||||||
cabac_start(&cabac);
|
cabac_start(&cabac);
|
||||||
|
@ -354,7 +354,7 @@ void encode_one_frame(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_TRAIL_R, 0);
|
encoder->stream->buffer_pos, 0, NAL_TRAIL_R, 0, 1);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ static void add_checksum(encoder_control* encoder)
|
||||||
bitstream_align(encoder->stream);
|
bitstream_align(encoder->stream);
|
||||||
bitstream_flush(encoder->stream);
|
bitstream_flush(encoder->stream);
|
||||||
nal_write(encoder->output, encoder->stream->buffer,
|
nal_write(encoder->output, encoder->stream->buffer,
|
||||||
encoder->stream->buffer_pos, 0, NAL_SUFFIT_SEI_NUT, 0);
|
encoder->stream->buffer_pos, 0, NAL_SUFFIT_SEI_NUT, 0, 0);
|
||||||
bitstream_clear_buffer(encoder->stream);
|
bitstream_clear_buffer(encoder->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
/**
|
/**
|
||||||
* \brief Write a Network Abstraction Layer (NAL) packet to the output.
|
* \brief Write a Network Abstraction Layer (NAL) packet to the output.
|
||||||
*/
|
*/
|
||||||
void nal_write(FILE *output, uint8_t *buffer, uint32_t buffer_len, uint8_t nal_ref, uint8_t nal_type, uint8_t temporal_id)
|
void nal_write(FILE *output, uint8_t *buffer, uint32_t buffer_len,
|
||||||
|
uint8_t nal_ref, uint8_t nal_type, uint8_t temporal_id,
|
||||||
|
int long_start_code)
|
||||||
{
|
{
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
@ -46,6 +48,11 @@ void nal_write(FILE *output, uint8_t *buffer, uint32_t buffer_len, uint8_t nal_r
|
||||||
const uint8_t start_code_prefix_one_3bytes = 0x01;
|
const uint8_t start_code_prefix_one_3bytes = 0x01;
|
||||||
const uint8_t zero = 0x00;
|
const uint8_t zero = 0x00;
|
||||||
|
|
||||||
|
// zero_byte (0x00) shall be present in the byte stream NALU of VPS, SPS
|
||||||
|
// and PPS, or the first NALU of an access unit
|
||||||
|
if(long_start_code)
|
||||||
|
fwrite(&zero, 1, 1, output);
|
||||||
|
|
||||||
// start_code_prefix_one_3bytes
|
// start_code_prefix_one_3bytes
|
||||||
fwrite(&zero, 1, 1, output);
|
fwrite(&zero, 1, 1, output);
|
||||||
fwrite(&zero, 1, 1, output);
|
fwrite(&zero, 1, 1, output);
|
||||||
|
|
|
@ -93,7 +93,8 @@ enum {
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// FUNCTIONS
|
// FUNCTIONS
|
||||||
void nal_write(FILE *output, uint8_t *buffer, uint32_t buffer_len,
|
void nal_write(FILE *output, uint8_t *buffer, uint32_t buffer_len,
|
||||||
uint8_t nal_ref, uint8_t nal_type, uint8_t temporal_id);
|
uint8_t nal_ref, uint8_t nal_type, uint8_t temporal_id,
|
||||||
|
int long_start_code);
|
||||||
void picture_checksum(const picture *pic,
|
void picture_checksum(const picture *pic,
|
||||||
unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]);
|
unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue