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
1238137c
Commit
1238137c
authored
Feb 21, 2017
by
Yushin Cho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change PVQ's generic coder to use dyadic and ec_adapt adaptation
Change-Id: I23b035340ed16b85a12856256d3115f19700dfb3
parent
52168e9d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
48 deletions
+13
-48
av1/common/generic_code.c
av1/common/generic_code.c
+1
-33
av1/common/generic_code.h
av1/common/generic_code.h
+2
-5
av1/common/pvq.c
av1/common/pvq.c
+3
-3
av1/common/pvq_state.c
av1/common/pvq_state.c
+1
-1
av1/decoder/generic_decoder.c
av1/decoder/generic_decoder.c
+3
-3
av1/encoder/generic_encoder.c
av1/encoder/generic_encoder.c
+3
-3
No files found.
av1/common/generic_code.c
View file @
1238137c
...
...
@@ -83,22 +83,6 @@ void aom_cdf_adapt_q15(int val, uint16_t *cdf, int n, int *count, int rate) {
OD_ASSERT
(
cdf
[
n
-
1
]
==
32768
);
}
/** Initializes the cdfs and freq counts for a model.
*
* @param [out] model model being initialized
*/
void
generic_model_init
(
generic_encoder
*
model
)
{
int
i
;
int
j
;
model
->
increment
=
64
;
for
(
i
=
0
;
i
<
GENERIC_TABLES
;
i
++
)
{
for
(
j
=
0
;
j
<
16
;
j
++
)
{
/* Do flat initialization equivalent to a single symbol in each bin. */
model
->
cdf
[
i
][
j
]
=
(
j
+
1
)
*
model
->
increment
;
}
}
}
/** Takes the base-2 log of E(x) in Q1.
*
* @param [in] ExQ16 expectation of x in Q16
...
...
@@ -132,23 +116,7 @@ int log_ex(int ex_q16) {
* @param [in] integration integration period of ExQ16 (leaky average over
* 1<<integration samples)
*/
void
generic_model_update
(
generic_encoder
*
model
,
int
*
ex_q16
,
int
x
,
int
xs
,
int
id
,
int
integration
)
{
int
i
;
int
xenc
;
uint16_t
*
cdf
;
cdf
=
model
->
cdf
[
id
];
/* Renormalize if we cannot add increment */
if
(
cdf
[
15
]
+
model
->
increment
>
32767
)
{
for
(
i
=
0
;
i
<
16
;
i
++
)
{
/* Second term ensures that the pdf is non-null */
cdf
[
i
]
=
(
cdf
[
i
]
>>
1
)
+
i
+
1
;
}
}
/* Update freq count */
xenc
=
OD_MINI
(
15
,
xs
);
/* This can be easily vectorized */
for
(
i
=
xenc
;
i
<
16
;
i
++
)
cdf
[
i
]
+=
model
->
increment
;
void
generic_model_update
(
int
*
ex_q16
,
int
x
,
int
integration
)
{
/* We could have saturated ExQ16 directly, but this is safe and simpler */
x
=
OD_MINI
(
x
,
32767
);
OD_IIR_DIADIC
(
*
ex_q16
,
x
<<
16
,
integration
);
...
...
av1/common/generic_code.h
View file @
1238137c
...
...
@@ -28,9 +28,7 @@
typedef
struct
{
/** cdf for multiple expectations of x */
uint16_t
cdf
[
GENERIC_TABLES
][
16
];
/** Frequency increment for learning the cdfs */
int
increment
;
uint16_t
cdf
[
GENERIC_TABLES
][
CDF_SIZE
(
16
)];
}
generic_encoder
;
#define OD_IIR_DIADIC(y, x, shift) ((y) += ((x) - (y)) >> (shift))
...
...
@@ -87,7 +85,6 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int
log_ex
(
int
ex_q16
);
void
generic_model_update
(
generic_encoder
*
model
,
int
*
ex_q16
,
int
x
,
int
xs
,
int
id
,
int
integration
);
void
generic_model_update
(
int
*
ex_q16
,
int
x
,
int
integration
);
#endif
av1/common/pvq.c
View file @
1238137c
...
...
@@ -187,9 +187,9 @@ void od_adapt_pvq_ctx_reset(od_pvq_adapt_ctx *state, int is_keyframe) {
int
pli
;
int
bs
;
ctx
=
&
state
->
pvq_codeword_ctx
;
generic_model_init
(
&
state
->
pvq_param_model
[
0
]);
generic_model_init
(
&
state
->
pvq_param_model
[
1
]);
generic_model_init
(
&
state
->
pvq_param_model
[
2
]);
OD_CDFS_INIT
(
state
->
pvq_param_model
[
0
]
.
cdf
,
0
);
OD_CDFS_INIT
(
state
->
pvq_param_model
[
1
]
.
cdf
,
0
);
OD_CDFS_INIT
(
state
->
pvq_param_model
[
2
]
.
cdf
,
0
);
for
(
i
=
0
;
i
<
2
*
OD_TXSIZES
;
i
++
)
{
ctx
->
pvq_adapt
[
4
*
i
+
OD_ADAPT_K_Q8
]
=
384
;
ctx
->
pvq_adapt
[
4
*
i
+
OD_ADAPT_SUM_EX_Q8
]
=
256
;
...
...
av1/common/pvq_state.c
View file @
1238137c
...
...
@@ -18,7 +18,7 @@ void od_adapt_ctx_reset(od_adapt_ctx *adapt, int is_keyframe) {
OD_CDFS_INIT_Q15
(
adapt
->
skip_cdf
);
for
(
pli
=
0
;
pli
<
OD_NPLANES_MAX
;
pli
++
)
{
int
i
;
generic_model_init
(
&
adapt
->
model_dc
[
pli
]);
OD_CDFS_INIT
(
adapt
->
model_dc
[
pli
]
.
cdf
,
0
);
for
(
i
=
0
;
i
<
OD_TXSIZES
;
i
++
)
{
int
j
;
adapt
->
ex_g
[
pli
][
i
]
=
8
;
...
...
av1/decoder/generic_decoder.c
View file @
1238137c
...
...
@@ -107,8 +107,8 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
id
=
OD_MINI
(
GENERIC_TABLES
-
1
,
lg_q1
);
cdf
=
model
->
cdf
[
id
];
ms
=
(
max
+
(
1
<<
shift
>>
1
))
>>
shift
;
if
(
max
==
-
1
)
xs
=
aom_read_
cdf_unscaled
(
r
,
cdf
,
16
,
ACCT_STR_NAME
);
else
xs
=
aom_read_
cdf_unscaled
(
r
,
cdf
,
OD_MINI
(
ms
+
1
,
16
),
ACCT_STR_NAME
);
if
(
max
==
-
1
)
xs
=
aom_read_
symbol_pvq
(
r
,
cdf
,
16
,
ACCT_STR_NAME
);
else
xs
=
aom_read_
symbol_pvq
(
r
,
cdf
,
OD_MINI
(
ms
+
1
,
16
),
ACCT_STR_NAME
);
if
(
xs
==
15
)
{
int
e
;
unsigned
decay
;
...
...
@@ -132,7 +132,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
lsb
-=
!
special
<<
(
shift
-
1
);
}
x
=
(
xs
<<
shift
)
+
lsb
;
generic_model_update
(
model
,
ex_q16
,
x
,
xs
,
id
,
integration
);
generic_model_update
(
ex_q16
,
x
,
integration
);
OD_LOG
((
OD_LOG_ENTROPY_CODER
,
OD_LOG_DEBUG
,
"dec: %d %d %d %d %d %x"
,
*
ex_q16
,
x
,
shift
,
id
,
xs
,
dec
->
rng
));
return
x
;
...
...
av1/encoder/generic_encoder.c
View file @
1238137c
...
...
@@ -105,9 +105,9 @@ void generic_encode(aom_writer *w, generic_encoder *model, int x, int max,
xs
=
(
x
+
(
1
<<
shift
>>
1
))
>>
shift
;
ms
=
(
max
+
(
1
<<
shift
>>
1
))
>>
shift
;
OD_ASSERT
(
max
==
-
1
||
xs
<=
ms
);
if
(
max
==
-
1
)
aom_write_
cdf_unscaled
(
w
,
OD_MINI
(
15
,
xs
),
cdf
,
16
);
if
(
max
==
-
1
)
aom_write_
symbol_pvq
(
w
,
OD_MINI
(
15
,
xs
),
cdf
,
16
);
else
{
aom_write_
cdf_unscaled
(
w
,
OD_MINI
(
15
,
xs
),
cdf
,
OD_MINI
(
ms
+
1
,
16
));
aom_write_
symbol_pvq
(
w
,
OD_MINI
(
15
,
xs
),
cdf
,
OD_MINI
(
ms
+
1
,
16
));
}
if
(
xs
>=
15
)
{
int
e
;
...
...
@@ -132,7 +132,7 @@ void generic_encode(aom_writer *w, generic_encoder *model, int x, int max,
shift
-
special
);
}
}
generic_model_update
(
model
,
ex_q16
,
x
,
xs
,
id
,
integration
);
generic_model_update
(
ex_q16
,
x
,
integration
);
OD_LOG
((
OD_LOG_ENTROPY_CODER
,
OD_LOG_DEBUG
,
"enc: %d %d %d %d %d %x"
,
*
ex_q16
,
x
,
shift
,
id
,
xs
,
enc
->
rng
));
}
...
...
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