Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
875f6955
Commit
875f6955
authored
Mar 25, 2017
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/vp9: misc cosmetics
Imported from Libav
parent
ff8436ba
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
337 additions
and
302 deletions
+337
-302
vp9.c
libavcodec/vp9.c
+31
-29
vp9block.c
libavcodec/vp9block.c
+112
-86
vp9data.c
libavcodec/vp9data.c
+47
-47
vp9mvs.c
libavcodec/vp9mvs.c
+106
-107
vp9prob.c
libavcodec/vp9prob.c
+41
-33
No files found.
libavcodec/vp9.c
View file @
875f6955
...
...
@@ -252,7 +252,7 @@ static int update_block_buffers(AVCodecContext *avctx)
return
0
;
}
//
for some reason t
he sign bit is at the end, not the start, of a bit sequence
//
T
he sign bit is at the end, not the start, of a bit sequence
static
av_always_inline
int
get_sbits_inv
(
GetBitContext
*
gb
,
int
n
)
{
int
v
=
get_bits
(
gb
,
n
);
...
...
@@ -292,13 +292,13 @@ static int update_prob(VP56RangeCoder *c, int p)
/* This code is trying to do a differential probability update. For a
* current probability A in the range [1, 255], the difference to a new
* probability of any value can be expressed differentially as 1-A,255-A
* probability of any value can be expressed differentially as 1-A,
255-A
* where some part of this (absolute range) exists both in positive as
* well as the negative part, whereas another part only exists in one
* half. We're trying to code this shared part differentially, i.e.
* times two where the value of the lowest bit specifies the sign, and
* the single part is then coded on top of this. This absolute difference
* then again has a value of [0,254], but a bigger value in this range
* then again has a value of [0,
254], but a bigger value in this range
* indicates that we're further away from the original value A, so we
* can code this as a VLC code, since higher values are increasingly
* unlikely. The first 20 values in inv_map_table[] allow 'cheap, rough'
...
...
@@ -414,12 +414,15 @@ static int decode_frame_header(AVCodecContext *avctx,
*
ref
=
get_bits
(
&
s
->
gb
,
3
);
return
0
;
}
s
->
last_keyframe
=
s
->
s
.
h
.
keyframe
;
s
->
s
.
h
.
keyframe
=
!
get_bits1
(
&
s
->
gb
);
last_invisible
=
s
->
s
.
h
.
invisible
;
s
->
s
.
h
.
invisible
=
!
get_bits1
(
&
s
->
gb
);
s
->
s
.
h
.
errorres
=
get_bits1
(
&
s
->
gb
);
s
->
s
.
h
.
use_last_frame_mvs
=
!
s
->
s
.
h
.
errorres
&&
!
last_invisible
;
if
(
s
->
s
.
h
.
keyframe
)
{
if
(
get_bits_long
(
&
s
->
gb
,
24
)
!=
VP9_SYNCCODE
)
{
// synccode
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid sync code
\n
"
);
...
...
@@ -565,12 +568,11 @@ static int decode_frame_header(AVCodecContext *avctx,
for
(
i
=
0
;
i
<
7
;
i
++
)
s
->
s
.
h
.
segmentation
.
prob
[
i
]
=
get_bits1
(
&
s
->
gb
)
?
get_bits
(
&
s
->
gb
,
8
)
:
255
;
if
((
s
->
s
.
h
.
segmentation
.
temporal
=
get_bits1
(
&
s
->
gb
)))
{
if
((
s
->
s
.
h
.
segmentation
.
temporal
=
get_bits1
(
&
s
->
gb
)))
for
(
i
=
0
;
i
<
3
;
i
++
)
s
->
s
.
h
.
segmentation
.
pred_prob
[
i
]
=
get_bits1
(
&
s
->
gb
)
?
get_bits
(
&
s
->
gb
,
8
)
:
255
;
}
}
if
(
get_bits1
(
&
s
->
gb
))
{
s
->
s
.
h
.
segmentation
.
absolute_vals
=
get_bits1
(
&
s
->
gb
);
...
...
@@ -734,9 +736,9 @@ static int decode_frame_header(AVCodecContext *avctx,
}
else
{
memset
(
&
s
->
counts
,
0
,
sizeof
(
s
->
counts
));
}
/
/
FIXME is it faster to not copy here, but do it down in the fw updates
//
as explicit copies if the fw update is missing (and skip the copy upon
// fw update)?
/
*
FIXME is it faster to not copy here, but do it down in the fw updates
*
as explicit copies if the fw update is missing (and skip the copy upon
* fw update)? */
s
->
prob
.
p
=
s
->
prob_ctx
[
c
].
p
;
// txfm updates
...
...
@@ -777,12 +779,11 @@ static int decode_frame_header(AVCodecContext *avctx,
if
(
m
>=
3
&&
l
==
0
)
// dc only has 3 pt
break
;
for
(
n
=
0
;
n
<
3
;
n
++
)
{
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
{
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
p
[
n
]
=
update_prob
(
&
s
->
c
,
r
[
n
]);
}
else
{
else
p
[
n
]
=
r
[
n
];
}
}
p
[
3
]
=
0
;
}
}
else
{
...
...
@@ -866,7 +867,8 @@ static int decode_frame_header(AVCodecContext *avctx,
for
(
k
=
0
;
k
<
3
;
k
++
)
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
s
->
prob
.
p
.
partition
[
3
-
i
][
j
][
k
]
=
update_prob
(
&
s
->
c
,
s
->
prob
.
p
.
partition
[
3
-
i
][
j
][
k
]);
update_prob
(
&
s
->
c
,
s
->
prob
.
p
.
partition
[
3
-
i
][
j
][
k
]);
// mv fields don't use the update_prob subexp model for some reason
for
(
i
=
0
;
i
<
3
;
i
++
)
...
...
@@ -875,7 +877,8 @@ static int decode_frame_header(AVCodecContext *avctx,
for
(
i
=
0
;
i
<
2
;
i
++
)
{
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
s
->
prob
.
p
.
mv_comp
[
i
].
sign
=
(
vp8_rac_get_uint
(
&
s
->
c
,
7
)
<<
1
)
|
1
;
s
->
prob
.
p
.
mv_comp
[
i
].
sign
=
(
vp8_rac_get_uint
(
&
s
->
c
,
7
)
<<
1
)
|
1
;
for
(
j
=
0
;
j
<
10
;
j
++
)
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
...
...
@@ -883,7 +886,8 @@ static int decode_frame_header(AVCodecContext *avctx,
(
vp8_rac_get_uint
(
&
s
->
c
,
7
)
<<
1
)
|
1
;
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
s
->
prob
.
p
.
mv_comp
[
i
].
class0
=
(
vp8_rac_get_uint
(
&
s
->
c
,
7
)
<<
1
)
|
1
;
s
->
prob
.
p
.
mv_comp
[
i
].
class0
=
(
vp8_rac_get_uint
(
&
s
->
c
,
7
)
<<
1
)
|
1
;
for
(
j
=
0
;
j
<
10
;
j
++
)
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
252
))
...
...
@@ -1210,11 +1214,11 @@ static void loopfilter_sb(AVCodecContext *avctx, struct VP9Filter *lflvl,
uint8_t
(
*
uv_masks
)[
8
][
4
]
=
lflvl
->
mask
[
s
->
ss_h
|
s
->
ss_v
];
int
p
;
/
/ FIXME i
n how far can we interleave the v/h loopfilter calls? E.g.
//
if you think of them as acting on a 8x8 block max, we can interleave
//
each v/h within the single x loop, but that only works if we work on
//
8 pixel blocks, and we won't always do that (we want at least 16px
// to use SSE2 optimizations, perhaps 32 for AVX2)
/
* FIXME: I
n how far can we interleave the v/h loopfilter calls? E.g.
*
if you think of them as acting on a 8x8 block max, we can interleave
*
each v/h within the single x loop, but that only works if we work on
*
8 pixel blocks, and we won't always do that (we want at least 16px
* to use SSE2 optimizations, perhaps 32 for AVX2) */
filter_plane_cols
(
s
,
col
,
0
,
0
,
lflvl
->
level
,
lflvl
->
mask
[
0
][
0
],
dst
,
ls_y
);
filter_plane_rows
(
s
,
row
,
0
,
0
,
lflvl
->
level
,
lflvl
->
mask
[
0
][
1
],
dst
,
ls_y
);
...
...
@@ -1485,14 +1489,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
yoff2
,
uvoff2
,
BL_64X64
);
}
}
if
(
s
->
pass
!=
2
)
{
if
(
s
->
pass
!=
2
)
memcpy
(
&
s
->
c_b
[
tile_col
],
&
s
->
c
,
sizeof
(
s
->
c
));
}
}
if
(
s
->
pass
==
1
)
{
if
(
s
->
pass
==
1
)
continue
;
}
// backup pre-loopfilter reconstruction data for intra
// prediction of next row of sb64s
...
...
libavcodec/vp9block.c
View file @
875f6955
This diff is collapsed.
Click to expand it.
libavcodec/vp9data.c
View file @
875f6955
...
...
@@ -1445,13 +1445,13 @@ const ProbContext ff_vp9_default_probs = {
{
34
,
3
,
},
{
149
,
144
,
},
},
{
/* mv_mode */
{
2
,
173
,
34
},
// 0 = both zero mv
{
7
,
145
,
85
},
// 1 = one zero mv + one a predicted mv
{
7
,
166
,
63
},
// 2 = two predicted mvs
{
7
,
94
,
66
},
// 3 = one predicted/zero and one new mv
{
8
,
64
,
46
},
// 4 = two new mvs
{
17
,
81
,
31
},
// 5 = one intra neighbou
r + x
{
25
,
29
,
30
},
// 6 = two intra neighbou
rs
{
2
,
173
,
34
},
// 0 = both zero mv
{
7
,
145
,
85
},
// 1 = one zero mv + one a predicted mv
{
7
,
166
,
63
},
// 2 = two predicted mvs
{
7
,
94
,
66
},
// 3 = one predicted/zero and one new mv
{
8
,
64
,
46
},
// 4 = two new mvs
{
17
,
81
,
31
},
// 5 = one intra neighbo
r + x
{
25
,
29
,
30
},
// 6 = two intra neighbo
rs
},
{
/* intra */
9
,
102
,
187
,
225
},
{
/* comp */
...
...
@@ -1481,7 +1481,7 @@ const ProbContext ff_vp9_default_probs = {
128
,
/* sign */
{
224
,
144
,
192
,
168
,
192
,
176
,
192
,
198
,
198
,
245
},
/* class */
216
,
/* class0 */
{
136
,
140
,
148
,
160
,
176
,
192
,
224
,
234
,
234
,
240
},
/* bits */
{
136
,
140
,
148
,
160
,
176
,
192
,
224
,
234
,
234
,
240
},
/* bits */
{
/* class0_fp */
{
128
,
128
,
64
},
{
96
,
112
,
64
}
...
...
libavcodec/vp9mvs.c
View file @
875f6955
...
...
@@ -37,32 +37,32 @@ static void find_ref_mvs(VP9Context *s,
VP56mv
*
pmv
,
int
ref
,
int
z
,
int
idx
,
int
sb
)
{
static
const
int8_t
mv_ref_blk_off
[
N_BS_SIZES
][
8
][
2
]
=
{
[
BS_64x64
]
=
{{
3
,
-
1
},
{
-
1
,
3
},
{
4
,
-
1
},
{
-
1
,
4
},
{
-
1
,
-
1
},
{
0
,
-
1
},
{
-
1
,
0
},
{
6
,
-
1
}
},
[
BS_64x32
]
=
{{
0
,
-
1
},
{
-
1
,
0
},
{
4
,
-
1
},
{
-
1
,
2
},
{
-
1
,
-
1
},
{
0
,
-
3
},
{
-
3
,
0
},
{
2
,
-
1
}
},
[
BS_32x64
]
=
{{
-
1
,
0
},
{
0
,
-
1
},
{
-
1
,
4
},
{
2
,
-
1
},
{
-
1
,
-
1
},
{
-
3
,
0
},
{
0
,
-
3
},
{
-
1
,
2
}
},
[
BS_32x32
]
=
{{
1
,
-
1
},
{
-
1
,
1
},
{
2
,
-
1
},
{
-
1
,
2
},
{
-
1
,
-
1
},
{
0
,
-
3
},
{
-
3
,
0
},
{
-
3
,
-
3
}
},
[
BS_32x16
]
=
{{
0
,
-
1
},
{
-
1
,
0
},
{
2
,
-
1
},
{
-
1
,
-
1
},
{
-
1
,
1
},
{
0
,
-
3
},
{
-
3
,
0
},
{
-
3
,
-
3
}
},
[
BS_16x32
]
=
{{
-
1
,
0
},
{
0
,
-
1
},
{
-
1
,
2
},
{
-
1
,
-
1
},
{
1
,
-
1
},
{
-
3
,
0
},
{
0
,
-
3
},
{
-
3
,
-
3
}
},
[
BS_16x16
]
=
{{
0
,
-
1
},
{
-
1
,
0
},
{
1
,
-
1
},
{
-
1
,
1
},
{
-
1
,
-
1
},
{
0
,
-
3
},
{
-
3
,
0
},
{
-
3
,
-
3
}
},
[
BS_16x8
]
=
{{
0
,
-
1
},
{
-
1
,
0
},
{
1
,
-
1
},
{
-
1
,
-
1
},
{
0
,
-
2
},
{
-
2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
[
BS_4x4
]
=
{
{
0
,
-
1
},
{
-
1
,
0
},
{
-
1
,
-
1
},
{
0
,
-
2
},
{
-
2
,
0
},
{
-
1
,
-
2
},
{
-
2
,
-
1
},
{
-
2
,
-
2
}
},
};
VP9Block
*
b
=
s
->
b
;
int
row
=
s
->
row
,
col
=
s
->
col
,
row7
=
s
->
row7
;
...
...
@@ -136,39 +136,37 @@ static void find_ref_mvs(VP9Context *s,
if
(
row
>
0
)
{
struct
VP9mvrefPair
*
mv
=
&
s
->
s
.
frames
[
CUR_FRAME
].
mv
[(
row
-
1
)
*
s
->
sb_cols
*
8
+
col
];
if
(
mv
->
ref
[
0
]
==
ref
)
{
if
(
mv
->
ref
[
0
]
==
ref
)
RETURN_MV
(
s
->
above_mv_ctx
[
2
*
col
+
(
sb
&
1
)][
0
]);
}
else
if
(
mv
->
ref
[
1
]
==
ref
)
{
else
if
(
mv
->
ref
[
1
]
==
ref
)
RETURN_MV
(
s
->
above_mv_ctx
[
2
*
col
+
(
sb
&
1
)][
1
]);
}
}
if
(
col
>
s
->
tile_col_start
)
{
struct
VP9mvrefPair
*
mv
=
&
s
->
s
.
frames
[
CUR_FRAME
].
mv
[
row
*
s
->
sb_cols
*
8
+
col
-
1
];
if
(
mv
->
ref
[
0
]
==
ref
)
{
if
(
mv
->
ref
[
0
]
==
ref
)
RETURN_MV
(
s
->
left_mv_ctx
[
2
*
row7
+
(
sb
>>
1
)][
0
]);
}
else
if
(
mv
->
ref
[
1
]
==
ref
)
{
else
if
(
mv
->
ref
[
1
]
==
ref
)
RETURN_MV
(
s
->
left_mv_ctx
[
2
*
row7
+
(
sb
>>
1
)][
1
]);
}
}
i
=
2
;
}
else
{
i
=
0
;
}
// previously coded MVs in this neighbo
u
rhood, using same reference frame
// previously coded MVs in this neighborhood, using same reference frame
for
(;
i
<
8
;
i
++
)
{
int
c
=
p
[
i
][
0
]
+
col
,
r
=
p
[
i
][
1
]
+
row
;
if
(
c
>=
s
->
tile_col_start
&&
c
<
s
->
cols
&&
r
>=
0
&&
r
<
s
->
rows
)
{
if
(
c
>=
s
->
tile_col_start
&&
c
<
s
->
cols
&&
r
>=
0
&&
r
<
s
->
rows
)
{
struct
VP9mvrefPair
*
mv
=
&
s
->
s
.
frames
[
CUR_FRAME
].
mv
[
r
*
s
->
sb_cols
*
8
+
c
];
if
(
mv
->
ref
[
0
]
==
ref
)
{
if
(
mv
->
ref
[
0
]
==
ref
)
RETURN_MV
(
mv
->
mv
[
0
]);
}
else
if
(
mv
->
ref
[
1
]
==
ref
)
{
else
if
(
mv
->
ref
[
1
]
==
ref
)
RETURN_MV
(
mv
->
mv
[
1
]);
}
}
}
// MV at this position in previous frame, using same reference frame
if
(
s
->
s
.
h
.
use_last_frame_mvs
)
{
...
...
@@ -176,12 +174,11 @@ static void find_ref_mvs(VP9Context *s,
if
(
!
s
->
s
.
frames
[
REF_FRAME_MVPAIR
].
uses_2pass
)
ff_thread_await_progress
(
&
s
->
s
.
frames
[
REF_FRAME_MVPAIR
].
tf
,
row
>>
3
,
0
);
if
(
mv
->
ref
[
0
]
==
ref
)
{
if
(
mv
->
ref
[
0
]
==
ref
)
RETURN_MV
(
mv
->
mv
[
0
]);
}
else
if
(
mv
->
ref
[
1
]
==
ref
)
{
else
if
(
mv
->
ref
[
1
]
==
ref
)
RETURN_MV
(
mv
->
mv
[
1
]);
}
}
#define RETURN_SCALE_MV(mv, scale) \
do { \
...
...
@@ -193,16 +190,16 @@ static void find_ref_mvs(VP9Context *s,
} \
} while (0)
// previously coded MVs in this neighbo
u
rhood, using different reference frame
// previously coded MVs in this neighborhood, using different reference frame
for
(
i
=
0
;
i
<
8
;
i
++
)
{
int
c
=
p
[
i
][
0
]
+
col
,
r
=
p
[
i
][
1
]
+
row
;
if
(
c
>=
s
->
tile_col_start
&&
c
<
s
->
cols
&&
r
>=
0
&&
r
<
s
->
rows
)
{
struct
VP9mvrefPair
*
mv
=
&
s
->
s
.
frames
[
CUR_FRAME
].
mv
[
r
*
s
->
sb_cols
*
8
+
c
];
if
(
mv
->
ref
[
0
]
!=
ref
&&
mv
->
ref
[
0
]
>=
0
)
{
RETURN_SCALE_MV
(
mv
->
mv
[
0
],
s
->
s
.
h
.
signbias
[
mv
->
ref
[
0
]]
!=
s
->
s
.
h
.
signbias
[
ref
]);
}
if
(
mv
->
ref
[
0
]
!=
ref
&&
mv
->
ref
[
0
]
>=
0
)
RETURN_SCALE_MV
(
mv
->
mv
[
0
],
s
->
s
.
h
.
signbias
[
mv
->
ref
[
0
]]
!=
s
->
s
.
h
.
signbias
[
ref
]);
if
(
mv
->
ref
[
1
]
!=
ref
&&
mv
->
ref
[
1
]
>=
0
&&
// BUG - libvpx has this condition regardless of whether
// we used the first ref MV and pre-scaling
...
...
@@ -217,9 +214,8 @@ static void find_ref_mvs(VP9Context *s,
struct
VP9mvrefPair
*
mv
=
&
s
->
s
.
frames
[
REF_FRAME_MVPAIR
].
mv
[
row
*
s
->
sb_cols
*
8
+
col
];
// no need to await_progress, because we already did that above
if
(
mv
->
ref
[
0
]
!=
ref
&&
mv
->
ref
[
0
]
>=
0
)
{
if
(
mv
->
ref
[
0
]
!=
ref
&&
mv
->
ref
[
0
]
>=
0
)
RETURN_SCALE_MV
(
mv
->
mv
[
0
],
s
->
s
.
h
.
signbias
[
mv
->
ref
[
0
]]
!=
s
->
s
.
h
.
signbias
[
ref
]);
}
if
(
mv
->
ref
[
1
]
!=
ref
&&
mv
->
ref
[
1
]
>=
0
&&
// BUG - libvpx has this condition regardless of whether
// we used the first ref MV and pre-scaling
...
...
@@ -252,7 +248,8 @@ static av_always_inline int read_mv_component(VP9Context *s, int idx, int hp)
s
->
counts
.
mv_comp
[
idx
].
bits
[
m
][
bit
]
++
;
}
n
<<=
3
;
bit
=
vp8_rac_get_tree
(
&
s
->
c
,
ff_vp9_mv_fp_tree
,
s
->
prob
.
p
.
mv_comp
[
idx
].
fp
);
bit
=
vp8_rac_get_tree
(
&
s
->
c
,
ff_vp9_mv_fp_tree
,
s
->
prob
.
p
.
mv_comp
[
idx
].
fp
);
n
|=
bit
<<
1
;
s
->
counts
.
mv_comp
[
idx
].
fp
[
bit
]
++
;
if
(
hp
)
{
...
...
@@ -302,7 +299,8 @@ void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
mode
==
NEWMV
?
-
1
:
sb
);
// FIXME maybe move this code into find_ref_mvs()
if
((
mode
==
NEWMV
||
sb
==
-
1
)
&&
!
(
hp
=
s
->
s
.
h
.
highprecisionmvs
&&
abs
(
mv
[
0
].
x
)
<
64
&&
abs
(
mv
[
0
].
y
)
<
64
))
{
!
(
hp
=
s
->
s
.
h
.
highprecisionmvs
&&
abs
(
mv
[
0
].
x
)
<
64
&&
abs
(
mv
[
0
].
y
)
<
64
))
{
if
(
mv
[
0
].
y
&
1
)
{
if
(
mv
[
0
].
y
<
0
)
mv
[
0
].
y
++
;
...
...
@@ -332,7 +330,8 @@ void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
find_ref_mvs
(
s
,
&
mv
[
1
],
b
->
ref
[
1
],
1
,
mode
==
NEARMV
,
mode
==
NEWMV
?
-
1
:
sb
);
if
((
mode
==
NEWMV
||
sb
==
-
1
)
&&
!
(
hp
=
s
->
s
.
h
.
highprecisionmvs
&&
abs
(
mv
[
1
].
x
)
<
64
&&
abs
(
mv
[
1
].
y
)
<
64
))
{
!
(
hp
=
s
->
s
.
h
.
highprecisionmvs
&&
abs
(
mv
[
1
].
x
)
<
64
&&
abs
(
mv
[
1
].
y
)
<
64
))
{
if
(
mv
[
1
].
y
&
1
)
{
if
(
mv
[
1
].
y
<
0
)
mv
[
1
].
y
++
;
...
...
libavcodec/vp9prob.c
View file @
875f6955
...
...
@@ -76,16 +76,19 @@ void ff_vp9_adapt_probs(VP9Context *s)
// skip flag
for
(
i
=
0
;
i
<
3
;
i
++
)
adapt_prob
(
&
p
->
skip
[
i
],
s
->
counts
.
skip
[
i
][
0
],
s
->
counts
.
skip
[
i
][
1
],
20
,
128
);
adapt_prob
(
&
p
->
skip
[
i
],
s
->
counts
.
skip
[
i
][
0
],
s
->
counts
.
skip
[
i
][
1
],
20
,
128
);
// intra/inter flag
for
(
i
=
0
;
i
<
4
;
i
++
)
adapt_prob
(
&
p
->
intra
[
i
],
s
->
counts
.
intra
[
i
][
0
],
s
->
counts
.
intra
[
i
][
1
],
20
,
128
);
adapt_prob
(
&
p
->
intra
[
i
],
s
->
counts
.
intra
[
i
][
0
],
s
->
counts
.
intra
[
i
][
1
],
20
,
128
);
// comppred flag
if
(
s
->
s
.
h
.
comppredmode
==
PRED_SWITCHABLE
)
{
for
(
i
=
0
;
i
<
5
;
i
++
)
adapt_prob
(
&
p
->
comp
[
i
],
s
->
counts
.
comp
[
i
][
0
],
s
->
counts
.
comp
[
i
][
1
],
20
,
128
);
adapt_prob
(
&
p
->
comp
[
i
],
s
->
counts
.
comp
[
i
][
0
],
s
->
counts
.
comp
[
i
][
1
],
20
,
128
);
}
// reference frames
...
...
@@ -121,7 +124,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
for
(
i
=
0
;
i
<
2
;
i
++
)
{
unsigned
*
c16
=
s
->
counts
.
tx16p
[
i
],
*
c32
=
s
->
counts
.
tx32p
[
i
];
adapt_prob
(
&
p
->
tx8p
[
i
],
s
->
counts
.
tx8p
[
i
][
0
],
s
->
counts
.
tx8p
[
i
][
1
],
20
,
128
);
adapt_prob
(
&
p
->
tx8p
[
i
],
s
->
counts
.
tx8p
[
i
][
0
],
s
->
counts
.
tx8p
[
i
][
1
],
20
,
128
);
adapt_prob
(
&
p
->
tx16p
[
i
][
0
],
c16
[
0
],
c16
[
1
]
+
c16
[
2
],
20
,
128
);
adapt_prob
(
&
p
->
tx16p
[
i
][
1
],
c16
[
1
],
c16
[
2
],
20
,
128
);
adapt_prob
(
&
p
->
tx32p
[
i
][
0
],
c32
[
0
],
c32
[
1
]
+
c32
[
2
]
+
c32
[
3
],
20
,
128
);
...
...
@@ -171,7 +175,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
pp
=
p
->
mv_comp
[
i
].
classes
;
c
=
s
->
counts
.
mv_comp
[
i
].
classes
;
sum
=
c
[
1
]
+
c
[
2
]
+
c
[
3
]
+
c
[
4
]
+
c
[
5
]
+
c
[
6
]
+
c
[
7
]
+
c
[
8
]
+
c
[
9
]
+
c
[
10
];
sum
=
c
[
1
]
+
c
[
2
]
+
c
[
3
]
+
c
[
4
]
+
c
[
5
]
+
c
[
6
]
+
c
[
7
]
+
c
[
8
]
+
c
[
9
]
+
c
[
10
];
adapt_prob
(
&
pp
[
0
],
c
[
0
],
sum
,
20
,
128
);
sum
-=
c
[
1
];
adapt_prob
(
&
pp
[
1
],
c
[
1
],
sum
,
20
,
128
);
...
...
@@ -208,7 +213,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
adapt_prob
(
&
pp
[
2
],
c
[
2
],
c
[
3
],
20
,
128
);
if
(
s
->
s
.
h
.
highprecisionmvs
)
{
adapt_prob
(
&
p
->
mv_comp
[
i
].
class0_hp
,
s
->
counts
.
mv_comp
[
i
].
class0_hp
[
0
],
adapt_prob
(
&
p
->
mv_comp
[
i
].
class0_hp
,
s
->
counts
.
mv_comp
[
i
].
class0_hp
[
0
],
s
->
counts
.
mv_comp
[
i
].
class0_hp
[
1
],
20
,
128
);
adapt_prob
(
&
p
->
mv_comp
[
i
].
hp
,
s
->
counts
.
mv_comp
[
i
].
hp
[
0
],
s
->
counts
.
mv_comp
[
i
].
hp
[
1
],
20
,
128
);
...
...
@@ -231,7 +237,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
adapt_prob
(
&
pp
[
3
],
s2
,
sum
,
20
,
128
);
s2
-=
c
[
HOR_PRED
];
adapt_prob
(
&
pp
[
4
],
c
[
HOR_PRED
],
s2
,
20
,
128
);
adapt_prob
(
&
pp
[
5
],
c
[
DIAG_DOWN_RIGHT_PRED
],
c
[
VERT_RIGHT_PRED
],
20
,
128
);
adapt_prob
(
&
pp
[
5
],
c
[
DIAG_DOWN_RIGHT_PRED
],
c
[
VERT_RIGHT_PRED
],
20
,
128
);
sum
-=
c
[
DIAG_DOWN_LEFT_PRED
];
adapt_prob
(
&
pp
[
6
],
c
[
DIAG_DOWN_LEFT_PRED
],
sum
,
20
,
128
);
sum
-=
c
[
VERT_LEFT_PRED
];
...
...
@@ -255,7 +262,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
adapt_prob
(
&
pp
[
3
],
s2
,
sum
,
20
,
128
);
s2
-=
c
[
HOR_PRED
];
adapt_prob
(
&
pp
[
4
],
c
[
HOR_PRED
],
s2
,
20
,
128
);
adapt_prob
(
&
pp
[
5
],
c
[
DIAG_DOWN_RIGHT_PRED
],
c
[
VERT_RIGHT_PRED
],
20
,
128
);
adapt_prob
(
&
pp
[
5
],
c
[
DIAG_DOWN_RIGHT_PRED
],
c
[
VERT_RIGHT_PRED
],
20
,
128
);
sum
-=
c
[
DIAG_DOWN_LEFT_PRED
];
adapt_prob
(
&
pp
[
6
],
c
[
DIAG_DOWN_LEFT_PRED
],
sum
,
20
,
128
);
sum
-=
c
[
VERT_LEFT_PRED
];
...
...
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