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
1c9e8616
Commit
1c9e8616
authored
May 19, 2016
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hwcontext: add a function for opening devices
parent
24b5cff0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
1 deletion
+71
-1
APIchanges
doc/APIchanges
+3
-0
hwcontext.c
libavutil/hwcontext.c
+36
-0
hwcontext.h
libavutil/hwcontext.h
+28
-0
hwcontext_internal.h
libavutil/hwcontext_internal.h
+3
-0
version.h
libavutil/version.h
+1
-1
No files found.
doc/APIchanges
View file @
1c9e8616
...
...
@@ -13,6 +13,9 @@ libavutil: 2015-08-28
API changes, most recent first:
2016-xx-xx - xxxxxxx - lavu 55.13.0 - hwcontext.h
Add av_hwdevice_ctx_create().
2016-xx-xx - xxxxxxx - lavc 57.19.1 - avcodec.h
Adjust values for JPEG 2000 profiles.
...
...
libavutil/hwcontext.c
View file @
1c9e8616
...
...
@@ -452,3 +452,39 @@ void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
}
av_freep
(
constraints
);
}
int
av_hwdevice_ctx_create
(
AVBufferRef
**
pdevice_ref
,
enum
AVHWDeviceType
type
,
const
char
*
device
,
AVDictionary
*
opts
,
int
flags
)
{
AVBufferRef
*
device_ref
=
NULL
;
AVHWDeviceContext
*
device_ctx
;
int
ret
=
0
;
device_ref
=
av_hwdevice_ctx_alloc
(
type
);
if
(
!
device_ref
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
device_ctx
=
(
AVHWDeviceContext
*
)
device_ref
->
data
;
if
(
!
device_ctx
->
internal
->
hw_type
->
device_create
)
{
ret
=
AVERROR
(
ENOSYS
);
goto
fail
;
}
ret
=
device_ctx
->
internal
->
hw_type
->
device_create
(
device_ctx
,
device
,
opts
,
flags
);
if
(
ret
<
0
)
goto
fail
;
ret
=
av_hwdevice_ctx_init
(
device_ref
);
if
(
ret
<
0
)
goto
fail
;
*
pdevice_ref
=
device_ref
;
return
0
;
fail:
av_buffer_unref
(
&
device_ref
);
*
pdevice_ref
=
NULL
;
return
ret
;
}
libavutil/hwcontext.h
View file @
1c9e8616
...
...
@@ -241,6 +241,34 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type);
*/
int
av_hwdevice_ctx_init
(
AVBufferRef
*
ref
);
/**
* Open a device of the specified type and create an AVHWDeviceContext for it.
*
* This is a convenience function intended to cover the simple cases. Callers
* who need to fine-tune device creation/management should open the device
* manually and then wrap it in an AVHWDeviceContext using
* av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
*
* The returned context is already initialized and ready for use, the caller
* should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
* the created AVHWDeviceContext are set by this function and should not be
* touched by the caller.
*
* @param device_ctx On success, a reference to the newly-created device context
* will be written here. The reference is owned by the caller
* and must be released with av_buffer_unref() when no longer
* needed. On failure, NULL will be written to this pointer.
* @param type The type of the device to create.
* @param device A type-specific string identifying the device to open.
* @param opts A dictionary of additional (type-specific) options to use in
* opening the device. The dictionary remains owned by the caller.
* @param flags currently unused
*
* @return 0 on success, a negative AVERROR code on failure.
*/
int
av_hwdevice_ctx_create
(
AVBufferRef
**
device_ctx
,
enum
AVHWDeviceType
type
,
const
char
*
device
,
AVDictionary
*
opts
,
int
flags
);
/**
* Allocate an AVHWFramesContext tied to a given device context.
*
...
...
libavutil/hwcontext_internal.h
View file @
1c9e8616
...
...
@@ -64,6 +64,9 @@ typedef struct HWContextType {
*/
size_t
frames_priv_size
;
int
(
*
device_create
)(
AVHWDeviceContext
*
ctx
,
const
char
*
device
,
AVDictionary
*
opts
,
int
flags
);
int
(
*
device_init
)(
AVHWDeviceContext
*
ctx
);
void
(
*
device_uninit
)(
AVHWDeviceContext
*
ctx
);
...
...
libavutil/version.h
View file @
1c9e8616
...
...
@@ -54,7 +54,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 1
2
#define LIBAVUTIL_VERSION_MINOR 1
3
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
...
...
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