Commit d1893f64 authored by Alex Converse's avatar Alex Converse Committed by Pascal Massimino

Code DCT tokens with ANS

Change-Id: I452f9675325a5f45bfbbe3e7e135009a125539f1
parent 9ffcb469
......@@ -133,7 +133,7 @@ const uint8_t vp10_pt_energy_class[ENTROPY_TOKENS] = {
0, 1, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5
};
// Model obtained from a 2-sided zero-centerd distribuition derived
// Model obtained from a 2-sided zero-centered distribution derived
// from a Pareto distribution. The cdf of the distribution is:
// cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta]
//
......@@ -405,6 +405,287 @@ const vpx_prob vp10_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES] = {
{255, 246, 247, 255, 239, 255, 253, 255},
};
#if CONFIG_ANS
// Model obtained from a 2-sided zero-centerd distribuition derived
// from a Pareto distribution. The cdf of the distribution is:
// cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta]
//
// For a given beta and a given probablity of the 1-node, the alpha
// is first solved, and then the {alpha, beta} pair is used to generate
// the probabilities for the rest of the nodes.
//
// beta = 8
// Values for tokens ONE_TOKEN through CATEGORY6_TOKEN included here.
// ZERO_TOKEN and EOB_TOKEN are coded as flags outside this coder.
const vpx_prob vp10_pareto8_token_probs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 2] = {
{1, 1, 1, 1, 2, 4, 8, 14, 26, 198},
{2, 2, 2, 2, 4, 7, 14, 26, 42, 155},
{3, 3, 3, 3, 6, 11, 20, 34, 51, 122},
{4, 4, 4, 4, 7, 14, 25, 41, 56, 97},
{5, 5, 5, 5, 9, 17, 30, 46, 58, 76},
{6, 6, 6, 5, 11, 20, 34, 50, 57, 61},
{7, 7, 7, 6, 12, 22, 37, 53, 56, 49},
{8, 8, 7, 7, 14, 25, 40, 54, 53, 40},
{9, 9, 8, 8, 15, 27, 43, 55, 50, 32},
{10, 10, 9, 9, 16, 29, 45, 55, 47, 26},
{11, 10, 10, 10, 18, 31, 47, 55, 43, 21},
{12, 11, 11, 10, 19, 32, 48, 55, 40, 18},
{13, 12, 12, 11, 20, 34, 49, 54, 37, 14},
{14, 13, 12, 12, 21, 35, 50, 53, 34, 12},
{15, 14, 13, 12, 22, 37, 51, 51, 31, 10},
{16, 15, 14, 13, 23, 38, 51, 50, 28, 8},
{17, 16, 15, 13, 24, 39, 51, 48, 26, 7},
{18, 17, 15, 14, 25, 40, 52, 46, 23, 6},
{19, 17, 16, 15, 26, 41, 51, 45, 21, 5},
{20, 18, 17, 15, 27, 42, 51, 43, 19, 4},
{21, 19, 17, 16, 28, 42, 51, 41, 18, 3},
{22, 20, 18, 16, 28, 43, 51, 39, 16, 3},
{23, 21, 19, 17, 29, 43, 50, 37, 14, 3},
{24, 22, 19, 17, 30, 44, 49, 36, 13, 2},
{25, 22, 20, 18, 30, 44, 49, 34, 12, 2},
{26, 23, 20, 18, 31, 44, 48, 33, 11, 2},
{27, 24, 21, 19, 31, 45, 47, 31, 10, 1},
{28, 25, 22, 19, 32, 45, 46, 29, 9, 1},
{29, 25, 22, 20, 32, 45, 46, 28, 8, 1},
{30, 26, 23, 20, 33, 45, 45, 26, 7, 1},
{31, 27, 23, 20, 33, 45, 44, 25, 7, 1},
{32, 27, 24, 21, 33, 45, 43, 24, 6, 1},
{33, 28, 24, 21, 34, 44, 42, 23, 6, 1},
{34, 29, 25, 21, 34, 44, 41, 22, 5, 1},
{35, 30, 25, 22, 34, 44, 40, 20, 5, 1},
{36, 30, 26, 22, 35, 44, 39, 19, 4, 1},
{37, 31, 26, 22, 35, 44, 38, 18, 4, 1},
{38, 32, 27, 22, 35, 43, 37, 17, 4, 1},
{39, 33, 27, 23, 35, 43, 36, 16, 3, 1},
{40, 33, 27, 23, 35, 43, 35, 16, 3, 1},
{41, 34, 28, 23, 35, 42, 34, 15, 3, 1},
{42, 35, 28, 23, 36, 42, 33, 14, 2, 1},
{43, 35, 29, 24, 35, 42, 32, 13, 2, 1},
{44, 36, 29, 24, 36, 41, 31, 12, 2, 1},
{45, 36, 29, 24, 36, 41, 30, 12, 2, 1},
{46, 37, 30, 24, 35, 40, 30, 11, 2, 1},
{47, 37, 30, 24, 36, 40, 29, 10, 2, 1},
{48, 38, 30, 24, 36, 40, 28, 10, 1, 1},
{49, 39, 31, 24, 36, 39, 27, 9, 1, 1},
{50, 39, 31, 25, 35, 39, 26, 9, 1, 1},
{51, 40, 31, 25, 36, 38, 25, 8, 1, 1},
{52, 40, 31, 25, 35, 38, 25, 8, 1, 1},
{53, 41, 32, 25, 35, 37, 24, 7, 1, 1},
{54, 41, 32, 25, 35, 37, 23, 7, 1, 1},
{55, 42, 32, 25, 35, 36, 22, 7, 1, 1},
{56, 42, 33, 25, 35, 35, 22, 6, 1, 1},
{57, 43, 33, 25, 34, 35, 21, 6, 1, 1},
{58, 43, 33, 25, 35, 34, 20, 6, 1, 1},
{59, 44, 33, 25, 34, 34, 20, 5, 1, 1},
{60, 45, 33, 25, 34, 33, 19, 5, 1, 1},
{61, 45, 33, 25, 34, 33, 18, 5, 1, 1},
{62, 45, 34, 25, 34, 32, 18, 4, 1, 1},
{63, 46, 34, 25, 33, 32, 17, 4, 1, 1},
{64, 46, 34, 25, 33, 31, 17, 4, 1, 1},
{65, 47, 34, 25, 33, 30, 16, 4, 1, 1},
{66, 47, 34, 25, 33, 30, 15, 4, 1, 1},
{67, 48, 34, 25, 33, 29, 15, 3, 1, 1},
{68, 48, 35, 25, 32, 29, 14, 3, 1, 1},
{69, 48, 35, 25, 32, 28, 14, 3, 1, 1},
{70, 49, 35, 25, 32, 27, 13, 3, 1, 1},
{71, 49, 35, 25, 31, 27, 13, 3, 1, 1},
{72, 49, 35, 25, 31, 27, 12, 3, 1, 1},
{73, 50, 35, 25, 31, 26, 12, 2, 1, 1},
{74, 50, 35, 25, 31, 25, 12, 2, 1, 1},
{75, 51, 35, 25, 30, 25, 11, 2, 1, 1},
{76, 51, 35, 25, 30, 24, 11, 2, 1, 1},
{77, 51, 35, 25, 30, 24, 10, 2, 1, 1},
{78, 52, 35, 24, 29, 24, 10, 2, 1, 1},
{79, 52, 35, 24, 29, 23, 10, 2, 1, 1},
{80, 52, 35, 24, 29, 23, 9, 2, 1, 1},
{81, 53, 35, 24, 28, 22, 9, 2, 1, 1},
{82, 53, 35, 24, 28, 22, 9, 1, 1, 1},
{83, 54, 35, 24, 28, 21, 8, 1, 1, 1},
{84, 54, 35, 24, 27, 21, 8, 1, 1, 1},
{85, 54, 35, 24, 27, 20, 8, 1, 1, 1},
{86, 54, 35, 24, 27, 20, 7, 1, 1, 1},
{87, 55, 35, 23, 27, 19, 7, 1, 1, 1},
{88, 55, 35, 23, 26, 19, 7, 1, 1, 1},
{89, 55, 35, 23, 26, 18, 7, 1, 1, 1},
{90, 55, 35, 23, 26, 18, 6, 1, 1, 1},
{91, 56, 35, 23, 25, 17, 6, 1, 1, 1},
{92, 56, 35, 22, 25, 17, 6, 1, 1, 1},
{93, 56, 35, 22, 24, 17, 6, 1, 1, 1},
{94, 57, 35, 22, 24, 16, 5, 1, 1, 1},
{95, 56, 35, 22, 24, 16, 5, 1, 1, 1},
{96, 57, 35, 22, 23, 15, 5, 1, 1, 1},
{97, 56, 35, 22, 23, 15, 5, 1, 1, 1},
{98, 57, 34, 21, 23, 15, 5, 1, 1, 1},
{99, 57, 35, 21, 23, 14, 4, 1, 1, 1},
{100, 58, 34, 21, 22, 14, 4, 1, 1, 1},
{101, 57, 34, 21, 22, 14, 4, 1, 1, 1},
{102, 58, 34, 21, 21, 13, 4, 1, 1, 1},
{103, 57, 34, 21, 21, 13, 4, 1, 1, 1},
{104, 57, 34, 20, 21, 13, 4, 1, 1, 1},
{105, 58, 34, 20, 20, 12, 4, 1, 1, 1},
{106, 58, 34, 20, 20, 12, 3, 1, 1, 1},
{107, 58, 33, 20, 20, 12, 3, 1, 1, 1},
{108, 59, 33, 20, 19, 11, 3, 1, 1, 1},
{109, 59, 33, 19, 19, 11, 3, 1, 1, 1},
{110, 58, 33, 19, 19, 11, 3, 1, 1, 1},
{111, 59, 33, 19, 18, 10, 3, 1, 1, 1},
{112, 58, 33, 19, 18, 10, 3, 1, 1, 1},
{113, 58, 32, 19, 18, 10, 3, 1, 1, 1},
{114, 59, 32, 18, 18, 10, 2, 1, 1, 1},
{115, 60, 32, 18, 17, 9, 2, 1, 1, 1},
{116, 59, 32, 18, 17, 9, 2, 1, 1, 1},
{117, 59, 32, 18, 16, 9, 2, 1, 1, 1},
{118, 59, 31, 18, 16, 9, 2, 1, 1, 1},
{119, 59, 32, 17, 16, 8, 2, 1, 1, 1},
{120, 59, 31, 17, 16, 8, 2, 1, 1, 1},
{121, 59, 31, 17, 15, 8, 2, 1, 1, 1},
{122, 59, 30, 17, 15, 8, 2, 1, 1, 1},
{123, 59, 30, 17, 15, 7, 2, 1, 1, 1},
{124, 59, 30, 16, 15, 7, 2, 1, 1, 1},
{125, 59, 30, 16, 14, 7, 2, 1, 1, 1},
{126, 59, 30, 16, 14, 7, 1, 1, 1, 1},
{127, 59, 30, 16, 14, 6, 1, 1, 1, 1},
{128, 59, 30, 16, 13, 6, 1, 1, 1, 1},
{129, 59, 30, 15, 13, 6, 1, 1, 1, 1},
{130, 59, 29, 15, 13, 6, 1, 1, 1, 1},
{131, 59, 29, 15, 12, 6, 1, 1, 1, 1},
{132, 59, 28, 15, 12, 6, 1, 1, 1, 1},
{133, 59, 28, 15, 12, 5, 1, 1, 1, 1},
{134, 59, 28, 14, 12, 5, 1, 1, 1, 1},
{135, 59, 28, 14, 11, 5, 1, 1, 1, 1},
{136, 58, 28, 14, 11, 5, 1, 1, 1, 1},
{137, 58, 27, 14, 11, 5, 1, 1, 1, 1},
{138, 58, 27, 13, 11, 5, 1, 1, 1, 1},
{139, 58, 27, 13, 11, 4, 1, 1, 1, 1},
{140, 58, 27, 13, 10, 4, 1, 1, 1, 1},
{141, 58, 26, 13, 10, 4, 1, 1, 1, 1},
{142, 57, 26, 13, 10, 4, 1, 1, 1, 1},
{143, 57, 26, 12, 10, 4, 1, 1, 1, 1},
{144, 57, 26, 12, 9, 4, 1, 1, 1, 1},
{145, 57, 25, 12, 9, 4, 1, 1, 1, 1},
{146, 57, 25, 12, 9, 3, 1, 1, 1, 1},
{147, 57, 25, 11, 9, 3, 1, 1, 1, 1},
{148, 57, 25, 11, 8, 3, 1, 1, 1, 1},
{149, 57, 24, 11, 8, 3, 1, 1, 1, 1},
{150, 56, 24, 11, 8, 3, 1, 1, 1, 1},
{151, 56, 23, 11, 8, 3, 1, 1, 1, 1},
{152, 56, 23, 10, 8, 3, 1, 1, 1, 1},
{153, 56, 23, 10, 7, 3, 1, 1, 1, 1},
{154, 55, 23, 10, 7, 3, 1, 1, 1, 1},
{155, 55, 22, 10, 7, 3, 1, 1, 1, 1},
{156, 55, 22, 10, 7, 2, 1, 1, 1, 1},
{157, 54, 22, 10, 7, 2, 1, 1, 1, 1},
{158, 54, 22, 9, 7, 2, 1, 1, 1, 1},
{159, 55, 21, 9, 6, 2, 1, 1, 1, 1},
{160, 54, 21, 9, 6, 2, 1, 1, 1, 1},
{161, 53, 21, 9, 6, 2, 1, 1, 1, 1},
{162, 53, 20, 9, 6, 2, 1, 1, 1, 1},
{163, 53, 20, 8, 6, 2, 1, 1, 1, 1},
{164, 53, 20, 8, 5, 2, 1, 1, 1, 1},
{165, 52, 20, 8, 5, 2, 1, 1, 1, 1},
{166, 52, 19, 8, 5, 2, 1, 1, 1, 1},
{167, 51, 19, 8, 5, 2, 1, 1, 1, 1},
{168, 51, 19, 7, 5, 2, 1, 1, 1, 1},
{169, 51, 19, 7, 5, 1, 1, 1, 1, 1},
{170, 51, 18, 7, 5, 1, 1, 1, 1, 1},
{171, 51, 18, 7, 4, 1, 1, 1, 1, 1},
{172, 50, 18, 7, 4, 1, 1, 1, 1, 1},
{173, 50, 17, 7, 4, 1, 1, 1, 1, 1},
{174, 49, 17, 7, 4, 1, 1, 1, 1, 1},
{175, 49, 17, 6, 4, 1, 1, 1, 1, 1},
{176, 49, 16, 6, 4, 1, 1, 1, 1, 1},
{177, 48, 16, 6, 4, 1, 1, 1, 1, 1},
{178, 47, 16, 6, 4, 1, 1, 1, 1, 1},
{179, 47, 16, 6, 3, 1, 1, 1, 1, 1},
{180, 47, 15, 6, 3, 1, 1, 1, 1, 1},
{181, 47, 15, 5, 3, 1, 1, 1, 1, 1},
{182, 46, 15, 5, 3, 1, 1, 1, 1, 1},
{183, 46, 14, 5, 3, 1, 1, 1, 1, 1},
{184, 45, 14, 5, 3, 1, 1, 1, 1, 1},
{185, 44, 14, 5, 3, 1, 1, 1, 1, 1},
{186, 44, 13, 5, 3, 1, 1, 1, 1, 1},
{187, 43, 13, 5, 3, 1, 1, 1, 1, 1},
{188, 44, 13, 4, 2, 1, 1, 1, 1, 1},
{189, 43, 13, 4, 2, 1, 1, 1, 1, 1},
{190, 43, 12, 4, 2, 1, 1, 1, 1, 1},
{191, 42, 12, 4, 2, 1, 1, 1, 1, 1},
{192, 41, 12, 4, 2, 1, 1, 1, 1, 1},
{193, 41, 11, 4, 2, 1, 1, 1, 1, 1},
{194, 40, 11, 4, 2, 1, 1, 1, 1, 1},
{195, 39, 11, 4, 2, 1, 1, 1, 1, 1},
{196, 39, 11, 3, 2, 1, 1, 1, 1, 1},
{197, 39, 10, 3, 2, 1, 1, 1, 1, 1},
{198, 38, 10, 3, 2, 1, 1, 1, 1, 1},
{199, 37, 10, 3, 2, 1, 1, 1, 1, 1},
{200, 37, 10, 3, 1, 1, 1, 1, 1, 1},
{201, 37, 9, 3, 1, 1, 1, 1, 1, 1},
{202, 36, 9, 3, 1, 1, 1, 1, 1, 1},
{203, 35, 9, 3, 1, 1, 1, 1, 1, 1},
{204, 35, 8, 3, 1, 1, 1, 1, 1, 1},
{205, 35, 8, 2, 1, 1, 1, 1, 1, 1},
{206, 34, 8, 2, 1, 1, 1, 1, 1, 1},
{207, 33, 8, 2, 1, 1, 1, 1, 1, 1},
{208, 32, 8, 2, 1, 1, 1, 1, 1, 1},
{209, 32, 7, 2, 1, 1, 1, 1, 1, 1},
{210, 31, 7, 2, 1, 1, 1, 1, 1, 1},
{211, 30, 7, 2, 1, 1, 1, 1, 1, 1},
{212, 30, 6, 2, 1, 1, 1, 1, 1, 1},
{213, 29, 6, 2, 1, 1, 1, 1, 1, 1},
{214, 28, 6, 2, 1, 1, 1, 1, 1, 1},
{215, 27, 6, 2, 1, 1, 1, 1, 1, 1},
{216, 27, 6, 1, 1, 1, 1, 1, 1, 1},
{217, 27, 5, 1, 1, 1, 1, 1, 1, 1},
{218, 26, 5, 1, 1, 1, 1, 1, 1, 1},
{219, 25, 5, 1, 1, 1, 1, 1, 1, 1},
{220, 24, 5, 1, 1, 1, 1, 1, 1, 1},
{221, 24, 4, 1, 1, 1, 1, 1, 1, 1},
{222, 23, 4, 1, 1, 1, 1, 1, 1, 1},
{223, 22, 4, 1, 1, 1, 1, 1, 1, 1},
{224, 21, 4, 1, 1, 1, 1, 1, 1, 1},
{225, 20, 4, 1, 1, 1, 1, 1, 1, 1},
{226, 20, 3, 1, 1, 1, 1, 1, 1, 1},
{227, 19, 3, 1, 1, 1, 1, 1, 1, 1},
{228, 18, 3, 1, 1, 1, 1, 1, 1, 1},
{229, 17, 3, 1, 1, 1, 1, 1, 1, 1},
{230, 16, 3, 1, 1, 1, 1, 1, 1, 1},
{231, 16, 2, 1, 1, 1, 1, 1, 1, 1},
{232, 15, 2, 1, 1, 1, 1, 1, 1, 1},
{233, 14, 2, 1, 1, 1, 1, 1, 1, 1},
{234, 13, 2, 1, 1, 1, 1, 1, 1, 1},
{235, 12, 2, 1, 1, 1, 1, 1, 1, 1},
{236, 11, 2, 1, 1, 1, 1, 1, 1, 1},
{237, 11, 1, 1, 1, 1, 1, 1, 1, 1},
{238, 10, 1, 1, 1, 1, 1, 1, 1, 1},
{239, 9, 1, 1, 1, 1, 1, 1, 1, 1},
{240, 8, 1, 1, 1, 1, 1, 1, 1, 1},
{241, 7, 1, 1, 1, 1, 1, 1, 1, 1},
{242, 6, 1, 1, 1, 1, 1, 1, 1, 1},
{243, 5, 1, 1, 1, 1, 1, 1, 1, 1},
{244, 4, 1, 1, 1, 1, 1, 1, 1, 1},
{245, 3, 1, 1, 1, 1, 1, 1, 1, 1},
{246, 2, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{247, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};
void vp10_build_pareto8_dec_tab(
const vpx_prob token_probs[COEFF_PROB_MODELS][ENTROPY_TOKENS - 2],
rans_dec_lut dec_tab[COEFF_PROB_MODELS]) {
int p;
for (p = 0; p < COEFF_PROB_MODELS; ++p) {
rans_build_dec_tab(token_probs[p], dec_tab[p]);
}
}
#endif // CONFIG_ANS
static const vp10_coeff_probs_model default_coef_probs_4x4[PLANE_TYPES] = {
{ // Y plane
{ // Intra
......
......@@ -14,6 +14,9 @@
#include "vpx/vpx_integer.h"
#include "vpx_dsp/prob.h"
#if CONFIG_ANS
#include "vp10/common/ans.h"
#endif // CONFIG_ANS
#include "vp10/common/common.h"
#include "vp10/common/enums.h"
......@@ -163,6 +166,14 @@ static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) {
#define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES)
extern const vpx_tree_index vp10_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)];
extern const vpx_prob vp10_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES];
#if CONFIG_ANS
extern const vpx_prob
vp10_pareto8_token_probs[COEFF_PROB_MODELS][ENTROPY_TOKENS - 2];
void vp10_build_pareto8_dec_tab(
const vpx_prob token_probs[COEFF_PROB_MODELS][ENTROPY_TOKENS - 2],
rans_dec_lut dec_tab[COEFF_PROB_MODELS]);
#endif // CONFIG_ANS
typedef vpx_prob vp10_coeff_probs_model[REF_TYPES][COEF_BANDS]
[COEFF_CONTEXTS][UNCONSTRAINED_NODES];
......
......@@ -350,7 +350,12 @@ static void inverse_transform_block_intra(MACROBLOCKD* xd, int plane,
}
static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
#if CONFIG_ANS
const rans_dec_lut *const token_tab,
struct AnsDecoder *const r,
#else
vpx_reader *r,
#endif // CONFIG_ANS
MB_MODE_INFO *const mbmi,
int plane,
int row, int col,
......@@ -373,7 +378,11 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
if (!mbmi->skip) {
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const scan_order *sc = get_scan(tx_size, tx_type, 0);
const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size,
const int eob = vp10_decode_block_tokens(xd,
#if CONFIG_ANS
token_tab,
#endif // CONFIG_ANS
plane, sc, col, row, tx_size,
r, mbmi->segment_id);
inverse_transform_block_intra(xd, plane, tx_type, tx_size,
dst, pd->dst.stride, eob);
......@@ -437,7 +446,13 @@ static void decode_reconstruct_tx(MACROBLOCKD *const xd, vpx_reader *r,
}
#endif // CONFIG_VAR_TX
static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
static int reconstruct_inter_block(MACROBLOCKD *const xd,
#if CONFIG_ANS
const rans_dec_lut *const token_tab,
struct AnsDecoder *const r,
#else
vpx_reader *r,
#endif
MB_MODE_INFO *const mbmi, int plane,
int row, int col, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
......@@ -445,8 +460,12 @@ static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
int block_idx = (row << 1) + col;
TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
const scan_order *sc = get_scan(tx_size, tx_type, 1);
const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
mbmi->segment_id);
const int eob = vp10_decode_block_tokens(xd,
#if CONFIG_ANS
token_tab,
#endif
plane, sc, col, row, tx_size, r,
mbmi->segment_id);
inverse_transform_block_inter(xd, plane, tx_size,
&pd->dst.buf[4 * row * pd->dst.stride + 4 * col],
......@@ -1513,7 +1532,11 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
int supertx_enabled,
#endif // CONFIG_SUPERTX
int mi_row, int mi_col,
vpx_reader *r, BLOCK_SIZE bsize,
vpx_reader *r,
#if CONFIG_ANS
struct AnsDecoder *const tok,
#endif // CONFIG_ANS
BLOCK_SIZE bsize,
int bwl, int bhl) {
VP10_COMMON *const cm = &pbi->common;
const int less8x8 = bsize < BLOCK_8X8;
......@@ -1573,7 +1596,13 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
predict_and_reconstruct_intra_block(xd, r, mbmi, plane,
predict_and_reconstruct_intra_block(xd,
#if CONFIG_ANS
pbi->token_tab, tok,
#else
r,
#endif
mbmi, plane,
row, col, tx_size);
}
} else {
......@@ -1621,7 +1650,13 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
eobtotal += reconstruct_inter_block(xd, r, mbmi, plane, row, col,
eobtotal += reconstruct_inter_block(xd,
#if CONFIG_ANS
pbi->token_tab, tok,
#else
r,
#endif
mbmi, plane, row, col,
tx_size);
#endif
}
......@@ -1704,7 +1739,11 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd,
int supertx_enabled,
#endif
int mi_row, int mi_col,
vpx_reader* r, BLOCK_SIZE bsize, int n4x4_l2) {
vpx_reader* r,
#if CONFIG_ANS
struct AnsDecoder *const tok,
#endif // CONFIG_ANS
BLOCK_SIZE bsize, int n4x4_l2) {
VP10_COMMON *const cm = &pbi->common;
const int n8x8_l2 = n4x4_l2 - 1;
const int num_8x8_wh = 1 << n8x8_l2;
......@@ -1777,7 +1816,11 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col, r, subsize, 1, 1);
mi_row, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, 1, 1);
} else {
switch (partition) {
case PARTITION_NONE:
......@@ -1785,55 +1828,91 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col, r, subsize, n4x4_l2, n4x4_l2);
mi_row, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n4x4_l2, n4x4_l2);
break;
case PARTITION_HORZ:
decode_block(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col, r, subsize, n4x4_l2, n8x8_l2);
mi_row, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n4x4_l2, n8x8_l2);
if (has_rows)
decode_block(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row + hbs, mi_col, r, subsize, n4x4_l2, n8x8_l2);
mi_row + hbs, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n4x4_l2, n8x8_l2);
break;
case PARTITION_VERT:
decode_block(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col, r, subsize, n8x8_l2, n4x4_l2);
mi_row, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2, n4x4_l2);
if (has_cols)
decode_block(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col + hbs, r, subsize, n8x8_l2, n4x4_l2);
mi_row, mi_col + hbs, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2, n4x4_l2);
break;
case PARTITION_SPLIT:
decode_partition(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col, r, subsize, n8x8_l2);
mi_row, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2);
decode_partition(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row, mi_col + hbs, r, subsize, n8x8_l2);
mi_row, mi_col + hbs, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2);
decode_partition(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row + hbs, mi_col, r, subsize, n8x8_l2);
mi_row + hbs, mi_col, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2);
decode_partition(pbi, xd,
#if CONFIG_SUPERTX
supertx_enabled,
#endif // CONFIG_SUPERTX
mi_row + hbs, mi_col + hbs, r, subsize, n8x8_l2);
mi_row + hbs, mi_col + hbs, r,
#if CONFIG_ANS
tok,
#endif // CONFIG_ANS
subsize, n8x8_l2);
break;
default:
assert(0 && "Invalid partition type");
......@@ -1878,7 +1957,13 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd,
for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step)
eobtotal += reconstruct_inter_block(xd, r, mbmi, i, row, col,
eobtotal += reconstruct_inter_block(xd,
#if CONFIG_ANS
pbi->token_tab, tok,
#else
r,
#endif
mbmi, i, row, col,
tx_size);
}
if (!(subsize < BLOCK_8X8) && eobtotal == 0)
......@@ -1898,13 +1983,34 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd,
dec_update_partition_context(xd, mi_row, mi_col, subsize, num_8x8_wh);
}
static void setup_bool_decoder(const uint8_t *data,
const uint8_t *data_end,
const size_t read_size,
struct vpx_internal_error_info *error_info,
vpx_reader *r,
vpx_decrypt_cb decrypt_cb,
void *decrypt_state) {
// Validate the calculated partition length. If the buffer
// described by the partition can't be fully read, then restrict
// it to the portion that can be (for EC mode) or throw an error.
if (!read_is_valid(data, read_size, data_end))