summaryrefslogtreecommitdiff
path: root/ffmpeg_opt.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-05-08 22:39:20 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-05-08 22:39:39 +0100
commit172d3568b38c6d0c872293bbffa947a43a8d86ec (patch)
tree6f7472f32b167dbdd8384b3eeb117ad1476476c1 /ffmpeg_opt.c
parent01938585f4cedbcabb3c879214c24b3fd4f91dcf (diff)
parent5d273d3efac340ef8de445c955ff44c7abed4e8f (diff)
downloadffmpeg-172d3568b38c6d0c872293bbffa947a43a8d86ec.tar.gz
Merge commit '5d273d3efac340ef8de445c955ff44c7abed4e8f'
* commit '5d273d3efac340ef8de445c955ff44c7abed4e8f': avconv: VAAPI hwcontext initialisation and hwaccel helper Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'ffmpeg_opt.c')
-rw-r--r--ffmpeg_opt.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 00d91c8295..c2174626be 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -81,8 +81,13 @@ const HWAccel hwaccels[] = {
#if CONFIG_LIBMFX
{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV },
#endif
+#if CONFIG_VAAPI
+ { "vaapi", vaapi_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI },
+#endif
{ 0 },
};
+int hwaccel_lax_profile_check = 0;
+AVBufferRef *hw_device_ctx;
char *vstats_filename;
char *sdp_filename;
@@ -441,6 +446,17 @@ static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
return 0;
}
+#if CONFIG_VAAPI
+static int opt_vaapi_device(void *optctx, const char *opt, const char *arg)
+{
+ int err;
+ err = vaapi_device_init(arg);
+ if (err < 0)
+ exit_program(1);
+ return 0;
+}
+#endif
+
/**
* Parse a metadata specifier passed as 'arg' parameter.
* @param arg metadata string to parse
@@ -633,6 +649,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
AVCodecContext *dec = st->codec;
InputStream *ist = av_mallocz(sizeof(*ist));
char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
+ char *hwaccel_output_format = NULL;
char *codec_tag = NULL;
char *next;
char *discard_str = NULL;
@@ -752,6 +769,19 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
if (!ist->hwaccel_device)
exit_program(1);
}
+
+ MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
+ hwaccel_output_format, ic, st);
+ if (hwaccel_output_format) {
+ ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
+ if (ist->hwaccel_output_format == AV_PIX_FMT_NONE) {
+ av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
+ "format: %s", hwaccel_output_format);
+ }
+ } else {
+ ist->hwaccel_output_format = AV_PIX_FMT_NONE;
+ }
+
ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;
break;
@@ -3348,6 +3378,12 @@ const OptionDef options[] = {
{ "hwaccel_device", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_devices) },
"select a device for HW acceleration", "devicename" },
+ { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
+ OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
+ "select output format used with HW accelerated decoding", "format" },
+ { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
+ OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
+ "select output format used with HW accelerated decoding", "format" },
#if CONFIG_VDA || CONFIG_VIDEOTOOLBOX
{ "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
#endif
@@ -3356,6 +3392,8 @@ const OptionDef options[] = {
{ "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) },
"automatically insert correct rotate filters" },
+ { "hwaccel_lax_profile_check", OPT_BOOL | OPT_EXPERT, { &hwaccel_lax_profile_check},
+ "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream" },
/* audio options */
{ "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },
@@ -3439,5 +3477,10 @@ const OptionDef options[] = {
{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
"disable data" },
+#if CONFIG_VAAPI
+ { "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
+ "set VAAPI hardware device (DRM path or X11 display name)", "device" },
+#endif
+
{ NULL, },
};