aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfoo86 <foobaz86@gmail.com>2017-07-10 17:11:40 +0300
committerJames Almer <jamrial@gmail.com>2017-07-18 21:04:58 -0300
commit012620aa1b40b0642e3081871059a1be98411df4 (patch)
tree3967cb2f558b93363756ee302c2e07103fe42f4a
parent902cd30e9b72d3ad5dfe01b27e3dd0928ad88562 (diff)
downloadffmpeg-012620aa1b40b0642e3081871059a1be98411df4.tar.gz
avcodec/dca: avoid using bitstream reader in a non-standard way
Use proper get_bits.h functions instead of directly accessing index. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/dca_core.c12
-rw-r--r--libavcodec/dca_core.h1
-rw-r--r--libavcodec/dca_xll.c2
-rw-r--r--libavcodec/dcadec.h4
4 files changed, 11 insertions, 8 deletions
diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 4a7ea4e3f3..3add9f812b 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -1804,6 +1804,7 @@ int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
if ((ret = init_get_bits8(&s->gb, data, size)) < 0)
return ret;
+ s->gb_in = s->gb;
if ((ret = parse_frame_header(s)) < 0)
return ret;
@@ -1831,7 +1832,6 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset
{
AVCodecContext *avctx = s->avctx;
DCAContext *dca = avctx->priv_data;
- GetBitContext gb = s->gb;
int exss_mask = asset ? asset->extension_mask : 0;
int ret = 0, ext = 0;
@@ -1843,11 +1843,13 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset
ret = parse_xxch_frame(s);
ext = DCA_EXSS_XXCH;
} else if (s->xxch_pos) {
- s->gb.index = s->xxch_pos;
+ s->gb = s->gb_in;
+ skip_bits_long(&s->gb, s->xxch_pos);
ret = parse_xxch_frame(s);
ext = DCA_CSS_XXCH;
} else if (s->xch_pos) {
- s->gb.index = s->xch_pos;
+ s->gb = s->gb_in;
+ skip_bits_long(&s->gb, s->xch_pos);
ret = parse_xch_frame(s);
ext = DCA_CSS_XCH;
}
@@ -1889,8 +1891,8 @@ int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset
s->ext_audio_mask |= DCA_EXSS_X96;
}
} else if (s->x96_pos) {
- s->gb = gb;
- s->gb.index = s->x96_pos;
+ s->gb = s->gb_in;
+ skip_bits_long(&s->gb, s->x96_pos);
if ((ret = parse_x96_frame(s)) < 0) {
if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h
index cce0ffd7b1..10128d1e32 100644
--- a/libavcodec/dca_core.h
+++ b/libavcodec/dca_core.h
@@ -101,6 +101,7 @@ typedef struct DCADSPData {
typedef struct DCACoreDecoder {
AVCodecContext *avctx;
GetBitContext gb;
+ GetBitContext gb_in;
// Bit stream header
int crc_present; ///< CRC present flag
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index 38a1999fc8..d265cab8df 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -1028,7 +1028,7 @@ static int parse_band_data(DCAXllDecoder *s)
return ret;
chs_clear_band_data(s, c, band, seg);
}
- s->gb.index = navi_pos;
+ skip_bits_long(&s->gb, navi_pos - get_bits_count(&s->gb));
}
navi_ptr++;
}
diff --git a/libavcodec/dcadec.h b/libavcodec/dcadec.h
index 456f3c433b..9da8d3b444 100644
--- a/libavcodec/dcadec.h
+++ b/libavcodec/dcadec.h
@@ -88,9 +88,9 @@ static inline int ff_dca_check_crc(AVCodecContext *avctx, GetBitContext *s,
static inline int ff_dca_seek_bits(GetBitContext *s, int p)
{
- if (p < s->index || p > s->size_in_bits)
+ if (p < get_bits_count(s) || p > s->size_in_bits)
return -1;
- s->index = p;
+ skip_bits_long(s, p - get_bits_count(s));
return 0;
}