blob: 38edbd8ebd8eec54f359840a16525b4b9909ddf9 [file] [log] [blame]
 #### 13.4 Token Probability Updates {#h-13-04} As mentioned above, the token-decoding probabilities may change from frame to frame. After detection of a key frame, they are of course set to their defaults shown in Section 13.5; this must occur before decoding the remainder of the header, as both key frames and interframes may adjust these probabilities. The layout and semantics of the coefficient probability update record (Section I of the frame header) are straightforward. For each position in the `coeff_probs` array there occurs a fixed-probability bool indicating whether or not the corresponding probability should be updated. If the bool is true, there follows a `P(8)` replacing that probability. Note that updates are cumulative, that is, a probability updated on one frame is in effect for all ensuing frames until the next key frame, or until the probability is explicitly updated by another frame. The algorithm to effect the foregoing is simple: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int i = 0; do { int j = 0; do { int k = 0; do { int t = 0; do { if( read_bool( d, coeff_update_probs [i] [j] [k] [t])) coeff_probs [i] [j] [k] [t] = read_literal( d, 8); } while( ++t < num_dct_tokens - 1); } while( ++k < 3); } while( ++j < 8); } while( ++i < 4); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {:lang="c"} The (constant) update probabilities are as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const Prob coeff_update_probs [4] [8] [3] [num_dct_tokens-1] = { { { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255}, { 249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255}, { 234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255}, { 250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255}, { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} } }, { { { 217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255}, { 234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255} }, { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} } }, { { { 186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255}, { 234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255}, { 251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255} }, { { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} } }, { { { 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255}, { 248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255} }, { { 255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255}, { 248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255}, { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} }, { { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} } } }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {:lang="c"}