Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
aom-rav1e
Commits
d27f5e27
Commit
d27f5e27
authored
Jul 14, 2017
by
Angie Chiang
Browse files
lv_map clean-up: merge get_nz_map_ctx/2
Change-Id: Ied1a493723cac2ec4674bac642525a937826733f
parent
0c6244b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
av1/common/txb_common.h
View file @
d27f5e27
...
...
@@ -195,71 +195,6 @@ static int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = {
{
-
1
,
1
},
{
0
,
-
2
},
{
0
,
-
1
},
{
1
,
-
2
},
{
1
,
-
1
},
};
static
INLINE
int
get_nz_map_ctx
(
const
tran_low_t
*
tcoeffs
,
const
uint8_t
*
txb_mask
,
const
int
coeff_idx
,
// raster order
const
int
bwl
,
const
int
height
)
{
const
int
row
=
coeff_idx
>>
bwl
;
const
int
col
=
coeff_idx
-
(
row
<<
bwl
);
int
ctx
=
0
;
int
idx
;
int
stride
=
1
<<
bwl
;
if
(
row
==
0
&&
col
==
0
)
return
0
;
if
(
row
==
0
&&
col
==
1
)
return
1
+
(
tcoeffs
[
0
]
!=
0
);
if
(
row
==
1
&&
col
==
0
)
return
3
+
(
tcoeffs
[
0
]
!=
0
);
if
(
row
==
1
&&
col
==
1
)
{
int
pos
;
ctx
=
(
tcoeffs
[
0
]
!=
0
);
if
(
txb_mask
[
1
])
ctx
+=
(
tcoeffs
[
1
]
!=
0
);
pos
=
1
<<
bwl
;
if
(
txb_mask
[
pos
])
ctx
+=
(
tcoeffs
[
pos
]
!=
0
);
ctx
=
(
ctx
+
1
)
>>
1
;
assert
(
5
+
ctx
<=
7
);
return
5
+
ctx
;
}
for
(
idx
=
0
;
idx
<
SIG_REF_OFFSET_NUM
;
++
idx
)
{
int
ref_row
=
row
+
sig_ref_offset
[
idx
][
0
];
int
ref_col
=
col
+
sig_ref_offset
[
idx
][
1
];
int
pos
;
if
(
ref_row
<
0
||
ref_col
<
0
||
ref_row
>=
height
||
ref_col
>=
stride
)
continue
;
pos
=
(
ref_row
<<
bwl
)
+
ref_col
;
if
(
txb_mask
[
pos
])
ctx
+=
(
tcoeffs
[
pos
]
!=
0
);
}
if
(
row
==
0
)
{
ctx
=
(
ctx
+
1
)
>>
1
;
assert
(
ctx
<
3
);
return
8
+
ctx
;
}
if
(
col
==
0
)
{
ctx
=
(
ctx
+
1
)
>>
1
;
assert
(
ctx
<
3
);
return
11
+
ctx
;
}
ctx
>>=
1
;
assert
(
14
+
ctx
<
20
);
return
14
+
ctx
;
}
static
INLINE
int
get_nz_count
(
const
tran_low_t
*
tcoeffs
,
int
stride
,
int
height
,
int
row
,
int
col
,
const
int16_t
*
iscan
)
{
...
...
@@ -328,12 +263,10 @@ static INLINE int get_nz_map_ctx_from_count(int count,
return
14
+
ctx
;
}
// TODO(angiebird): merge this function with get_nz_map_ctx() after proper
// testing
static
INLINE
int
get_nz_map_ctx2
(
const
tran_low_t
*
tcoeffs
,
const
int
coeff_idx
,
// raster order
const
int
bwl
,
const
int
height
,
const
int16_t
*
iscan
)
{
static
INLINE
int
get_nz_map_ctx
(
const
tran_low_t
*
tcoeffs
,
const
int
coeff_idx
,
// raster order
const
int
bwl
,
const
int
height
,
const
int16_t
*
iscan
)
{
int
stride
=
1
<<
bwl
;
const
int
row
=
coeff_idx
>>
bwl
;
const
int
col
=
coeff_idx
-
(
row
<<
bwl
);
...
...
av1/decoder/decodetxb.c
View file @
d27f5e27
...
...
@@ -60,7 +60,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const
int
height
=
tx_size_high
[
tx_size
];
int
cul_level
=
0
;
unsigned
int
(
*
nz_map_count
)[
SIG_COEF_CONTEXTS
][
2
];
uint8_t
txb_mask
[
32
*
32
]
=
{
0
};
nz_map_count
=
(
counts
)
?
&
counts
->
nz_map
[
txs_ctx
][
plane_type
]
:
NULL
;
...
...
@@ -85,10 +84,11 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const
TX_TYPE
tx_type
=
av1_get_tx_type
(
plane_type
,
xd
,
block
,
tx_size
);
const
SCAN_ORDER
*
const
scan_order
=
get_scan
(
cm
,
tx_size
,
tx_type
,
mbmi
);
const
int16_t
*
scan
=
scan_order
->
scan
;
const
int16_t
*
iscan
=
scan_order
->
iscan
;
for
(
c
=
0
;
c
<
seg_eob
;
++
c
)
{
int
is_nz
;
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeffs
,
txb_mask
,
scan
[
c
],
bwl
,
height
);
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeffs
,
scan
[
c
],
bwl
,
height
,
iscan
);
int
eob_ctx
=
get_eob_ctx
(
tcoeffs
,
scan
[
c
],
txs_ctx
);
if
(
c
<
seg_eob
-
1
)
...
...
@@ -111,7 +111,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if
(
counts
)
++
counts
->
eob_flag
[
txs_ctx
][
plane_type
][
eob_ctx
][
is_eob
];
if
(
is_eob
)
break
;
}
txb_mask
[
scan
[
c
]]
=
1
;
}
*
eob
=
AOMMIN
(
seg_eob
,
c
+
1
);
...
...
av1/encoder/encodetxb.c
View file @
d27f5e27
...
...
@@ -81,12 +81,12 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
const
TX_TYPE
tx_type
=
av1_get_tx_type
(
plane_type
,
xd
,
block
,
tx_size
);
const
SCAN_ORDER
*
const
scan_order
=
get_scan
(
cm
,
tx_size
,
tx_type
,
mbmi
);
const
int16_t
*
scan
=
scan_order
->
scan
;
const
int16_t
*
iscan
=
scan_order
->
iscan
;
int
c
;
int
is_nz
;
const
int
bwl
=
b_width_log2_lookup
[
txsize_to_bsize
[
tx_size
]]
+
2
;
const
int
height
=
tx_size_high
[
tx_size
];
const
int
seg_eob
=
tx_size_2d
[
tx_size
];
uint8_t
txb_mask
[
32
*
32
]
=
{
0
};
uint16_t
update_eob
=
0
;
(
void
)
blk_row
;
...
...
@@ -103,7 +103,7 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
eob_flag
=
cm
->
fc
->
eob_flag
[
txs_ctx
][
plane_type
];
for
(
c
=
0
;
c
<
eob
;
++
c
)
{
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeff
,
txb_mask
,
scan
[
c
],
bwl
,
height
);
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeff
,
scan
[
c
],
bwl
,
height
,
iscan
);
int
eob_ctx
=
get_eob_ctx
(
tcoeff
,
scan
[
c
],
txs_ctx
);
tran_low_t
v
=
tcoeff
[
scan
[
c
]];
...
...
@@ -116,7 +116,6 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if
(
is_nz
)
{
aom_write
(
w
,
c
==
(
eob
-
1
),
eob_flag
[
eob_ctx
]);
}
txb_mask
[
scan
[
c
]]
=
1
;
}
int
i
;
...
...
@@ -308,14 +307,12 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
const
int
bwl
=
b_width_log2_lookup
[
txsize_to_bsize
[
tx_size
]]
+
2
;
const
int
height
=
tx_size_high
[
tx_size
];
// txb_mask is only initialized for once here. After that, it will be set when
// coding zero map and then reset when coding level 1 info.
uint8_t
txb_mask
[
32
*
32
]
=
{
0
};
aom_prob
(
*
coeff_base
)[
COEFF_BASE_CONTEXTS
]
=
xd
->
fc
->
coeff_base
[
txs_ctx
][
plane_type
];
const
SCAN_ORDER
*
const
scan_order
=
get_scan
(
cm
,
tx_size
,
tx_type
,
mbmi
);
const
int16_t
*
scan
=
scan_order
->
scan
;
const
int16_t
*
iscan
=
scan_order
->
iscan
;
cost
=
0
;
...
...
@@ -336,7 +333,7 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int
level
=
abs
(
v
);
if
(
c
<
seg_eob
)
{
int
coeff_ctx
=
get_nz_map_ctx
(
qcoeff
,
txb_mask
,
scan
[
c
],
bwl
,
height
);
int
coeff_ctx
=
get_nz_map_ctx
(
qcoeff
,
scan
[
c
],
bwl
,
height
,
iscan
);
cost
+=
av1_cost_bit
(
nz_map
[
coeff_ctx
],
is_nz
);
}
...
...
@@ -405,8 +402,6 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
c
==
(
eob
-
1
));
}
}
txb_mask
[
scan
[
c
]]
=
1
;
}
return
cost
;
...
...
@@ -1059,7 +1054,7 @@ void update_level_down(int coeff_idx, TxbCache *txb_cache, TxbInfo *txb_info) {
const
int
count
=
txb_cache
->
nz_count_arr
[
nb_coeff_idx
];
txb_cache
->
nz_ctx_arr
[
nb_coeff_idx
][
0
]
=
get_nz_map_ctx_from_count
(
count
,
txb_info
->
qcoeff
,
nb_coeff_idx
,
txb_info
->
bwl
,
iscan
);
// int ref_ctx = get_nz_map_ctx
2
(txb_info->qcoeff, nb_coeff_idx,
// int ref_ctx = get_nz_map_ctx(txb_info->qcoeff, nb_coeff_idx,
// txb_info->bwl, iscan);
// if (ref_ctx != txb_cache->nz_ctx_arr[nb_coeff_idx][0])
// printf("nz ctx %d ref_ctx %d\n",
...
...
@@ -1149,8 +1144,8 @@ static int get_coeff_cost(tran_low_t qc, int scan_idx, TxbInfo *txb_info,
const
int16_t
*
iscan
=
txb_info
->
scan_order
->
iscan
;
if
(
scan_idx
<
txb_info
->
seg_eob
)
{
int
coeff_ctx
=
get_nz_map_ctx
2
(
txb_info
->
qcoeff
,
scan
[
scan_idx
],
txb_info
->
bwl
,
txb_info
->
height
,
iscan
);
int
coeff_ctx
=
get_nz_map_ctx
(
txb_info
->
qcoeff
,
scan
[
scan_idx
],
txb_info
->
bwl
,
txb_info
->
height
,
iscan
);
cost
+=
av1_cost_bit
(
txb_probs
->
nz_map
[
coeff_ctx
],
is_nz
);
}
...
...
@@ -1576,6 +1571,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const
TX_TYPE
tx_type
=
av1_get_tx_type
(
plane_type
,
xd
,
block
,
tx_size
);
const
SCAN_ORDER
*
const
scan_order
=
get_scan
(
cm
,
tx_size
,
tx_type
,
mbmi
);
const
int16_t
*
scan
=
scan_order
->
scan
;
const
int16_t
*
iscan
=
scan_order
->
iscan
;
const
int
seg_eob
=
get_tx_eob
(
&
cpi
->
common
.
seg
,
segment_id
,
tx_size
);
int
c
,
i
;
TXB_CTX
txb_ctx
;
...
...
@@ -1585,7 +1581,6 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const
int
height
=
tx_size_high
[
tx_size
];
int
cul_level
=
0
;
unsigned
int
(
*
nz_map_count
)[
SIG_COEF_CONTEXTS
][
2
];
uint8_t
txb_mask
[
32
*
32
]
=
{
0
};
TX_SIZE
txsize_ctx
=
get_txsize_context
(
tx_size
);
...
...
@@ -1611,7 +1606,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
for
(
c
=
0
;
c
<
eob
;
++
c
)
{
tran_low_t
v
=
qcoeff
[
scan
[
c
]];
int
is_nz
=
(
v
!=
0
);
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeff
,
txb_mask
,
scan
[
c
],
bwl
,
height
);
int
coeff_ctx
=
get_nz_map_ctx
(
tcoeff
,
scan
[
c
],
bwl
,
height
,
iscan
);
int
eob_ctx
=
get_eob_ctx
(
tcoeff
,
scan
[
c
],
txsize_ctx
);
if
(
c
==
seg_eob
-
1
)
break
;
...
...
@@ -1621,7 +1616,6 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
if
(
is_nz
)
{
++
td
->
counts
->
eob_flag
[
txsize_ctx
][
plane_type
][
eob_ctx
][
c
==
(
eob
-
1
)];
}
txb_mask
[
scan
[
c
]]
=
1
;
}
// Reverse process order to handle coefficient level and sign.
...
...
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