From 5d16fa6c4fa53555d9bb553ba67cdf8ab9dd1d93 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Thu, 22 Jan 2015 13:13:23 +0200 Subject: [PATCH] Add VPS every intra frame. - Just rdo=0 for now. Later this can be extended to be configured separately. --- src/encmain.c | 3 +++ src/encoder.h | 3 +++ src/encoder_state-bitstream.c | 44 +++++++++++++++++------------------ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index 9a63f5ed..c75063aa 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -296,6 +296,9 @@ int main(int argc, char *argv[]) // AUD encoder.aud_enable = (int8_t)encoder.cfg->aud_enable; + // TODO: Add config option for vps_period. + encoder.vps_period = (encoder.cfg->rdo == 0 ? encoder.cfg->intra_period : 0); + encoder.in.file = input; fprintf(stderr, "Input: %s, output: %s\n", cfg->input, cfg->output); diff --git a/src/encoder.h b/src/encoder.h index ad253bf9..64975128 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -142,6 +142,9 @@ typedef struct encoder_control uint8_t max; } pu_depth_inter, pu_depth_intra; + // How often Video Parameter Set is re-sent. + uint32_t vps_period; + } encoder_control; int encoder_control_init(encoder_control *encoder, const config *cfg); diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 763609c0..8db404d2 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -697,32 +697,32 @@ static void encoder_state_write_bitstream_main(encoder_state * const main_state) encoder_state_write_bitstream_aud(main_state); } - if (main_state->global->is_radl_frame) { - // Only write the parameter sets in the first frame. - // TODO: Add option to include parameter sets before intra frames. - if (main_state->global->frame == 0) { - first_nal_in_au = false; + if ((encoder->vps_period > 0 && main_state->global->frame % encoder->vps_period == 0) + || main_state->global->frame == 0) + { + first_nal_in_au = false; - // Video Parameter Set (VPS) - nal_write(stream, NAL_VPS_NUT, 0, 1); - encoder_state_write_bitstream_vid_parameter_set(main_state); - bitstream_align(stream); + // Video Parameter Set (VPS) + nal_write(stream, NAL_VPS_NUT, 0, 1); + encoder_state_write_bitstream_vid_parameter_set(main_state); + bitstream_align(stream); - // Sequence Parameter Set (SPS) - nal_write(stream, NAL_SPS_NUT, 0, 1); - encoder_state_write_bitstream_seq_parameter_set(main_state); - bitstream_align(stream); + // Sequence Parameter Set (SPS) + nal_write(stream, NAL_SPS_NUT, 0, 1); + encoder_state_write_bitstream_seq_parameter_set(main_state); + bitstream_align(stream); - // Picture Parameter Set (PPS) - nal_write(stream, NAL_PPS_NUT, 0, 1); - encoder_state_write_bitstream_pic_parameter_set(main_state); - bitstream_align(stream); + // Picture Parameter Set (PPS) + nal_write(stream, NAL_PPS_NUT, 0, 1); + encoder_state_write_bitstream_pic_parameter_set(main_state); + bitstream_align(stream); + } - // Prefix SEI - nal_write(stream, PREFIX_SEI_NUT, 0, first_nal_in_au); - encoder_state_write_bitstream_prefix_sei_version(main_state); - bitstream_align(stream); - } + // Send Kvazaar version information only in the first frame. + if (main_state->global->frame == 0) { + nal_write(stream, PREFIX_SEI_NUT, 0, first_nal_in_au); + encoder_state_write_bitstream_prefix_sei_version(main_state); + bitstream_align(stream); } {