aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/av1dec.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-10-28 11:23:44 -0300
committerJames Almer <jamrial@gmail.com>2020-10-28 11:26:25 -0300
commitfec1b4738f351260b12cc88b79e95b39308190ba (patch)
treed6b145518e64b3ada6bbb5500b65581290e3341e /libavcodec/av1dec.c
parent7dac8ddb20ee663ca211bd8c152228536a884605 (diff)
downloadffmpeg-fec1b4738f351260b12cc88b79e95b39308190ba.tar.gz
avcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame none
Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/av1dec.c')
-rw-r--r--libavcodec/av1dec.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index e01ac6641a..9566f7aa7d 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -57,13 +57,22 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
{
uint8_t primary_frame, prev_frame;
uint32_t abs_bits, prec_bits, round, prec_diff, sub, mx;
- int32_t r;
+ int32_t r, prev_gm_param;
primary_frame = s->raw_frame_header->primary_ref_frame;
prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame];
abs_bits = AV1_GM_ABS_ALPHA_BITS;
prec_bits = AV1_GM_ALPHA_PREC_BITS;
+ /* setup_past_independence() sets PrevGmParams to default values. We can
+ * simply point to the current's frame gm_params as they will be initialized
+ * with defaults at this point.
+ */
+ if (s->raw_frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE)
+ prev_gm_param = s->cur_frame.gm_params[ref][idx];
+ else
+ prev_gm_param = s->ref[prev_frame].gm_params[ref][idx];
+
if (idx < 2) {
if (type == AV1_WARP_MODEL_TRANSLATION) {
abs_bits = AV1_GM_ABS_TRANS_ONLY_BITS -
@@ -79,7 +88,7 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
prec_diff = AV1_WARPEDMODEL_PREC_BITS - prec_bits;
sub = (idx % 3) == 2 ? (1 << prec_bits) : 0;
mx = 1 << abs_bits;
- r = (s->ref[prev_frame].gm_params[ref][idx] >> prec_diff) - sub;
+ r = (prev_gm_param >> prec_diff) - sub;
s->cur_frame.gm_params[ref][idx] =
(decode_signed_subexp_with_ref(s->raw_frame_header->gm_params[ref][idx],