summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Scheel <julian@jusst.de>2010-04-09 18:55:47 +0200
committerJulian Scheel <julian@jusst.de>2010-04-09 18:55:47 +0200
commit89d474eeed64e139e31b68311ff173905142301f (patch)
treed681d7d128de1d1e5e473dd1a8f00bccf53db60f /src
parentfc66d3d7b2375f5c56c7310f04bb941a4bbe1e65 (diff)
downloadxine-lib-89d474eeed64e139e31b68311ff173905142301f.tar.gz
xine-lib-89d474eeed64e139e31b68311ff173905142301f.tar.bz2
skip stuffing bytes
properly skip the emulation_prevention_three_byte in the bitstream, which fixes some glitches which could happen whenever such a stuffing byte was in one of the parsed sections
Diffstat (limited to 'src')
-rw-r--r--src/video_dec/libvdpau/h264_parser.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/video_dec/libvdpau/h264_parser.c b/src/video_dec/libvdpau/h264_parser.c
index bb010a342..75e065c12 100644
--- a/src/video_dec/libvdpau/h264_parser.c
+++ b/src/video_dec/libvdpau/h264_parser.c
@@ -157,6 +157,17 @@ static inline uint32_t bits_read(struct buf_reader *buf)
return bits_read;
}
+/* skips stuffing bytes in the buf_reader */
+static inline void skip_emulation_prevention_three_byte(struct buf_reader *buf)
+{
+ if(buf->cur_pos - buf->buf > 2 &&
+ *(buf->cur_pos-2) == 0x00 &&
+ *(buf->cur_pos-1) == 0x00 &&
+ *buf->cur_pos == 0x03) {
+ buf->cur_pos++;
+ }
+}
+
/*
* read len bits from the buffer and return them
* @return right aligned bits
@@ -179,6 +190,8 @@ static inline uint32_t read_bits(struct buf_reader *buf, int len)
if (buf->cur_offset == 0) {
buf->cur_pos++;
buf->cur_offset = 8;
+
+ skip_emulation_prevention_three_byte(buf);
}
return bits;
}
@@ -187,6 +200,8 @@ static inline uint32_t read_bits(struct buf_reader *buf, int len)
len -= buf->cur_offset;
buf->cur_pos++;
buf->cur_offset = 8;
+
+ skip_emulation_prevention_three_byte(buf);
}
}
return bits;
@@ -259,11 +274,7 @@ struct nal_unit* parse_nal_header(struct buf_reader *buf,
switch (nal->nal_unit_type) {
case NAL_SPS:
- decode_nal(&ibuf.buf, &ibuf.len, buf->cur_pos, buf->len - 1);
- ibuf.cur_pos = ibuf.buf;
-
- parse_sps(&ibuf, &nal->sps);
- free(ibuf.buf);
+ parse_sps(buf, &nal->sps);
break;
case NAL_PPS:
parse_pps(buf, &nal->pps);