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
Yushin Cho
aom-rav1e
Commits
b1c3bb57
Commit
b1c3bb57
authored
Sep 07, 2016
by
Urvang Joshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Palette: Use inverse_color_order to find color index faster.
Change-Id: Icfc16070160fd9763abb1dbf5545103e62b4b9ff
parent
39d69bc0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
49 deletions
+45
-49
av1/common/entropymode.c
av1/common/entropymode.c
+12
-2
av1/common/entropymode.h
av1/common/entropymode.h
+2
-1
av1/decoder/detokenize.c
av1/decoder/detokenize.c
+8
-8
av1/encoder/rdopt.c
av1/encoder/rdopt.c
+8
-18
av1/encoder/tokenize.c
av1/encoder/tokenize.c
+13
-18
av1/encoder/tokenize.h
av1/encoder/tokenize.h
+2
-2
No files found.
av1/common/entropymode.c
View file @
b1c3bb57
...
@@ -688,12 +688,14 @@ static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
...
@@ -688,12 +688,14 @@ static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
};
};
int
av1_get_palette_color_context
(
const
uint8_t
*
color_map
,
int
cols
,
int
r
,
int
av1_get_palette_color_context
(
const
uint8_t
*
color_map
,
int
cols
,
int
r
,
int
c
,
int
n
,
int
*
color_order
)
{
int
c
,
int
n
,
uint8_t
*
color_order
,
int
*
color_idx
)
{
int
i
,
j
,
max
,
max_idx
,
temp
;
int
i
,
j
,
max
,
max_idx
,
temp
;
int
scores
[
PALETTE_MAX_SIZE
+
10
];
int
scores
[
PALETTE_MAX_SIZE
+
10
];
int
weights
[
4
]
=
{
3
,
2
,
3
,
2
};
int
weights
[
4
]
=
{
3
,
2
,
3
,
2
};
int
color_ctx
=
0
;
int
color_ctx
=
0
;
int
color_neighbors
[
4
];
int
color_neighbors
[
4
];
int
inverse_color_order
[
PALETTE_MAX_SIZE
];
assert
(
n
<=
PALETTE_MAX_SIZE
);
assert
(
n
<=
PALETTE_MAX_SIZE
);
if
(
c
-
1
>=
0
)
if
(
c
-
1
>=
0
)
color_neighbors
[
0
]
=
color_map
[
r
*
cols
+
c
-
1
];
color_neighbors
[
0
]
=
color_map
[
r
*
cols
+
c
-
1
];
...
@@ -711,7 +713,10 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
...
@@ -711,7 +713,10 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
color_neighbors
[
3
]
=
color_map
[(
r
-
1
)
*
cols
+
c
+
1
];
color_neighbors
[
3
]
=
color_map
[(
r
-
1
)
*
cols
+
c
+
1
];
else
else
color_neighbors
[
3
]
=
-
1
;
color_neighbors
[
3
]
=
-
1
;
for
(
i
=
0
;
i
<
PALETTE_MAX_SIZE
;
++
i
)
color_order
[
i
]
=
i
;
for
(
i
=
0
;
i
<
PALETTE_MAX_SIZE
;
++
i
)
{
color_order
[
i
]
=
i
;
inverse_color_order
[
i
]
=
i
;
}
memset
(
scores
,
0
,
PALETTE_MAX_SIZE
*
sizeof
(
scores
[
0
]));
memset
(
scores
,
0
,
PALETTE_MAX_SIZE
*
sizeof
(
scores
[
0
]));
for
(
i
=
0
;
i
<
4
;
++
i
)
{
for
(
i
=
0
;
i
<
4
;
++
i
)
{
if
(
color_neighbors
[
i
]
>=
0
)
scores
[
color_neighbors
[
i
]]
+=
weights
[
i
];
if
(
color_neighbors
[
i
]
>=
0
)
scores
[
color_neighbors
[
i
]]
+=
weights
[
i
];
...
@@ -734,6 +739,8 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
...
@@ -734,6 +739,8 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
temp
=
color_order
[
i
];
temp
=
color_order
[
i
];
color_order
[
i
]
=
color_order
[
max_idx
];
color_order
[
i
]
=
color_order
[
max_idx
];
color_order
[
max_idx
]
=
temp
;
color_order
[
max_idx
]
=
temp
;
inverse_color_order
[
color_order
[
i
]]
=
i
;
inverse_color_order
[
color_order
[
max_idx
]]
=
max_idx
;
}
}
}
}
for
(
i
=
0
;
i
<
4
;
++
i
)
color_ctx
=
color_ctx
*
11
+
scores
[
i
];
for
(
i
=
0
;
i
<
4
;
++
i
)
color_ctx
=
color_ctx
*
11
+
scores
[
i
];
...
@@ -743,6 +750,9 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
...
@@ -743,6 +750,9 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
break
;
break
;
}
}
if
(
color_ctx
>=
PALETTE_COLOR_CONTEXTS
)
color_ctx
=
0
;
if
(
color_ctx
>=
PALETTE_COLOR_CONTEXTS
)
color_ctx
=
0
;
if
(
color_idx
!=
NULL
)
{
*
color_idx
=
inverse_color_order
[
color_map
[
r
*
cols
+
c
]];
}
return
color_ctx
;
return
color_ctx
;
}
}
#endif // CONFIG_PALETTE
#endif // CONFIG_PALETTE
...
...
av1/common/entropymode.h
View file @
b1c3bb57
...
@@ -222,7 +222,8 @@ static INLINE int av1_ceil_log2(int n) {
...
@@ -222,7 +222,8 @@ static INLINE int av1_ceil_log2(int n) {
#if CONFIG_PALETTE
#if CONFIG_PALETTE
int
av1_get_palette_color_context
(
const
uint8_t
*
color_map
,
int
cols
,
int
r
,
int
av1_get_palette_color_context
(
const
uint8_t
*
color_map
,
int
cols
,
int
r
,
int
c
,
int
n
,
int
*
color_order
);
int
c
,
int
n
,
uint8_t
*
color_order
,
int
*
color_idx
);
#endif // CONFIG_PALETTE
#endif // CONFIG_PALETTE
#ifdef __cplusplus
#ifdef __cplusplus
...
...
av1/decoder/detokenize.c
View file @
b1c3bb57
...
@@ -282,15 +282,15 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
...
@@ -282,15 +282,15 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
#if CONFIG_PALETTE
#if CONFIG_PALETTE
void
av1_decode_palette_tokens
(
MACROBLOCKD
*
const
xd
,
int
plane
,
void
av1_decode_palette_tokens
(
MACROBLOCKD
*
const
xd
,
int
plane
,
aom_reader
*
r
)
{
aom_reader
*
r
)
{
MODE_INFO
*
const
mi
=
xd
->
mi
[
0
];
const
MODE_INFO
*
const
mi
=
xd
->
mi
[
0
];
MB_MODE_INFO
*
const
mbmi
=
&
mi
->
mbmi
;
const
MB_MODE_INFO
*
const
mbmi
=
&
mi
->
mbmi
;
const
BLOCK_SIZE
bsize
=
mbmi
->
sb_type
;
const
BLOCK_SIZE
bsize
=
mbmi
->
sb_type
;
const
int
rows
=
(
4
*
num_4x4_blocks_high_lookup
[
bsize
])
>>
const
int
rows
=
(
4
*
num_4x4_blocks_high_lookup
[
bsize
])
>>
(
xd
->
plane
[
plane
!=
0
].
subsampling_y
);
(
xd
->
plane
[
plane
!=
0
].
subsampling_y
);
const
int
cols
=
(
4
*
num_4x4_blocks_wide_lookup
[
bsize
])
>>
const
int
cols
=
(
4
*
num_4x4_blocks_wide_lookup
[
bsize
])
>>
(
xd
->
plane
[
plane
!=
0
].
subsampling_x
);
(
xd
->
plane
[
plane
!=
0
].
subsampling_x
);
int
color_idx
,
color_ctx
,
color_order
[
PALETTE_MAX_SIZE
];
u
int
8_t
color_order
[
PALETTE_MAX_SIZE
];
int
n
=
mbmi
->
palette_mode_info
.
palette_size
[
plane
!=
0
];
const
int
n
=
mbmi
->
palette_mode_info
.
palette_size
[
plane
!=
0
];
int
i
,
j
;
int
i
,
j
;
uint8_t
*
color_map
=
xd
->
plane
[
plane
!=
0
].
color_index_map
;
uint8_t
*
color_map
=
xd
->
plane
[
plane
!=
0
].
color_index_map
;
const
aom_prob
(
*
const
prob
)[
PALETTE_COLOR_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
const
aom_prob
(
*
const
prob
)[
PALETTE_COLOR_CONTEXTS
][
PALETTE_COLORS
-
1
]
=
...
@@ -299,10 +299,10 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
...
@@ -299,10 +299,10 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
co
lor_ctx
=
co
nst
int
color_ctx
=
av1_get_palette_color_context
(
color_map
,
cols
,
i
,
j
,
av1_get_palette_color_context
(
color_map
,
cols
,
i
,
j
,
n
,
color_order
);
n
,
color_order
,
NULL
);
color_idx
=
aom_read_tree
(
r
,
av1_palette_color_tree
[
n
-
2
],
const
int
color_idx
=
aom_read_tree
(
r
,
av1_palette_color_tree
[
n
-
2
],
prob
[
n
-
2
][
color_ctx
],
ACCT_STR
);
prob
[
n
-
2
][
color_ctx
],
ACCT_STR
);
assert
(
color_idx
>=
0
&&
color_idx
<
n
);
assert
(
color_idx
>=
0
&&
color_idx
<
n
);
color_map
[
i
*
cols
+
j
]
=
color_order
[
color_idx
];
color_map
[
i
*
cols
+
j
]
=
color_order
[
color_idx
];
}
}
...
...
av1/encoder/rdopt.c
View file @
b1c3bb57
...
@@ -888,8 +888,7 @@ static int rd_pick_palette_intra_sby(
...
@@ -888,8 +888,7 @@ static int rd_pick_palette_intra_sby(
if
(
colors
>
1
&&
colors
<=
64
)
{
if
(
colors
>
1
&&
colors
<=
64
)
{
int
r
,
c
,
i
,
j
,
k
;
int
r
,
c
,
i
,
j
,
k
;
const
int
max_itr
=
50
;
const
int
max_itr
=
50
;
int
color_ctx
,
color_idx
=
0
;
uint8_t
color_order
[
PALETTE_MAX_SIZE
];
int
color_order
[
PALETTE_MAX_SIZE
];
float
*
const
data
=
x
->
palette_buffer
->
kmeans_data_buf
;
float
*
const
data
=
x
->
palette_buffer
->
kmeans_data_buf
;
float
centroids
[
PALETTE_MAX_SIZE
];
float
centroids
[
PALETTE_MAX_SIZE
];
uint8_t
*
const
color_map
=
xd
->
plane
[
0
].
color_index_map
;
uint8_t
*
const
color_map
=
xd
->
plane
[
0
].
color_index_map
;
...
@@ -970,13 +969,9 @@ static int rd_pick_palette_intra_sby(
...
@@ -970,13 +969,9 @@ static int rd_pick_palette_intra_sby(
1
);
1
);
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
color_ctx
=
av1_get_palette_color_context
(
color_map
,
cols
,
i
,
j
,
k
,
int
color_idx
;
color_order
);
const
int
color_ctx
=
av1_get_palette_color_context
(
for
(
r
=
0
;
r
<
k
;
++
r
)
color_map
,
cols
,
i
,
j
,
k
,
color_order
,
&
color_idx
);
if
(
color_map
[
i
*
cols
+
j
]
==
color_order
[
r
])
{
color_idx
=
r
;
break
;
}
assert
(
color_idx
>=
0
&&
color_idx
<
k
);
assert
(
color_idx
>=
0
&&
color_idx
<
k
);
this_rate
+=
cpi
->
palette_y_color_cost
[
k
-
2
][
color_ctx
][
color_idx
];
this_rate
+=
cpi
->
palette_y_color_cost
[
k
-
2
][
color_ctx
][
color_idx
];
}
}
...
@@ -1785,8 +1780,7 @@ static void rd_pick_palette_intra_sbuv(
...
@@ -1785,8 +1780,7 @@ static void rd_pick_palette_intra_sbuv(
if
(
colors
>
1
&&
colors
<=
64
)
{
if
(
colors
>
1
&&
colors
<=
64
)
{
int
r
,
c
,
n
,
i
,
j
;
int
r
,
c
,
n
,
i
,
j
;
const
int
max_itr
=
50
;
const
int
max_itr
=
50
;
int
color_ctx
,
color_idx
=
0
;
uint8_t
color_order
[
PALETTE_MAX_SIZE
];
int
color_order
[
PALETTE_MAX_SIZE
];
int64_t
this_sse
;
int64_t
this_sse
;
float
lb_u
,
ub_u
,
val_u
;
float
lb_u
,
ub_u
,
val_u
;
float
lb_v
,
ub_v
,
val_v
;
float
lb_v
,
ub_v
,
val_v
;
...
@@ -1876,13 +1870,9 @@ static void rd_pick_palette_intra_sbuv(
...
@@ -1876,13 +1870,9 @@ static void rd_pick_palette_intra_sbuv(
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
color_ctx
=
av1_get_palette_color_context
(
color_map
,
cols
,
i
,
j
,
n
,
int
color_idx
;
color_order
);
const
int
color_ctx
=
av1_get_palette_color_context
(
for
(
r
=
0
;
r
<
n
;
++
r
)
color_map
,
cols
,
i
,
j
,
n
,
color_order
,
&
color_idx
);
if
(
color_map
[
i
*
cols
+
j
]
==
color_order
[
r
])
{
color_idx
=
r
;
break
;
}
assert
(
color_idx
>=
0
&&
color_idx
<
n
);
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
-
2
][
color_ctx
][
color_idx
];
}
}
...
...
av1/encoder/tokenize.c
View file @
b1c3bb57
...
@@ -341,16 +341,16 @@ static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id,
...
@@ -341,16 +341,16 @@ static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id,
}
}
#if CONFIG_PALETTE
#if CONFIG_PALETTE
void
av1_tokenize_palette_sb
(
struct
ThreadData
*
const
td
,
BLOCK_SIZE
bsize
,
void
av1_tokenize_palette_sb
(
const
struct
ThreadData
*
const
td
,
int
plane
,
TOKENEXTRA
**
t
)
{
BLOCK_SIZE
bsize
,
int
plane
,
TOKENEXTRA
**
t
)
{
MACROBLOCK
*
const
x
=
&
td
->
mb
;
const
MACROBLOCK
*
const
x
=
&
td
->
mb
;
MACROBLOCKD
*
const
xd
=
&
x
->
e_mbd
;
const
MACROBLOCKD
*
const
xd
=
&
x
->
e_mbd
;
MB_MODE_INFO
*
mbmi
=
&
xd
->
mi
[
0
]
->
mbmi
;
const
MB_MODE_INFO
*
const
mbmi
=
&
xd
->
mi
[
0
]
->
mbmi
;
uint8_t
*
color_map
=
xd
->
plane
[
plane
!=
0
].
color_index_map
;
const
uint8_t
*
const
color_map
=
xd
->
plane
[
plane
!=
0
].
color_index_map
;
PALETTE_MODE_INFO
*
pmi
=
&
mbmi
->
palette_mode_info
;
const
PALETTE_MODE_INFO
*
const
pmi
=
&
mbmi
->
palette_mode_info
;
int
n
=
pmi
->
palette_size
[
plane
!=
0
];
const
int
n
=
pmi
->
palette_size
[
plane
!=
0
];
int
i
,
j
,
k
;
int
i
,
j
;
int
color_new_idx
=
-
1
,
color_ctx
,
color_order
[
PALETTE_MAX_SIZE
];
u
int
8_t
color_order
[
PALETTE_MAX_SIZE
];
const
int
rows
=
(
4
*
num_4x4_blocks_high_lookup
[
bsize
])
>>
const
int
rows
=
(
4
*
num_4x4_blocks_high_lookup
[
bsize
])
>>
(
xd
->
plane
[
plane
!=
0
].
subsampling_y
);
(
xd
->
plane
[
plane
!=
0
].
subsampling_y
);
const
int
cols
=
(
4
*
num_4x4_blocks_wide_lookup
[
bsize
])
>>
const
int
cols
=
(
4
*
num_4x4_blocks_wide_lookup
[
bsize
])
>>
...
@@ -361,15 +361,10 @@ void av1_tokenize_palette_sb(struct ThreadData *const td, BLOCK_SIZE bsize,
...
@@ -361,15 +361,10 @@ void av1_tokenize_palette_sb(struct ThreadData *const td, BLOCK_SIZE bsize,
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
i
=
0
;
i
<
rows
;
++
i
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
for
(
j
=
(
i
==
0
?
1
:
0
);
j
<
cols
;
++
j
)
{
color_ctx
=
int
color_new_idx
;
av1_get_palette_color_context
(
color_map
,
cols
,
i
,
j
,
n
,
color_order
);
const
int
color_ctx
=
av1_get_palette_color_context
(
for
(
k
=
0
;
k
<
n
;
++
k
)
color_map
,
cols
,
i
,
j
,
n
,
color_order
,
&
color_new_idx
);
if
(
color_map
[
i
*
cols
+
j
]
==
color_order
[
k
])
{
color_new_idx
=
k
;
break
;
}
assert
(
color_new_idx
>=
0
&&
color_new_idx
<
n
);
assert
(
color_new_idx
>=
0
&&
color_new_idx
<
n
);
(
*
t
)
->
token
=
color_new_idx
;
(
*
t
)
->
token
=
color_new_idx
;
(
*
t
)
->
context_tree
=
probs
[
n
-
2
][
color_ctx
];
(
*
t
)
->
context_tree
=
probs
[
n
-
2
][
color_ctx
];
(
*
t
)
->
skip_eob_node
=
0
;
(
*
t
)
->
skip_eob_node
=
0
;
...
...
av1/encoder/tokenize.h
View file @
b1c3bb57
...
@@ -55,8 +55,8 @@ struct AV1_COMP;
...
@@ -55,8 +55,8 @@ struct AV1_COMP;
struct
ThreadData
;
struct
ThreadData
;
#if CONFIG_PALETTE
#if CONFIG_PALETTE
void
av1_tokenize_palette_sb
(
struct
ThreadData
*
const
td
,
BLOCK_SIZE
bsize
,
void
av1_tokenize_palette_sb
(
const
struct
ThreadData
*
const
td
,
int
plane
,
TOKENEXTRA
**
t
);
BLOCK_SIZE
bsize
,
int
plane
,
TOKENEXTRA
**
t
);
#endif // CONFIG_PALETTE
#endif // CONFIG_PALETTE
void
av1_tokenize_sb
(
const
struct
AV1_COMP
*
cpi
,
struct
ThreadData
*
td
,
void
av1_tokenize_sb
(
const
struct
AV1_COMP
*
cpi
,
struct
ThreadData
*
td
,
...
...
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