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
89d7f926
Commit
89d7f926
authored
Nov 11, 2011
by
Sebastien Zwickert
Committed by
Michael Niedermayer
Nov 11, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vda: use fast reallocation.
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
7437db84
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
24 deletions
+40
-24
vda.c
libavcodec/vda.c
+6
-0
vda.h
libavcodec/vda.h
+24
-0
vda_h264.c
libavcodec/vda_h264.c
+10
-24
No files found.
libavcodec/vda.c
View file @
89d7f926
...
...
@@ -168,6 +168,9 @@ int ff_vda_create_decoder(struct vda_context *vda_ctx,
CFMutableDictionaryRef
io_surface_properties
;
CFNumberRef
cv_pix_fmt
;
vda_ctx
->
bitstream
=
NULL
;
vda_ctx
->
ref_size
=
0
;
if
(
av_lockmgr_register
(
vda_lock_operation
))
return
-
1
;
...
...
@@ -239,6 +242,9 @@ int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
if
(
vda_ctx
->
queue_mutex
!=
NULL
)
vda_lock_operation
(
&
vda_ctx
->
queue_mutex
,
AV_LOCK_DESTROY
);
if
(
vda_ctx
->
bitstream
)
av_freep
(
&
vda_ctx
->
bitstream
);
if
(
kVDADecoderNoErr
!=
status
)
return
status
;
...
...
libavcodec/vda.h
View file @
89d7f926
...
...
@@ -129,6 +129,30 @@ struct vda_context {
* - decoding: Set/Unset by user.
*/
OSType
cv_pix_fmt_type
;
/**
* The current bitstream buffer.
*
* - encoding: unused
* - decoding: Set/Unset by libavcodec.
*/
uint8_t
*
bitstream
;
/**
* The current size of the bitstream.
*
* - encoding: unused
* - decoding: Set/Unset by libavcodec.
*/
int
bitstream_size
;
/**
* The reference size used for fast reallocation.
*
* - encoding: unused
* - decoding: Set/Unset by libavcodec.
*/
int
ref_size
;
};
/** Creates the video decoder. */
...
...
libavcodec/vda_h264.c
View file @
89d7f926
...
...
@@ -22,25 +22,16 @@
#include "vda_internal.h"
/* This structure is used to store the bitstream of the current frame. */
struct
vda_picture_context
{
uint8_t
*
bitstream
;
int
bitstream_size
;
};
static
int
start_frame
(
AVCodecContext
*
avctx
,
av_unused
const
uint8_t
*
buffer
,
av_unused
uint32_t
size
)
{
const
H264Context
*
h
=
avctx
->
priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
struct
vda_picture_context
*
pic_ctx
=
h
->
s
.
current_picture_ptr
->
f
.
hwaccel_picture_private
;
if
(
!
vda_ctx
->
decoder
)
return
-
1
;
pic_ctx
->
bitstream
=
NULL
;
pic_ctx
->
bitstream_size
=
0
;
vda_ctx
->
bitstream_size
=
0
;
return
0
;
}
...
...
@@ -49,24 +40,22 @@ static int decode_slice(AVCodecContext *avctx,
const
uint8_t
*
buffer
,
uint32_t
size
)
{
H264Context
*
h
=
avctx
->
priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
struct
vda_picture_context
*
pic_ctx
=
h
->
s
.
current_picture_ptr
->
f
.
hwaccel_picture_private
;
void
*
tmp
;
if
(
!
vda_ctx
->
decoder
)
return
-
1
;
tmp
=
av_
realloc
(
pic_ctx
->
bitstream
,
pic
_ctx
->
bitstream_size
+
size
+
4
);
tmp
=
av_
fast_realloc
(
vda_ctx
->
bitstream
,
&
vda_ctx
->
ref_size
,
vda
_ctx
->
bitstream_size
+
size
+
4
);
if
(
!
tmp
)
return
AVERROR
(
ENOMEM
);
pic
_ctx
->
bitstream
=
tmp
;
vda
_ctx
->
bitstream
=
tmp
;
AV_WB32
(
pic_ctx
->
bitstream
+
pic
_ctx
->
bitstream_size
,
size
);
memcpy
(
pic_ctx
->
bitstream
+
pic
_ctx
->
bitstream_size
+
4
,
buffer
,
size
);
AV_WB32
(
vda_ctx
->
bitstream
+
vda
_ctx
->
bitstream_size
,
size
);
memcpy
(
vda_ctx
->
bitstream
+
vda
_ctx
->
bitstream_size
+
4
,
buffer
,
size
);
pic
_ctx
->
bitstream_size
+=
size
+
4
;
vda
_ctx
->
bitstream_size
+=
size
+
4
;
return
0
;
}
...
...
@@ -75,22 +64,19 @@ static int end_frame(AVCodecContext *avctx)
{
H264Context
*
h
=
avctx
->
priv_data
;
struct
vda_context
*
vda_ctx
=
avctx
->
hwaccel_context
;
struct
vda_picture_context
*
pic_ctx
=
h
->
s
.
current_picture_ptr
->
f
.
hwaccel_picture_private
;
AVFrame
*
frame
=
(
AVFrame
*
)
h
->
s
.
current_picture_ptr
;
int
status
;
if
(
!
vda_ctx
->
decoder
||
!
pic
_ctx
->
bitstream
)
if
(
!
vda_ctx
->
decoder
||
!
vda
_ctx
->
bitstream
)
return
-
1
;
status
=
ff_vda_decoder_decode
(
vda_ctx
,
pic
_ctx
->
bitstream
,
pic
_ctx
->
bitstream_size
,
status
=
ff_vda_decoder_decode
(
vda_ctx
,
vda
_ctx
->
bitstream
,
vda
_ctx
->
bitstream_size
,
frame
->
reordered_opaque
);
if
(
status
)
av_log
(
avctx
,
AV_LOG_ERROR
,
"Failed to decode frame (%d)
\n
"
,
status
);
av_freep
(
&
pic_ctx
->
bitstream
);
return
status
;
}
...
...
@@ -103,5 +89,5 @@ AVHWAccel ff_h264_vda_hwaccel = {
.
start_frame
=
start_frame
,
.
decode_slice
=
decode_slice
,
.
end_frame
=
end_frame
,
.
priv_data_size
=
sizeof
(
struct
vda_picture_context
)
,
.
priv_data_size
=
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