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
b2e9b0f5
Commit
b2e9b0f5
authored
Jan 25, 2015
by
Hendrik Leppkes
Committed by
Michael Niedermayer
Jan 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hevc: add hwaccel hooks
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
06894f1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
hevc.c
libavcodec/hevc.c
+36
-2
hevc.h
libavcodec/hevc.h
+3
-0
hevc_refs.c
libavcodec/hevc_refs.c
+18
-0
No files found.
libavcodec/hevc.c
View file @
b2e9b0f5
...
@@ -300,6 +300,8 @@ static int get_buffer_sao(HEVCContext *s, AVFrame *frame, const HEVCSPS *sps)
...
@@ -300,6 +300,8 @@ static int get_buffer_sao(HEVCContext *s, AVFrame *frame, const HEVCSPS *sps)
static
int
set_sps
(
HEVCContext
*
s
,
const
HEVCSPS
*
sps
)
static
int
set_sps
(
HEVCContext
*
s
,
const
HEVCSPS
*
sps
)
{
{
#define HWACCEL_MAX (0)
enum
AVPixelFormat
pix_fmts
[
HWACCEL_MAX
+
2
],
*
fmt
=
pix_fmts
;
int
ret
;
int
ret
;
unsigned
int
num
=
0
,
den
=
0
;
unsigned
int
num
=
0
,
den
=
0
;
...
@@ -312,9 +314,16 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
...
@@ -312,9 +314,16 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
s
->
avctx
->
coded_height
=
sps
->
height
;
s
->
avctx
->
coded_height
=
sps
->
height
;
s
->
avctx
->
width
=
sps
->
output_width
;
s
->
avctx
->
width
=
sps
->
output_width
;
s
->
avctx
->
height
=
sps
->
output_height
;
s
->
avctx
->
height
=
sps
->
output_height
;
s
->
avctx
->
pix_fmt
=
sps
->
pix_fmt
;
s
->
avctx
->
has_b_frames
=
sps
->
temporal_layer
[
sps
->
max_sub_layers
-
1
].
num_reorder_pics
;
s
->
avctx
->
has_b_frames
=
sps
->
temporal_layer
[
sps
->
max_sub_layers
-
1
].
num_reorder_pics
;
*
fmt
++
=
sps
->
pix_fmt
;
*
fmt
=
AV_PIX_FMT_NONE
;
ret
=
ff_thread_get_format
(
s
->
avctx
,
pix_fmts
);
if
(
ret
<
0
)
goto
fail
;
s
->
avctx
->
pix_fmt
=
ret
;
ff_set_sar
(
s
->
avctx
,
sps
->
vui
.
sar
);
ff_set_sar
(
s
->
avctx
,
sps
->
vui
.
sar
);
if
(
sps
->
vui
.
video_signal_type_present_flag
)
if
(
sps
->
vui
.
video_signal_type_present_flag
)
...
@@ -337,7 +346,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
...
@@ -337,7 +346,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
ff_hevc_dsp_init
(
&
s
->
hevcdsp
,
sps
->
bit_depth
);
ff_hevc_dsp_init
(
&
s
->
hevcdsp
,
sps
->
bit_depth
);
ff_videodsp_init
(
&
s
->
vdsp
,
sps
->
bit_depth
);
ff_videodsp_init
(
&
s
->
vdsp
,
sps
->
bit_depth
);
if
(
sps
->
sao_enabled
)
{
if
(
sps
->
sao_enabled
&&
!
s
->
avctx
->
hwaccel
)
{
av_frame_unref
(
s
->
tmp_frame
);
av_frame_unref
(
s
->
tmp_frame
);
ret
=
get_buffer_sao
(
s
,
s
->
tmp_frame
,
sps
);
ret
=
get_buffer_sao
(
s
,
s
->
tmp_frame
,
sps
);
s
->
sao_frame
=
s
->
tmp_frame
;
s
->
sao_frame
=
s
->
tmp_frame
;
...
@@ -2686,6 +2695,17 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
...
@@ -2686,6 +2695,17 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
}
}
}
}
if
(
s
->
sh
.
first_slice_in_pic_flag
&&
s
->
avctx
->
hwaccel
)
{
ret
=
s
->
avctx
->
hwaccel
->
start_frame
(
s
->
avctx
,
NULL
,
0
);
if
(
ret
<
0
)
goto
fail
;
}
if
(
s
->
avctx
->
hwaccel
)
{
ret
=
s
->
avctx
->
hwaccel
->
decode_slice
(
s
->
avctx
,
nal
->
raw_data
,
nal
->
raw_size
);
if
(
ret
<
0
)
goto
fail
;
}
else
{
if
(
s
->
threads_number
>
1
&&
s
->
sh
.
num_entry_point_offsets
>
0
)
if
(
s
->
threads_number
>
1
&&
s
->
sh
.
num_entry_point_offsets
>
0
)
ctb_addr_ts
=
hls_slice_data_wpp
(
s
,
nal
->
data
,
nal
->
size
);
ctb_addr_ts
=
hls_slice_data_wpp
(
s
,
nal
->
data
,
nal
->
size
);
else
else
...
@@ -2698,6 +2718,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
...
@@ -2698,6 +2718,7 @@ static int decode_nal_unit(HEVCContext *s, const HEVCNAL *nal)
ret
=
ctb_addr_ts
;
ret
=
ctb_addr_ts
;
goto
fail
;
goto
fail
;
}
}
}
break
;
break
;
case
NAL_EOS_NUT
:
case
NAL_EOS_NUT
:
case
NAL_EOB_NUT
:
case
NAL_EOB_NUT
:
...
@@ -3051,6 +3072,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
...
@@ -3051,6 +3072,11 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
if
(
avctx
->
hwaccel
)
{
if
(
s
->
ref
&&
avctx
->
hwaccel
->
end_frame
(
avctx
)
<
0
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"hardware accelerator failed to decode picture
\n
"
);
}
else
{
/* verify the SEI checksum */
/* verify the SEI checksum */
if
(
avctx
->
err_recognition
&
AV_EF_CRCCHECK
&&
s
->
is_decoded
&&
if
(
avctx
->
err_recognition
&
AV_EF_CRCCHECK
&&
s
->
is_decoded
&&
s
->
is_md5
)
{
s
->
is_md5
)
{
...
@@ -3060,6 +3086,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
...
@@ -3060,6 +3086,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, void *data, int *got_output,
return
ret
;
return
ret
;
}
}
}
}
}
s
->
is_md5
=
0
;
s
->
is_md5
=
0
;
if
(
s
->
is_decoded
)
{
if
(
s
->
is_decoded
)
{
...
@@ -3103,6 +3130,13 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
...
@@ -3103,6 +3130,13 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
dst
->
flags
=
src
->
flags
;
dst
->
flags
=
src
->
flags
;
dst
->
sequence
=
src
->
sequence
;
dst
->
sequence
=
src
->
sequence
;
if
(
src
->
hwaccel_picture_private
)
{
dst
->
hwaccel_priv_buf
=
av_buffer_ref
(
src
->
hwaccel_priv_buf
);
if
(
!
dst
->
hwaccel_priv_buf
)
goto
fail
;
dst
->
hwaccel_picture_private
=
dst
->
hwaccel_priv_buf
->
data
;
}
return
0
;
return
0
;
fail:
fail:
ff_hevc_unref_frame
(
s
,
dst
,
~
0
);
ff_hevc_unref_frame
(
s
,
dst
,
~
0
);
...
...
libavcodec/hevc.h
View file @
b2e9b0f5
...
@@ -718,6 +718,9 @@ typedef struct HEVCFrame {
...
@@ -718,6 +718,9 @@ typedef struct HEVCFrame {
AVBufferRef
*
rpl_tab_buf
;
AVBufferRef
*
rpl_tab_buf
;
AVBufferRef
*
rpl_buf
;
AVBufferRef
*
rpl_buf
;
AVBufferRef
*
hwaccel_priv_buf
;
void
*
hwaccel_picture_private
;
/**
/**
* A sequence counter, so that old frames are output first
* A sequence counter, so that old frames are output first
* after a POC reset
* after a POC reset
...
...
libavcodec/hevc_refs.c
View file @
b2e9b0f5
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#include "libavutil/avassert.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixdesc.h"
#include "internal.h"
#include "internal.h"
...
@@ -46,6 +47,9 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
...
@@ -46,6 +47,9 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
frame
->
refPicList
=
NULL
;
frame
->
refPicList
=
NULL
;
frame
->
collocated_ref
=
NULL
;
frame
->
collocated_ref
=
NULL
;
av_buffer_unref
(
&
frame
->
hwaccel_priv_buf
);
frame
->
hwaccel_picture_private
=
NULL
;
}
}
}
}
...
@@ -106,6 +110,18 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
...
@@ -106,6 +110,18 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
frame
->
frame
->
top_field_first
=
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_TOP_FIELD
;
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
);
frame
->
frame
->
interlaced_frame
=
(
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_TOP_FIELD
)
||
(
s
->
picture_struct
==
AV_PICTURE_STRUCTURE_BOTTOM_FIELD
);
if
(
s
->
avctx
->
hwaccel
)
{
const
AVHWAccel
*
hwaccel
=
s
->
avctx
->
hwaccel
;
av_assert0
(
!
frame
->
hwaccel_picture_private
);
if
(
hwaccel
->
frame_priv_data_size
)
{
frame
->
hwaccel_priv_buf
=
av_buffer_allocz
(
hwaccel
->
frame_priv_data_size
);
if
(
!
frame
->
hwaccel_priv_buf
)
goto
fail
;
frame
->
hwaccel_picture_private
=
frame
->
hwaccel_priv_buf
->
data
;
}
}
return
frame
;
return
frame
;
fail:
fail:
ff_hevc_unref_frame
(
s
,
frame
,
~
0
);
ff_hevc_unref_frame
(
s
,
frame
,
~
0
);
...
@@ -390,6 +406,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
...
@@ -390,6 +406,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
if
(
!
frame
)
if
(
!
frame
)
return
NULL
;
return
NULL
;
if
(
!
s
->
avctx
->
hwaccel
)
{
if
(
!
s
->
sps
->
pixel_shift
)
{
if
(
!
s
->
sps
->
pixel_shift
)
{
for
(
i
=
0
;
frame
->
frame
->
buf
[
i
];
i
++
)
for
(
i
=
0
;
frame
->
frame
->
buf
[
i
];
i
++
)
memset
(
frame
->
frame
->
buf
[
i
]
->
data
,
1
<<
(
s
->
sps
->
bit_depth
-
1
),
memset
(
frame
->
frame
->
buf
[
i
]
->
data
,
1
<<
(
s
->
sps
->
bit_depth
-
1
),
...
@@ -402,6 +419,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
...
@@ -402,6 +419,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
1
<<
(
s
->
sps
->
bit_depth
-
1
));
1
<<
(
s
->
sps
->
bit_depth
-
1
));
}
}
}
}
}
frame
->
poc
=
poc
;
frame
->
poc
=
poc
;
frame
->
sequence
=
s
->
seq_decode
;
frame
->
sequence
=
s
->
seq_decode
;
...
...
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