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
f578e5d9
Commit
f578e5d9
authored
Nov 01, 2013
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/hevc: Adjust white-spaces to reduce difference to
064698d3
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
38612379
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1125 additions
and
1016 deletions
+1125
-1016
hevc.c
libavcodec/hevc.c
+85
-61
hevc_cabac.c
libavcodec/hevc_cabac.c
+285
-288
hevc_filter.c
libavcodec/hevc_filter.c
+183
-120
hevc_mvs.c
libavcodec/hevc_mvs.c
+69
-66
hevc_parser.c
libavcodec/hevc_parser.c
+7
-6
hevc_ps.c
libavcodec/hevc_ps.c
+31
-29
hevc_refs.c
libavcodec/hevc_refs.c
+29
-27
hevc_sei.c
libavcodec/hevc_sei.c
+10
-9
hevcdsp.c
libavcodec/hevcdsp.c
+126
-127
hevcdsp_template.c
libavcodec/hevcdsp_template.c
+222
-210
hevcpred.c
libavcodec/hevcpred.c
+6
-6
hevcpred_template.c
libavcodec/hevcpred_template.c
+72
-67
No files found.
libavcodec/hevc.c
View file @
f578e5d9
...
...
@@ -112,8 +112,10 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
goto
fail
;
s
->
filter_slice_edges
=
av_malloc
(
ctb_count
);
s
->
tab_slice_address
=
av_malloc
(
pic_size_in_ctb
*
sizeof
(
*
s
->
tab_slice_address
));
s
->
qp_y_tab
=
av_malloc
(
pic_size_in_ctb
*
sizeof
(
*
s
->
qp_y_tab
));
s
->
tab_slice_address
=
av_malloc
(
pic_size_in_ctb
*
sizeof
(
*
s
->
tab_slice_address
));
s
->
qp_y_tab
=
av_malloc
(
pic_size_in_ctb
*
sizeof
(
*
s
->
qp_y_tab
));
if
(
!
s
->
qp_y_tab
||
!
s
->
filter_slice_edges
||
!
s
->
tab_slice_address
)
goto
fail
;
...
...
@@ -130,6 +132,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
goto
fail
;
return
0
;
fail:
pic_arrays_free
(
s
);
return
AVERROR
(
ENOMEM
);
...
...
@@ -308,6 +311,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
s
->
sps
=
sps
;
s
->
vps
=
s
->
vps_list
[
s
->
sps
->
vps_id
];
return
0
;
fail:
pic_arrays_free
(
s
);
s
->
sps
=
NULL
;
...
...
@@ -366,7 +370,8 @@ static int hls_slice_header(HEVCContext *s)
s
->
sps
->
ctb_height
);
sh
->
slice_segment_addr
=
get_bits
(
gb
,
slice_address_length
);
if
(
sh
->
slice_segment_addr
>=
s
->
sps
->
ctb_width
*
s
->
sps
->
ctb_height
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid slice segment address: %u.
\n
"
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid slice segment address: %u.
\n
"
,
sh
->
slice_segment_addr
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -388,7 +393,8 @@ static int hls_slice_header(HEVCContext *s)
skip_bits
(
gb
,
1
);
// slice_reserved_undetermined_flag[]
sh
->
slice_type
=
get_ue_golomb_long
(
gb
);
if
(
!
(
sh
->
slice_type
==
I_SLICE
||
sh
->
slice_type
==
P_SLICE
||
if
(
!
(
sh
->
slice_type
==
I_SLICE
||
sh
->
slice_type
==
P_SLICE
||
sh
->
slice_type
==
B_SLICE
))
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Unknown slice type: %d.
\n
"
,
sh
->
slice_type
);
...
...
@@ -537,7 +543,8 @@ static int hls_slice_header(HEVCContext *s)
sh
->
collocated_ref_idx
=
get_ue_golomb_long
(
gb
);
if
(
sh
->
collocated_ref_idx
>=
sh
->
nb_refs
[
sh
->
collocated_list
])
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Invalid collocated_ref_idx: %d.
\n
"
,
sh
->
collocated_ref_idx
);
"Invalid collocated_ref_idx: %d.
\n
"
,
sh
->
collocated_ref_idx
);
return
AVERROR_INVALIDDATA
;
}
}
...
...
@@ -714,7 +721,8 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
if
(
sao
->
type_idx
[
c_idx
]
==
SAO_BAND
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
{
if
(
sao
->
offset_abs
[
c_idx
][
i
])
{
SET_SAO
(
offset_sign
[
c_idx
][
i
],
ff_hevc_sao_offset_sign_decode
(
s
));
SET_SAO
(
offset_sign
[
c_idx
][
i
],
ff_hevc_sao_offset_sign_decode
(
s
));
}
else
{
sao
->
offset_sign
[
c_idx
][
i
]
=
0
;
}
...
...
@@ -741,7 +749,6 @@ static void hls_sao_param(HEVCContext *s, int rx, int ry)
#undef SET_SAO
#undef CTB
static
void
hls_transform_unit
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
xBase
,
int
yBase
,
int
cb_xBase
,
int
cb_yBase
,
int
log2_cb_size
,
int
log2_trafo_size
,
...
...
@@ -761,7 +768,8 @@ static void hls_transform_unit(HEVCContext *s, int x0, int y0,
s
->
hpc
.
intra_pred
(
s
,
x0
,
y0
,
log2_trafo_size
-
1
,
2
);
}
else
if
(
blk_idx
==
3
)
{
trafo_size
=
trafo_size
<<
(
s
->
sps
->
hshift
[
1
]);
ff_hevc_set_neighbour_available
(
s
,
xBase
,
yBase
,
trafo_size
,
trafo_size
);
ff_hevc_set_neighbour_available
(
s
,
xBase
,
yBase
,
trafo_size
,
trafo_size
);
s
->
hpc
.
intra_pred
(
s
,
xBase
,
yBase
,
log2_trafo_size
,
1
);
s
->
hpc
.
intra_pred
(
s
,
xBase
,
yBase
,
log2_trafo_size
,
2
);
}
...
...
@@ -860,7 +868,8 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
lc
->
tt
.
inter_split_flag
=
(
s
->
sps
->
max_transform_hierarchy_depth_inter
==
0
&&
lc
->
cu
.
pred_mode
==
MODE_INTER
&&
lc
->
cu
.
part_mode
!=
PART_2Nx2N
&&
trafo_depth
==
0
);
lc
->
cu
.
part_mode
!=
PART_2Nx2N
&&
trafo_depth
==
0
);
if
(
log2_trafo_size
<=
s
->
sps
->
log2_max_trafo_size
&&
log2_trafo_size
>
s
->
sps
->
log2_min_tb_size
&&
...
...
@@ -880,7 +889,8 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
ff_hevc_cbf_cb_cr_decode
(
s
,
trafo_depth
);
}
if
(
trafo_depth
==
0
||
SAMPLE_CBF
(
lc
->
tt
.
cbf_cr
[
trafo_depth
-
1
],
xBase
,
yBase
))
{
if
(
trafo_depth
==
0
||
SAMPLE_CBF
(
lc
->
tt
.
cbf_cr
[
trafo_depth
-
1
],
xBase
,
yBase
))
{
SAMPLE_CBF
(
lc
->
tt
.
cbf_cr
[
trafo_depth
],
x0
,
y0
)
=
ff_hevc_cbf_cb_cr_decode
(
s
,
trafo_depth
);
}
...
...
@@ -926,7 +936,8 @@ static void hls_transform_tree(HEVCContext *s, int x0, int y0,
ff_hevc_deblocking_boundary_strengths
(
s
,
x0
,
y0
,
log2_trafo_size
,
lc
->
slice_or_tiles_up_boundary
,
lc
->
slice_or_tiles_left_boundary
);
if
(
s
->
pps
->
transquant_bypass_enable_flag
&&
lc
->
cu
.
cu_transquant_bypass_flag
)
if
(
s
->
pps
->
transquant_bypass_enable_flag
&&
lc
->
cu
.
cu_transquant_bypass_flag
)
set_deblocking_bypass
(
s
,
x0
,
y0
,
log2_trafo_size
);
}
}
...
...
@@ -1001,7 +1012,8 @@ static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride,
int
offset
=
extra_top
*
srcstride
+
(
extra_left
<<
s
->
sps
->
pixel_shift
);
s
->
vdsp
.
emulated_edge_mc
(
lc
->
edge_emu_buffer
,
srcstride
,
src
-
offset
,
srcstride
,
block_w
+
ff_hevc_qpel_extra
[
mx
],
block_h
+
ff_hevc_qpel_extra
[
my
],
block_w
+
ff_hevc_qpel_extra
[
mx
],
block_h
+
ff_hevc_qpel_extra
[
my
],
x_off
-
extra_left
,
y_off
-
extra_top
,
pic_width
,
pic_height
);
src
=
lc
->
edge_emu_buffer
+
offset
;
...
...
@@ -1024,8 +1036,9 @@ static void luma_mc(HEVCContext *s, int16_t *dst, ptrdiff_t dststride,
* @param block_w width of block
* @param block_h height of block
*/
static
void
chroma_mc
(
HEVCContext
*
s
,
int16_t
*
dst1
,
int16_t
*
dst2
,
ptrdiff_t
dststride
,
AVFrame
*
ref
,
const
Mv
*
mv
,
int
x_off
,
int
y_off
,
int
block_w
,
int
block_h
)
static
void
chroma_mc
(
HEVCContext
*
s
,
int16_t
*
dst1
,
int16_t
*
dst2
,
ptrdiff_t
dststride
,
AVFrame
*
ref
,
const
Mv
*
mv
,
int
x_off
,
int
y_off
,
int
block_w
,
int
block_h
)
{
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
uint8_t
*
src1
=
ref
->
data
[
1
];
...
...
@@ -1124,8 +1137,11 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
else
merge_idx
=
0
;
ff_hevc_luma_mv_merge_mode
(
s
,
x0
,
y0
,
1
<<
log2_cb_size
,
1
<<
log2_cb_size
,
log2_cb_size
,
partIdx
,
merge_idx
,
&
current_mv
);
ff_hevc_luma_mv_merge_mode
(
s
,
x0
,
y0
,
1
<<
log2_cb_size
,
1
<<
log2_cb_size
,
log2_cb_size
,
partIdx
,
merge_idx
,
&
current_mv
);
x_pu
=
x0
>>
s
->
sps
->
log2_min_pu_size
;
y_pu
=
y0
>>
s
->
sps
->
log2_min_pu_size
;
...
...
@@ -1163,7 +1179,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
ff_hevc_hls_mvd_coding
(
s
,
x0
,
y0
,
0
);
mvp_flag
[
0
]
=
ff_hevc_mvp_lx_flag_decode
(
s
);
ff_hevc_luma_mv_mvp_mode
(
s
,
x0
,
y0
,
nPbW
,
nPbH
,
log2_cb_size
,
partIdx
,
merge_idx
,
&
current_mv
,
mvp_flag
[
0
],
0
);
partIdx
,
merge_idx
,
&
current_mv
,
mvp_flag
[
0
],
0
);
current_mv
.
mv
[
0
].
x
+=
lc
->
pu
.
mvd
.
x
;
current_mv
.
mv
[
0
].
y
+=
lc
->
pu
.
mvd
.
y
;
}
...
...
@@ -1184,7 +1201,8 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
current_mv
.
pred_flag
[
1
]
=
1
;
mvp_flag
[
1
]
=
ff_hevc_mvp_lx_flag_decode
(
s
);
ff_hevc_luma_mv_mvp_mode
(
s
,
x0
,
y0
,
nPbW
,
nPbH
,
log2_cb_size
,
partIdx
,
merge_idx
,
&
current_mv
,
mvp_flag
[
1
],
1
);
partIdx
,
merge_idx
,
&
current_mv
,
mvp_flag
[
1
],
1
);
current_mv
.
mv
[
1
].
x
+=
lc
->
pu
.
mvd
.
x
;
current_mv
.
mv
[
1
].
y
+=
lc
->
pu
.
mvd
.
y
;
}
...
...
@@ -1212,7 +1230,7 @@ static void hls_prediction_unit(HEVCContext *s, int x0, int y0,
}
if
(
current_mv
.
pred_flag
[
0
]
&&
!
current_mv
.
pred_flag
[
1
])
{
DECLARE_ALIGNED
(
16
,
int16_t
,
tmp
[
MAX_PB_SIZE
*
MAX_PB_SIZE
]);
DECLARE_ALIGNED
(
16
,
int16_t
,
tmp
[
MAX_PB_SIZE
*
MAX_PB_SIZE
]);
DECLARE_ALIGNED
(
16
,
int16_t
,
tmp2
[
MAX_PB_SIZE
*
MAX_PB_SIZE
]);
luma_mc
(
s
,
tmp
,
tmpstride
,
ref0
->
frame
,
...
...
@@ -1523,11 +1541,11 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
lc
->
cu
.
x
=
x0
;
lc
->
cu
.
y
=
y0
;
lc
->
cu
.
rqt_root_cbf
=
1
;
lc
->
cu
.
pred_mode
=
MODE_INTRA
;
lc
->
cu
.
part_mode
=
PART_2Nx2N
;
lc
->
cu
.
intra_split_flag
=
0
;
lc
->
cu
.
pcm_flag
=
0
;
SAMPLE_CTB
(
s
->
skip_flag
,
x_cb
,
y_cb
)
=
0
;
for
(
x
=
0
;
x
<
4
;
x
++
)
lc
->
pu
.
intra_pred_mode
[
x
]
=
1
;
...
...
@@ -1594,7 +1612,7 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
break
;
case
PART_2NxN
:
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
,
cb_size
/
2
,
log2_cb_size
,
0
);
hls_prediction_unit
(
s
,
x0
,
y0
+
cb_size
/
2
,
cb_size
,
cb_size
/
2
,
log2_cb_size
,
1
);
hls_prediction_unit
(
s
,
x0
,
y0
+
cb_size
/
2
,
cb_size
,
cb_size
/
2
,
log2_cb_size
,
1
);
break
;
case
PART_Nx2N
:
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
/
2
,
cb_size
,
log2_cb_size
,
0
);
...
...
@@ -1609,12 +1627,12 @@ static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size)
hls_prediction_unit
(
s
,
x0
,
y0
+
cb_size
*
3
/
4
,
cb_size
,
cb_size
/
4
,
log2_cb_size
,
1
);
break
;
case
PART_nLx2N
:
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
/
4
,
cb_size
,
log2_cb_size
,
0
);
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
/
4
,
cb_size
,
log2_cb_size
,
0
);
hls_prediction_unit
(
s
,
x0
+
cb_size
/
4
,
y0
,
cb_size
*
3
/
4
,
cb_size
,
log2_cb_size
,
1
);
break
;
case
PART_nRx2N
:
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
*
3
/
4
,
cb_size
,
log2_cb_size
,
0
);
hls_prediction_unit
(
s
,
x0
+
cb_size
*
3
/
4
,
y0
,
cb_size
/
4
,
cb_size
,
log2_cb_size
,
1
);
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
*
3
/
4
,
cb_size
,
log2_cb_size
,
0
);
hls_prediction_unit
(
s
,
x0
+
cb_size
*
3
/
4
,
y0
,
cb_size
/
4
,
cb_size
,
log2_cb_size
,
1
);
break
;
case
PART_NxN
:
hls_prediction_unit
(
s
,
x0
,
y0
,
cb_size
/
2
,
cb_size
/
2
,
log2_cb_size
,
0
);
...
...
@@ -1725,7 +1743,8 @@ static int hls_coding_quadtree(HEVCContext *s, int x0, int y0,
return
0
;
}
static
void
hls_decode_neighbour
(
HEVCContext
*
s
,
int
x_ctb
,
int
y_ctb
,
int
ctb_addr_ts
)
static
void
hls_decode_neighbour
(
HEVCContext
*
s
,
int
x_ctb
,
int
y_ctb
,
int
ctb_addr_ts
)
{
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
int
ctb_size
=
1
<<
s
->
sps
->
log2_ctb_size
;
...
...
@@ -2076,6 +2095,7 @@ static int hevc_frame_start(HEVCContext *s)
ff_thread_finish_setup
(
s
->
avctx
);
return
0
;
fail:
if
(
s
->
ref
&&
s
->
threads_type
==
FF_THREAD_FRAME
)
ff_thread_report_progress
(
&
s
->
ref
->
tf
,
INT_MAX
,
0
);
...
...
@@ -2316,8 +2336,8 @@ int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
}
while
(
si
<
length
)
dst
[
di
++
]
=
src
[
si
++
];
nsc:
nsc:
memset
(
dst
+
di
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
nal
->
data
=
dst
;
...
...
@@ -2378,7 +2398,8 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
goto
fail
;
}
s
->
nals
=
tmp
;
memset
(
s
->
nals
+
s
->
nals_allocated
,
0
,
(
new_size
-
s
->
nals_allocated
)
*
sizeof
(
*
tmp
));
memset
(
s
->
nals
+
s
->
nals_allocated
,
0
,
(
new_size
-
s
->
nals_allocated
)
*
sizeof
(
*
tmp
));
av_reallocp_array
(
&
s
->
skipped_bytes_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_nal
));
av_reallocp_array
(
&
s
->
skipped_bytes_pos_size_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_pos_size_nal
));
av_reallocp_array
(
&
s
->
skipped_bytes_pos_nal
,
new_size
,
sizeof
(
*
s
->
skipped_bytes_pos_nal
));
...
...
@@ -2691,6 +2712,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
s
->
context_initialized
=
1
;
return
0
;
fail:
hevc_decode_free
(
avctx
);
return
AVERROR
(
ENOMEM
);
...
...
@@ -2803,7 +2825,8 @@ static int hevc_decode_extradata(HEVCContext *s)
ret
=
decode_nal_units
(
s
,
gb
.
buffer
,
nalsize
);
if
(
ret
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Decoding nal unit %d %d from hvcC failed
\n
"
,
type
,
i
);
"Decoding nal unit %d %d from hvcC failed
\n
"
,
type
,
i
);
return
ret
;
}
bytestream2_skip
(
&
gb
,
nalsize
);
...
...
@@ -2907,5 +2930,6 @@ AVCodec ff_hevc_decoder = {
.
flush
=
hevc_decode_flush
,
.
update_thread_context
=
hevc_update_thread_context
,
.
init_thread_copy
=
hevc_init_thread_copy
,
.
capabilities
=
CODEC_CAP_DR1
|
CODEC_CAP_DELAY
|
CODEC_CAP_SLICE_THREADS
|
CODEC_CAP_FRAME_THREADS
,
.
capabilities
=
CODEC_CAP_DR1
|
CODEC_CAP_DELAY
|
CODEC_CAP_SLICE_THREADS
|
CODEC_CAP_FRAME_THREADS
,
};
libavcodec/hevc_cabac.c
View file @
f578e5d9
...
...
@@ -132,8 +132,7 @@ static const int elem_offset[sizeof(num_bins_in_se)] = {
* Indexed by init_type
*/
static
const
uint8_t
init_values
[
3
][
HEVC_CONTEXTS
]
=
{
{
// sao_merge_flag
{
// sao_merge_flag
153
,
// sao_type_idx
200
,
...
...
@@ -195,10 +194,8 @@ static const uint8_t init_values[3][HEVC_CONTEXTS] = {
140
,
92
,
137
,
138
,
140
,
152
,
138
,
139
,
153
,
74
,
149
,
92
,
139
,
107
,
122
,
152
,
140
,
179
,
166
,
182
,
140
,
227
,
122
,
197
,
// coeff_abs_level_greater2_flag
138
,
153
,
136
,
167
,
152
,
152
,
},
{
// sao_merge_flag
138
,
153
,
136
,
167
,
152
,
152
,
},
{
// sao_merge_flag
153
,
// sao_type_idx
185
,
...
...
@@ -260,10 +257,8 @@ static const uint8_t init_values[3][HEVC_CONTEXTS] = {
154
,
196
,
196
,
167
,
154
,
152
,
167
,
182
,
182
,
134
,
149
,
136
,
153
,
121
,
136
,
137
,
169
,
194
,
166
,
167
,
154
,
167
,
137
,
182
,
// coeff_abs_level_greater2_flag
107
,
167
,
91
,
122
,
107
,
167
,
},
{
// sao_merge_flag
107
,
167
,
91
,
122
,
107
,
167
,
},
{
// sao_merge_flag
153
,
// sao_type_idx
160
,
...
...
@@ -561,7 +556,8 @@ void ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts)
(
s
->
pps
->
tile_id
[
ctb_addr_ts
]
!=
s
->
pps
->
tile_id
[
ctb_addr_ts
-
1
])))
cabac_init_state
(
s
);
if
(
!
s
->
sh
.
first_slice_in_pic_flag
&&
s
->
pps
->
entropy_coding_sync_enabled_flag
)
{
if
(
!
s
->
sh
.
first_slice_in_pic_flag
&&
s
->
pps
->
entropy_coding_sync_enabled_flag
)
{
if
((
ctb_addr_ts
%
s
->
sps
->
ctb_width
)
==
0
)
{
if
(
s
->
sps
->
ctb_width
==
1
)
cabac_init_state
(
s
);
...
...
@@ -662,9 +658,9 @@ int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
int
y0b
=
y0
&
((
1
<<
s
->
sps
->
log2_ctb_size
)
-
1
);
if
(
s
->
HEVClc
->
ctb_left_flag
||
x0b
)
inc
=
!!
SAMPLE_CTB
(
s
->
skip_flag
,
x_cb
-
1
,
y_cb
);
inc
=
!!
SAMPLE_CTB
(
s
->
skip_flag
,
x_cb
-
1
,
y_cb
);
if
(
s
->
HEVClc
->
ctb_up_flag
||
y0b
)
inc
+=
!!
SAMPLE_CTB
(
s
->
skip_flag
,
x_cb
,
y_cb
-
1
);
inc
+=
!!
SAMPLE_CTB
(
s
->
skip_flag
,
x_cb
,
y_cb
-
1
);
return
GET_CABAC
(
elem_offset
[
SKIP_FLAG
]
+
inc
);
}
...
...
@@ -713,12 +709,13 @@ int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0,
int
y_cb
=
y0
>>
s
->
sps
->
log2_min_cb_size
;
if
(
s
->
HEVClc
->
ctb_left_flag
||
x0b
)
depth_left
=
s
->
tab_ct_depth
[(
y_cb
)
*
s
->
sps
->
min_cb_width
+
x_cb
-
1
];
depth_left
=
s
->
tab_ct_depth
[(
y_cb
)
*
s
->
sps
->
min_cb_width
+
x_cb
-
1
];
if
(
s
->
HEVClc
->
ctb_up_flag
||
y0b
)
depth_top
=
s
->
tab_ct_depth
[(
y_cb
-
1
)
*
s
->
sps
->
min_cb_width
+
x_cb
];
depth_top
=
s
->
tab_ct_depth
[(
y_cb
-
1
)
*
s
->
sps
->
min_cb_width
+
x_cb
];
inc
+=
(
depth_left
>
ct_depth
);
inc
+=
(
depth_top
>
ct_depth
);
return
GET_CABAC
(
elem_offset
[
SPLIT_CODING_UNIT_FLAG
]
+
inc
);
}
...
...
libavcodec/hevc_filter.c
View file @
f578e5d9
...
...
@@ -37,18 +37,20 @@
static
const
uint8_t
tctable
[
54
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
// QP 0...18
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
// QP 19...37
5
,
5
,
6
,
6
,
7
,
8
,
9
,
10
,
11
,
13
,
14
,
16
,
18
,
20
,
22
,
24
// QP 38...53
5
,
5
,
6
,
6
,
7
,
8
,
9
,
10
,
11
,
13
,
14
,
16
,
18
,
20
,
22
,
24
// QP 38...53
};
static
const
uint8_t
betatable
[
52
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
6
,
7
,
8
,
// QP 0...18
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
34
,
36
,
// QP 19...37
38
,
40
,
42
,
44
,
46
,
48
,
50
,
52
,
54
,
56
,
58
,
60
,
62
,
64
// QP 38...51
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
20
,
22
,
24
,
26
,
28
,
30
,
32
,
34
,
36
,
// QP 19...37
38
,
40
,
42
,
44
,
46
,
48
,
50
,
52
,
54
,
56
,
58
,
60
,
62
,
64
// QP 38...51
};
static
int
chroma_tc
(
HEVCContext
*
s
,
int
qp_y
,
int
c_idx
,
int
tc_offset
)
{
static
const
int
qp_c
[]
=
{
29
,
30
,
31
,
32
,
33
,
33
,
34
,
34
,
35
,
35
,
36
,
36
,
37
,
37
};
static
const
int
qp_c
[]
=
{
29
,
30
,
31
,
32
,
33
,
33
,
34
,
34
,
35
,
35
,
36
,
36
,
37
,
37
};
int
qp_i
,
offset
;
int
qp
;
int
idxt
;
...
...
@@ -71,19 +73,23 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
return
tctable
[
idxt
];
}
static
int
get_qPy_pred
(
HEVCContext
*
s
,
int
xC
,
int
yC
,
int
xBase
,
int
yBase
,
int
log2_cb_size
)
static
int
get_qPy_pred
(
HEVCContext
*
s
,
int
xC
,
int
yC
,
int
xBase
,
int
yBase
,
int
log2_cb_size
)
{
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
int
ctb_size_mask
=
(
1
<<
s
->
sps
->
log2_ctb_size
)
-
1
;
int
MinCuQpDeltaSizeMask
=
(
1
<<
(
s
->
sps
->
log2_ctb_size
-
s
->
pps
->
diff_cu_qp_delta_depth
))
-
1
;
int
xQgBase
=
xBase
-
(
xBase
&
MinCuQpDeltaSizeMask
);
int
yQgBase
=
yBase
-
(
yBase
&
MinCuQpDeltaSizeMask
);
int
MinCuQpDeltaSizeMask
=
(
1
<<
(
s
->
sps
->
log2_ctb_size
-
s
->
pps
->
diff_cu_qp_delta_depth
))
-
1
;
int
xQgBase
=
xBase
-
(
xBase
&
MinCuQpDeltaSizeMask
);
int
yQgBase
=
yBase
-
(
yBase
&
MinCuQpDeltaSizeMask
);
int
min_cb_width
=
s
->
sps
->
min_cb_width
;
int
min_cb_height
=
s
->
sps
->
min_cb_height
;
int
x_cb
=
xQgBase
>>
s
->
sps
->
log2_min_cb_size
;
int
y_cb
=
yQgBase
>>
s
->
sps
->
log2_min_cb_size
;
int
availableA
=
(
xBase
&
ctb_size_mask
)
&&
(
xQgBase
&
ctb_size_mask
);
int
availableB
=
(
yBase
&
ctb_size_mask
)
&&
(
yQgBase
&
ctb_size_mask
);
int
availableA
=
(
xBase
&
ctb_size_mask
)
&&
(
xQgBase
&
ctb_size_mask
);
int
availableB
=
(
yBase
&
ctb_size_mask
)
&&
(
yQgBase
&
ctb_size_mask
);
int
qPy_pred
;
int
qPy_a
;
int
qPy_b
;
...
...
@@ -94,26 +100,27 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in
qPy_pred
=
s
->
sh
.
slice_qp
;
}
else
{
qPy_pred
=
lc
->
qp_y
;
if
(
log2_cb_size
<
s
->
sps
->
log2_ctb_size
-
s
->
pps
->
diff_cu_qp_delta_depth
)
{
if
(
log2_cb_size
<
s
->
sps
->
log2_ctb_size
-
s
->
pps
->
diff_cu_qp_delta_depth
)
{
static
const
int
offsetX
[
8
][
8
]
=
{
{
-
1
,
1
,
3
,
1
,
7
,
1
,
3
,
1
},
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
1
,
3
,
1
,
3
,
1
,
3
,
1
,
3
},
{
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
},
{
3
,
5
,
7
,
5
,
3
,
5
,
7
,
5
},
{
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
},
{
5
,
7
,
5
,
7
,
5
,
7
,
5
,
7
},
{
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
}
{
-
1
,
1
,
3
,
1
,
7
,
1
,
3
,
1
},
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
},
{
1
,
3
,
1
,
3
,
1
,
3
,
1
,
3
},
{
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
},
{
3
,
5
,
7
,
5
,
3
,
5
,
7
,
5
},
{
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
},
{
5
,
7
,
5
,
7
,
5
,
7
,
5
,
7
},
{
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
}
};
static
const
int
offsetY
[
8
][
8
]
=
{
{
7
,
0
,
1
,
2
,
3
,
4
,
5
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
1
,
0
,
3
,
2
,
5
,
4
,
7
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
3
,
0
,
1
,
2
,
7
,
4
,
5
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
1
,
0
,
3
,
2
,
5
,
4
,
7
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
}
{
7
,
0
,
1
,
2
,
3
,
4
,
5
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
1
,
0
,
3
,
2
,
5
,
4
,
7
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
3
,
0
,
1
,
2
,
7
,
4
,
5
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
},
{
1
,
0
,
3
,
2
,
5
,
4
,
7
,
6
},
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
}
};
int
xC0b
=
(
xC
-
(
xC
&
ctb_size_mask
))
>>
s
->
sps
->
log2_min_cb_size
;
int
yC0b
=
(
yC
-
(
yC
&
ctb_size_mask
))
>>
s
->
sps
->
log2_min_cb_size
;
...
...
@@ -149,13 +156,15 @@ static int get_qPy_pred(HEVCContext *s, int xC, int yC, int xBase, int yBase, in
return
(
qPy_a
+
qPy_b
+
1
)
>>
1
;
}
void
ff_hevc_set_qPy
(
HEVCContext
*
s
,
int
xC
,
int
yC
,
int
xBase
,
int
yBase
,
int
log2_cb_size
)
void
ff_hevc_set_qPy
(
HEVCContext
*
s
,
int
xC
,
int
yC
,
int
xBase
,
int
yBase
,
int
log2_cb_size
)
{
int
qp_y
=
get_qPy_pred
(
s
,
xC
,
yC
,
xBase
,
yBase
,
log2_cb_size
);
if
(
s
->
HEVClc
->
tu
.
cu_qp_delta
!=
0
)
{
int
off
=
s
->
sps
->
qp_bd_offset
;
s
->
HEVClc
->
qp_y
=
((
qp_y
+
s
->
HEVClc
->
tu
.
cu_qp_delta
+
52
+
2
*
off
)
%
(
52
+
off
))
-
off
;
s
->
HEVClc
->
qp_y
=
((
qp_y
+
s
->
HEVClc
->
tu
.
cu_qp_delta
+
52
+
2
*
off
)
%
(
52
+
off
))
-
off
;
}
else
s
->
HEVClc
->
qp_y
=
qp_y
;
}
...
...
@@ -168,11 +177,12 @@ static int get_qPy(HEVCContext *s, int xC, int yC)
return
s
->
qp_y_tab
[
x
+
y
*
s
->
sps
->
min_cb_width
];
}
static
void
copy_CTB
(
uint8_t
*
dst
,
uint8_t
*
src
,
int
width
,
int
height
,
int
stride
)
static
void
copy_CTB
(
uint8_t
*
dst
,
uint8_t
*
src
,
int
width
,
int
height
,
int
stride
)
{
int
i
;
for
(
i
=
0
;
i
<
height
;
i
++
)
{
for
(
i
=
0
;
i
<
height
;
i
++
)
{
memcpy
(
dst
,
src
,
width
);
dst
+=
stride
;
src
+=
stride
;
...
...
@@ -191,17 +201,18 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
SAOParams
*
sao
[
4
];
int
classes
[
4
];
int
x_shift
=
0
,
y_shift
=
0
;
int
x_ctb
=
x
>>
s
->
sps
->
log2_ctb_size
;
int
y_ctb
=
y
>>
s
->
sps
->
log2_ctb_size
;
int
x_ctb
=
x
>>
s
->
sps
->
log2_ctb_size
;
int
y_ctb
=
y
>>
s
->
sps
->
log2_ctb_size
;
int
ctb_addr_rs
=
y_ctb
*
s
->
sps
->
ctb_width
+
x_ctb
;
int
ctb_addr_ts
=
s
->
pps
->
ctb_addr_rs_to_ts
[
ctb_addr_rs
];
// flags indicating unfilterable edges
uint8_t
vert_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
horiz_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
diag_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
vert_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
horiz_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
diag_edge
[]
=
{
0
,
0
,
0
,
0
};
uint8_t
lfase
[
3
];
// current, above, left
uint8_t
no_tile_filter
=
s
->
pps
->
tiles_enabled_flag
&&
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
;
uint8_t
no_tile_filter
=
s
->
pps
->
tiles_enabled_flag
&&
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
;
uint8_t
left_tile_edge
=
0
;
uint8_t
up_tile_edge
=
0
;
...
...
@@ -249,10 +260,12 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
diag_edge
[
3
]
=
diag_edge
[
0
];
// Does left CTB comes after above CTB?
if
(
CTB
(
s
->
tab_slice_address
,
x_ctb
-
1
,
y_ctb
)
>
CTB
(
s
->
tab_slice_address
,
x_ctb
,
y_ctb
-
1
))
{
if
(
CTB
(
s
->
tab_slice_address
,
x_ctb
-
1
,
y_ctb
)
>
CTB
(
s
->
tab_slice_address
,
x_ctb
,
y_ctb
-
1
))
{
diag_edge
[
2
]
=
!
lfase
[
2
]
||
left_tile_edge
||
up_tile_edge
;
diag_edge
[
1
]
=
diag_edge
[
2
];
}
else
if
(
CTB
(
s
->
tab_slice_address
,
x_ctb
-
1
,
y_ctb
)
<
CTB
(
s
->
tab_slice_address
,
x_ctb
,
y_ctb
-
1
))
{
}
else
if
(
CTB
(
s
->
tab_slice_address
,
x_ctb
-
1
,
y_ctb
)
<
CTB
(
s
->
tab_slice_address
,
x_ctb
,
y_ctb
-
1
))
{
diag_edge
[
1
]
=
!
lfase
[
1
]
||
left_tile_edge
||
up_tile_edge
;
diag_edge
[
2
]
=
diag_edge
[
1
];
}
else
{
...
...
@@ -286,10 +299,21 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
switch
(
sao
[
class_index
]
->
type_idx
[
c_idx
])
{
case
SAO_BAND
:
s
->
hevcdsp
.
sao_band_filter
[
classes
[
class_index
]](
dst
,
src
,
stride
,
sao
[
class_index
],
edges
,
width
,
height
,
c_idx
);
s
->
hevcdsp
.
sao_band_filter
[
classes
[
class_index
]](
dst
,
src
,
stride
,
sao
[
class_index
],
edges
,
width
,
height
,
c_idx
);
break
;
case
SAO_EDGE
:
s
->
hevcdsp
.
sao_edge_filter
[
classes
[
class_index
]](
dst
,
src
,
stride
,
sao
[
class_index
],
edges
,
width
,
height
,
c_idx
,
vert_edge
[
classes
[
class_index
]],
horiz_edge
[
classes
[
class_index
]],
diag_edge
[
classes
[
class_index
]]);
s
->
hevcdsp
.
sao_edge_filter
[
classes
[
class_index
]](
dst
,
src
,
stride
,
sao
[
class_index
],
edges
,
width
,
height
,
c_idx
,
vert_edge
[
classes
[
class_index
]],
horiz_edge
[
classes
[
class_index
]],
diag_edge
[
classes
[
class_index
]]);
break
;
}
}
...
...
@@ -318,29 +342,31 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
int
c_tc
[
2
];
int
beta
[
2
];
int
tc
[
2
];
uint8_t
no_p
[
2
]
=
{
0
};
uint8_t
no_q
[
2
]
=
{
0
};
uint8_t
no_p
[
2
]
=
{
0
};
uint8_t
no_q
[
2
]
=
{
0
};
int
log2_ctb_size
=
s
->
sps
->
log2_ctb_size
;
int
x_end
,
y_end
;
int
ctb_size
=
1
<<
log2_ctb_size
;
int
ctb
=
(
x0
>>
log2_ctb_size
)
+
(
y0
>>
log2_ctb_size
)
*
s
->
sps
->
ctb_width
;
int
ctb_size
=
1
<<
log2_ctb_size
;
int
ctb
=
(
x0
>>
log2_ctb_size
)
+
(
y0
>>
log2_ctb_size
)
*
s
->
sps
->
ctb_width
;
int
cur_tc_offset
=
s
->
deblock
[
ctb
].
tc_offset
;
int
cur_beta_offset
=
s
->
deblock
[
ctb
].
beta_offset
;
int
left_tc_offset
,
left_beta_offset
;
int
tc_offset
,
beta_offset
;
int
pcmf
=
(
s
->
sps
->
pcm_enabled_flag
&&
s
->
sps
->
pcm
.
loop_filter_disable_flag
)
||
int
pcmf
=
(
s
->
sps
->
pcm_enabled_flag
&&
s
->
sps
->
pcm
.
loop_filter_disable_flag
)
||
s
->
pps
->
transquant_bypass_enable_flag
;
if
(
x0
)
{
left_tc_offset
=
s
->
deblock
[
ctb
-
1
].
tc_offset
;
left_beta_offset
=
s
->
deblock
[
ctb
-
1
].
beta_offset
;
left_tc_offset
=
s
->
deblock
[
ctb
-
1
].
tc_offset
;
left_beta_offset
=
s
->
deblock
[
ctb
-
1
].
beta_offset
;
}
x_end
=
x0
+
ctb_size
;
x_end
=
x0
+
ctb_size
;
if
(
x_end
>
s
->
sps
->
width
)
x_end
=
s
->
sps
->
width
;
y_end
=
y0
+
ctb_size
;
y_end
=
y0
+
ctb_size
;
if
(
y_end
>
s
->
sps
->
height
)
y_end
=
s
->
sps
->
height
;
...
...
@@ -366,9 +392,13 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
no_p
[
1
]
=
get_pcm
(
s
,
x
-
1
,
y
+
4
);
no_q
[
0
]
=
get_pcm
(
s
,
x
,
y
);
no_q
[
1
]
=
get_pcm
(
s
,
x
,
y
+
4
);
s
->
hevcdsp
.
hevc_v_loop_filter_luma_c
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_v_loop_filter_luma_c
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
}
else
s
->
hevcdsp
.
hevc_v_loop_filter_luma
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_v_loop_filter_luma
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
}
}
}
...
...
@@ -376,7 +406,7 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
// vertical filtering chroma
for
(
chroma
=
1
;
chroma
<=
2
;
chroma
++
)
{
for
(
y
=
y0
;
y
<
y_end
;
y
+=
16
)
{
for
(
x
=
x0
?
x0
:
16
;
x
<
x_end
;
x
+=
16
)
{
for
(
x
=
x0
?
x0
:
16
;
x
<
x_end
;
x
+=
16
)
{
const
int
bs0
=
s
->
vertical_bs
[(
x
>>
3
)
+
(
y
>>
2
)
*
s
->
bs_width
];
const
int
bs1
=
s
->
vertical_bs
[(
x
>>
3
)
+
((
y
+
8
)
>>
2
)
*
s
->
bs_width
];
if
((
bs0
==
2
)
||
(
bs1
==
2
))
{
...
...
@@ -391,9 +421,13 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
no_p
[
1
]
=
get_pcm
(
s
,
x
-
1
,
y
+
8
);
no_q
[
0
]
=
get_pcm
(
s
,
x
,
y
);
no_q
[
1
]
=
get_pcm
(
s
,
x
,
y
+
8
);
s
->
hevcdsp
.
hevc_v_loop_filter_chroma_c
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_v_loop_filter_chroma_c
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
}
else
s
->
hevcdsp
.
hevc_v_loop_filter_chroma
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_v_loop_filter_chroma
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
}
}
}
...
...
@@ -423,9 +457,13 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
no_p
[
1
]
=
get_pcm
(
s
,
x
+
4
,
y
-
1
);
no_q
[
0
]
=
get_pcm
(
s
,
x
,
y
);
no_q
[
1
]
=
get_pcm
(
s
,
x
+
4
,
y
);
s
->
hevcdsp
.
hevc_h_loop_filter_luma_c
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_h_loop_filter_luma_c
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
}
else
s
->
hevcdsp
.
hevc_h_loop_filter_luma
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_h_loop_filter_luma
(
src
,
s
->
frame
->
linesize
[
LUMA
],
beta
,
tc
,
no_p
,
no_q
);
}
}
}
...
...
@@ -461,9 +499,13 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
no_p
[
1
]
=
get_pcm
(
s
,
x
+
8
,
y
-
1
);
no_q
[
0
]
=
get_pcm
(
s
,
x
,
y
);
no_q
[
1
]
=
get_pcm
(
s
,
x
+
8
,
y
);
s
->
hevcdsp
.
hevc_h_loop_filter_chroma_c
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_h_loop_filter_chroma_c
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
}
else
s
->
hevcdsp
.
hevc_h_loop_filter_chroma
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
s
->
hevcdsp
.
hevc_h_loop_filter_chroma
(
src
,
s
->
frame
->
linesize
[
chroma
],
c_tc
,
no_p
,
no_q
);
}
}
}
...
...
@@ -472,7 +514,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
static
int
boundary_strength
(
HEVCContext
*
s
,
MvField
*
curr
,
uint8_t
curr_cbf_luma
,
MvField
*
neigh
,
uint8_t
neigh_cbf_luma
,
RefPicList
*
neigh_refPicList
,
uint8_t
neigh_cbf_luma
,
RefPicList
*
neigh_refPicList
,
int
tu_border
)
{
int
mvs
=
curr
->
pred_flag
[
0
]
+
curr
->
pred_flag
[
1
];
...
...
@@ -548,16 +591,18 @@ static int boundary_strength(HEVCContext *s, MvField *curr,
return
1
;
}
void
ff_hevc_deblocking_boundary_strengths
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
log2_trafo_size
,
int
slice_or_tiles_up_boundary
,
int
slice_or_tiles_left_boundary
)
void
ff_hevc_deblocking_boundary_strengths
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
log2_trafo_size
,
int
slice_or_tiles_up_boundary
,
int
slice_or_tiles_left_boundary
)
{
MvField
*
tab_mvf
=
s
->
ref
->
tab_mvf
;
int
log2_min_pu_size
=
s
->
sps
->
log2_min_pu_size
;
int
log2_min_tu_size
=
s
->
sps
->
log2_min_tb_size
;
int
min_pu_width
=
s
->
sps
->
min_pu_width
;
int
min_tu_width
=
s
->
sps
->
min_tb_width
;
int
is_intra
=
tab_mvf
[(
y0
>>
log2_min_pu_size
)
*
min_pu_width
+
(
x0
>>
log2_min_pu_size
)].
is_intra
;
int
is_intra
=
tab_mvf
[(
y0
>>
log2_min_pu_size
)
*
min_pu_width
+
(
x0
>>
log2_min_pu_size
)].
is_intra
;
int
i
,
j
;
int
bs
;
...
...
@@ -574,12 +619,18 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l
MvField
*
curr
=
&
tab_mvf
[
yq_pu
*
min_pu_width
+
x_pu
];
uint8_t
top_cbf_luma
=
s
->
cbf_luma
[
yp_tu
*
min_tu_width
+
x_tu
];
uint8_t
curr_cbf_luma
=
s
->
cbf_luma
[
yq_tu
*
min_tu_width
+
x_tu
];
RefPicList
*
top_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
,
y0
-
1
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
top
,
top_cbf_luma
,
top_refPicList
,
1
);
if
(
!
s
->
sh
.
slice_loop_filter_across_slices_enabled_flag
&&
(
slice_or_tiles_up_boundary
&
1
)
&&
(
y0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
RefPicList
*
top_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
,
y0
-
1
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
top
,
top_cbf_luma
,
top_refPicList
,
1
);
if
(
!
s
->
sh
.
slice_loop_filter_across_slices_enabled_flag
&&
(
slice_or_tiles_up_boundary
&
1
)
&&
(
y0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
bs
=
0
;
else
if
(
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
&&
(
slice_or_tiles_up_boundary
&
2
)
&&
(
y0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
else
if
(
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
&&
(
slice_or_tiles_up_boundary
&
2
)
&&
(
y0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
bs
=
0
;
if
(
y0
==
0
||
s
->
sh
.
disable_deblocking_filter_flag
==
1
)
bs
=
0
;
...
...
@@ -596,17 +647,19 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l
int
yp_tu
=
(
y0
+
j
-
1
)
>>
log2_min_tu_size
;
int
yq_tu
=
(
y0
+
j
)
>>
log2_min_tu_size
;
for
(
i
=
0
;
i
<
(
1
<<
log2_trafo_size
);
i
+=
4
)
{
for
(
i
=
0
;
i
<
(
1
<<
log2_trafo_size
);
i
+=
4
)
{
int
x_pu
=
(
x0
+
i
)
>>
log2_min_pu_size
;
int
x_tu
=
(
x0
+
i
)
>>
log2_min_tu_size
;
MvField
*
top
=
&
tab_mvf
[
yp_pu
*
min_pu_width
+
x_pu
];
MvField
*
curr
=
&
tab_mvf
[
yq_pu
*
min_pu_width
+
x_pu
];
uint8_t
top_cbf_luma
=
s
->
cbf_luma
[
yp_tu
*
min_tu_width
+
x_tu
];
uint8_t
curr_cbf_luma
=
s
->
cbf_luma
[
yq_tu
*
min_tu_width
+
x_tu
];
RefPicList
*
top_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
,
y0
+
j
-
1
);
RefPicList
*
top_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
,
y0
+
j
-
1
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
top
,
top_cbf_luma
,
top_refPicList
,
0
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
top
,
top_cbf_luma
,
top_refPicList
,
0
);
if
(
s
->
sh
.
disable_deblocking_filter_flag
==
1
)
bs
=
0
;
if
(
bs
)
...
...
@@ -629,12 +682,18 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l
uint8_t
left_cbf_luma
=
s
->
cbf_luma
[
y_tu
*
min_tu_width
+
xp_tu
];
uint8_t
curr_cbf_luma
=
s
->
cbf_luma
[
y_tu
*
min_tu_width
+
xq_tu
];
RefPicList
*
left_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
-
1
,
y0
+
i
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
left
,
left_cbf_luma
,
left_refPicList
,
1
);
if
(
!
s
->
sh
.
slice_loop_filter_across_slices_enabled_flag
&&
(
slice_or_tiles_left_boundary
&
1
)
&&
(
x0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
RefPicList
*
left_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
-
1
,
y0
+
i
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
left
,
left_cbf_luma
,
left_refPicList
,
1
);
if
(
!
s
->
sh
.
slice_loop_filter_across_slices_enabled_flag
&&
(
slice_or_tiles_left_boundary
&
1
)
&&
(
x0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
bs
=
0
;
else
if
(
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
&&
(
slice_or_tiles_left_boundary
&
2
)
&&
(
x0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
else
if
(
!
s
->
pps
->
loop_filter_across_tiles_enabled_flag
&&
(
slice_or_tiles_left_boundary
&
2
)
&&
(
x0
%
(
1
<<
s
->
sps
->
log2_ctb_size
))
==
0
)
bs
=
0
;
if
(
x0
==
0
||
s
->
sh
.
disable_deblocking_filter_flag
==
1
)
bs
=
0
;
...
...
@@ -658,9 +717,12 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l
MvField
*
curr
=
&
tab_mvf
[
y_pu
*
min_pu_width
+
xq_pu
];
uint8_t
left_cbf_luma
=
s
->
cbf_luma
[
y_tu
*
min_tu_width
+
xp_tu
];
uint8_t
curr_cbf_luma
=
s
->
cbf_luma
[
y_tu
*
min_tu_width
+
xq_tu
];
RefPicList
*
left_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
-
1
,
y0
+
j
);
RefPicList
*
left_refPicList
=
ff_hevc_get_ref_list
(
s
,
s
->
ref
,
x0
+
i
-
1
,
y0
+
j
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
left
,
left_cbf_luma
,
left_refPicList
,
0
);
bs
=
boundary_strength
(
s
,
curr
,
curr_cbf_luma
,
left
,
left_cbf_luma
,
left_refPicList
,
0
);
if
(
s
->
sh
.
disable_deblocking_filter_flag
==
1
)
bs
=
0
;
if
(
bs
)
...
...
@@ -668,6 +730,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int l
}
}
}
#undef LUMA
#undef CB
#undef CR
...
...
libavcodec/hevc_mvs.c
View file @
f578e5d9
...
...
@@ -38,7 +38,8 @@ static const uint8_t l0_l1_cand_idx[12][2] = {
{
3
,
2
,
},
};
void
ff_hevc_set_neighbour_available
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
)
void
ff_hevc_set_neighbour_available
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
)
{
HEVCLocalContext
*
lc
=
s
->
HEVClc
;
int
x0b
=
x0
&
((
1
<<
s
->
sps
->
log2_ctb_size
)
-
1
);
...
...
@@ -80,7 +81,6 @@ static int z_scan_block_avail(HEVCContext *s, int xCurr, int yCurr,
return
N
<=
Curr
;
}
static
int
same_prediction_block
(
HEVCLocalContext
*
lc
,
int
log2_cb_size
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
,
int
xA1
,
int
yA1
,
int
partIdx
)
...
...
@@ -184,12 +184,12 @@ static int check_mvset(Mv *mvLXCol, Mv *mvCol,
check_mvset(mvLXCol, temp_col.mv + l, \
colPic, s->poc, \
refPicList, X, refIdxLx, \
refPicList_col, L
##
l, temp_col.ref_idx[l])
refPicList_col, L
##
l, temp_col.ref_idx[l])
// derive the motion vectors section 8.5.3.1.8
static
int
derive_temporal_colocated_mvs
(
HEVCContext
*
s
,
MvField
temp_col
,
int
refIdxLx
,
Mv
*
mvLXCol
,
int
X
,
int
colPic
,
RefPicList
*
refPicList_col
)
int
refIdxLx
,
Mv
*
mvLXCol
,
int
X
,
int
colPic
,
RefPicList
*
refPicList_col
)
{
RefPicList
*
refPicList
=
s
->
ref
->
refPicList
;
...
...
@@ -233,7 +233,7 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
tab_mvf[(y) * min_pu_width + x]
#define TAB_MVF_PU(v) \
TAB_MVF(x
##v##_pu, y##v##
_pu)
TAB_MVF(x
## v ## _pu, y ## v ##
_pu)
#define DERIVE_TEMPORAL_COLOCATED_MVS \
derive_temporal_colocated_mvs(s, temp_col, \
...
...
@@ -245,7 +245,7 @@ static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
*/
static
int
temporal_luma_motion_vector
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
,
int
refIdxLx
,
Mv
*
mvLXCol
,
int
X
)
Mv
*
mvLXCol
,
int
X
)
{
MvField
*
tab_mvf
;
MvField
temp_col
;
...
...
@@ -301,7 +301,7 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
#define PRED_BLOCK_AVAILABLE(v) \
check_prediction_block_available(s, log2_cb_size, \
x0, y0, nPbW, nPbH, \
x
##v, y##
v, part_idx)
x
## v, y ##
v, part_idx)
#define COMPARE_MV_REFIDX(a, b) \
compareMVrefidx(TAB_MVF_PU(a), TAB_MVF_PU(b))
...
...
@@ -310,7 +310,8 @@ static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
* 8.5.3.1.2 Derivation process for spatial merging candidates
*/
static
void
derive_spatial_merge_candidates
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
,
int
log2_cb_size
,
int
nPbW
,
int
nPbH
,
int
log2_cb_size
,
int
singleMCLFlag
,
int
part_idx
,
struct
MvField
mergecandlist
[])
{
...
...
@@ -560,7 +561,7 @@ void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
*
mv
=
mergecand_list
[
merge_idx
];
}
static
av_always_inline
void
dist_scale
(
HEVCContext
*
s
,
Mv
*
mv
,
static
av_always_inline
void
dist_scale
(
HEVCContext
*
s
,
Mv
*
mv
,
int
min_pu_width
,
int
x
,
int
y
,
int
elist
,
int
ref_idx_curr
,
int
ref_idx
)
{
...
...
@@ -589,7 +590,6 @@ static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
return
0
;
}
static
int
mv_mp_mode_mx_lt
(
HEVCContext
*
s
,
int
x
,
int
y
,
int
pred_flag_index
,
Mv
*
mv
,
int
ref_idx_curr
,
int
ref_idx
)
{
...
...
@@ -602,20 +602,22 @@ static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
int
colIsLongTerm
=
refPicList
[
pred_flag_index
].
isLongTerm
[(
TAB_MVF
(
x
,
y
).
ref_idx
[
pred_flag_index
])];
if
(
TAB_MVF
(
x
,
y
).
pred_flag
[
pred_flag_index
]
&&
colIsLongTerm
==
currIsLongTerm
)
{
if
(
TAB_MVF
(
x
,
y
).
pred_flag
[
pred_flag_index
]
&&
colIsLongTerm
==
currIsLongTerm
)
{
*
mv
=
TAB_MVF
(
x
,
y
).
mv
[
pred_flag_index
];
if
(
!
currIsLongTerm
)
dist_scale
(
s
,
mv
,
min_pu_width
,
x
,
y
,
pred_flag_index
,
ref_idx_curr
,
ref_idx
);
dist_scale
(
s
,
mv
,
min_pu_width
,
x
,
y
,
pred_flag_index
,
ref_idx_curr
,
ref_idx
);
return
1
;
}
return
0
;
}
#define MP_MX(v, pred, mx) \
mv_mp_mode_mx(s, x
##v##_pu, y##v##
_pu, pred, &mx, ref_idx_curr, ref_idx)
mv_mp_mode_mx(s, x
## v ## _pu, y ## v ##
_pu, pred, &mx, ref_idx_curr, ref_idx)
#define MP_MX_LT(v, pred, mx) \
mv_mp_mode_mx_lt(s, x
##v##_pu, y##v##
_pu, pred, &mx, ref_idx_curr, ref_idx)
mv_mp_mode_mx_lt(s, x
## v ## _pu, y ## v ##
_pu, pred, &mx, ref_idx_curr, ref_idx)
void
ff_hevc_luma_mv_mvp_mode
(
HEVCContext
*
s
,
int
x0
,
int
y0
,
int
nPbW
,
int
nPbH
,
int
log2_cb_size
,
int
part_idx
,
...
...
@@ -800,7 +802,8 @@ void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
if
(
numMVPCandLX
<
2
&&
s
->
sh
.
slice_temporal_mvp_enabled_flag
)
{
Mv
mv_col
;
int
available_col
=
temporal_luma_motion_vector
(
s
,
x0
,
y0
,
nPbW
,
nPbH
,
ref_idx
,
&
mv_col
,
LX
);
nPbH
,
ref_idx
,
&
mv_col
,
LX
);
if
(
available_col
)
mvpcand_list
[
numMVPCandLX
++
]
=
mv_col
;
}
...
...
libavcodec/hevc_parser.c
View file @
f578e5d9
...
...
@@ -21,6 +21,7 @@
*/
#include "libavutil/common.h"
#include "parser.h"
#include "hevc.h"
#include "golomb.h"
...
...
@@ -36,7 +37,8 @@ typedef struct HEVCParseContext {
* Find the end of the current frame in the bitstream.
* @return the position of the first byte of the next frame, or END_NOT_FOUND
*/
static
int
hevc_find_frame_end
(
AVCodecParserContext
*
s
,
const
uint8_t
*
buf
,
int
buf_size
)
static
int
hevc_find_frame_end
(
AVCodecParserContext
*
s
,
const
uint8_t
*
buf
,
int
buf_size
)
{
int
i
;
ParseContext
*
pc
=
&
((
HEVCParseContext
*
)
s
->
priv_data
)
->
pc
;
...
...
@@ -82,8 +84,7 @@ static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf, int
* @param buf buffer with field/frame data.
* @param buf_size size of the buffer.
*/
static
inline
int
parse_nal_units
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
static
inline
int
parse_nal_units
(
AVCodecParserContext
*
s
,
AVCodecContext
*
avctx
,
const
uint8_t
*
buf
,
int
buf_size
)
{
HEVCContext
*
h
=
&
((
HEVCParseContext
*
)
s
->
priv_data
)
->
h
;
...
...
libavcodec/hevc_ps.c
View file @
f578e5d9
...
...
@@ -273,7 +273,8 @@ static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb,
}
}
static
void
decode_hrd
(
HEVCContext
*
s
,
int
common_inf_present
,
int
max_sublayers
)
static
void
decode_hrd
(
HEVCContext
*
s
,
int
common_inf_present
,
int
max_sublayers
)
{
GetBitContext
*
gb
=
&
s
->
HEVClc
->
gb
;
int
nal_params_present
=
0
,
vcl_params_present
=
0
;
...
...
@@ -643,7 +644,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
}
skip_bits1
(
gb
);
// temporal_id_nesting_flag
if
(
decode_profile_tier_level
(
s
,
&
sps
->
ptl
,
sps
->
max_sub_layers
)
<
0
)
{
if
(
decode_profile_tier_level
(
s
,
&
sps
->
ptl
,
sps
->
max_sub_layers
)
<
0
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"error decoding profile tier level
\n
"
);
ret
=
AVERROR_INVALIDDATA
;
goto
err
;
...
...
@@ -820,7 +822,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
sps
->
nb_st_rps
=
get_ue_golomb_long
(
gb
);
if
(
sps
->
nb_st_rps
>
MAX_SHORT_TERM_RPS_COUNT
)
{
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Too many short term RPS: %d.
\n
"
,
av_log
(
s
->
avctx
,
AV_LOG_ERROR
,
"Too many short term RPS: %d.
\n
"
,
sps
->
nb_st_rps
);
ret
=
AVERROR_INVALIDDATA
;
goto
err
;
...
...
@@ -872,8 +875,7 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
ret
=
AVERROR_INVALIDDATA
;
goto
err
;
}
av_log
(
s
->
avctx
,
AV_LOG_WARNING
,
"Displaying the whole video surface.
\n
"
);
av_log
(
s
->
avctx
,
AV_LOG_WARNING
,
"Displaying the whole video surface.
\n
"
);
sps
->
pic_conf_win
.
left_offset
=
sps
->
pic_conf_win
.
right_offset
=
sps
->
pic_conf_win
.
top_offset
=
...
...
libavcodec/hevc_refs.c
View file @
f578e5d9
...
...
@@ -49,16 +49,17 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
}
}
RefPicList
*
ff_hevc_get_ref_list
(
HEVCContext
*
s
,
HEVCFrame
*
ref
,
int
x0
,
int
y0
)
RefPicList
*
ff_hevc_get_ref_list
(
HEVCContext
*
s
,
HEVCFrame
*
ref
,
int
x0
,
int
y0
)
{
if
(
x0
<
0
||
y0
<
0
)
{
return
s
->
ref
->
refPicList
;
}
else
{
int
x_cb
=
x0
>>
s
->
sps
->
log2_ctb_size
;
int
y_cb
=
y0
>>
s
->
sps
->
log2_ctb_size
;
int
pic_width_cb
=
(
s
->
sps
->
width
+
(
1
<<
s
->
sps
->
log2_ctb_size
)
-
1
)
>>
s
->
sps
->
log2_ctb_size
;
int
pic_width_cb
=
(
s
->
sps
->
width
+
(
1
<<
s
->
sps
->
log2_ctb_size
)
-
1
)
>>
s
->
sps
->
log2_ctb_size
;
int
ctb_addr_ts
=
s
->
pps
->
ctb_addr_rs_to_ts
[
y_cb
*
pic_width_cb
+
x_cb
];
return
(
RefPicList
*
)
ref
->
rpl_tab
[
ctb_addr_ts
];
return
(
RefPicList
*
)
ref
->
rpl_tab
[
ctb_addr_ts
];
}
}
...
...
@@ -67,7 +68,8 @@ void ff_hevc_clear_refs(HEVCContext *s)
int
i
;
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
s
->
DPB
);
i
++
)
ff_hevc_unref_frame
(
s
,
&
s
->
DPB
[
i
],
HEVC_FRAME_FLAG_SHORT_REF
|
HEVC_FRAME_FLAG_LONG_REF
);
HEVC_FRAME_FLAG_SHORT_REF
|
HEVC_FRAME_FLAG_LONG_REF
);
}
void
ff_hevc_flush_dpb
(
HEVCContext
*
s
)
...
...
@@ -85,7 +87,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
if
(
frame
->
frame
->
buf
[
0
])
continue
;
ret
=
ff_thread_get_buffer
(
s
->
avctx
,
&
frame
->
tf
,
AV_GET_BUFFER_FLAG_REF
);
ret
=
ff_thread_get_buffer
(
s
->
avctx
,
&
frame
->
tf
,
AV_GET_BUFFER_FLAG_REF
);
if
(
ret
<
0
)
return
NULL
;
...
...
@@ -96,15 +99,15 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
frame
->
tab_mvf_buf
=
av_buffer_pool_get
(
s
->
tab_mvf_pool
);
if
(
!
frame
->
tab_mvf_buf
)
goto
fail
;
frame
->
tab_mvf
=
(
MvField
*
)
frame
->
tab_mvf_buf
->
data
;
frame
->
tab_mvf
=
(
MvField
*
)
frame
->
tab_mvf_buf
->
data
;
frame
->
rpl_tab_buf
=
av_buffer_pool_get
(
s
->
rpl_tab_pool
);
if
(
!
frame
->
rpl_tab_buf
)
goto
fail
;
frame
->
rpl_tab
=
(
RefPicListTab
**
)
frame
->
rpl_tab_buf
->
data
;
frame
->
rpl_tab
=
(
RefPicListTab
**
)
frame
->
rpl_tab_buf
->
data
;
frame
->
ctb_count
=
s
->
sps
->
ctb_width
*
s
->
sps
->
ctb_height
;
for
(
j
=
0
;
j
<
frame
->
ctb_count
;
j
++
)
frame
->
rpl_tab
[
j
]
=
(
RefPicListTab
*
)
frame
->
rpl_buf
->
data
;
frame
->
rpl_tab
[
j
]
=
(
RefPicListTab
*
)
frame
->
rpl_buf
->
data
;
frame
->
frame
->
top_field_first
=
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_TOP_FIELD
;
frame
->
frame
->
interlaced_frame
=
(
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_TOP_FIELD
)
||
(
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_BOTTOM_FIELD
);
...
...
@@ -140,8 +143,8 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
*
frame
=
ref
->
frame
;
s
->
ref
=
ref
;
ref
->
poc
=
poc
;
ref
->
poc
=
poc
;
ref
->
flags
=
HEVC_FRAME_FLAG_OUTPUT
|
HEVC_FRAME_FLAG_SHORT_REF
;
ref
->
sequence
=
s
->
seq_decode
;
ref
->
window
=
s
->
sps
->
output_window
;
...
...
@@ -192,7 +195,8 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush)
(
frame
->
window
.
top_offset
>>
vshift
)
*
dst
->
linesize
[
j
];
dst
->
data
[
j
]
+=
off
;
}
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"Output frame with POC %d.
\n
"
,
frame
->
poc
);
av_log
(
s
->
avctx
,
AV_LOG_DEBUG
,
"Output frame with POC %d.
\n
"
,
frame
->
poc
);
return
1
;
}
...
...
@@ -216,9 +220,9 @@ static int init_slice_rpl(HEVCContext *s)
return
AVERROR_INVALIDDATA
;
for
(
i
=
ctb_addr_ts
;
i
<
ctb_count
;
i
++
)
frame
->
rpl_tab
[
i
]
=
(
RefPicListTab
*
)
frame
->
rpl_buf
->
data
+
s
->
slice_idx
;
frame
->
rpl_tab
[
i
]
=
(
RefPicListTab
*
)
frame
->
rpl_buf
->
data
+
s
->
slice_idx
;
frame
->
refPicList
=
(
RefPicList
*
)
frame
->
rpl_tab
[
ctb_addr_ts
];
frame
->
refPicList
=
(
RefPicList
*
)
frame
->
rpl_tab
[
ctb_addr_ts
];
return
0
;
}
...
...
@@ -247,8 +251,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
/* The order of the elements is
* ST_CURR_BEF - ST_CURR_AFT - LT_CURR for the L0 and
* ST_CURR_AFT - ST_CURR_BEF - LT_CURR for the L1
*/
* ST_CURR_AFT - ST_CURR_BEF - LT_CURR for the L1 */
int
cand_lists
[
3
]
=
{
list_idx
?
ST_CURR_AFT
:
ST_CURR_BEF
,
list_idx
?
ST_CURR_BEF
:
ST_CURR_AFT
,
LT_CURR
};
...
...
@@ -331,7 +334,6 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
HEVCFrame
*
frame
;
int
i
,
x
,
y
;
frame
=
alloc_frame
(
s
);
if
(
!
frame
)
return
NULL
;
...
...
libavcodec/hevc_sei.c
View file @
f578e5d9
...
...
@@ -25,7 +25,8 @@
#include "hevc.h"
#include "golomb.h"
static
void
decode_nal_sei_decoded_picture_hash
(
HEVCContext
*
s
,
int
payload_size
)
static
void
decode_nal_sei_decoded_picture_hash
(
HEVCContext
*
s
,
int
payload_size
)
{
int
cIdx
,
i
;
uint8_t
hash_type
;
...
...
@@ -34,17 +35,16 @@ static void decode_nal_sei_decoded_picture_hash(HEVCContext *s, int payload_size
GetBitContext
*
gb
=
&
s
->
HEVClc
->
gb
;
hash_type
=
get_bits
(
gb
,
8
);
for
(
cIdx
=
0
;
cIdx
<
3
/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/
;
cIdx
++
)
{
if
(
hash_type
==
0
)
{
for
(
cIdx
=
0
;
cIdx
<
3
/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/
;
cIdx
++
)
{
if
(
hash_type
==
0
)
{
s
->
is_md5
=
1
;
for
(
i
=
0
;
i
<
16
;
i
++
)
{
for
(
i
=
0
;
i
<
16
;
i
++
)
{
s
->
md5
[
cIdx
][
i
]
=
get_bits
(
gb
,
8
);
}
}
else
if
(
hash_type
==
1
)
{
}
else
if
(
hash_type
==
1
)
{
// picture_crc = get_bits(gb, 16);
skip_bits
(
gb
,
16
);
}
else
if
(
hash_type
==
2
)
{
}
else
if
(
hash_type
==
2
)
{
// picture_checksum = get_bits(gb, 32);
skip_bits
(
gb
,
32
);
}
...
...
@@ -101,7 +101,8 @@ static int decode_pic_timing(HEVCContext *s)
return
1
;
}
static
void
active_parameter_sets
(
HEVCContext
*
s
)
{
static
void
active_parameter_sets
(
HEVCContext
*
s
)
{
GetBitContext
*
gb
=
&
s
->
HEVClc
->
gb
;
int
num_sps_ids_minus1
;
int
i
;
...
...
libavcodec/hevcdsp.c
View file @
f578e5d9
...
...
@@ -91,13 +91,13 @@ static const int8_t transform[32][32] = {
};
DECLARE_ALIGNED
(
16
,
const
int8_t
,
ff_hevc_epel_filters
[
7
][
16
])
=
{
{
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
},
{
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
},
{
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
},
{
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
},
{
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
},
{
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
},
{
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
},
{
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
,
-
2
,
58
,
10
,
-
2
},
{
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
,
-
4
,
54
,
16
,
-
2
},
{
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
,
-
6
,
46
,
28
,
-
4
},
{
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
,
-
4
,
36
,
36
,
-
4
},
{
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
,
-
4
,
28
,
46
,
-
6
},
{
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
,
-
2
,
16
,
54
,
-
4
},
{
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
,
-
2
,
10
,
58
,
-
2
},
};
#define BIT_DEPTH 8
...
...
@@ -177,7 +177,6 @@ void ff_hevc_dsp_init(HEVCDSPContext *hevcdsp, int bit_depth)
hevcdsp->hevc_h_loop_filter_chroma_c = FUNC(hevc_h_loop_filter_chroma, depth); \
hevcdsp->hevc_v_loop_filter_chroma_c = FUNC(hevc_v_loop_filter_chroma, depth);
switch
(
bit_depth
)
{
case
9
:
HEVC_DSP
(
9
);
...
...
libavcodec/hevcdsp_template.c
View file @
f578e5d9
...
...
@@ -23,6 +23,7 @@
#include "get_bits.h"
#include "bit_depth_template.c"
#include "hevcdsp.h"
#include "hevc.h"
#define SET(dst, x) (dst) = (x)
...
...
@@ -46,7 +47,7 @@ static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int size,
static
void
FUNC
(
transquant_bypass4x4
)(
uint8_t
*
_dst
,
int16_t
*
coeffs
,
ptrdiff_t
_stride
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
stride
=
_stride
/
sizeof
(
pixel
);
for
(
y
=
0
;
y
<
4
;
y
++
)
{
...
...
@@ -212,14 +213,15 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _s
int o_8[4] = { 0 }; \
for (i = 0; i < 4; i++) \
for (j = 1; j < 8; j += 2) \
o_8[i] += transform[4
*j][i] * src[j*sstep];
\
TR_4(e_8, src, 1, 2
*sstep, SET);
\
o_8[i] += transform[4
* j][i] * src[j * sstep];
\
TR_4(e_8, src, 1, 2
* sstep, SET);
\
\
for (i = 0; i < 4; i++) { \
assign(dst[i
*dstep], e_8[i] + o_8[i]);
\
assign(dst[(7
-i)*dstep], e_8[i] - o_8[i]);
\
assign(dst[i
* dstep], e_8[i] + o_8[i]);
\
assign(dst[(7
- i) * dstep], e_8[i] - o_8[i]);
\
} \
} while (0)
#define TR_16(dst, src, dstep, sstep, assign) \
do { \
int i, j; \
...
...
@@ -227,14 +229,15 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _s
int o_16[8] = { 0 }; \
for (i = 0; i < 8; i++) \
for (j = 1; j < 16; j += 2) \
o_16[i] += transform[2
*j][i] * src[j*sstep];
\
TR_8(e_16, src, 1, 2
*
sstep, SET); \
o_16[i] += transform[2
* j][i] * src[j * sstep];
\
TR_8(e_16, src, 1, 2
*
sstep, SET); \
\
for (i = 0; i < 8; i++) { \
assign(dst[i
*
dstep], e_16[i] + o_16[i]); \
assign(dst[(15
-i)*dstep], e_16[i] - o_16[i]);
\
assign(dst[i
*
dstep], e_16[i] + o_16[i]); \
assign(dst[(15
- i) * dstep], e_16[i] - o_16[i]);
\
} \
} while (0)
#define TR_32(dst, src, dstep, sstep, assign) \
do { \
int i, j; \
...
...
@@ -242,12 +245,12 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _s
int o_32[16] = { 0 }; \
for (i = 0; i < 16; i++) \
for (j = 1; j < 32; j += 2) \
o_32[i] += transform[j][i] * src[j
*sstep];
\
TR_16(e_32, src, 1, 2
*sstep, SET);
\
o_32[i] += transform[j][i] * src[j
* sstep];
\
TR_16(e_32, src, 1, 2
* sstep, SET);
\
\
for (i = 0; i < 16; i++) { \
assign(dst[i
*dstep], e_32[i] + o_32[i]);
\
assign(dst[(31
-i)*dstep], e_32[i] - o_32[i]);
\
assign(dst[i
* dstep], e_32[i] + o_32[i]);
\
assign(dst[(31
- i) * dstep], e_32[i] - o_32[i]);
\
} \
} while (0)
...
...
@@ -262,7 +265,7 @@ static void FUNC(transform_4x4_add)(uint8_t *_dst, int16_t *coeffs, ptrdiff_t _s
static
void
FUNC
(
transform_8x8_add
)(
uint8_t
*
_dst
,
int16_t
*
coeffs
,
ptrdiff_t
_stride
)
{
int
i
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
stride
=
_stride
/
sizeof
(
pixel
);
int
shift
=
7
;
int
add
=
1
<<
(
shift
-
1
);
...
...
@@ -402,7 +405,8 @@ static void FUNC(sao_band_filter_0)(uint8_t *dst, uint8_t *src,
int
*
borders
,
int
width
,
int
height
,
int
c_idx
)
{
FUNC
(
sao_band_filter
)(
dst
,
src
,
stride
,
sao
,
borders
,
width
,
height
,
c_idx
,
0
);
FUNC
(
sao_band_filter
)(
dst
,
src
,
stride
,
sao
,
borders
,
width
,
height
,
c_idx
,
0
);
}
static
void
FUNC
(
sao_band_filter_1
)(
uint8_t
*
dst
,
uint8_t
*
src
,
...
...
@@ -410,7 +414,8 @@ static void FUNC(sao_band_filter_1)(uint8_t *dst, uint8_t *src,
int
*
borders
,
int
width
,
int
height
,
int
c_idx
)
{
FUNC
(
sao_band_filter
)(
dst
,
src
,
stride
,
sao
,
borders
,
width
,
height
,
c_idx
,
1
);
FUNC
(
sao_band_filter
)(
dst
,
src
,
stride
,
sao
,
borders
,
width
,
height
,
c_idx
,
1
);
}
static
void
FUNC
(
sao_band_filter_2
)(
uint8_t
*
dst
,
uint8_t
*
src
,
...
...
@@ -444,10 +449,10 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
int
sao_eo_class
=
sao
->
eo_class
[
c_idx
];
static
const
int8_t
pos
[
4
][
2
][
2
]
=
{
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
};
static
const
uint8_t
edge_idx
[]
=
{
1
,
2
,
0
,
3
,
4
};
...
...
@@ -480,19 +485,18 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
dst
[
x_stride
]
=
av_clip_pixel
(
src
[
x_stride
]
+
offset_val
);
x_stride
+=
stride
;
}
width
--
;
width
--
;
}
}
if
(
sao_eo_class
!=
SAO_EO_HORIZ
)
{
if
(
borders
[
1
]){
if
(
sao_eo_class
!=
SAO_EO_HORIZ
)
{
if
(
borders
[
1
])
{
int
offset_val
=
sao_offset_val
[
0
];
for
(
x
=
init_x
;
x
<
width
;
x
++
)
{
dst
[
x
]
=
av_clip_pixel
(
src
[
x
]
+
offset_val
);
}
init_y
=
1
;
}
if
(
borders
[
3
]){
if
(
borders
[
3
])
{
int
offset_val
=
sao_offset_val
[
0
];
int
y_stride
=
stride
*
(
height
-
1
);
for
(
x
=
init_x
;
x
<
width
;
x
++
)
{
...
...
@@ -542,22 +546,22 @@ static void FUNC(sao_edge_filter_0)(uint8_t *_dst, uint8_t *_src,
static
void
FUNC
(
sao_edge_filter_1
)(
uint8_t
*
_dst
,
uint8_t
*
_src
,
ptrdiff_t
_stride
,
SAOParams
*
sao
,
int
*
borders
,
int
_width
,
int
_height
,
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
stride
=
_stride
/
sizeof
(
pixel
);
int
chroma
=
!!
c_idx
;
int
*
sao_offset_val
=
sao
->
offset_val
[
c_idx
];
int
sao_eo_class
=
sao
->
eo_class
[
c_idx
];
static
const
int8_t
pos
[
4
][
2
][
2
]
=
{
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
};
static
const
uint8_t
edge_idx
[]
=
{
1
,
2
,
0
,
3
,
4
};
...
...
@@ -592,7 +596,6 @@ static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
}
width
--
;
}
}
{
int
y_stride
=
init_y
*
stride
;
...
...
@@ -635,22 +638,22 @@ static void FUNC(sao_edge_filter_1)(uint8_t *_dst, uint8_t *_src,
static
void
FUNC
(
sao_edge_filter_2
)(
uint8_t
*
_dst
,
uint8_t
*
_src
,
ptrdiff_t
_stride
,
SAOParams
*
sao
,
int
*
borders
,
int
_width
,
int
_height
,
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
stride
=
_stride
/
sizeof
(
pixel
);
int
chroma
=
!!
c_idx
;
int
*
sao_offset_val
=
sao
->
offset_val
[
c_idx
];
int
sao_eo_class
=
sao
->
eo_class
[
c_idx
];
static
const
int8_t
pos
[
4
][
2
][
2
]
=
{
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
};
static
const
uint8_t
edge_idx
[]
=
{
1
,
2
,
0
,
3
,
4
};
...
...
@@ -667,14 +670,14 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
src
=
src
+
(
init_y
*
stride
+
init_x
);
init_y
=
init_x
=
0
;
if
(
sao_eo_class
!=
SAO_EO_HORIZ
)
{
if
(
borders
[
1
]){
if
(
borders
[
1
])
{
int
offset_val
=
sao_offset_val
[
0
];
for
(
x
=
init_x
;
x
<
width
;
x
++
)
{
dst
[
x
]
=
av_clip_pixel
(
src
[
x
]
+
offset_val
);
}
init_y
=
1
;
}
if
(
borders
[
3
]){
if
(
borders
[
3
])
{
int
offset_val
=
sao_offset_val
[
0
];
int
y_stride
=
stride
*
(
height
-
1
);
for
(
x
=
init_x
;
x
<
width
;
x
++
)
{
...
...
@@ -723,22 +726,22 @@ static void FUNC(sao_edge_filter_2)(uint8_t *_dst, uint8_t *_src,
static
void
FUNC
(
sao_edge_filter_3
)(
uint8_t
*
_dst
,
uint8_t
*
_src
,
ptrdiff_t
_stride
,
SAOParams
*
sao
,
int
*
borders
,
int
_width
,
int
_height
,
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
int
c_idx
,
uint8_t
vert_edge
,
uint8_t
horiz_edge
,
uint8_t
diag_edge
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
stride
=
_stride
/
sizeof
(
pixel
);
int
chroma
=
!!
c_idx
;
int
*
sao_offset_val
=
sao
->
offset_val
[
c_idx
];
int
sao_eo_class
=
sao
->
eo_class
[
c_idx
];
static
const
int8_t
pos
[
4
][
2
][
2
]
=
{
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
{
{
-
1
,
0
},
{
1
,
0
}
},
// horizontal
{
{
0
,
-
1
},
{
0
,
1
}
},
// vertical
{
{
-
1
,
-
1
},
{
1
,
1
}
},
// 45 degree
{
{
1
,
-
1
},
{
-
1
,
1
}
},
// 135 degree
};
static
const
uint8_t
edge_idx
[]
=
{
1
,
2
,
0
,
3
,
4
};
...
...
@@ -815,7 +818,7 @@ static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
int
width
,
int
height
,
int16_t
*
mcbuffer
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
srcstride
=
_srcstride
/
sizeof
(
pixel
);
for
(
y
=
0
;
y
<
height
;
y
++
)
{
...
...
@@ -827,14 +830,16 @@ static void FUNC(put_hevc_qpel_pixels)(int16_t *dst, ptrdiff_t dststride,
}
#define QPEL_FILTER_1(src, stride) \
(-src[x-3*stride] + 4*src[x-2*stride] - 10*src[x-stride] + 58*src[x] + \
17*src[x+stride] - 5*src[x+2*stride] + 1*src[x+3*stride])
(-src[x - 3 * stride] + 4 * src[x - 2 * stride] - 10 * src[x - stride] + 58 * src[x] + \
17 * src[x + stride] - 5 * src[x + 2 * stride] + 1 * src[x + 3 * stride])
#define QPEL_FILTER_2(src, stride) \
(-src[x-3*stride] + 4*src[x-2*stride] - 11*src[x-stride] + 40*src[x] + \
40*src[x+stride] - 11*src[x+2*stride] + 4*src[x+3*stride] - src[x+4*stride])
(-src[x - 3 * stride] + 4 * src[x - 2 * stride] - 11 * src[x - stride] + 40 * src[x] + \
40 * src[x + stride] - 11 * src[x + 2 * stride] + 4 * src[x + 3 * stride] - src[x + 4 * stride])
#define QPEL_FILTER_3(src, stride) \
(src[x
-2*stride] - 5*src[x-stride] + 17*src[x] + 58*src[x+
stride] \
- 10
*src[x+2*stride] + 4*src[x+3*stride] - src[x+4*
stride])
(src[x
- 2 * stride] - 5 * src[x - stride] + 17 * src[x] + 58 * src[x +
stride] \
- 10
* src[x + 2 * stride] + 4 * src[x + 3 * stride] - src[x + 4 *
stride])
#define PUT_HEVC_QPEL_H(H) \
...
...
@@ -849,7 +854,7 @@ static void FUNC(put_hevc_qpel_h ## H)(int16_t *dst, ptrdiff_t dststride, \
\
for (y = 0; y < height; y++) { \
for (x = 0; x < width; x++) \
dst[x] = QPEL_FILTER_ ## H
(src, 1) >> (BIT_DEPTH - 8);
\
dst[x] = QPEL_FILTER_ ## H
(src, 1) >> (BIT_DEPTH - 8);
\
src += srcstride; \
dst += dststride; \
} \
...
...
@@ -867,7 +872,7 @@ static void FUNC(put_hevc_qpel_v ## V)(int16_t *dst, ptrdiff_t dststride, \
\
for (y = 0; y < height; y++) { \
for (x = 0; x < width; x++) \
dst[x] = QPEL_FILTER_ ## V
(src, srcstride) >> (BIT_DEPTH - 8);
\
dst[x] = QPEL_FILTER_ ## V
(src, srcstride) >> (BIT_DEPTH - 8);
\
src += srcstride; \
dst += dststride; \
} \
...
...
@@ -883,14 +888,14 @@ static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, ptrdiff_t dststr
pixel *src = (pixel*)_src; \
ptrdiff_t srcstride = _srcstride / sizeof(pixel); \
\
int16_t tmp_array[(MAX_PB_SIZE + 7)
*MAX_PB_SIZE];
\
int16_t tmp_array[(MAX_PB_SIZE + 7)
* MAX_PB_SIZE];
\
int16_t *tmp = tmp_array; \
\
src -= ff_hevc_qpel_extra_before[V] * srcstride; \
\
for (y = 0; y < height + ff_hevc_qpel_extra[V]; y++) { \
for (x = 0; x < width; x++) \
tmp[x] = QPEL_FILTER_ ## H
(src, 1) >> (BIT_DEPTH - 8);
\
tmp[x] = QPEL_FILTER_ ## H
(src, 1) >> (BIT_DEPTH - 8);
\
src += srcstride; \
tmp += MAX_PB_SIZE; \
} \
...
...
@@ -899,7 +904,7 @@ static void FUNC(put_hevc_qpel_h ## H ## v ## V)(int16_t *dst, ptrdiff_t dststr
\
for (y = 0; y < height; y++) { \
for (x = 0; x < width; x++) \
dst[x] = QPEL_FILTER_ ## V
(tmp, MAX_PB_SIZE) >> 6;
\
dst[x] = QPEL_FILTER_ ## V
(tmp, MAX_PB_SIZE) >> 6;
\
tmp += MAX_PB_SIZE; \
dst += dststride; \
} \
...
...
@@ -927,7 +932,7 @@ static void FUNC(put_hevc_epel_pixels)(int16_t *dst, ptrdiff_t dststride,
int16_t
*
mcbuffer
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
srcstride
=
_srcstride
/
sizeof
(
pixel
);
for
(
y
=
0
;
y
<
height
;
y
++
)
{
...
...
@@ -940,7 +945,7 @@ static void FUNC(put_hevc_epel_pixels)(int16_t *dst, ptrdiff_t dststride,
}
#define EPEL_FILTER(src, stride) \
(filter_0
*src[x-stride] + filter_1*src[x] + filter_2*src[x+stride] + filter_3*src[x+2*
stride])
(filter_0
* src[x - stride] + filter_1 * src[x] + filter_2 * src[x + stride] + filter_3 * src[x + 2 *
stride])
static
void
FUNC
(
put_hevc_epel_h
)(
int16_t
*
dst
,
ptrdiff_t
dststride
,
uint8_t
*
_src
,
ptrdiff_t
_srcstride
,
...
...
@@ -948,7 +953,7 @@ static void FUNC(put_hevc_epel_h)(int16_t *dst, ptrdiff_t dststride,
int16_t
*
mcbuffer
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
srcstride
=
_srcstride
/
sizeof
(
pixel
);
const
int8_t
*
filter
=
ff_hevc_epel_filters
[
mx
-
1
];
int8_t
filter_0
=
filter
[
0
];
...
...
@@ -970,9 +975,9 @@ static void FUNC(put_hevc_epel_v)(int16_t *dst, ptrdiff_t dststride,
int16_t
*
mcbuffer
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
srcstride
=
_srcstride
/
sizeof
(
pixel
);
const
int8_t
*
filter
=
ff_hevc_epel_filters
[
my
-
1
];
const
int8_t
*
filter
=
ff_hevc_epel_filters
[
my
-
1
];
int8_t
filter_0
=
filter
[
0
];
int8_t
filter_1
=
filter
[
1
];
int8_t
filter_2
=
filter
[
2
];
...
...
@@ -993,15 +998,15 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst, ptrdiff_t dststride,
int16_t
*
mcbuffer
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
pixel
*
src
=
(
pixel
*
)
_src
;
ptrdiff_t
srcstride
=
_srcstride
/
sizeof
(
pixel
);
const
int8_t
*
filter_h
=
ff_hevc_epel_filters
[
mx
-
1
];
const
int8_t
*
filter_v
=
ff_hevc_epel_filters
[
my
-
1
];
const
int8_t
*
filter_h
=
ff_hevc_epel_filters
[
mx
-
1
];
const
int8_t
*
filter_v
=
ff_hevc_epel_filters
[
my
-
1
];
int8_t
filter_0
=
filter_h
[
0
];
int8_t
filter_1
=
filter_h
[
1
];
int8_t
filter_2
=
filter_h
[
2
];
int8_t
filter_3
=
filter_h
[
3
];
int16_t
tmp_array
[(
MAX_PB_SIZE
+
3
)
*
MAX_PB_SIZE
];
int16_t
tmp_array
[(
MAX_PB_SIZE
+
3
)
*
MAX_PB_SIZE
];
int16_t
*
tmp
=
tmp_array
;
src
-=
EPEL_EXTRA_BEFORE
*
srcstride
;
...
...
@@ -1033,7 +1038,7 @@ static void FUNC(put_unweighted_pred)(uint8_t *_dst, ptrdiff_t _dststride,
int
width
,
int
height
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
dststride
=
_dststride
/
sizeof
(
pixel
);
int
shift
=
14
-
BIT_DEPTH
;
...
...
@@ -1057,7 +1062,7 @@ static void FUNC(put_weighted_pred_avg)(uint8_t *_dst, ptrdiff_t _dststride,
int
width
,
int
height
)
{
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
dststride
=
_dststride
/
sizeof
(
pixel
);
int
shift
=
14
+
1
-
BIT_DEPTH
;
...
...
@@ -1088,7 +1093,7 @@ static void FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
int
ox
;
int
x
,
y
;
int
offset
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
dststride
=
_dststride
/
sizeof
(
pixel
);
shift
=
14
-
BIT_DEPTH
;
...
...
@@ -1110,10 +1115,12 @@ static void FUNC(weighted_pred)(uint8_t denom, int16_t wlxFlag, int16_t olxFlag,
}
}
static
void
FUNC
(
weighted_pred_avg
)(
uint8_t
denom
,
int16_t
wl0Flag
,
int16_t
wl1Flag
,
static
void
FUNC
(
weighted_pred_avg
)(
uint8_t
denom
,
int16_t
wl0Flag
,
int16_t
wl1Flag
,
int16_t
ol0Flag
,
int16_t
ol1Flag
,
uint8_t
*
_dst
,
ptrdiff_t
_dststride
,
int16_t
*
src1
,
int16_t
*
src2
,
ptrdiff_t
srcstride
,
int16_t
*
src1
,
int16_t
*
src2
,
ptrdiff_t
srcstride
,
int
width
,
int
height
)
{
int
shift
;
...
...
@@ -1123,7 +1130,7 @@ static void FUNC(weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1F
int
o0
;
int
o1
;
int
x
,
y
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
pixel
*
dst
=
(
pixel
*
)
_dst
;
ptrdiff_t
dststride
=
_dststride
/
sizeof
(
pixel
);
shift
=
14
-
BIT_DEPTH
;
...
...
@@ -1145,31 +1152,32 @@ static void FUNC(weighted_pred_avg)(uint8_t denom, int16_t wl0Flag, int16_t wl1F
}
// line zero
#define P3 pix[-4
*
xstride]
#define P2 pix[-3
*
xstride]
#define P1 pix[-2
*
xstride]
#define P3 pix[-4
*
xstride]
#define P2 pix[-3
*
xstride]
#define P1 pix[-2
*
xstride]
#define P0 pix[-xstride]
#define Q0 pix[0]
#define Q1 pix[xstride]
#define Q2 pix[2
*
xstride]
#define Q3 pix[3
*
xstride]
#define Q2 pix[2
*
xstride]
#define Q3 pix[3
*
xstride]
// line three. used only for deblocking decision
#define TP3 pix[-4*xstride+3*ystride]
#define TP2 pix[-3*xstride+3*ystride]
#define TP1 pix[-2*xstride+3*ystride]
#define TP0 pix[-xstride+3*ystride]
#define TQ0 pix[3*ystride]
#define TQ1 pix[xstride+3*ystride]
#define TQ2 pix[2*xstride+3*ystride]
#define TQ3 pix[3*xstride+3*ystride]
static
void
FUNC
(
hevc_loop_filter_luma
)(
uint8_t
*
_pix
,
ptrdiff_t
_xstride
,
ptrdiff_t
_ystride
,
int
*
_beta
,
int
*
_tc
,
#define TP3 pix[-4 * xstride + 3 * ystride]
#define TP2 pix[-3 * xstride + 3 * ystride]
#define TP1 pix[-2 * xstride + 3 * ystride]
#define TP0 pix[-xstride+3 * ystride]
#define TQ0 pix[3 * ystride]
#define TQ1 pix[xstride+3 * ystride]
#define TQ2 pix[2 * xstride + 3 * ystride]
#define TQ3 pix[3 * xstride + 3 * ystride]
static
void
FUNC
(
hevc_loop_filter_luma
)(
uint8_t
*
_pix
,
ptrdiff_t
_xstride
,
ptrdiff_t
_ystride
,
int
*
_beta
,
int
*
_tc
,
uint8_t
*
_no_p
,
uint8_t
*
_no_q
)
{
int
d
,
j
;
pixel
*
pix
=
(
pixel
*
)
_pix
;
pixel
*
pix
=
(
pixel
*
)
_pix
;
ptrdiff_t
xstride
=
_xstride
/
sizeof
(
pixel
);
ptrdiff_t
ystride
=
_ystride
/
sizeof
(
pixel
);
...
...
@@ -1193,7 +1201,7 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, ptrdiff_t _xstride,
const
int
beta_2
=
beta
>>
2
;
const
int
tc25
=
((
tc
*
5
+
1
)
>>
1
);
if
(
abs
(
P3
-
P0
)
+
abs
(
Q3
-
Q0
)
<
beta_3
&&
abs
(
P0
-
Q0
)
<
tc25
&&
if
(
abs
(
P3
-
P0
)
+
abs
(
Q3
-
Q0
)
<
beta_3
&&
abs
(
P0
-
Q0
)
<
tc25
&&
abs
(
TP3
-
TP0
)
+
abs
(
TQ3
-
TQ0
)
<
beta_3
&&
abs
(
TP0
-
TQ0
)
<
tc25
&&
(
d0
<<
1
)
<
beta_2
&&
(
d3
<<
1
)
<
beta_2
)
{
// strong filtering
...
...
@@ -1208,14 +1216,14 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix, ptrdiff_t _xstride,
const
int
q2
=
Q2
;
const
int
q3
=
Q3
;
if
(
!
no_p
)
{
P0
=
p0
+
av_clip
(((
p2
+
2
*
p1
+
2
*
p0
+
2
*
q0
+
q1
+
4
)
>>
3
)
-
p0
,
-
tc2
,
tc2
);
P1
=
p1
+
av_clip
(((
p2
+
p1
+
p0
+
q0
+
2
)
>>
2
)
-
p1
,
-
tc2
,
tc2
);
P2
=
p2
+
av_clip
(((
2
*
p3
+
3
*
p2
+
p1
+
p0
+
q0
+
4
)
>>
3
)
-
p2
,
-
tc2
,
tc2
);
P0
=
p0
+
av_clip
(((
p2
+
2
*
p1
+
2
*
p0
+
2
*
q0
+
q1
+
4
)
>>
3
)
-
p0
,
-
tc2
,
tc2
);
P1
=
p1
+
av_clip
(((
p2
+
p1
+
p0
+
q0
+
2
)
>>
2
)
-
p1
,
-
tc2
,
tc2
);
P2
=
p2
+
av_clip
(((
2
*
p3
+
3
*
p2
+
p1
+
p0
+
q0
+
4
)
>>
3
)
-
p2
,
-
tc2
,
tc2
);
}
if
(
!
no_q
)
{
Q0
=
q0
+
av_clip
(((
p1
+
2
*
p0
+
2
*
q0
+
2
*
q1
+
q2
+
4
)
>>
3
)
-
q0
,
-
tc2
,
tc2
);
Q1
=
q1
+
av_clip
(((
p0
+
q0
+
q1
+
q2
+
2
)
>>
2
)
-
q1
,
-
tc2
,
tc2
);
Q2
=
q2
+
av_clip
(((
2
*
q3
+
3
*
q2
+
q1
+
q0
+
p0
+
4
)
>>
3
)
-
q2
,
-
tc2
,
tc2
);
Q0
=
q0
+
av_clip
(((
p1
+
2
*
p0
+
2
*
q0
+
2
*
q1
+
q2
+
4
)
>>
3
)
-
q0
,
-
tc2
,
tc2
);
Q1
=
q1
+
av_clip
(((
p0
+
q0
+
q1
+
q2
+
2
)
>>
2
)
-
q1
,
-
tc2
,
tc2
);
Q2
=
q2
+
av_clip
(((
2
*
q3
+
3
*
q2
+
q1
+
q0
+
p0
+
4
)
>>
3
)
-
q2
,
-
tc2
,
tc2
);
}
pix
+=
ystride
;
}
...
...
@@ -1264,7 +1272,7 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
{
int
d
,
j
;
int
no_p
,
no_q
;
pixel
*
pix
=
(
pixel
*
)
_pix
;
pixel
*
pix
=
(
pixel
*
)
_pix
;
ptrdiff_t
xstride
=
_xstride
/
sizeof
(
pixel
);
ptrdiff_t
ystride
=
_ystride
/
sizeof
(
pixel
);
...
...
@@ -1294,13 +1302,15 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
}
static
void
FUNC
(
hevc_h_loop_filter_chroma
)(
uint8_t
*
pix
,
ptrdiff_t
stride
,
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
{
FUNC
(
hevc_loop_filter_chroma
)(
pix
,
stride
,
sizeof
(
pixel
),
tc
,
no_p
,
no_q
);
}
static
void
FUNC
(
hevc_v_loop_filter_chroma
)(
uint8_t
*
pix
,
ptrdiff_t
stride
,
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
{
FUNC
(
hevc_loop_filter_chroma
)(
pix
,
sizeof
(
pixel
),
stride
,
tc
,
no_p
,
no_q
);
}
...
...
@@ -1309,14 +1319,16 @@ static void FUNC(hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
int
*
beta
,
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
{
FUNC
(
hevc_loop_filter_luma
)(
pix
,
stride
,
sizeof
(
pixel
),
beta
,
tc
,
no_p
,
no_q
);
FUNC
(
hevc_loop_filter_luma
)(
pix
,
stride
,
sizeof
(
pixel
),
beta
,
tc
,
no_p
,
no_q
);
}
static
void
FUNC
(
hevc_v_loop_filter_luma
)(
uint8_t
*
pix
,
ptrdiff_t
stride
,
int
*
beta
,
int
*
tc
,
uint8_t
*
no_p
,
uint8_t
*
no_q
)
{
FUNC
(
hevc_loop_filter_luma
)(
pix
,
sizeof
(
pixel
),
stride
,
beta
,
tc
,
no_p
,
no_q
);
FUNC
(
hevc_loop_filter_luma
)(
pix
,
sizeof
(
pixel
),
stride
,
beta
,
tc
,
no_p
,
no_q
);
}
#undef P3
...
...
libavcodec/hevcpred.c
View file @
f578e5d9
...
...
@@ -47,9 +47,9 @@ void ff_hevc_pred_init(HEVCPredContext *hpc, int bit_depth)
hpc->pred_planar[2] = FUNC(pred_planar_2, depth); \
hpc->pred_planar[3] = FUNC(pred_planar_3, depth); \
hpc->pred_dc = FUNC(pred_dc, depth); \
hpc->pred_angular[0] = FUNC(pred_angular_0, depth);\
hpc->pred_angular[1] = FUNC(pred_angular_1, depth);\
hpc->pred_angular[2] = FUNC(pred_angular_2, depth);\
hpc->pred_angular[0] = FUNC(pred_angular_0, depth);
\
hpc->pred_angular[1] = FUNC(pred_angular_1, depth);
\
hpc->pred_angular[2] = FUNC(pred_angular_2, depth);
\
hpc->pred_angular[3] = FUNC(pred_angular_3, depth);
switch
(
bit_depth
)
{
...
...
libavcodec/hevcpred_template.c
View file @
f578e5d9
...
...
@@ -111,7 +111,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
int
size_in_luma_pu
=
PU
(
size_in_luma
);
int
on_pu_edge_x
=
!
(
x0
&
((
1
<<
s
->
sps
->
log2_min_pu_size
)
-
1
));
int
on_pu_edge_y
=
!
(
y0
&
((
1
<<
s
->
sps
->
log2_min_pu_size
)
-
1
));
if
(
!
size_in_luma_pu
)
if
(
!
size_in_luma_pu
)
size_in_luma_pu
++
;
if
(
cand_bottom_left
==
1
&&
on_pu_edge_x
)
{
int
x_left_pu
=
PU
(
x0
-
1
);
...
...
@@ -157,7 +157,8 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
}
if
(
cand_bottom_left
)
{
for
(
i
=
size
+
bottom_left_size
;
i
<
(
size
<<
1
);
i
++
)
if
(
IS_INTRA
(
-
1
,
size
+
bottom_left_size
-
1
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
if
(
IS_INTRA
(
-
1
,
size
+
bottom_left_size
-
1
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
left
[
i
]
=
POS
(
-
1
,
size
+
bottom_left_size
-
1
);
for
(
i
=
size
+
bottom_left_size
-
1
;
i
>=
size
;
i
--
)
if
(
IS_INTRA
(
-
1
,
i
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
...
...
@@ -178,7 +179,8 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
top
[
i
]
=
POS
(
i
,
-
1
);
if
(
cand_up_right
)
{
for
(
i
=
size
+
top_right_size
;
i
<
(
size
<<
1
);
i
++
)
if
(
IS_INTRA
(
size
+
top_right_size
-
1
,
-
1
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
if
(
IS_INTRA
(
size
+
top_right_size
-
1
,
-
1
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
top
[
i
]
=
POS
(
size
+
top_right_size
-
1
,
-
1
);
for
(
i
=
size
+
top_right_size
-
1
;
i
>=
size
;
i
--
)
if
(
IS_INTRA
(
i
,
-
1
)
||
!
s
->
pps
->
constrained_intra_pred_flag
)
...
...
@@ -201,20 +203,23 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
size
:
(
s
->
sps
->
height
-
y0
)
>>
vshift
;
}
if
(
cand_bottom_left
||
cand_left
||
cand_up_left
)
{
while
(
j
>-
1
&&
!
IS_INTRA
(
-
1
,
j
))
j
--
;
while
(
j
>
-
1
&&
!
IS_INTRA
(
-
1
,
j
))
j
--
;
if
(
!
IS_INTRA
(
-
1
,
j
))
{
j
=
0
;
while
(
j
<
size_max_x
&&
!
IS_INTRA
(
j
,
-
1
))
j
++
;
EXTEND_LEFT_CIP
(
top
,
j
,
j
+
1
);
while
(
j
<
size_max_x
&&
!
IS_INTRA
(
j
,
-
1
))
j
++
;
EXTEND_LEFT_CIP
(
top
,
j
,
j
+
1
);
left
[
-
1
]
=
top
[
-
1
];
j
=
0
;
}
}
else
{
j
=
0
;
while
(
j
<
size_max_x
&&
!
IS_INTRA
(
j
,
-
1
))
j
++
;
while
(
j
<
size_max_x
&&
!
IS_INTRA
(
j
,
-
1
))
j
++
;
if
(
j
>
0
)
if
(
x0
>
0
)
{
EXTEND_LEFT_CIP
(
top
,
j
,
j
+
1
);
EXTEND_LEFT_CIP
(
top
,
j
,
j
+
1
);
}
else
{
EXTEND_LEFT_CIP
(
top
,
j
,
j
);
top
[
-
1
]
=
top
[
0
];
...
...
@@ -223,7 +228,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
j
=
0
;
}
if
(
cand_bottom_left
||
cand_left
)
{
EXTEND_DOWN_CIP
(
left
,
j
,
size_max_y
-
j
);
EXTEND_DOWN_CIP
(
left
,
j
,
size_max_y
-
j
);
}
if
(
!
cand_left
)
{
EXTEND_DOWN
(
left
,
0
,
size
);
...
...
@@ -233,10 +238,10 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
}
if
(
x0
!=
0
&&
y0
!=
0
)
{
EXTEND_UP_CIP
(
left
,
size_max_y
-
1
,
size_max_y
);
}
else
if
(
x0
==
0
)
{
}
else
if
(
x0
==
0
)
{
EXTEND_UP_CIP_0
(
left
,
size_max_y
-
1
,
size_max_y
);
}
else
{
EXTEND_UP_CIP
(
left
,
size_max_y
-
1
,
size_max_y
-
1
);
}
else
{
EXTEND_UP_CIP
(
left
,
size_max_y
-
1
,
size_max_y
-
1
);
}
top
[
-
1
]
=
left
[
-
1
];
if
(
y0
!=
0
)
{
...
...
@@ -259,7 +264,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
}
else
if
(
cand_up_right
)
{
EXTEND_LEFT
(
top
,
size
,
size
);
left
[
-
1
]
=
top
[
0
];
EXTEND_DOWN
(
left
,
0
,
2
*
size
);
EXTEND_DOWN
(
left
,
0
,
2
*
size
);
cand_up
=
1
;
cand_up_left
=
1
;
cand_left
=
1
;
...
...
@@ -278,7 +283,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
}
if
(
!
cand_up
)
{
top
[
0
]
=
left
[
-
1
];
EXTEND_RIGHT
(
top
,
1
,
size
-
1
);
EXTEND_RIGHT
(
top
,
1
,
size
-
1
);
}
if
(
!
cand_up_right
)
{
EXTEND_RIGHT
(
top
,
size
,
size
);
...
...
@@ -329,8 +334,7 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
filtered_left
[
i
]
=
(
left
[
i
+
1
]
+
2
*
left
[
i
]
+
left
[
i
-
1
]
+
2
)
>>
2
;
filtered_top
[
-
1
]
=
filtered_left
[
-
1
]
=
(
left
[
0
]
+
2
*
left
[
-
1
]
+
top
[
0
]
+
2
)
>>
2
;
filtered_left
[
-
1
]
=
(
left
[
0
]
+
2
*
left
[
-
1
]
+
top
[
0
]
+
2
)
>>
2
;
for
(
i
=
2
*
size
-
2
;
i
>=
0
;
i
--
)
filtered_top
[
i
]
=
(
top
[
i
+
1
]
+
2
*
top
[
i
]
+
top
[
i
-
1
]
+
2
)
>>
2
;
...
...
@@ -342,16 +346,17 @@ static void FUNC(intra_pred)(HEVCContext *s, int x0, int y0, int log2_size, int
switch
(
mode
)
{
case
INTRA_PLANAR
:
s
->
hpc
.
pred_planar
[
log2_size
-
2
]((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
);
s
->
hpc
.
pred_planar
[
log2_size
-
2
]((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
);
break
;
case
INTRA_DC
:
s
->
hpc
.
pred_dc
((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
,
log2_size
,
c_idx
);
s
->
hpc
.
pred_dc
((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
,
log2_size
,
c_idx
);
break
;
default:
s
->
hpc
.
pred_angular
[
log2_size
-
2
]((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
,
c_idx
,
mode
);
s
->
hpc
.
pred_angular
[
log2_size
-
2
]((
uint8_t
*
)
src
,
(
uint8_t
*
)
top
,
(
uint8_t
*
)
left
,
stride
,
c_idx
,
mode
);
break
;
}
}
...
...
@@ -361,9 +366,9 @@ static void FUNC(pred_planar_0)(uint8_t *_src, const uint8_t *_top,
ptrdiff_t
stride
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
for
(
y
=
0
;
y
<
4
;
y
++
)
for
(
x
=
0
;
x
<
4
;
x
++
)
POS
(
x
,
y
)
=
((
3
-
x
)
*
left
[
y
]
+
(
x
+
1
)
*
top
[
4
]
+
...
...
@@ -374,9 +379,9 @@ static void FUNC(pred_planar_1)(uint8_t *_src, const uint8_t *_top,
const
uint8_t
*
_left
,
ptrdiff_t
stride
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
for
(
y
=
0
;
y
<
8
;
y
++
)
for
(
x
=
0
;
x
<
8
;
x
++
)
POS
(
x
,
y
)
=
((
7
-
x
)
*
left
[
y
]
+
(
x
+
1
)
*
top
[
8
]
+
...
...
@@ -387,9 +392,9 @@ static void FUNC(pred_planar_2)(uint8_t *_src, const uint8_t *_top,
const
uint8_t
*
_left
,
ptrdiff_t
stride
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
for
(
y
=
0
;
y
<
16
;
y
++
)
for
(
x
=
0
;
x
<
16
;
x
++
)
POS
(
x
,
y
)
=
((
15
-
x
)
*
left
[
y
]
+
(
x
+
1
)
*
top
[
16
]
+
...
...
@@ -400,9 +405,9 @@ static void FUNC(pred_planar_3)(uint8_t *_src, const uint8_t *_top,
const
uint8_t
*
_left
,
ptrdiff_t
stride
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
for
(
y
=
0
;
y
<
32
;
y
++
)
for
(
x
=
0
;
x
<
32
;
x
++
)
POS
(
x
,
y
)
=
((
31
-
x
)
*
left
[
y
]
+
(
x
+
1
)
*
top
[
32
]
+
...
...
@@ -415,9 +420,9 @@ static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
{
int
i
,
j
,
x
,
y
;
int
size
=
(
1
<<
log2_size
);
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
int
dc
=
size
;
pixel4
a
;
for
(
i
=
0
;
i
<
size
;
i
++
)
...
...
@@ -447,9 +452,9 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
int
mode
,
int
size
)
{
int
x
,
y
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
pixel
*
src
=
(
pixel
*
)
_src
;
const
pixel
*
top
=
(
const
pixel
*
)
_top
;
const
pixel
*
left
=
(
const
pixel
*
)
_left
;
static
const
int
intra_pred_angle
[]
=
{
32
,
26
,
21
,
17
,
13
,
9
,
5
,
2
,
0
,
-
2
,
-
5
,
-
9
,
-
13
,
-
17
,
-
21
,
-
26
,
-
32
,
...
...
@@ -472,7 +477,7 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
for
(
x
=
0
;
x
<=
size
;
x
++
)
ref_tmp
[
x
]
=
top
[
x
-
1
];
for
(
x
=
last
;
x
<=
-
1
;
x
++
)
ref_tmp
[
x
]
=
left
[
-
1
+
((
x
*
inv_angle
[
mode
-
11
]
+
128
)
>>
8
)];
ref_tmp
[
x
]
=
left
[
-
1
+
((
x
*
inv_angle
[
mode
-
11
]
+
128
)
>>
8
)];
ref
=
ref_tmp
;
}
...
...
@@ -500,7 +505,7 @@ static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
for
(
x
=
0
;
x
<=
size
;
x
++
)
ref_tmp
[
x
]
=
left
[
x
-
1
];
for
(
x
=
last
;
x
<=
-
1
;
x
++
)
ref_tmp
[
x
]
=
top
[
-
1
+
((
x
*
inv_angle
[
mode
-
11
]
+
128
)
>>
8
)];
ref_tmp
[
x
]
=
top
[
-
1
+
((
x
*
inv_angle
[
mode
-
11
]
+
128
)
>>
8
)];
ref
=
ref_tmp
;
}
...
...
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