diff --git a/test/h264.c b/test/h264.c index 186724b10..2b8168cc2 100644 --- a/test/h264.c +++ b/test/h264.c @@ -635,29 +635,12 @@ static int depack_handle_h264(struct state *st, bool marker, } else if (H264_NALU_STAP_A == h264_hdr.type) { - while (mbuf_get_left(src) >= 2) { - - uint16_t len = ntohs(mbuf_read_u16(src)); - struct h264_nal_header lhdr; - - if (mbuf_get_left(src) < len) - return EBADMSG; - - err = h264_nal_header_decode(&lhdr, src); - if (err) - return err; - - --src->pos; - - err = mbuf_write_mem(st->mb, - st->long_startcode ? nal_seq4 : nal_seq3, - nal_seq_len); - err |= mbuf_write_mem(st->mb, mbuf_buf(src), len); - if (err) - goto out; - - src->pos += len; - } + if (st->long_startcode) + err = h264_stap_decode_annexb_long(st->mb, src); + else + err = h264_stap_decode_annexb(st->mb, src); + if (err) + goto out; } else { DEBUG_WARNING("decode: unknown NAL type %u\n",