I am using the h264bitstream command to help me writing an h.264 decoder and i think the implementation of function more_rbsp_data() in h264bitstream_data is wrong. The parser is not detecting PPS with transform_8x8_mode_flag = 1 (nor the remaining PPS syntax elements) due to more_rbsp_data() interpreting that bit as the rsbp_stop_bit. Also, sei messages are not correctly parsed. This is a working implementation:
int more_rbsp_data(h264_stream_t* h, bs_t* bs) {
/* no more data */
if (bs_eof(bs)) return 0;
/* no rbsp_stop_bit yet */
if (bs_peek_u1(bs) == 0) return 1;
/* next bit is 1, is it the rsbp_stop_bit? only if the rest of bits are 0 */
bs_t aux;
bs_clone(&aux, bs);
bs_skip_u1(&aux);
while(!bs_eof(&aux)) {
/* A later bit was 1, it wasn't the rsbp_stop_bit */
if (bs_read_u1(&aux) == 1) return 1;
}
/* All following bits were 0, it was the rsbp_stop_bit */
return 0;
}
I am using the h264bitstream command to help me writing an h.264 decoder and i think the implementation of function more_rbsp_data() in h264bitstream_data is wrong. The parser is not detecting PPS with transform_8x8_mode_flag = 1 (nor the remaining PPS syntax elements) due to more_rbsp_data() interpreting that bit as the rsbp_stop_bit. Also, sei messages are not correctly parsed. This is a working implementation: