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
ff8436ba
Commit
ff8436ba
authored
Mar 25, 2017
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/vp9: rename res to ret
parent
0f8ae9d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
66 deletions
+66
-66
vp9.c
libavcodec/vp9.c
+66
-66
No files found.
libavcodec/vp9.c
View file @
ff8436ba
...
...
@@ -83,11 +83,11 @@ fail:
static
int
vp9_frame_ref
(
AVCodecContext
*
avctx
,
VP9Frame
*
dst
,
VP9Frame
*
src
)
{
int
re
s
;
int
re
t
;
re
s
=
ff_thread_ref_frame
(
&
dst
->
tf
,
&
src
->
tf
);
if
(
re
s
<
0
)
return
re
s
;
re
t
=
ff_thread_ref_frame
(
&
dst
->
tf
,
&
src
->
tf
);
if
(
re
t
<
0
)
return
re
t
;
dst
->
extradata
=
av_buffer_ref
(
src
->
extradata
);
if
(
!
dst
->
extradata
)
...
...
@@ -117,13 +117,13 @@ static int update_size(AVCodecContext *avctx, int w, int h)
enum
AVPixelFormat
pix_fmts
[
HWACCEL_MAX
+
2
],
*
fmtp
=
pix_fmts
;
VP9Context
*
s
=
avctx
->
priv_data
;
uint8_t
*
p
;
int
bytesperpixel
=
s
->
bytesperpixel
,
re
s
,
cols
,
rows
;
int
bytesperpixel
=
s
->
bytesperpixel
,
re
t
,
cols
,
rows
;
av_assert0
(
w
>
0
&&
h
>
0
);
if
(
!
(
s
->
pix_fmt
==
s
->
gf_fmt
&&
w
==
s
->
w
&&
h
==
s
->
h
))
{
if
((
re
s
=
ff_set_dimensions
(
avctx
,
w
,
h
))
<
0
)
return
re
s
;
if
((
re
t
=
ff_set_dimensions
(
avctx
,
w
,
h
))
<
0
)
return
re
t
;
switch
(
s
->
pix_fmt
)
{
case
AV_PIX_FMT_YUV420P
:
...
...
@@ -148,11 +148,11 @@ static int update_size(AVCodecContext *avctx, int w, int h)
*
fmtp
++
=
s
->
pix_fmt
;
*
fmtp
=
AV_PIX_FMT_NONE
;
re
s
=
ff_thread_get_format
(
avctx
,
pix_fmts
);
if
(
re
s
<
0
)
return
re
s
;
re
t
=
ff_thread_get_format
(
avctx
,
pix_fmts
);
if
(
re
t
<
0
)
return
re
t
;
avctx
->
pix_fmt
=
re
s
;
avctx
->
pix_fmt
=
re
t
;
s
->
gf_fmt
=
s
->
pix_fmt
;
s
->
w
=
w
;
s
->
h
=
h
;
...
...
@@ -389,14 +389,14 @@ static int decode_frame_header(AVCodecContext *avctx,
const
uint8_t
*
data
,
int
size
,
int
*
ref
)
{
VP9Context
*
s
=
avctx
->
priv_data
;
int
c
,
i
,
j
,
k
,
l
,
m
,
n
,
w
,
h
,
max
,
size2
,
re
s
,
sharp
;
int
c
,
i
,
j
,
k
,
l
,
m
,
n
,
w
,
h
,
max
,
size2
,
re
t
,
sharp
;
int
last_invisible
;
const
uint8_t
*
data2
;
/* general header */
if
((
re
s
=
init_get_bits8
(
&
s
->
gb
,
data
,
size
))
<
0
)
{
if
((
re
t
=
init_get_bits8
(
&
s
->
gb
,
data
,
size
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Failed to initialize bitstream reader
\n
"
);
return
re
s
;
return
re
t
;
}
if
(
get_bits
(
&
s
->
gb
,
2
)
!=
0x2
)
{
// frame marker
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid frame marker
\n
"
);
...
...
@@ -425,8 +425,8 @@ static int decode_frame_header(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid sync code
\n
"
);
return
AVERROR_INVALIDDATA
;
}
if
((
re
s
=
read_colorspace_details
(
avctx
))
<
0
)
return
re
s
;
if
((
re
t
=
read_colorspace_details
(
avctx
))
<
0
)
return
re
t
;
// for profile 1, here follows the subsampling bits
s
->
s
.
h
.
refreshrefmask
=
0xff
;
w
=
get_bits
(
&
s
->
gb
,
16
)
+
1
;
...
...
@@ -442,8 +442,8 @@ static int decode_frame_header(AVCodecContext *avctx,
return
AVERROR_INVALIDDATA
;
}
if
(
avctx
->
profile
>=
1
)
{
if
((
re
s
=
read_colorspace_details
(
avctx
))
<
0
)
return
re
s
;
if
((
re
t
=
read_colorspace_details
(
avctx
))
<
0
)
return
re
t
;
}
else
{
s
->
ss_h
=
s
->
ss_v
=
1
;
s
->
s
.
h
.
bpp
=
8
;
...
...
@@ -636,10 +636,10 @@ static int decode_frame_header(AVCodecContext *avctx,
}
/* tiling info */
if
((
re
s
=
update_size
(
avctx
,
w
,
h
))
<
0
)
{
if
((
re
t
=
update_size
(
avctx
,
w
,
h
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Failed to initialize decoder for %dx%d @ %d
\n
"
,
w
,
h
,
s
->
pix_fmt
);
return
re
s
;
return
re
t
;
}
for
(
s
->
s
.
h
.
tiling
.
log2_tile_cols
=
0
;
s
->
sb_cols
>
(
64
<<
s
->
s
.
h
.
tiling
.
log2_tile_cols
);
...
...
@@ -719,9 +719,9 @@ static int decode_frame_header(AVCodecContext *avctx,
av_log
(
avctx
,
AV_LOG_ERROR
,
"Invalid compressed header size
\n
"
);
return
AVERROR_INVALIDDATA
;
}
re
s
=
ff_vp56_init_range_decoder
(
&
s
->
c
,
data2
,
size2
);
if
(
re
s
<
0
)
return
re
s
;
re
t
=
ff_vp56_init_range_decoder
(
&
s
->
c
,
data2
,
size2
);
if
(
re
t
<
0
)
return
re
t
;
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c
,
128
))
{
// marker bit
av_log
(
avctx
,
AV_LOG_ERROR
,
"Marker bit was set
\n
"
);
...
...
@@ -1273,22 +1273,22 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
const
uint8_t
*
data
=
pkt
->
data
;
int
size
=
pkt
->
size
;
VP9Context
*
s
=
avctx
->
priv_data
;
int
re
s
,
tile_row
,
tile_col
,
i
,
ref
,
row
,
col
;
int
re
t
,
tile_row
,
tile_col
,
i
,
ref
,
row
,
col
;
int
retain_segmap_ref
=
s
->
s
.
frames
[
REF_FRAME_SEGMAP
].
segmentation_map
&&
(
!
s
->
s
.
h
.
segmentation
.
enabled
||
!
s
->
s
.
h
.
segmentation
.
update_map
);
ptrdiff_t
yoff
,
uvoff
,
ls_y
,
ls_uv
;
AVFrame
*
f
;
int
bytesperpixel
;
if
((
re
s
=
decode_frame_header
(
avctx
,
data
,
size
,
&
ref
))
<
0
)
{
return
re
s
;
}
else
if
(
re
s
==
0
)
{
if
((
re
t
=
decode_frame_header
(
avctx
,
data
,
size
,
&
ref
))
<
0
)
{
return
re
t
;
}
else
if
(
re
t
==
0
)
{
if
(
!
s
->
s
.
refs
[
ref
].
f
->
buf
[
0
])
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Requested reference %d not available
\n
"
,
ref
);
return
AVERROR_INVALIDDATA
;
}
if
((
re
s
=
av_frame_ref
(
frame
,
s
->
s
.
refs
[
ref
].
f
))
<
0
)
return
re
s
;
if
((
re
t
=
av_frame_ref
(
frame
,
s
->
s
.
refs
[
ref
].
f
))
<
0
)
return
re
t
;
((
AVFrame
*
)
frame
)
->
pts
=
pkt
->
pts
;
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
...
...
@@ -1300,31 +1300,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
if
(
s
->
next_refs
[
i
].
f
->
buf
[
0
])
ff_thread_release_buffer
(
avctx
,
&
s
->
next_refs
[
i
]);
if
(
s
->
s
.
refs
[
i
].
f
->
buf
[
0
]
&&
(
re
s
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
refs
[
i
]))
<
0
)
return
re
s
;
(
re
t
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
refs
[
i
]))
<
0
)
return
re
t
;
}
*
got_frame
=
1
;
return
pkt
->
size
;
}
data
+=
re
s
;
size
-=
re
s
;
data
+=
re
t
;
size
-=
re
t
;
if
(
!
retain_segmap_ref
||
s
->
s
.
h
.
keyframe
||
s
->
s
.
h
.
intraonly
)
{
if
(
s
->
s
.
frames
[
REF_FRAME_SEGMAP
].
tf
.
f
->
buf
[
0
])
vp9_frame_unref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_SEGMAP
]);
if
(
!
s
->
s
.
h
.
keyframe
&&
!
s
->
s
.
h
.
intraonly
&&
!
s
->
s
.
h
.
errorres
&&
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
->
buf
[
0
]
&&
(
re
s
=
vp9_frame_ref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_SEGMAP
],
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
s
;
(
re
t
=
vp9_frame_ref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_SEGMAP
],
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
t
;
}
if
(
s
->
s
.
frames
[
REF_FRAME_MVPAIR
].
tf
.
f
->
buf
[
0
])
vp9_frame_unref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_MVPAIR
]);
if
(
!
s
->
s
.
h
.
intraonly
&&
!
s
->
s
.
h
.
keyframe
&&
!
s
->
s
.
h
.
errorres
&&
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
->
buf
[
0
]
&&
(
re
s
=
vp9_frame_ref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_MVPAIR
],
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
s
;
(
re
t
=
vp9_frame_ref
(
avctx
,
&
s
->
s
.
frames
[
REF_FRAME_MVPAIR
],
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
t
;
if
(
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
->
buf
[
0
])
vp9_frame_unref
(
avctx
,
&
s
->
s
.
frames
[
CUR_FRAME
]);
if
((
re
s
=
vp9_frame_alloc
(
avctx
,
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
s
;
if
((
re
t
=
vp9_frame_alloc
(
avctx
,
&
s
->
s
.
frames
[
CUR_FRAME
]))
<
0
)
return
re
t
;
f
=
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
;
f
->
key_frame
=
s
->
s
.
h
.
keyframe
;
f
->
pict_type
=
(
s
->
s
.
h
.
keyframe
||
s
->
s
.
h
.
intraonly
)
?
AV_PICTURE_TYPE_I
:
AV_PICTURE_TYPE_P
;
...
...
@@ -1342,24 +1342,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
if
(
s
->
next_refs
[
i
].
f
->
buf
[
0
])
ff_thread_release_buffer
(
avctx
,
&
s
->
next_refs
[
i
]);
if
(
s
->
s
.
h
.
refreshrefmask
&
(
1
<<
i
))
{
re
s
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
frames
[
CUR_FRAME
].
tf
);
re
t
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
frames
[
CUR_FRAME
].
tf
);
}
else
if
(
s
->
s
.
refs
[
i
].
f
->
buf
[
0
])
{
re
s
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
refs
[
i
]);
re
t
=
ff_thread_ref_frame
(
&
s
->
next_refs
[
i
],
&
s
->
s
.
refs
[
i
]);
}
if
(
re
s
<
0
)
return
re
s
;
if
(
re
t
<
0
)
return
re
t
;
}
if
(
avctx
->
hwaccel
)
{
re
s
=
avctx
->
hwaccel
->
start_frame
(
avctx
,
NULL
,
0
);
if
(
re
s
<
0
)
return
re
s
;
re
s
=
avctx
->
hwaccel
->
decode_slice
(
avctx
,
pkt
->
data
,
pkt
->
size
);
if
(
re
s
<
0
)
return
re
s
;
re
s
=
avctx
->
hwaccel
->
end_frame
(
avctx
);
if
(
re
s
<
0
)
return
re
s
;
re
t
=
avctx
->
hwaccel
->
start_frame
(
avctx
,
NULL
,
0
);
if
(
re
t
<
0
)
return
re
t
;
re
t
=
avctx
->
hwaccel
->
decode_slice
(
avctx
,
pkt
->
data
,
pkt
->
size
);
if
(
re
t
<
0
)
return
re
t
;
re
t
=
avctx
->
hwaccel
->
end_frame
(
avctx
);
if
(
re
t
<
0
)
return
re
t
;
goto
finish
;
}
...
...
@@ -1378,10 +1378,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
memset
(
s
->
above_segpred_ctx
,
0
,
s
->
cols
);
s
->
pass
=
s
->
s
.
frames
[
CUR_FRAME
].
uses_2pass
=
avctx
->
active_thread_type
==
FF_THREAD_FRAME
&&
s
->
s
.
h
.
refreshctx
&&
!
s
->
s
.
h
.
parallelmode
;
if
((
re
s
=
update_block_buffers
(
avctx
))
<
0
)
{
if
((
re
t
=
update_block_buffers
(
avctx
))
<
0
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Failed to allocate block buffers
\n
"
);
return
re
s
;
return
re
t
;
}
if
(
s
->
s
.
h
.
refreshctx
&&
s
->
s
.
h
.
parallelmode
)
{
int
j
,
k
,
l
,
m
;
...
...
@@ -1431,9 +1431,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_thread_report_progress
(
&
s
->
s
.
frames
[
CUR_FRAME
].
tf
,
INT_MAX
,
0
);
return
AVERROR_INVALIDDATA
;
}
re
s
=
ff_vp56_init_range_decoder
(
&
s
->
c_b
[
tile_col
],
data
,
tile_size
);
if
(
re
s
<
0
)
return
re
s
;
re
t
=
ff_vp56_init_range_decoder
(
&
s
->
c_b
[
tile_col
],
data
,
tile_size
);
if
(
re
t
<
0
)
return
re
t
;
if
(
vp56_rac_get_prob_branchy
(
&
s
->
c_b
[
tile_col
],
128
))
{
// marker bit
ff_thread_report_progress
(
&
s
->
s
.
frames
[
CUR_FRAME
].
tf
,
INT_MAX
,
0
);
return
AVERROR_INVALIDDATA
;
...
...
@@ -1540,13 +1540,13 @@ finish:
if
(
s
->
s
.
refs
[
i
].
f
->
buf
[
0
])
ff_thread_release_buffer
(
avctx
,
&
s
->
s
.
refs
[
i
]);
if
(
s
->
next_refs
[
i
].
f
->
buf
[
0
]
&&
(
re
s
=
ff_thread_ref_frame
(
&
s
->
s
.
refs
[
i
],
&
s
->
next_refs
[
i
]))
<
0
)
return
re
s
;
(
re
t
=
ff_thread_ref_frame
(
&
s
->
s
.
refs
[
i
],
&
s
->
next_refs
[
i
]))
<
0
)
return
re
t
;
}
if
(
!
s
->
s
.
h
.
invisible
)
{
if
((
re
s
=
av_frame_ref
(
frame
,
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
))
<
0
)
return
re
s
;
if
((
re
t
=
av_frame_ref
(
frame
,
s
->
s
.
frames
[
CUR_FRAME
].
tf
.
f
))
<
0
)
return
re
t
;
*
got_frame
=
1
;
}
...
...
@@ -1609,23 +1609,23 @@ static av_cold int vp9_decode_init_thread_copy(AVCodecContext *avctx)
static
int
vp9_decode_update_thread_context
(
AVCodecContext
*
dst
,
const
AVCodecContext
*
src
)
{
int
i
,
re
s
;
int
i
,
re
t
;
VP9Context
*
s
=
dst
->
priv_data
,
*
ssrc
=
src
->
priv_data
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
s
->
s
.
frames
[
i
].
tf
.
f
->
buf
[
0
])
vp9_frame_unref
(
dst
,
&
s
->
s
.
frames
[
i
]);
if
(
ssrc
->
s
.
frames
[
i
].
tf
.
f
->
buf
[
0
])
{
if
((
re
s
=
vp9_frame_ref
(
dst
,
&
s
->
s
.
frames
[
i
],
&
ssrc
->
s
.
frames
[
i
]))
<
0
)
return
re
s
;
if
((
re
t
=
vp9_frame_ref
(
dst
,
&
s
->
s
.
frames
[
i
],
&
ssrc
->
s
.
frames
[
i
]))
<
0
)
return
re
t
;
}
}
for
(
i
=
0
;
i
<
8
;
i
++
)
{
if
(
s
->
s
.
refs
[
i
].
f
->
buf
[
0
])
ff_thread_release_buffer
(
dst
,
&
s
->
s
.
refs
[
i
]);
if
(
ssrc
->
next_refs
[
i
].
f
->
buf
[
0
])
{
if
((
re
s
=
ff_thread_ref_frame
(
&
s
->
s
.
refs
[
i
],
&
ssrc
->
next_refs
[
i
]))
<
0
)
return
re
s
;
if
((
re
t
=
ff_thread_ref_frame
(
&
s
->
s
.
refs
[
i
],
&
ssrc
->
next_refs
[
i
]))
<
0
)
return
re
t
;
}
}
...
...
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