Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
aom-rav1e
Commits
92109818
Commit
92109818
authored
Feb 22, 2017
by
Alex Converse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
palette: Use some enums / defines
Change-Id: If5d4f6d261276d9cfdd59fd7779467d92f56c395
parent
e580092b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
28 deletions
+31
-28
av1/common/entropymode.c
av1/common/entropymode.c
+3
-4
av1/common/entropymode.h
av1/common/entropymode.h
+5
-4
av1/decoder/detokenize.c
av1/decoder/detokenize.c
+2
-2
av1/encoder/bitstream.c
av1/encoder/bitstream.c
+9
-8
av1/encoder/encoder.h
av1/encoder/encoder.h
+2
-2
av1/encoder/rd.c
av1/encoder/rd.c
+1
-1
av1/encoder/rdopt.c
av1/encoder/rdopt.c
+6
-5
av1/encoder/tokenize.c
av1/encoder/tokenize.c
+3
-2
No files found.
av1/common/entropymode.c
View file @
92109818
...
...
@@ -833,8 +833,7 @@ const aom_prob av1_default_palette_uv_mode_prob[PALETTE_UV_MODE_CONTEXTS] = {
// Trees to code palette color indices (for various palette sizes), and the
// corresponding probability tables for Y and UV planes.
const
aom_tree_index
av1_palette_color_index_tree
[
PALETTE_MAX_SIZE
-
1
][
TREE_SIZE
(
PALETTE_COLORS
)]
=
{
av1_palette_color_index_tree
[
PALETTE_SIZES
][
TREE_SIZE
(
PALETTE_COLORS
)]
=
{
{
// 2 colors
-
PALETTE_COLOR_ONE
,
-
PALETTE_COLOR_TWO
},
{
// 3 colors
...
...
@@ -862,7 +861,7 @@ const aom_tree_index
#define UNUSED_PROB 128
const
aom_prob
av1_default_palette_y_color_index_prob
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
{
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
{
{
// 2 colors
{
231
,
UNUSED_PROB
,
UNUSED_PROB
,
UNUSED_PROB
,
UNUSED_PROB
,
...
...
@@ -932,7 +931,7 @@ const aom_prob av1_default_palette_y_color_index_prob
};
const
aom_prob
av1_default_palette_uv_color_index_prob
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
{
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
{
{
// 2 colors
{
233
,
UNUSED_PROB
,
UNUSED_PROB
,
UNUSED_PROB
,
UNUSED_PROB
,
...
...
av1/common/entropymode.h
View file @
92109818
...
...
@@ -40,6 +40,8 @@ extern "C" {
// Maximum number of colors in a palette.
#define PALETTE_MAX_SIZE 8
// Minimum number of colors in a palette.
#define PALETTE_MIN_SIZE 2
// Palette mode is available for block sizes >= 8x8.
#define PALETTE_BLOCK_SIZES (BLOCK_LARGEST - BLOCK_8X8 + 1)
...
...
@@ -390,9 +392,9 @@ extern const aom_prob av1_default_palette_y_size_prob[PALETTE_BLOCK_SIZES]
extern
const
aom_prob
av1_default_palette_uv_size_prob
[
PALETTE_BLOCK_SIZES
]
[
PALETTE_SIZES
-
1
];
extern
const
aom_prob
av1_default_palette_y_color_index_prob
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
];
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
];
extern
const
aom_prob
av1_default_palette_uv_color_index_prob
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
];
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
][
PALETTE_COLORS
-
1
];
#endif // CONFIG_PALETTE
extern
const
aom_tree_index
av1_intra_mode_tree
[
TREE_SIZE
(
INTRA_MODES
)];
...
...
@@ -420,8 +422,7 @@ extern const aom_tree_index
#if CONFIG_PALETTE
extern
const
aom_tree_index
av1_palette_size_tree
[
TREE_SIZE
(
PALETTE_SIZES
)];
extern
const
aom_tree_index
av1_palette_color_index_tree
[
PALETTE_MAX_SIZE
-
1
]
[
TREE_SIZE
(
PALETTE_COLORS
)];
av1_palette_color_index_tree
[
PALETTE_SIZES
][
TREE_SIZE
(
PALETTE_COLORS
)];
#endif // CONFIG_PALETTE
extern
const
aom_tree_index
av1_tx_size_tree
[
MAX_TX_DEPTH
][
TREE_SIZE
(
TX_SIZES
)];
#if CONFIG_EXT_INTRA
...
...
av1/decoder/detokenize.c
View file @
92109818
...
...
@@ -466,8 +466,8 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
const
int
color_ctx
=
av1_get_palette_color_index_context
(
color_map
,
plane_block_width
,
i
,
j
,
n
,
color_order
,
NULL
);
const
int
color_idx
=
aom_read_tree
(
r
,
av1_palette_color_index_tree
[
n
-
2
],
prob
[
n
-
2
][
color_ctx
],
ACCT_STR
);
aom_read_tree
(
r
,
av1_palette_color_index_tree
[
n
-
PALETTE_MIN_SIZE
],
prob
[
n
-
PALETTE_MIN_SIZE
][
color_ctx
],
ACCT_STR
);
assert
(
color_idx
>=
0
&&
color_idx
<
n
);
color_map
[
i
*
plane_block_width
+
j
]
=
color_order
[
color_idx
];
}
...
...
av1/encoder/bitstream.c
View file @
92109818
...
...
@@ -74,9 +74,9 @@ static const struct av1_token
};
#endif // CONFIG_EXT_INTER
#if CONFIG_PALETTE
static
struct
av1_token
palette_size_encodings
[
PALETTE_
MAX_SIZE
-
1
];
static
struct
av1_token
palette_color_index_encodings
[
PALETTE_
MAX_SIZE
-
1
]
[
PALETTE_
MAX_SIZE
];
static
struct
av1_token
palette_size_encodings
[
PALETTE_
SIZES
];
static
struct
av1_token
palette_color_index_encodings
[
PALETTE_
SIZES
]
[
PALETTE_
COLORS
];
#endif // CONFIG_PALETTE
#if !CONFIG_EC_MULTISYMBOL
static
const
struct
av1_token
tx_size_encodings
[
MAX_TX_DEPTH
][
TX_SIZES
]
=
{
...
...
@@ -159,7 +159,7 @@ void av1_encode_token_init(void) {
#if CONFIG_PALETTE
av1_tokens_from_tree
(
palette_size_encodings
,
av1_palette_size_tree
);
for
(
s
=
0
;
s
<
PALETTE_
MAX_SIZE
-
1
;
++
s
)
{
for
(
s
=
0
;
s
<
PALETTE_
SIZES
;
++
s
)
{
av1_tokens_from_tree
(
palette_color_index_encodings
[
s
],
av1_palette_color_index_tree
[
s
]);
}
...
...
@@ -741,8 +741,9 @@ static void pack_palette_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
const
TOKENEXTRA
*
p
=
*
tp
;
for
(
i
=
0
;
i
<
num
;
++
i
)
{
av1_write_token
(
w
,
av1_palette_color_index_tree
[
n
-
2
],
p
->
context_tree
,
&
palette_color_index_encodings
[
n
-
2
][
p
->
token
]);
av1_write_token
(
w
,
av1_palette_color_index_tree
[
n
-
PALETTE_MIN_SIZE
],
p
->
context_tree
,
&
palette_color_index_encodings
[
n
-
PALETTE_MIN_SIZE
][
p
->
token
]);
++
p
;
}
...
...
@@ -1246,7 +1247,7 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if
(
n
>
0
)
{
av1_write_token
(
w
,
av1_palette_size_tree
,
av1_default_palette_y_size_prob
[
bsize
-
BLOCK_8X8
],
&
palette_size_encodings
[
n
-
2
]);
&
palette_size_encodings
[
n
-
PALETTE_MIN_SIZE
]);
for
(
i
=
0
;
i
<
n
;
++
i
)
aom_write_literal
(
w
,
pmi
->
palette_colors
[
i
],
cm
->
bit_depth
);
write_uniform
(
w
,
n
,
pmi
->
palette_first_color_idx
[
0
]);
...
...
@@ -1260,7 +1261,7 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if
(
n
>
0
)
{
av1_write_token
(
w
,
av1_palette_size_tree
,
av1_default_palette_uv_size_prob
[
bsize
-
BLOCK_8X8
],
&
palette_size_encodings
[
n
-
2
]);
&
palette_size_encodings
[
n
-
PALETTE_MIN_SIZE
]);
for
(
i
=
0
;
i
<
n
;
++
i
)
{
aom_write_literal
(
w
,
pmi
->
palette_colors
[
PALETTE_MAX_SIZE
+
i
],
cm
->
bit_depth
);
...
...
av1/encoder/encoder.h
View file @
92109818
...
...
@@ -577,9 +577,9 @@ typedef struct AV1_COMP {
#if CONFIG_PALETTE
int
palette_y_size_cost
[
PALETTE_BLOCK_SIZES
][
PALETTE_SIZES
];
int
palette_uv_size_cost
[
PALETTE_BLOCK_SIZES
][
PALETTE_SIZES
];
int
palette_y_color_cost
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
]
int
palette_y_color_cost
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
]
[
PALETTE_COLORS
];
int
palette_uv_color_cost
[
PALETTE_
MAX_SIZE
-
1
][
PALETTE_COLOR_INDEX_CONTEXTS
]
int
palette_uv_color_cost
[
PALETTE_
SIZES
][
PALETTE_COLOR_INDEX_CONTEXTS
]
[
PALETTE_COLORS
];
#endif // CONFIG_PALETTE
int
tx_size_cost
[
TX_SIZES
-
1
][
TX_SIZE_CONTEXTS
][
TX_SIZES
];
...
...
av1/encoder/rd.c
View file @
92109818
...
...
@@ -101,7 +101,7 @@ static void fill_mode_costs(AV1_COMP *cpi) {
av1_default_palette_uv_size_prob
[
i
],
av1_palette_size_tree
);
}
for
(
i
=
0
;
i
<
PALETTE_
MAX_SIZE
-
1
;
++
i
)
{
for
(
i
=
0
;
i
<
PALETTE_
SIZES
;
++
i
)
{
for
(
j
=
0
;
j
<
PALETTE_COLOR_INDEX_CONTEXTS
;
++
j
)
{
av1_cost_tokens
(
cpi
->
palette_y_color_cost
[
i
][
j
],
av1_default_palette_y_color_index_prob
[
i
][
j
],
...
...
av1/encoder/rdopt.c
View file @
92109818
...
...
@@ -2442,7 +2442,7 @@ static int rd_pick_palette_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x,
block_height);
palette_mode_cost =
dc_mode_cost + cpi->common.bit_depth * k * av1_cost_bit(128, 0) +
cpi->palette_y_size_cost[bsize - BLOCK_8X8][k -
2
] +
cpi->palette_y_size_cost[bsize - BLOCK_8X8][k -
PALETTE_MIN_SIZE
] +
write_uniform_cost(k, color_map[0]) +
av1_cost_bit(
av1_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx],
...
...
@@ -2453,8 +2453,8 @@ static int rd_pick_palette_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x,
const int color_ctx = av1_get_palette_color_index_context(
color_map, block_width, i, j, k, color_order, &color_idx);
assert(color_idx >= 0 && color_idx < k);
palette_mode_cost +=
cpi->palette_y_color_cost[k - 2]
[color_ctx][color_idx];
palette_mode_cost +=
cpi->palette_y_color_cost[k - PALETTE_MIN_SIZE]
[color_ctx][color_idx];
}
}
this_model_rd = intra_model_yrd(cpi, x, bsize, palette_mode_cost);
...
...
@@ -4543,7 +4543,7 @@ static void rd_pick_palette_intra_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
this_rate =
tokenonly_rd_stats.rate + dc_mode_cost +
2 * cpi->common.bit_depth * n * av1_cost_bit(128, 0) +
cpi->palette_uv_size_cost[bsize - BLOCK_8X8][n -
2
] +
cpi->palette_uv_size_cost[bsize - BLOCK_8X8][n -
PALETTE_MIN_SIZE
] +
write_uniform_cost(n, color_map[0]) +
av1_cost_bit(
av1_default_palette_uv_mode_prob[pmi->palette_size[0] > 0], 1);
...
...
@@ -4554,7 +4554,8 @@ static void rd_pick_palette_intra_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
const int color_ctx = av1_get_palette_color_index_context(
color_map, plane_block_width, i, j, n, color_order, &color_idx);
assert(color_idx >= 0 && color_idx < n);
this_rate += cpi->palette_uv_color_cost[n - 2][color_ctx][color_idx];
this_rate += cpi->palette_uv_color_cost[n - PALETTE_MIN_SIZE]
[color_ctx][color_idx];
}
}
...
...
av1/encoder/tokenize.c
View file @
92109818
...
...
@@ -429,9 +429,10 @@ void av1_tokenize_palette_sb(const AV1_COMP *cpi,
color_map
,
plane_block_width
,
i
,
j
,
n
,
color_order
,
&
color_new_idx
);
assert
(
color_new_idx
>=
0
&&
color_new_idx
<
n
);
if
(
dry_run
==
DRY_RUN_COSTCOEFFS
)
this_rate
+=
cpi
->
palette_y_color_cost
[
n
-
2
][
color_ctx
][
color_new_idx
];
this_rate
+=
cpi
->
palette_y_color_cost
[
n
-
PALETTE_MIN_SIZE
][
color_ctx
]
[
color_new_idx
];
(
*
t
)
->
token
=
color_new_idx
;
(
*
t
)
->
context_tree
=
probs
[
n
-
2
][
color_ctx
];
(
*
t
)
->
context_tree
=
probs
[
n
-
PALETTE_MIN_SIZE
][
color_ctx
];
(
*
t
)
->
skip_eob_node
=
0
;
++
(
*
t
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment