Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Mira
ffmpeg
Commits
9b62a2ea
Commit
9b62a2ea
authored
Nov 25, 2022
by
Sebastian Jedruszkiewicz
Browse files
Alloc hw_frames_ctx for hw frames wrapped in AVFrames.
parent
a2a9d14c
Changes
1
Hide whitespace changes
Inline
Side-by-side
libavcodec/mediacodecdec_common.c
View file @
9b62a2ea
...
...
@@ -326,6 +326,31 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
buffer
->
pts
=
info
->
presentationTimeUs
;
frame
->
data
[
3
]
=
(
uint8_t
*
)
buffer
;
if
(
!
frame
->
hw_frames_ctx
)
{
AVHWFramesContext
*
hwframes_ctx
;
AVBufferRef
*
hw_frames_ctx
=
av_hwframe_ctx_alloc
(
avctx
->
hw_device_ctx
);
if
(
!
avctx
->
hw_frames_ctx
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"av_hwframe_ctx_alloc failed
\n
"
);
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
hwframes_ctx
=
(
AVHWFramesContext
*
)
hw_frames_ctx
->
data
;
hwframes_ctx
->
width
=
avctx
->
width
;
hwframes_ctx
->
height
=
avctx
->
height
;
hwframes_ctx
->
format
=
AV_PIX_FMT_MEDIACODEC
;
hwframes_ctx
->
sw_format
=
avctx
->
sw_pix_fmt
;
ret
=
av_hwframe_ctx_init
(
avctx
->
hw_frames_ctx
);
if
(
ret
<
0
)
{
av_log
(
NULL
,
AV_LOG_ERROR
,
"Error initializing hwframe ctx
\n
"
);
av_buffer_unref
(
&
hw_frames_ctx
);
goto
fail
;
}
frame
->
hw_frames_ctx
=
av_buffer_ref
(
hw_frames_ctx
);
}
atomic_fetch_add
(
&
s
->
hw_buffer_count
,
1
);
av_log
(
avctx
,
AV_LOG_DEBUG
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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