Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
d2e6dd32
Commit
d2e6dd32
authored
Mar 04, 2017
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: Generic device setup
Not yet enabled for any hwaccels.
parent
b7487f4f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
6 deletions
+69
-6
Makefile
avtools/Makefile
+2
-1
avconv.c
avtools/avconv.c
+22
-0
avconv.h
avtools/avconv.h
+17
-0
avconv_hw.c
avtools/avconv_hw.c
+0
-0
avconv_opt.c
avtools/avconv_opt.c
+28
-5
No files found.
avtools/Makefile
View file @
d2e6dd32
...
...
@@ -8,7 +8,8 @@ PROGS += $(AVPROGS)
AVBASENAMES
=
avconv avplay avprobe
ALLAVPROGS
=
$
(
AVBASENAMES:%
=
%
$(EXESUF)
)
OBJS-avconv
+=
avtools/avconv_opt.o avtools/avconv_filter.o
OBJS-avconv
+=
avtools/avconv_opt.o avtools/avconv_filter.o
\
avtools/avconv_hw.o
OBJS-avconv-$(CONFIG_LIBMFX)
+=
avtools/avconv_qsv.o
OBJS-avconv-$(CONFIG_VAAPI)
+=
avtools/avconv_vaapi.o
OBJS-avconv-$(CONFIG_VDA)
+=
avtools/avconv_vda.o
...
...
avtools/avconv.c
View file @
d2e6dd32
...
...
@@ -1704,6 +1704,17 @@ static int init_input_stream(int ist_index, char *error, int error_len)
if
(
!
av_dict_get
(
ist
->
decoder_opts
,
"threads"
,
NULL
,
0
))
av_dict_set
(
&
ist
->
decoder_opts
,
"threads"
,
"auto"
,
0
);
ret
=
hw_device_setup_for_decode
(
ist
);
if
(
ret
<
0
)
{
char
errbuf
[
128
];
av_strerror
(
ret
,
errbuf
,
sizeof
(
errbuf
));
snprintf
(
error
,
error_len
,
"Device setup failed for "
"decoder on input stream #%d:%d : %s"
,
ist
->
file_index
,
ist
->
st
->
index
,
errbuf
);
return
ret
;
}
if
((
ret
=
avcodec_open2
(
ist
->
dec_ctx
,
codec
,
&
ist
->
decoder_opts
))
<
0
)
{
char
errbuf
[
128
];
if
(
ret
==
AVERROR_EXPERIMENTAL
)
...
...
@@ -2046,6 +2057,16 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
ost
->
enc_ctx
->
hw_frames_ctx
=
av_buffer_ref
(
ost
->
filter
->
filter
->
inputs
[
0
]
->
hw_frames_ctx
);
if
(
!
ost
->
enc_ctx
->
hw_frames_ctx
)
return
AVERROR
(
ENOMEM
);
}
else
{
ret
=
hw_device_setup_for_encode
(
ost
);
if
(
ret
<
0
)
{
char
errbuf
[
128
];
av_strerror
(
ret
,
errbuf
,
sizeof
(
errbuf
));
snprintf
(
error
,
error_len
,
"Device setup failed for "
"encoder on output stream #%d:%d : %s"
,
ost
->
file_index
,
ost
->
index
,
errbuf
);
return
ret
;
}
}
if
((
ret
=
avcodec_open2
(
ost
->
enc_ctx
,
codec
,
&
ost
->
encoder_opts
))
<
0
)
{
...
...
@@ -2795,6 +2816,7 @@ static int transcode(void)
}
av_buffer_unref
(
&
hw_device_ctx
);
hw_device_free_all
();
/* finished ! */
ret
=
0
;
...
...
avtools/avconv.h
View file @
d2e6dd32
...
...
@@ -40,6 +40,7 @@
#include "libavutil/avutil.h"
#include "libavutil/dict.h"
#include "libavutil/fifo.h"
#include "libavutil/hwcontext.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
...
...
@@ -63,8 +64,15 @@ typedef struct HWAccel {
int
(
*
init
)(
AVCodecContext
*
s
);
enum
HWAccelID
id
;
enum
AVPixelFormat
pix_fmt
;
enum
AVHWDeviceType
device_type
;
}
HWAccel
;
typedef
struct
HWDevice
{
char
*
name
;
enum
AVHWDeviceType
type
;
AVBufferRef
*
device_ref
;
}
HWDevice
;
/* select an input stream for an output stream */
typedef
struct
StreamMap
{
int
disabled
;
/* 1 is this mapping is disabled by a negative map */
...
...
@@ -510,4 +518,13 @@ int qsv_transcode_init(OutputStream *ost);
int
vaapi_decode_init
(
AVCodecContext
*
avctx
);
int
vaapi_device_init
(
const
char
*
device
);
HWDevice
*
hw_device_get_by_name
(
const
char
*
name
);
int
hw_device_init_from_string
(
const
char
*
arg
,
HWDevice
**
dev
);
void
hw_device_free_all
(
void
);
int
hw_device_setup_for_decode
(
InputStream
*
ist
);
int
hw_device_setup_for_encode
(
OutputStream
*
ost
);
int
hwaccel_decode_init
(
AVCodecContext
*
avctx
);
#endif
/* AVCONV_H */
avtools/avconv_hw.c
0 → 100644
View file @
d2e6dd32
This diff is collapsed.
Click to expand it.
avtools/avconv_opt.c
View file @
d2e6dd32
...
...
@@ -57,19 +57,24 @@
const
HWAccel
hwaccels
[]
=
{
#if HAVE_VDPAU_X11
{
"vdpau"
,
vdpau_init
,
HWACCEL_VDPAU
,
AV_PIX_FMT_VDPAU
},
{
"vdpau"
,
vdpau_init
,
HWACCEL_VDPAU
,
AV_PIX_FMT_VDPAU
,
AV_HWDEVICE_TYPE_NONE
},
#endif
#if HAVE_DXVA2_LIB
{
"dxva2"
,
dxva2_init
,
HWACCEL_DXVA2
,
AV_PIX_FMT_DXVA2_VLD
},
{
"dxva2"
,
dxva2_init
,
HWACCEL_DXVA2
,
AV_PIX_FMT_DXVA2_VLD
,
AV_HWDEVICE_TYPE_NONE
},
#endif
#if CONFIG_VDA
{
"vda"
,
vda_init
,
HWACCEL_VDA
,
AV_PIX_FMT_VDA
},
{
"vda"
,
vda_init
,
HWACCEL_VDA
,
AV_PIX_FMT_VDA
,
AV_HWDEVICE_TYPE_NONE
},
#endif
#if CONFIG_LIBMFX
{
"qsv"
,
qsv_init
,
HWACCEL_QSV
,
AV_PIX_FMT_QSV
},
{
"qsv"
,
qsv_init
,
HWACCEL_QSV
,
AV_PIX_FMT_QSV
,
AV_HWDEVICE_TYPE_NONE
},
#endif
#if CONFIG_VAAPI
{
"vaapi"
,
vaapi_decode_init
,
HWACCEL_VAAPI
,
AV_PIX_FMT_VAAPI
},
{
"vaapi"
,
vaapi_decode_init
,
HWACCEL_VAAPI
,
AV_PIX_FMT_VAAPI
,
AV_HWDEVICE_TYPE_NONE
},
#endif
{
0
},
};
...
...
@@ -337,6 +342,21 @@ static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
}
#endif
static
int
opt_init_hw_device
(
void
*
optctx
,
const
char
*
opt
,
const
char
*
arg
)
{
if
(
!
strcmp
(
arg
,
"list"
))
{
enum
AVHWDeviceType
type
=
AV_HWDEVICE_TYPE_NONE
;
printf
(
"Supported hardware device types:
\n
"
);
while
((
type
=
av_hwdevice_iterate_types
(
type
))
!=
AV_HWDEVICE_TYPE_NONE
)
printf
(
"%s
\n
"
,
av_hwdevice_get_type_name
(
type
));
printf
(
"
\n
"
);
exit_program
(
0
);
}
else
{
return
hw_device_init_from_string
(
arg
,
NULL
);
}
}
/**
* Parse a metadata specifier passed as 'arg' parameter.
* @param arg metadata string to parse
...
...
@@ -2741,5 +2761,8 @@ const OptionDef options[] = {
"set VAAPI hardware device (DRM path or X11 display name)"
,
"device"
},
#endif
{
"init_hw_device"
,
HAS_ARG
|
OPT_EXPERT
,
{
.
func_arg
=
opt_init_hw_device
},
"initialise hardware device"
,
"args"
},
{
NULL
,
},
};
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