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
d4d9068c
Commit
d4d9068c
authored
Jan 17, 2015
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h264: move mb_{x,y} into the per-slice context
parent
0edbe6fa
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
193 additions
and
188 deletions
+193
-188
dxva2_h264.c
libavcodec/dxva2_h264.c
+1
-1
h264.c
libavcodec/h264.c
+8
-8
h264.h
libavcodec/h264.h
+3
-2
h264_cabac.c
libavcodec/h264_cabac.c
+9
-9
h264_cavlc.c
libavcodec/h264_cavlc.c
+12
-12
h264_direct.c
libavcodec/h264_direct.c
+19
-19
h264_mb.c
libavcodec/h264_mb.c
+22
-22
h264_mb_template.c
libavcodec/h264_mb_template.c
+11
-11
h264_mc_template.c
libavcodec/h264_mc_template.c
+1
-1
h264_mvpred.h
libavcodec/h264_mvpred.h
+8
-8
h264_slice.c
libavcodec/h264_slice.c
+67
-63
svq3.c
libavcodec/svq3.c
+31
-31
vaapi_h264.c
libavcodec/vaapi_h264.c
+1
-1
No files found.
libavcodec/dxva2_h264.c
View file @
d4d9068c
...
...
@@ -220,7 +220,7 @@ static void fill_slice_long(AVCodecContext *avctx, DXVA_Slice_H264_Long *slice,
slice
->
SliceBytesInBuffer
=
size
;
slice
->
wBadSliceChopping
=
0
;
slice
->
first_mb_in_slice
=
(
h
->
mb_y
>>
FIELD_OR_MBAFF_PICTURE
(
h
))
*
h
->
mb_width
+
h
->
mb_x
;
slice
->
first_mb_in_slice
=
(
sl
->
mb_y
>>
FIELD_OR_MBAFF_PICTURE
(
h
))
*
h
->
mb_width
+
sl
->
mb_x
;
slice
->
NumMbsForSlice
=
0
;
/* XXX it is set once we have all slices */
slice
->
BitOffsetToSliceData
=
get_bits_count
(
&
h
->
gb
);
slice
->
slice_type
=
ff_h264_get_slice_type
(
sl
);
...
...
libavcodec/h264.c
View file @
d4d9068c
...
...
@@ -58,8 +58,8 @@ static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
H264Context
*
h
=
opaque
;
H264SliceContext
*
sl
=
&
h
->
slice_ctx
[
0
];
h
->
mb_x
=
mb_x
;
h
->
mb_y
=
mb_y
;
sl
->
mb_x
=
mb_x
;
sl
->
mb_y
=
mb_y
;
sl
->
mb_xy
=
mb_x
+
mb_y
*
h
->
mb_stride
;
memset
(
sl
->
non_zero_count_cache
,
0
,
sizeof
(
sl
->
non_zero_count_cache
));
assert
(
ref
>=
0
);
...
...
@@ -143,7 +143,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl)
if
(
status
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"top block unavailable for requested intra4x4 mode %d at %d %d
\n
"
,
status
,
h
->
mb_x
,
h
->
mb_y
);
status
,
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
else
if
(
status
)
{
sl
->
intra4x4_pred_mode_cache
[
scan8
[
0
]
+
i
]
=
status
;
...
...
@@ -159,7 +159,7 @@ int ff_h264_check_intra4x4_pred_mode(H264Context *h, H264SliceContext *sl)
if
(
status
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"left block unavailable for requested intra4x4 mode %d at %d %d
\n
"
,
status
,
h
->
mb_x
,
h
->
mb_y
);
status
,
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
else
if
(
status
)
{
sl
->
intra4x4_pred_mode_cache
[
scan8
[
0
]
+
8
*
i
]
=
status
;
...
...
@@ -183,7 +183,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if
(
mode
>
3U
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"out of range intra chroma pred mode at %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -192,7 +192,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if
(
mode
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"top block unavailable for requested intra mode at %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
}
...
...
@@ -208,7 +208,7 @@ int ff_h264_check_intra_pred_mode(H264Context *h, H264SliceContext *sl,
if
(
mode
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"left block unavailable for requested intra mode at %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
}
...
...
@@ -1114,7 +1114,7 @@ static void flush_dpb(AVCodecContext *avctx)
h
->
cur_pic_ptr
=
NULL
;
ff_h264_unref_picture
(
h
,
&
h
->
cur_pic
);
h
->
mb_
x
=
h
->
mb_
y
=
0
;
h
->
mb_y
=
0
;
ff_h264_free_tables
(
h
,
1
);
h
->
context_initialized
=
0
;
...
...
libavcodec/h264.h
View file @
d4d9068c
...
...
@@ -356,6 +356,7 @@ typedef struct H264SliceContext {
ptrdiff_t
mb_linesize
;
///< may be equal to s->linesize or s->linesize * 2, for mbaff
ptrdiff_t
mb_uvlinesize
;
int
mb_x
,
mb_y
;
int
mb_xy
;
int
mb_skip_run
;
int
is_complex
;
...
...
@@ -526,7 +527,7 @@ typedef struct H264Context {
int
x264_build
;
int
mb_
x
,
mb_
y
;
int
mb_y
;
int
resync_mb_x
;
int
resync_mb_y
;
int
mb_height
,
mb_width
;
...
...
@@ -1020,7 +1021,7 @@ static av_always_inline void write_back_motion(H264Context *h,
int
mb_type
)
{
const
int
b_stride
=
h
->
b_stride
;
const
int
b_xy
=
4
*
h
->
mb_x
+
4
*
h
->
mb_y
*
h
->
b_stride
;
// try mb2b(8)_xy
const
int
b_xy
=
4
*
sl
->
mb_x
+
4
*
sl
->
mb_y
*
h
->
b_stride
;
// try mb2b(8)_xy
const
int
b8_xy
=
4
*
sl
->
mb_xy
;
if
(
USES_LIST
(
mb_type
,
0
))
{
...
...
libavcodec/h264_cabac.c
View file @
d4d9068c
...
...
@@ -1288,7 +1288,7 @@ static int decode_cabac_field_decoding_flag(H264Context *h, H264SliceContext *sl
unsigned
long
ctx
=
0
;
ctx
+=
h
->
mb_field_decoding_flag
&
!!
h
->
mb_x
;
//for FMO:(s->current_picture.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
ctx
+=
h
->
mb_field_decoding_flag
&
!!
sl
->
mb_x
;
//for FMO:(s->current_picture.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
ctx
+=
(
h
->
cur_pic
.
mb_type
[
mbb_xy
]
>>
7
)
&
(
h
->
slice_table
[
mbb_xy
]
==
sl
->
slice_num
);
return
get_cabac_noinline
(
&
sl
->
cabac
,
&
(
sl
->
cabac_state
+
70
)[
ctx
]
);
...
...
@@ -1914,21 +1914,21 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
int
decode_chroma
=
h
->
sps
.
chroma_format_idc
==
1
||
h
->
sps
.
chroma_format_idc
==
2
;
const
int
pixel_shift
=
h
->
pixel_shift
;
mb_xy
=
sl
->
mb_xy
=
h
->
mb_x
+
h
->
mb_y
*
h
->
mb_stride
;
mb_xy
=
sl
->
mb_xy
=
sl
->
mb_x
+
sl
->
mb_y
*
h
->
mb_stride
;
tprintf
(
h
->
avctx
,
"pic:%d mb:%d/%d
\n
"
,
h
->
frame_num
,
h
->
mb_x
,
h
->
mb_y
);
tprintf
(
h
->
avctx
,
"pic:%d mb:%d/%d
\n
"
,
h
->
frame_num
,
sl
->
mb_x
,
sl
->
mb_y
);
if
(
sl
->
slice_type_nos
!=
AV_PICTURE_TYPE_I
)
{
int
skip
;
/* a skipped mb needs the aff flag from the following mb */
if
(
FRAME_MBAFF
(
h
)
&&
(
h
->
mb_y
&
1
)
==
1
&&
sl
->
prev_mb_skipped
)
if
(
FRAME_MBAFF
(
h
)
&&
(
sl
->
mb_y
&
1
)
==
1
&&
sl
->
prev_mb_skipped
)
skip
=
sl
->
next_mb_skipped
;
else
skip
=
decode_cabac_mb_skip
(
h
,
sl
,
h
->
mb_x
,
h
->
mb_y
);
skip
=
decode_cabac_mb_skip
(
h
,
sl
,
sl
->
mb_x
,
sl
->
mb_y
);
/* read skip flags */
if
(
skip
)
{
if
(
FRAME_MBAFF
(
h
)
&&
(
h
->
mb_y
&
1
)
==
0
)
{
if
(
FRAME_MBAFF
(
h
)
&&
(
sl
->
mb_y
&
1
)
==
0
)
{
h
->
cur_pic
.
mb_type
[
mb_xy
]
=
MB_TYPE_SKIP
;
sl
->
next_mb_skipped
=
decode_cabac_mb_skip
(
h
,
sl
,
h
->
mb_x
,
h
->
mb_y
+
1
);
sl
->
next_mb_skipped
=
decode_cabac_mb_skip
(
h
,
sl
,
sl
->
mb_x
,
sl
->
mb_y
+
1
);
if
(
!
sl
->
next_mb_skipped
)
h
->
mb_mbaff
=
h
->
mb_field_decoding_flag
=
decode_cabac_field_decoding_flag
(
h
,
sl
);
}
...
...
@@ -1944,7 +1944,7 @@ int ff_h264_decode_mb_cabac(H264Context *h, H264SliceContext *sl)
}
}
if
(
FRAME_MBAFF
(
h
))
{
if
(
(
h
->
mb_y
&
1
)
==
0
)
if
((
sl
->
mb_y
&
1
)
==
0
)
h
->
mb_mbaff
=
h
->
mb_field_decoding_flag
=
decode_cabac_field_decoding_flag
(
h
,
sl
);
}
...
...
@@ -2367,7 +2367,7 @@ decode_intra_mb:
ctx
=
3
;
val
++
;
if
(
val
>
2
*
max_qp
){
//prevent infinite loop
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cabac decode of qscale diff failed at %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cabac decode of qscale diff failed at %d %d
\n
"
,
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
}
...
...
libavcodec/h264_cavlc.c
View file @
d4d9068c
...
...
@@ -477,7 +477,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl,
if
(
total_coeff
==
0
)
return
0
;
if
(
total_coeff
>
(
unsigned
)
max_coeff
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"corrupted macroblock %d %d (total_coeff=%d)
\n
"
,
h
->
mb_x
,
h
->
mb_y
,
total_coeff
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"corrupted macroblock %d %d (total_coeff=%d)
\n
"
,
sl
->
mb_x
,
sl
->
mb_y
,
total_coeff
);
return
-
1
;
}
...
...
@@ -615,7 +615,7 @@ static int decode_residual(H264Context *h, H264SliceContext *sl,
if
(
zeros_left
<
0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"negative number of zero coeffs at %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
"negative number of zero coeffs at %d %d
\n
"
,
sl
->
mb_x
,
sl
->
mb_y
);
return
AVERROR_INVALIDDATA
;
}
...
...
@@ -703,9 +703,9 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
int
decode_chroma
=
h
->
sps
.
chroma_format_idc
==
1
||
h
->
sps
.
chroma_format_idc
==
2
;
const
int
pixel_shift
=
h
->
pixel_shift
;
mb_xy
=
sl
->
mb_xy
=
h
->
mb_x
+
h
->
mb_y
*
h
->
mb_stride
;
mb_xy
=
sl
->
mb_xy
=
sl
->
mb_x
+
sl
->
mb_y
*
h
->
mb_stride
;
tprintf
(
h
->
avctx
,
"pic:%d mb:%d/%d
\n
"
,
h
->
frame_num
,
h
->
mb_x
,
h
->
mb_y
);
tprintf
(
h
->
avctx
,
"pic:%d mb:%d/%d
\n
"
,
h
->
frame_num
,
sl
->
mb_x
,
sl
->
mb_y
);
cbp
=
0
;
/* avoid warning. FIXME: find a solution without slowing
down the code */
if
(
sl
->
slice_type_nos
!=
AV_PICTURE_TYPE_I
)
{
...
...
@@ -713,7 +713,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
sl
->
mb_skip_run
=
get_ue_golomb
(
&
h
->
gb
);
if
(
sl
->
mb_skip_run
--
)
{
if
(
FRAME_MBAFF
(
h
)
&&
(
h
->
mb_y
&
1
)
==
0
)
{
if
(
FRAME_MBAFF
(
h
)
&&
(
sl
->
mb_y
&
1
)
==
0
)
{
if
(
sl
->
mb_skip_run
==
0
)
h
->
mb_mbaff
=
h
->
mb_field_decoding_flag
=
get_bits1
(
&
h
->
gb
);
}
...
...
@@ -722,7 +722,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
}
}
if
(
FRAME_MBAFF
(
h
))
{
if
(
(
h
->
mb_y
&
1
)
==
0
)
if
((
sl
->
mb_y
&
1
)
==
0
)
h
->
mb_mbaff
=
h
->
mb_field_decoding_flag
=
get_bits1
(
&
h
->
gb
);
}
...
...
@@ -751,7 +751,7 @@ int ff_h264_decode_mb_cavlc(H264Context *h, H264SliceContext *sl)
mb_type
--
;
decode_intra_mb
:
if
(
mb_type
>
25
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"mb_type %d in %c slice too large at %d %d
\n
"
,
mb_type
,
av_get_picture_type_char
(
sl
->
slice_type
),
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"mb_type %d in %c slice too large at %d %d
\n
"
,
mb_type
,
av_get_picture_type_char
(
sl
->
slice_type
),
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
partition_count
=
0
;
...
...
@@ -838,7 +838,7 @@ decode_intra_mb:
for
(
i
=
0
;
i
<
4
;
i
++
){
sl
->
sub_mb_type
[
i
]
=
get_ue_golomb_31
(
&
h
->
gb
);
if
(
sl
->
sub_mb_type
[
i
]
>=
13
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"B sub_mb_type %u out of range at %d %d
\n
"
,
sl
->
sub_mb_type
[
i
],
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"B sub_mb_type %u out of range at %d %d
\n
"
,
sl
->
sub_mb_type
[
i
],
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
sub_partition_count
[
i
]
=
b_sub_mb_type_info
[
sl
->
sub_mb_type
[
i
]
].
partition_count
;
...
...
@@ -856,7 +856,7 @@ decode_intra_mb:
for
(
i
=
0
;
i
<
4
;
i
++
){
sl
->
sub_mb_type
[
i
]
=
get_ue_golomb_31
(
&
h
->
gb
);
if
(
sl
->
sub_mb_type
[
i
]
>=
4
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"P sub_mb_type %u out of range at %d %d
\n
"
,
sl
->
sub_mb_type
[
i
],
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"P sub_mb_type %u out of range at %d %d
\n
"
,
sl
->
sub_mb_type
[
i
],
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
sub_partition_count
[
i
]
=
p_sub_mb_type_info
[
sl
->
sub_mb_type
[
i
]
].
partition_count
;
...
...
@@ -1057,14 +1057,14 @@ decode_intra_mb:
if
(
decode_chroma
){
if
(
cbp
>
47
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cbp too large (%u) at %d %d
\n
"
,
cbp
,
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cbp too large (%u) at %d %d
\n
"
,
cbp
,
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
if
(
IS_INTRA4x4
(
mb_type
))
cbp
=
golomb_to_intra4x4_cbp
[
cbp
];
else
cbp
=
golomb_to_inter_cbp
[
cbp
];
}
else
{
if
(
cbp
>
15
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cbp too large (%u) at %d %d
\n
"
,
cbp
,
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"cbp too large (%u) at %d %d
\n
"
,
cbp
,
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
if
(
IS_INTRA4x4
(
mb_type
))
cbp
=
golomb_to_intra4x4_cbp_gray
[
cbp
];
...
...
@@ -1103,7 +1103,7 @@ decode_intra_mb:
if
(
sl
->
qscale
<
0
)
sl
->
qscale
+=
max_qp
+
1
;
else
sl
->
qscale
-=
max_qp
+
1
;
if
(((
unsigned
)
sl
->
qscale
)
>
max_qp
){
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"dquant out of range (%d) at %d %d
\n
"
,
dquant
,
h
->
mb_x
,
h
->
mb_y
);
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"dquant out of range (%d) at %d %d
\n
"
,
dquant
,
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
}
...
...
libavcodec/h264_direct.c
View file @
d4d9068c
...
...
@@ -179,7 +179,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
{
int
b8_stride
=
2
;
int
b4_stride
=
h
->
b_stride
;
int
mb_xy
=
sl
->
mb_xy
,
mb_y
=
h
->
mb_y
;
int
mb_xy
=
sl
->
mb_xy
,
mb_y
=
sl
->
mb_y
;
int
mb_type_col
[
2
];
const
int16_t
(
*
l1mv0
)[
2
],
(
*
l1mv1
)[
2
];
const
int8_t
*
l1ref0
,
*
l1ref1
;
...
...
@@ -193,7 +193,7 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
assert
(
sl
->
ref_list
[
1
][
0
].
reference
&
3
);
await_reference_mb_row
(
h
,
&
sl
->
ref_list
[
1
][
0
],
h
->
mb_y
+
!!
IS_INTERLACED
(
*
mb_type
));
sl
->
mb_y
+
!!
IS_INTERLACED
(
*
mb_type
));
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
...
...
@@ -262,9 +262,9 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
if
(
IS_INTERLACED
(
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
]))
{
// AFL/AFR/FR/FL -> AFL/FL
if
(
!
IS_INTERLACED
(
*
mb_type
))
{
// AFR/FR -> AFL/FL
mb_y
=
(
h
->
mb_y
&
~
1
)
+
sl
->
col_parity
;
mb_xy
=
h
->
mb_x
+
((
h
->
mb_y
&
~
1
)
+
sl
->
col_parity
)
*
h
->
mb_stride
;
mb_y
=
(
sl
->
mb_y
&
~
1
)
+
sl
->
col_parity
;
mb_xy
=
sl
->
mb_x
+
((
sl
->
mb_y
&
~
1
)
+
sl
->
col_parity
)
*
h
->
mb_stride
;
b8_stride
=
0
;
}
else
{
mb_y
+=
sl
->
col_fieldoff
;
...
...
@@ -273,8 +273,8 @@ static void pred_spatial_direct_motion(H264Context *const h, H264SliceContext *s
goto
single_col
;
}
else
{
// AFL/AFR/FR/FL -> AFR/FR
if
(
IS_INTERLACED
(
*
mb_type
))
{
// AFL /FL -> AFR/FR
mb_y
=
h
->
mb_y
&
~
1
;
mb_xy
=
(
h
->
mb_y
&
~
1
)
*
h
->
mb_stride
+
h
->
mb_x
;
mb_y
=
sl
->
mb_y
&
~
1
;
mb_xy
=
(
sl
->
mb_y
&
~
1
)
*
h
->
mb_stride
+
sl
->
mb_x
;
mb_type_col
[
0
]
=
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
];
mb_type_col
[
1
]
=
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
+
h
->
mb_stride
];
b8_stride
=
2
+
4
*
h
->
mb_stride
;
...
...
@@ -323,7 +323,7 @@ single_col:
l1ref0
=
&
sl
->
ref_list
[
1
][
0
].
ref_index
[
0
][
4
*
mb_xy
];
l1ref1
=
&
sl
->
ref_list
[
1
][
0
].
ref_index
[
1
][
4
*
mb_xy
];
if
(
!
b8_stride
)
{
if
(
h
->
mb_y
&
1
)
{
if
(
sl
->
mb_y
&
1
)
{
l1ref0
+=
2
;
l1ref1
+=
2
;
l1mv0
+=
2
*
b4_stride
;
...
...
@@ -465,7 +465,7 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
{
int
b8_stride
=
2
;
int
b4_stride
=
h
->
b_stride
;
int
mb_xy
=
sl
->
mb_xy
,
mb_y
=
h
->
mb_y
;
int
mb_xy
=
sl
->
mb_xy
,
mb_y
=
sl
->
mb_y
;
int
mb_type_col
[
2
];
const
int16_t
(
*
l1mv0
)[
2
],
(
*
l1mv1
)[
2
];
const
int8_t
*
l1ref0
,
*
l1ref1
;
...
...
@@ -476,13 +476,13 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
assert
(
sl
->
ref_list
[
1
][
0
].
reference
&
3
);
await_reference_mb_row
(
h
,
&
sl
->
ref_list
[
1
][
0
],
h
->
mb_y
+
!!
IS_INTERLACED
(
*
mb_type
));
sl
->
mb_y
+
!!
IS_INTERLACED
(
*
mb_type
));
if
(
IS_INTERLACED
(
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
]))
{
// AFL/AFR/FR/FL -> AFL/FL
if
(
!
IS_INTERLACED
(
*
mb_type
))
{
// AFR/FR -> AFL/FL
mb_y
=
(
h
->
mb_y
&
~
1
)
+
sl
->
col_parity
;
mb_xy
=
h
->
mb_x
+
((
h
->
mb_y
&
~
1
)
+
sl
->
col_parity
)
*
h
->
mb_stride
;
mb_y
=
(
sl
->
mb_y
&
~
1
)
+
sl
->
col_parity
;
mb_xy
=
sl
->
mb_x
+
((
sl
->
mb_y
&
~
1
)
+
sl
->
col_parity
)
*
h
->
mb_stride
;
b8_stride
=
0
;
}
else
{
mb_y
+=
sl
->
col_fieldoff
;
...
...
@@ -491,8 +491,8 @@ static void pred_temp_direct_motion(H264Context *const h, H264SliceContext *sl,
goto
single_col
;
}
else
{
// AFL/AFR/FR/FL -> AFR/FR
if
(
IS_INTERLACED
(
*
mb_type
))
{
// AFL /FL -> AFR/FR
mb_y
=
h
->
mb_y
&
~
1
;
mb_xy
=
h
->
mb_x
+
(
h
->
mb_y
&
~
1
)
*
h
->
mb_stride
;
mb_y
=
sl
->
mb_y
&
~
1
;
mb_xy
=
sl
->
mb_x
+
(
sl
->
mb_y
&
~
1
)
*
h
->
mb_stride
;
mb_type_col
[
0
]
=
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
];
mb_type_col
[
1
]
=
sl
->
ref_list
[
1
][
0
].
mb_type
[
mb_xy
+
h
->
mb_stride
];
b8_stride
=
2
+
4
*
h
->
mb_stride
;
...
...
@@ -547,7 +547,7 @@ single_col:
l1ref0
=
&
sl
->
ref_list
[
1
][
0
].
ref_index
[
0
][
4
*
mb_xy
];
l1ref1
=
&
sl
->
ref_list
[
1
][
0
].
ref_index
[
1
][
4
*
mb_xy
];
if
(
!
b8_stride
)
{
if
(
h
->
mb_y
&
1
)
{
if
(
sl
->
mb_y
&
1
)
{
l1ref0
+=
2
;
l1ref1
+=
2
;
l1mv0
+=
2
*
b4_stride
;
...
...
@@ -562,9 +562,9 @@ single_col:
int
ref_offset
;
if
(
FRAME_MBAFF
(
h
)
&&
IS_INTERLACED
(
*
mb_type
))
{
map_col_to_list0
[
0
]
=
sl
->
map_col_to_list0_field
[
h
->
mb_y
&
1
][
0
];
map_col_to_list0
[
1
]
=
sl
->
map_col_to_list0_field
[
h
->
mb_y
&
1
][
1
];
dist_scale_factor
=
sl
->
dist_scale_factor_field
[
h
->
mb_y
&
1
];
map_col_to_list0
[
0
]
=
sl
->
map_col_to_list0_field
[
sl
->
mb_y
&
1
][
0
];
map_col_to_list0
[
1
]
=
sl
->
map_col_to_list0_field
[
sl
->
mb_y
&
1
][
1
];
dist_scale_factor
=
sl
->
dist_scale_factor_field
[
sl
->
mb_y
&
1
];
}
ref_offset
=
(
sl
->
ref_list
[
1
][
0
].
mbaff
<<
4
)
&
(
mb_type_col
[
0
]
>>
3
);
...
...
libavcodec/h264_mb.c
View file @
d4d9068c
...
...
@@ -57,7 +57,7 @@ static inline void get_lowest_part_y(H264Context *h, H264SliceContext *sl,
{
int
my
;
y_offset
+=
16
*
(
h
->
mb_y
>>
MB_FIELD
(
h
));
y_offset
+=
16
*
(
sl
->
mb_y
>>
MB_FIELD
(
h
));
if
(
list0
)
{
int
ref_n
=
sl
->
ref_cache
[
0
][
scan8
[
n
]];
...
...
@@ -287,7 +287,7 @@ static av_always_inline void mc_dir_part(H264Context *h, H264SliceContext *sl,
ysh
=
3
-
(
chroma_idc
==
2
/* yuv422 */
);
if
(
chroma_idc
==
1
/* yuv420 */
&&
MB_FIELD
(
h
))
{
// chroma offset when predicting from a field of opposite parity
my
+=
2
*
((
h
->
mb_y
&
1
)
-
(
pic
->
reference
-
1
));
my
+=
2
*
((
sl
->
mb_y
&
1
)
-
(
pic
->
reference
-
1
));
emu
|=
(
my
>>
3
)
<
0
||
(
my
>>
3
)
+
8
>=
(
pic_height
>>
1
);
}
...
...
@@ -345,8 +345,8 @@ static av_always_inline void mc_part_std(H264Context *h, H264SliceContext *sl,
dest_cb
+=
(
x_offset
<<
pixel_shift
)
+
y_offset
*
sl
->
mb_uvlinesize
;
dest_cr
+=
(
x_offset
<<
pixel_shift
)
+
y_offset
*
sl
->
mb_uvlinesize
;
}
x_offset
+=
8
*
h
->
mb_x
;
y_offset
+=
8
*
(
h
->
mb_y
>>
MB_FIELD
(
h
));
x_offset
+=
8
*
sl
->
mb_x
;
y_offset
+=
8
*
(
sl
->
mb_y
>>
MB_FIELD
(
h
));
if
(
list0
)
{
H264Picture
*
ref
=
&
sl
->
ref_list
[
0
][
sl
->
ref_cache
[
0
][
scan8
[
n
]]];
...
...
@@ -399,8 +399,8 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
dest_cb
+=
(
x_offset
<<
pixel_shift
)
+
y_offset
*
sl
->
mb_uvlinesize
;
dest_cr
+=
(
x_offset
<<
pixel_shift
)
+
y_offset
*
sl
->
mb_uvlinesize
;
}
x_offset
+=
8
*
h
->
mb_x
;
y_offset
+=
8
*
(
h
->
mb_y
>>
MB_FIELD
(
h
));
x_offset
+=
8
*
sl
->
mb_x
;
y_offset
+=
8
*
(
sl
->
mb_y
>>
MB_FIELD
(
h
));
if
(
list0
&&
list1
)
{
/* don't optimize for luma-only case, since B-frames usually
...
...
@@ -421,7 +421,7 @@ static av_always_inline void mc_part_weighted(H264Context *h, H264SliceContext *
pixel_shift
,
chroma_idc
);
if
(
sl
->
use_weight
==
2
)
{
int
weight0
=
sl
->
implicit_weight
[
refn0
][
refn1
][
h
->
mb_y
&
1
];
int
weight0
=
sl
->
implicit_weight
[
refn0
][
refn1
][
sl
->
mb_y
&
1
];
int
weight1
=
64
-
weight0
;
luma_weight_avg
(
dest_y
,
tmp_y
,
sl
->
mb_linesize
,
height
,
5
,
weight0
,
weight1
,
0
);
...
...
@@ -482,11 +482,11 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s
* optimized for 64byte cache lines */
const
int
refn
=
sl
->
ref_cache
[
list
][
scan8
[
0
]];
if
(
refn
>=
0
)
{
const
int
mx
=
(
sl
->
mv_cache
[
list
][
scan8
[
0
]][
0
]
>>
2
)
+
16
*
h
->
mb_x
+
8
;
const
int
my
=
(
sl
->
mv_cache
[
list
][
scan8
[
0
]][
1
]
>>
2
)
+
16
*
h
->
mb_y
;
const
int
mx
=
(
sl
->
mv_cache
[
list
][
scan8
[
0
]][
0
]
>>
2
)
+
16
*
sl
->
mb_x
+
8
;
const
int
my
=
(
sl
->
mv_cache
[
list
][
scan8
[
0
]][
1
]
>>
2
)
+
16
*
sl
->
mb_y
;
uint8_t
**
src
=
sl
->
ref_list
[
list
][
refn
].
f
.
data
;
int
off
=
(
mx
<<
pixel_shift
)
+
(
my
+
(
h
->
mb_x
&
3
)
*
4
)
*
sl
->
mb_linesize
+
(
my
+
(
sl
->
mb_x
&
3
)
*
4
)
*
sl
->
mb_linesize
+
(
64
<<
pixel_shift
);
h
->
vdsp
.
prefetch
(
src
[
0
]
+
off
,
h
->
linesize
,
4
);
if
(
chroma_idc
==
3
/* yuv444 */
)
{
...
...
@@ -494,7 +494,7 @@ static av_always_inline void prefetch_motion(H264Context *h, H264SliceContext *s
h
->
vdsp
.
prefetch
(
src
[
2
]
+
off
,
h
->
linesize
,
4
);
}
else
{
off
=
((
mx
>>
1
)
<<
pixel_shift
)
+
((
my
>>
1
)
+
(
h
->
mb_x
&
7
))
*
h
->
uvlinesize
+
((
my
>>
1
)
+
(
sl
->
mb_x
&
7
))
*
h
->
uvlinesize
+
(
64
<<
pixel_shift
);
h
->
vdsp
.
prefetch
(
src
[
1
]
+
off
,
src
[
2
]
-
src
[
1
],
2
);
}
...
...
@@ -515,7 +515,7 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
uint8_t
*
top_border
;
if
(
!
simple
&&
FRAME_MBAFF
(
h
))
{
if
(
h
->
mb_y
&
1
)
{
if
(
sl
->
mb_y
&
1
)
{
if
(
!
MB_MBAFF
(
h
))
return
;
}
else
{
...
...
@@ -527,16 +527,16 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
deblock_topleft
=
h
->
slice_table
[
sl
->
mb_xy
-
1
-
h
->
mb_stride
]
==
sl
->
slice_num
;
deblock_top
=
sl
->
top_type
;
}
else
{
deblock_topleft
=
(
h
->
mb_x
>
0
);
deblock_top
=
(
h
->
mb_y
>
!!
MB_FIELD
(
h
));
deblock_topleft
=
(
sl
->
mb_x
>
0
);
deblock_top
=
(
sl
->
mb_y
>
!!
MB_FIELD
(
h
));
}
src_y
-=
linesize
+
1
+
pixel_shift
;
src_cb
-=
uvlinesize
+
1
+
pixel_shift
;
src_cr
-=
uvlinesize
+
1
+
pixel_shift
;
top_border_m1
=
h
->
top_borders
[
top_idx
][
h
->
mb_x
-
1
];
top_border
=
h
->
top_borders
[
top_idx
][
h
->
mb_x
];
top_border_m1
=
h
->
top_borders
[
top_idx
][
sl
->
mb_x
-
1
];
top_border
=
h
->
top_borders
[
top_idx
][
sl
->
mb_x
];
#define XCHG(a, b, xchg) \
if (pixel_shift) { \
...
...
@@ -558,8 +558,8 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
}
XCHG
(
top_border
+
(
0
<<
pixel_shift
),
src_y
+
(
1
<<
pixel_shift
),
xchg
);
XCHG
(
top_border
+
(
8
<<
pixel_shift
),
src_y
+
(
9
<<
pixel_shift
),
1
);
if
(
h
->
mb_x
+
1
<
h
->
mb_width
)
{
XCHG
(
h
->
top_borders
[
top_idx
][
h
->
mb_x
+
1
],
if
(
sl
->
mb_x
+
1
<
h
->
mb_width
)
{
XCHG
(
h
->
top_borders
[
top_idx
][
sl
->
mb_x
+
1
],
src_y
+
(
17
<<
pixel_shift
),
1
);
}
}
...
...
@@ -574,9 +574,9 @@ static av_always_inline void xchg_mb_border(H264Context *h, H264SliceContext *sl
XCHG
(
top_border
+
(
24
<<
pixel_shift
),
src_cb
+
(
9
<<
pixel_shift
),
1
);
XCHG
(
top_border
+
(
32
<<
pixel_shift
),
src_cr
+
(
1
<<
pixel_shift
),
xchg
);
XCHG
(
top_border
+
(
40
<<
pixel_shift
),
src_cr
+
(
9
<<
pixel_shift
),
1
);
if
(
h
->
mb_x
+
1
<
h
->
mb_width
)
{
XCHG
(
h
->
top_borders
[
top_idx
][
h
->
mb_x
+
1
]
+
(
16
<<
pixel_shift
),
src_cb
+
(
17
<<
pixel_shift
),
1
);
XCHG
(
h
->
top_borders
[
top_idx
][
h
->
mb_x
+
1
]
+
(
32
<<
pixel_shift
),
src_cr
+
(
17
<<
pixel_shift
),
1
);
if
(
sl
->
mb_x
+
1
<
h
->
mb_width
)
{
XCHG
(
h
->
top_borders
[
top_idx
][
sl
->
mb_x
+
1
]
+
(
16
<<
pixel_shift
),
src_cb
+
(
17
<<
pixel_shift
),
1
);
XCHG
(
h
->
top_borders
[
top_idx
][
sl
->
mb_x
+
1
]
+
(
32
<<
pixel_shift
),
src_cr
+
(
17
<<
pixel_shift
),
1
);
}
}
}
else
{
...
...
@@ -671,7 +671,7 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
uint64_t
tr_high
;
if
(
dir
==
DIAG_DOWN_LEFT_PRED
||
dir
==
VERT_LEFT_PRED
)
{
const
int
topright_avail
=
(
sl
->
topright_samples_available
<<
i
)
&
0x8000
;
assert
(
h
->
mb_y
||
linesize
<=
block_offset
[
i
]);
assert
(
sl
->
mb_y
||
linesize
<=
block_offset
[
i
]);
if
(
!
topright_avail
)
{
if
(
pixel_shift
)
{
tr_high
=
((
uint16_t
*
)
ptr
)[
3
-
linesize
/
2
]
*
0x0001000100010001ULL
;
...
...
libavcodec/h264_mb_template.c
View file @
d4d9068c
...
...
@@ -42,8 +42,8 @@
static
av_noinline
void
FUNC
(
hl_decode_mb
)(
H264Context
*
h
,
H264SliceContext
*
sl
)
{
const
int
mb_x
=
h
->
mb_x
;
const
int
mb_y
=
h
->
mb_y
;
const
int
mb_x
=
sl
->
mb_x
;
const
int
mb_y
=
sl
->
mb_y
;
const
int
mb_xy
=
sl
->
mb_xy
;
const
int
mb_type
=
h
->
cur_pic
.
mb_type
[
mb_xy
];
uint8_t
*
dest_y
,
*
dest_cb
,
*
dest_cr
;
...
...
@@ -61,8 +61,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
dest_cb
=
h
->
cur_pic
.
f
.
data
[
1
]
+
(
mb_x
<<
PIXEL_SHIFT
)
*
8
+
mb_y
*
h
->
uvlinesize
*
block_h
;
dest_cr
=
h
->
cur_pic
.
f
.
data
[
2
]
+
(
mb_x
<<
PIXEL_SHIFT
)
*
8
+
mb_y
*
h
->
uvlinesize
*
block_h
;
h
->
vdsp
.
prefetch
(
dest_y
+
(
h
->
mb_x
&
3
)
*
4
*
h
->
linesize
+
(
64
<<
PIXEL_SHIFT
),
h
->
linesize
,
4
);
h
->
vdsp
.
prefetch
(
dest_cb
+
(
h
->
mb_x
&
7
)
*
h
->
uvlinesize
+
(
64
<<
PIXEL_SHIFT
),
dest_cr
-
dest_cb
,
2
);
h
->
vdsp
.
prefetch
(
dest_y
+
(
sl
->
mb_x
&
3
)
*
4
*
h
->
linesize
+
(
64
<<
PIXEL_SHIFT
),
h
->
linesize
,
4
);
h
->
vdsp
.
prefetch
(
dest_cb
+
(
sl
->
mb_x
&
7
)
*
h
->
uvlinesize
+
(
64
<<
PIXEL_SHIFT
),
dest_cr
-
dest_cb
,
2
);
h
->
list_counts
[
mb_xy
]
=
sl
->
list_count
;
...
...
@@ -82,13 +82,13 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
continue
;
if
(
IS_16X16
(
mb_type
))
{
int8_t
*
ref
=
&
sl
->
ref_cache
[
list
][
scan8
[
0
]];
fill_rectangle
(
ref
,
4
,
4
,
8
,
(
16
+
*
ref
)
^
(
h
->
mb_y
&
1
),
1
);
fill_rectangle
(
ref
,
4
,
4
,
8
,
(
16
+
*
ref
)
^
(
sl
->
mb_y
&
1
),
1
);
}
else
{
for
(
i
=
0
;
i
<
16
;
i
+=
4
)
{
int
ref
=
sl
->
ref_cache
[
list
][
scan8
[
i
]];
if
(
ref
>=
0
)
fill_rectangle
(
&
sl
->
ref_cache
[
list
][
scan8
[
i
]],
2
,
2
,
8
,
(
16
+
ref
)
^
(
h
->
mb_y
&
1
),
1
);
8
,
(
16
+
ref
)
^
(
sl
->
mb_y
&
1
),
1
);
}
}
}
...
...
@@ -274,8 +274,8 @@ static av_noinline void FUNC(hl_decode_mb)(H264Context *h, H264SliceContext *sl)
static
av_noinline
void
FUNC
(
hl_decode_mb_444
)(
H264Context
*
h
,
H264SliceContext
*
sl
)
{
const
int
mb_x
=
h
->
mb_x
;
const
int
mb_y
=
h
->
mb_y
;
const
int
mb_x
=
sl
->
mb_x
;
const
int
mb_y
=
sl
->
mb_y
;
const
int
mb_xy
=
sl
->
mb_xy
;
const
int
mb_type
=
h
->
cur_pic
.
mb_type
[
mb_xy
];
uint8_t
*
dest
[
3
];
...
...
@@ -288,7 +288,7 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
for
(
p
=
0
;
p
<
plane_count
;
p
++
)
{
dest
[
p
]
=
h
->
cur_pic
.
f
.
data
[
p
]
+
((
mb_x
<<
PIXEL_SHIFT
)
+
mb_y
*
h
->
linesize
)
*
16
;
h
->
vdsp
.
prefetch
(
dest
[
p
]
+
(
h
->
mb_x
&
3
)
*
4
*
h
->
linesize
+
(
64
<<
PIXEL_SHIFT
),
h
->
vdsp
.
prefetch
(
dest
[
p
]
+
(
sl
->
mb_x
&
3
)
*
4
*
h
->
linesize
+
(
64
<<
PIXEL_SHIFT
),
h
->
linesize
,
4
);
}
...
...
@@ -307,13 +307,13 @@ static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h, H264SliceContext
continue
;
if
(
IS_16X16
(
mb_type
))
{
int8_t
*
ref
=
&
sl
->
ref_cache
[
list
][
scan8
[
0
]];
fill_rectangle
(
ref
,
4
,
4
,
8
,
(
16
+
*
ref
)
^
(
h
->
mb_y
&
1
),
1
);
fill_rectangle
(
ref
,
4
,
4
,
8
,
(
16
+
*
ref
)
^
(
sl
->
mb_y
&
1
),
1
);
}
else
{
for
(
i
=
0
;
i
<
16
;
i
+=
4
)
{
int
ref
=
sl
->
ref_cache
[
list
][
scan8
[
i
]];
if
(
ref
>=
0
)
fill_rectangle
(
&
sl
->
ref_cache
[
list
][
scan8
[
i
]],
2
,
2
,
8
,
(
16
+
ref
)
^
(
h
->
mb_y
&
1
),
1
);
8
,
(
16
+
ref
)
^
(
sl
->
mb_y
&
1
),
1
);
}
}
}
...
...
libavcodec/h264_mc_template.c
View file @
d4d9068c
...
...
@@ -49,7 +49,7 @@ static void mc_part(H264Context *h, H264SliceContext *sl,
int
list0
,
int
list1
)
{
if
((
sl
->
use_weight
==
2
&&
list0
&&
list1
&&
(
sl
->
implicit_weight
[
sl
->
ref_cache
[
0
][
scan8
[
n
]]][
sl
->
ref_cache
[
1
][
scan8
[
n
]]][
h
->
mb_y
&
1
]
!=
32
))
||
(
sl
->
implicit_weight
[
sl
->
ref_cache
[
0
][
scan8
[
n
]]][
sl
->
ref_cache
[
1
][
scan8
[
n
]]][
sl
->
mb_y
&
1
]
!=
32
))
||
sl
->
use_weight
==
1
)
mc_part_weighted
(
h
,
sl
,
n
,
square
,
height
,
delta
,
dest_y
,
dest_cb
,
dest_cr
,
x_offset
,
y_offset
,
qpix_put
,
chroma_put
,
...
...
libavcodec/h264_mvpred.h
View file @
d4d9068c
...
...
@@ -64,7 +64,7 @@ static av_always_inline int fetch_diagonal_mv(H264Context *h, H264SliceContext *
if
(
!
MB_FIELD
(
h
)
&&
IS_INTERLACED
(
sl
->
left_type
[
0
]))
{
SET_DIAG_MV
(
*
2
,
>>
1
,
sl
->
left_mb_xy
[
0
]
+
h
->
mb_stride
,
(
h
->
mb_y
&
1
)
*
2
+
(
i
>>
5
));
(
sl
->
mb_y
&
1
)
*
2
+
(
i
>>
5
));
}
if
(
MB_FIELD
(
h
)
&&
!
IS_INTERLACED
(
sl
->
left_type
[
0
]))
{
// left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
...
...
@@ -148,7 +148,7 @@ static av_always_inline void pred_motion(H264Context *const h,
tprintf
(
h
->
avctx
,
"pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d
\n
"
,
top_ref
,
B
[
0
],
B
[
1
],
diagonal_ref
,
C
[
0
],
C
[
1
],
left_ref
,
A
[
0
],
A
[
1
],
ref
,
*
mx
,
*
my
,
h
->
mb_x
,
h
->
mb_y
,
n
,
list
);
A
[
0
],
A
[
1
],
ref
,
*
mx
,
*
my
,
sl
->
mb_x
,
sl
->
mb_y
,
n
,
list
);
}
/**
...
...
@@ -167,7 +167,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h,
const
int16_t
*
const
B
=
sl
->
mv_cache
[
list
][
scan8
[
0
]
-
8
];
tprintf
(
h
->
avctx
,
"pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d
\n
"
,
top_ref
,
B
[
0
],
B
[
1
],
h
->
mb_x
,
h
->
mb_y
,
n
,
list
);
top_ref
,
B
[
0
],
B
[
1
],
sl
->
mb_x
,
sl
->
mb_y
,
n
,
list
);
if
(
top_ref
==
ref
)
{
*
mx
=
B
[
0
];
...
...
@@ -179,7 +179,7 @@ static av_always_inline void pred_16x8_motion(H264Context *const h,
const
int16_t
*
const
A
=
sl
->
mv_cache
[
list
][
scan8
[
8
]
-
1
];
tprintf
(
h
->
avctx
,
"pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d
\n
"
,
left_ref
,
A
[
0
],
A
[
1
],
h
->
mb_x
,
h
->
mb_y
,
n
,
list
);
left_ref
,
A
[
0
],
A
[
1
],
sl
->
mb_x
,
sl
->
mb_y
,
n
,
list
);
if
(
left_ref
==
ref
)
{
*
mx
=
A
[
0
];
...
...
@@ -208,7 +208,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h,
const
int16_t
*
const
A
=
sl
->
mv_cache
[
list
][
scan8
[
0
]
-
1
];
tprintf
(
h
->
avctx
,
"pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d
\n
"
,
left_ref
,
A
[
0
],
A
[
1
],
h
->
mb_x
,
h
->
mb_y
,
n
,
list
);
left_ref
,
A
[
0
],
A
[
1
],
sl
->
mb_x
,
sl
->
mb_y
,
n
,
list
);
if
(
left_ref
==
ref
)
{
*
mx
=
A
[
0
];
...
...
@@ -222,7 +222,7 @@ static av_always_inline void pred_8x16_motion(H264Context *const h,
diagonal_ref
=
fetch_diagonal_mv
(
h
,
sl
,
&
C
,
scan8
[
4
],
list
,
2
);
tprintf
(
h
->
avctx
,
"pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d
\n
"
,
diagonal_ref
,
C
[
0
],
C
[
1
],
h
->
mb_x
,
h
->
mb_y
,
n
,
list
);
diagonal_ref
,
C
[
0
],
C
[
1
],
sl
->
mb_x
,
sl
->
mb_y
,
n
,
list
);
if
(
diagonal_ref
==
ref
)
{
*
mx
=
C
[
0
];
...
...
@@ -299,7 +299,7 @@ static av_always_inline void pred_pskip_motion(H264Context *const h,
}
tprintf
(
h
->
avctx
,
"pred_pskip: (%d) (%d) at %2d %2d
\n
"
,
top_ref
,
left_ref
,
h
->
mb_x
,
h
->
mb_y
);
top_ref
,
left_ref
,
sl
->
mb_x
,
sl
->
mb_y
);
if
(
USES_LIST
(
sl
->
topright_type
,
0
))
{
diagonal_ref
=
ref
[
4
*
sl
->
topright_mb_xy
+
2
];
...
...
@@ -378,7 +378,7 @@ static void fill_decode_neighbors(H264Context *h, H264SliceContext *sl, int mb_t
if
(
FRAME_MBAFF
(
h
))
{
const
int
left_mb_field_flag
=
IS_INTERLACED
(
h
->
cur_pic
.
mb_type
[
mb_xy
-
1
]);
const
int
curr_mb_field_flag
=
IS_INTERLACED
(
mb_type
);
if
(
h
->
mb_y
&
1
)
{
if
(
sl
->
mb_y
&
1
)
{
if
(
left_mb_field_flag
!=
curr_mb_field_flag
)
{
left_xy
[
LBOT
]
=
left_xy
[
LTOP
]
=
mb_xy
-
h
->
mb_stride
-
1
;
if
(
curr_mb_field_flag
)
{
...
...
libavcodec/h264_slice.c
View file @
d4d9068c
This diff is collapsed.
Click to expand it.
libavcodec/svq3.c
View file @
d4d9068c
...
...
@@ -378,11 +378,11 @@ static inline int svq3_mc_dir(SVQ3Context *s, int size, int mode,
for
(
i
=
0
;
i
<
16
;
i
+=
part_height
)
for
(
j
=
0
;
j
<
16
;
j
+=
part_width
)
{
const
int
b_xy
=
(
4
*
h
->
mb_x
+
(
j
>>
2
))
+
(
4
*
h
->
mb_y
+
(
i
>>
2
))
*
h
->
b_stride
;
const
int
b_xy
=
(
4
*
sl
->
mb_x
+
(
j
>>
2
))
+
(
4
*
sl
->
mb_y
+
(
i
>>
2
))
*
h
->
b_stride
;
int
dxy
;
x
=
16
*
h
->
mb_x
+
j
;
y
=
16
*
h
->
mb_y
+
i
;
x
=
16
*
sl
->
mb_x
+
j
;
y
=
16
*
sl
->
mb_y
+
i
;
k
=
(
j
>>
2
&
1
)
+
(
i
>>
1
&
2
)
+
(
j
>>
1
&
4
)
+
(
i
&
8
);
...
...
@@ -488,20 +488,20 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
uint32_t
vlc
;
int8_t
*
top
,
*
left
;
const
int
mb_xy
=
sl
->
mb_xy
;
const
int
b_xy
=
4
*
h
->
mb_x
+
4
*
h
->
mb_y
*
h
->
b_stride
;
const
int
b_xy
=
4
*
sl
->
mb_x
+
4
*
sl
->
mb_y
*
h
->
b_stride
;
sl
->
top_samples_available
=
(
h
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
sl
->
left_samples_available
=
(
h
->
mb_x
==
0
)
?
0x5F5F
:
0xFFFF
;
sl
->
top_samples_available
=
(
sl
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
sl
->
left_samples_available
=
(
sl
->
mb_x
==
0
)
?
0x5F5F
:
0xFFFF
;
sl
->
topright_samples_available
=
0xFFFF
;
if
(
mb_type
==
0
)
{
/* SKIP */
if
(
h
->
pict_type
==
AV_PICTURE_TYPE_P
||
s
->
next_pic
->
mb_type
[
mb_xy
]
==
-
1
)
{
svq3_mc_dir_part
(
s
,
16
*
h
->
mb_x
,
16
*
h
->
mb_y
,
16
,
16
,
svq3_mc_dir_part
(
s
,
16
*
sl
->
mb_x
,
16
*
sl
->
mb_y
,
16
,
16
,
0
,
0
,
0
,
0
,
0
,
0
);
if
(
h
->
pict_type
==
AV_PICTURE_TYPE_B
)
svq3_mc_dir_part
(
s
,
16
*
h
->
mb_x
,
16
*
h
->
mb_y
,
16
,
16
,
svq3_mc_dir_part
(
s
,
16
*
sl
->
mb_x
,
16
*
sl
->
mb_y
,
16
,
16
,
0
,
0
,
0
,
0
,
1
,
1
);
mb_type
=
MB_TYPE_SKIP
;
...
...
@@ -533,7 +533,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
*/
for
(
m
=
0
;
m
<
2
;
m
++
)
{
if
(
h
->
mb_x
>
0
&&
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
1
]
+
6
]
!=
-
1
)
{
if
(
sl
->
mb_x
>
0
&&
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
1
]
+
6
]
!=
-
1
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
AV_COPY32
(
sl
->
mv_cache
[
m
][
scan8
[
0
]
-
1
+
i
*
8
],
h
->
cur_pic
.
motion_val
[
m
][
b_xy
-
1
+
i
*
h
->
b_stride
]);
...
...
@@ -541,14 +541,14 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
for
(
i
=
0
;
i
<
4
;
i
++
)
AV_ZERO32
(
sl
->
mv_cache
[
m
][
scan8
[
0
]
-
1
+
i
*
8
]);
}
if
(
h
->
mb_y
>
0
)
{
if
(
sl
->
mb_y
>
0
)
{
memcpy
(
sl
->
mv_cache
[
m
][
scan8
[
0
]
-
1
*
8
],
h
->
cur_pic
.
motion_val
[
m
][
b_xy
-
h
->
b_stride
],
4
*
2
*
sizeof
(
int16_t
));
memset
(
&
sl
->
ref_cache
[
m
][
scan8
[
0
]
-
1
*
8
],
(
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
]]
==
-
1
)
?
PART_NOT_AVAILABLE
:
1
,
4
);
if
(
h
->
mb_x
<
h
->
mb_width
-
1
)
{
if
(
sl
->
mb_x
<
h
->
mb_width
-
1
)
{
AV_COPY32
(
sl
->
mv_cache
[
m
][
scan8
[
0
]
+
4
-
1
*
8
],
h
->
cur_pic
.
motion_val
[
m
][
b_xy
-
h
->
b_stride
+
4
]);
sl
->
ref_cache
[
m
][
scan8
[
0
]
+
4
-
1
*
8
]
=
...
...
@@ -556,7 +556,7 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
]]
==
-
1
)
?
PART_NOT_AVAILABLE
:
1
;
}
else
sl
->
ref_cache
[
m
][
scan8
[
0
]
+
4
-
1
*
8
]
=
PART_NOT_AVAILABLE
;
if
(
h
->
mb_x
>
0
)
{
if
(
sl
->
mb_x
>
0
)
{
AV_COPY32
(
sl
->
mv_cache
[
m
][
scan8
[
0
]
-
1
-
1
*
8
],
h
->
cur_pic
.
motion_val
[
m
][
b_xy
-
h
->
b_stride
-
1
]);
sl
->
ref_cache
[
m
][
scan8
[
0
]
-
1
-
1
*
8
]
=
...
...
@@ -599,13 +599,13 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
memset
(
sl
->
intra4x4_pred_mode_cache
,
-
1
,
8
*
5
*
sizeof
(
int8_t
));
if
(
mb_type
==
8
)
{
if
(
h
->
mb_x
>
0
)
{
if
(
sl
->
mb_x
>
0
)
{
for
(
i
=
0
;
i
<
4
;
i
++
)
sl
->
intra4x4_pred_mode_cache
[
scan8
[
0
]
-
1
+
i
*
8
]
=
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
1
]
+
6
-
i
];
if
(
sl
->
intra4x4_pred_mode_cache
[
scan8
[
0
]
-
1
]
==
-
1
)
sl
->
left_samples_available
=
0x5F5F
;
}
if
(
h
->
mb_y
>
0
)
{
if
(
sl
->
mb_y
>
0
)
{
sl
->
intra4x4_pred_mode_cache
[
4
+
8
*
0
]
=
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
]
+
0
];
sl
->
intra4x4_pred_mode_cache
[
5
+
8
*
0
]
=
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
]
+
1
];
sl
->
intra4x4_pred_mode_cache
[
6
+
8
*
0
]
=
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
]
+
2
];
...
...
@@ -646,8 +646,8 @@ static int svq3_decode_mb(SVQ3Context *s, unsigned int mb_type)
if
(
mb_type
==
8
)
{
ff_h264_check_intra4x4_pred_mode
(
h
,
sl
);
sl
->
top_samples_available
=
(
h
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
sl
->
left_samples_available
=
(
h
->
mb_x
==
0
)
?
0x5F5F
:
0xFFFF
;
sl
->
top_samples_available
=
(
sl
->
mb_y
==
0
)
?
0x33FF
:
0xFFFF
;
sl
->
left_samples_available
=
(
sl
->
mb_x
==
0
)
?
0x5F5F
:
0xFFFF
;
}
else
{
for
(
i
=
0
;
i
<
4
;
i
++
)
memset
(
&
sl
->
intra4x4_pred_mode_cache
[
scan8
[
0
]
+
8
*
i
],
DC_128_PRED
,
4
);
...
...
@@ -822,7 +822,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
if
((
header
&
0x9F
)
==
2
)
{
i
=
(
h
->
mb_num
<
64
)
?
6
:
(
1
+
av_log2
(
h
->
mb_num
-
1
));
sl
->
mb_skip_run
=
get_bits
(
&
h
->
gb
,
i
)
-
(
h
->
mb_y
*
h
->
mb_width
+
h
->
mb_x
);
(
sl
->
mb_y
*
h
->
mb_width
+
sl
->
mb_x
);
}
else
{
skip_bits1
(
&
h
->
gb
);
sl
->
mb_skip_run
=
0
;
...
...
@@ -845,17 +845,17 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
skip_bits
(
&
h
->
gb
,
8
);
/* reset intra predictors and invalidate motion vector references */
if
(
h
->
mb_x
>
0
)
{
if
(
sl
->
mb_x
>
0
)
{
memset
(
sl
->
intra4x4_pred_mode
+
h
->
mb2br_xy
[
mb_xy
-
1
]
+
3
,
-
1
,
4
*
sizeof
(
int8_t
));
memset
(
sl
->
intra4x4_pred_mode
+
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_x
],
-
1
,
8
*
sizeof
(
int8_t
)
*
h
->
mb_x
);
memset
(
sl
->
intra4x4_pred_mode
+
h
->
mb2br_xy
[
mb_xy
-
sl
->
mb_x
],
-
1
,
8
*
sizeof
(
int8_t
)
*
sl
->
mb_x
);
}
if
(
h
->
mb_y
>
0
)
{
if
(
sl
->
mb_y
>
0
)
{
memset
(
sl
->
intra4x4_pred_mode
+
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
],
-
1
,
8
*
sizeof
(
int8_t
)
*
(
h
->
mb_width
-
h
->
mb_x
));
-
1
,
8
*
sizeof
(
int8_t
)
*
(
h
->
mb_width
-
sl
->
mb_x
));
if
(
h
->
mb_x
>
0
)
if
(
sl
->
mb_x
>
0
)
sl
->
intra4x4_pred_mode
[
h
->
mb2br_xy
[
mb_xy
-
h
->
mb_stride
-
1
]
+
3
]
=
-
1
;
}
...
...
@@ -1132,7 +1132,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
init_get_bits
(
&
h
->
gb
,
buf
,
8
*
buf_size
);
h
->
mb_x
=
h
->
mb_y
=
sl
->
mb_xy
=
0
;
sl
->
mb_x
=
sl
->
mb_y
=
sl
->
mb_xy
=
0
;
if
(
svq3_decode_slice_header
(
avctx
))
return
-
1
;
...
...
@@ -1245,10 +1245,10 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
}
}
for
(
h
->
mb_y
=
0
;
h
->
mb_y
<
h
->
mb_height
;
h
->
mb_y
++
)
{
for
(
h
->
mb_x
=
0
;
h
->
mb_x
<
h
->
mb_width
;
h
->
mb_x
++
)
{
for
(
sl
->
mb_y
=
0
;
sl
->
mb_y
<
h
->
mb_height
;
sl
->
mb_y
++
)
{
for
(
sl
->
mb_x
=
0
;
sl
->
mb_x
<
h
->
mb_width
;
sl
->
mb_x
++
)
{
unsigned
mb_type
;
sl
->
mb_xy
=
h
->
mb_x
+
h
->
mb_y
*
h
->
mb_stride
;
sl
->
mb_xy
=
sl
->
mb_x
+
sl
->
mb_y
*
h
->
mb_stride
;
if
((
get_bits_count
(
&
h
->
gb
)
+
7
)
>=
h
->
gb
.
size_in_bits
&&
((
get_bits_count
(
&
h
->
gb
)
&
7
)
==
0
||
...
...
@@ -1270,7 +1270,7 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
mb_type
+=
4
;
if
(
mb_type
>
33
||
svq3_decode_mb
(
s
,
mb_type
))
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"error while decoding MB %d %d
\n
"
,
h
->
mb_x
,
h
->
mb_y
);
"error while decoding MB %d %d
\n
"
,
sl
->
mb_x
,
sl
->
mb_y
);
return
-
1
;
}
...
...
@@ -1278,13 +1278,13 @@ static int svq3_decode_frame(AVCodecContext *avctx, void *data,
ff_h264_hl_decode_mb
(
h
,
&
h
->
slice_ctx
[
0
]);
if
(
h
->
pict_type
!=
AV_PICTURE_TYPE_B
&&
!
h
->
low_delay
)
h
->
cur_pic
.
mb_type
[
h
->
mb_x
+
h
->
mb_y
*
h
->
mb_stride
]
=
h
->
cur_pic
.
mb_type
[
sl
->
mb_x
+
sl
->
mb_y
*
h
->
mb_stride
]
=
(
h
->
pict_type
==
AV_PICTURE_TYPE_P
&&
mb_type
<
8
)
?
(
mb_type
-
1
)
:
-
1
;
}
ff_draw_horiz_band
(
avctx
,
&
s
->
cur_pic
->
f
,
s
->
last_pic
->
f
.
data
[
0
]
?
&
s
->
last_pic
->
f
:
NULL
,
16
*
h
->
mb_y
,
16
,
h
->
picture_structure
,
0
,
16
*
sl
->
mb_y
,
16
,
h
->
picture_structure
,
0
,
h
->
low_delay
);
}
...
...
libavcodec/vaapi_h264.c
View file @
d4d9068c
...
...
@@ -329,7 +329,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
if
(
!
slice_param
)
return
-
1
;
slice_param
->
slice_data_bit_offset
=
get_bits_count
(
&
h
->
gb
)
+
8
;
/* bit buffer started beyond nal_unit_type */
slice_param
->
first_mb_in_slice
=
(
h
->
mb_y
>>
FIELD_OR_MBAFF_PICTURE
(
h
))
*
h
->
mb_width
+
h
->
mb_x
;
slice_param
->
first_mb_in_slice
=
(
sl
->
mb_y
>>
FIELD_OR_MBAFF_PICTURE
(
h
))
*
h
->
mb_width
+
sl
->
mb_x
;
slice_param
->
slice_type
=
ff_h264_get_slice_type
(
sl
);
slice_param
->
direct_spatial_mv_pred_flag
=
sl
->
slice_type
==
AV_PICTURE_TYPE_B
?
sl
->
direct_spatial_mv_pred
:
0
;
slice_param
->
num_ref_idx_l0_active_minus1
=
sl
->
list_count
>
0
?
sl
->
ref_count
[
0
]
-
1
:
0
;
...
...
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