summaryrefslogtreecommitdiffstats
path: root/media/ffvpx/libavcodec/flacdec.c
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-10-01 14:34:26 +0200
committerGitHub <noreply@github.com>2018-10-01 14:34:26 +0200
commit79b00fc33b5cb6d56d29b50efac6d62ce3a89018 (patch)
tree77d8179bb3d9d76d9ec4fcfe396a35afcc8f73cd /media/ffvpx/libavcodec/flacdec.c
parentab881a3bf513e591b6cc2966560cdab2b63a0f2a (diff)
parent7d1ee0e5e4958175ccde5d153b025f97a17caeb2 (diff)
downloadUXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar
UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.gz
UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.lz
UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.tar.xz
UXP-79b00fc33b5cb6d56d29b50efac6d62ce3a89018.zip
Merge pull request #801 from trav90/update-from-upstream
Update ffvpx code to 4.0.2
Diffstat (limited to 'media/ffvpx/libavcodec/flacdec.c')
-rw-r--r--media/ffvpx/libavcodec/flacdec.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/media/ffvpx/libavcodec/flacdec.c b/media/ffvpx/libavcodec/flacdec.c
index 3d41a1af7..c8eb45604 100644
--- a/media/ffvpx/libavcodec/flacdec.c
+++ b/media/ffvpx/libavcodec/flacdec.c
@@ -220,20 +220,27 @@ static int get_metadata_size(const uint8_t *buf, int buf_size)
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
{
+ GetBitContext gb = s->gb;
int i, tmp, partition, method_type, rice_order;
int rice_bits, rice_esc;
int samples;
- method_type = get_bits(&s->gb, 2);
+ method_type = get_bits(&gb, 2);
+ rice_order = get_bits(&gb, 4);
+
+ samples = s->blocksize >> rice_order;
+ rice_bits = 4 + method_type;
+ rice_esc = (1 << rice_bits) - 1;
+
+ decoded += pred_order;
+ i = pred_order;
+
if (method_type > 1) {
av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
method_type);
return AVERROR_INVALIDDATA;
}
- rice_order = get_bits(&s->gb, 4);
-
- samples= s->blocksize >> rice_order;
if (samples << rice_order != s->blocksize) {
av_log(s->avctx, AV_LOG_ERROR, "invalid rice order: %i blocksize %i\n",
rice_order, s->blocksize);
@@ -246,21 +253,16 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
return AVERROR_INVALIDDATA;
}
- rice_bits = 4 + method_type;
- rice_esc = (1 << rice_bits) - 1;
-
- decoded += pred_order;
- i= pred_order;
for (partition = 0; partition < (1 << rice_order); partition++) {
- tmp = get_bits(&s->gb, rice_bits);
+ tmp = get_bits(&gb, rice_bits);
if (tmp == rice_esc) {
- tmp = get_bits(&s->gb, 5);
+ tmp = get_bits(&gb, 5);
for (; i < samples; i++)
- *decoded++ = get_sbits_long(&s->gb, tmp);
+ *decoded++ = get_sbits_long(&gb, tmp);
} else {
int real_limit = tmp ? (INT_MAX >> tmp) + 2 : INT_MAX;
for (; i < samples; i++) {
- int v = get_sr_golomb_flac(&s->gb, tmp, real_limit, 0);
+ int v = get_sr_golomb_flac(&gb, tmp, real_limit, 0);
if (v == 0x80000000){
av_log(s->avctx, AV_LOG_ERROR, "invalid residual\n");
return AVERROR_INVALIDDATA;
@@ -272,6 +274,8 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
i= 0;
}
+ s->gb = gb;
+
return 0;
}