From 636fa8fbdd1e2155eab65b5fe050d59cc42fb36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Thu, 15 Feb 2018 11:27:05 +0200 Subject: [PATCH] Fix maximum decoded picture buffer size --- src/encoder_state-bitstream.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/encoder_state-bitstream.c b/src/encoder_state-bitstream.c index 94509f3c..8516b06b 100644 --- a/src/encoder_state-bitstream.c +++ b/src/encoder_state-bitstream.c @@ -383,13 +383,15 @@ static void encoder_state_write_bitstream_seq_parameter_set(bitstream_t* stream, //for each layer if (encoder->cfg.gop_lowdelay) { - WRITE_UE(stream, encoder->cfg.ref_frames, "sps_max_dec_pic_buffering"); - WRITE_UE(stream, 0, "sps_num_reorder_pics"); + const int dpb = encoder->cfg.ref_frames; + WRITE_UE(stream, dpb - 1, "sps_max_dec_pic_buffering_minus1"); + WRITE_UE(stream, 0, "sps_max_num_reorder_pics"); } else { - WRITE_UE(stream, encoder->cfg.ref_frames + encoder->cfg.gop_len, "sps_max_dec_pic_buffering"); - WRITE_UE(stream, encoder->cfg.gop_len, "sps_num_reorder_pics"); + const int dpb = MIN(16, encoder->cfg.gop_len); + WRITE_UE(stream, dpb - 1, "sps_max_dec_pic_buffering_minus1"); + WRITE_UE(stream, encoder->cfg.gop_len - 1, "sps_max_num_reorder_pics"); } - WRITE_UE(stream, 0, "sps_max_latency_increase"); + WRITE_UE(stream, 0, "sps_max_latency_increase_plus1"); //end for WRITE_UE(stream, MIN_SIZE-3, "log2_min_coding_block_size_minus3");