ref: 6c6a97814ff5b7707fadaccc445615f91a07ebf7
parent: 26a0721268cfbb921f8b2320ccecab2c3d8982f2
author: Alexander Voronov <[email protected]>
date: Thu Dec 11 15:44:19 EST 2014
Prevent decoder from using uninitialized entropy context. If decoding starts with intra-only frame, there is a possibility of using uninitialized entropy context, what leads to undefined behavior. Change-Id: Icbb64b5b1bd1e5de2a4bfa2884e56bc0a20840af
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -453,6 +453,7 @@
vp9_default_coef_probs(cm);
vp9_init_mode_probs(cm->fc);
vp9_init_mv_probs(cm);
+ cm->fc->initialized = 1;
if (cm->frame_type == KEY_FRAME ||
cm->error_resilient_mode || cm->reset_frame_context == 3) {
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -50,6 +50,7 @@
struct tx_probs tx_probs;
vp9_prob skip_probs[SKIP_CONTEXTS];
nmv_context nmvc;
+ int initialized;
} FRAME_CONTEXT;
typedef struct {
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -1558,6 +1558,10 @@
vp9_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);
*cm->fc = cm->frame_contexts[cm->frame_context_idx];
+ if (!cm->fc->initialized)
+ vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
+ "Uninitialized entropy context.");
+
vp9_zero(cm->counts);
vp9_zero(xd->dqcoeff);