summaryrefslogtreecommitdiff
path: root/avconv_opt.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-02 22:06:36 +0100
committerAnton Khirnov <anton@khirnov.net>2013-11-23 11:55:43 +0100
commit07fd0a22192805d56c635eb294dc26b0a54ae325 (patch)
tree1ee9675c6b69f5cde5e44bbb31a9d5856894cbe0 /avconv_opt.c
parentd4df02131b5522a99a4e6035368484e809706ed5 (diff)
downloadffmpeg-07fd0a22192805d56c635eb294dc26b0a54ae325.tar.gz
avconv: add infrastructure for using hwaccels
Diffstat (limited to 'avconv_opt.c')
-rw-r--r--avconv_opt.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/avconv_opt.c b/avconv_opt.c
index 70cbd719cd..cbd8370eba 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -53,6 +53,10 @@
}\
}
+const HWAccel hwaccels[] = {
+ { 0 },
+};
+
char *vstats_filename;
float audio_drift_threshold = 0.1;
@@ -455,7 +459,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
AVStream *st = ic->streams[i];
AVCodecContext *dec = st->codec;
InputStream *ist = av_mallocz(sizeof(*ist));
- char *framerate = NULL;
+ char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
if (!ist)
exit_program(1);
@@ -488,6 +492,40 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
exit_program(1);
}
+ MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
+ if (hwaccel) {
+ if (!strcmp(hwaccel, "none"))
+ ist->hwaccel_id = HWACCEL_NONE;
+ else if (!strcmp(hwaccel, "auto"))
+ ist->hwaccel_id = HWACCEL_AUTO;
+ else {
+ int i;
+ for (i = 0; hwaccels[i].name; i++) {
+ if (!strcmp(hwaccels[i].name, hwaccel)) {
+ ist->hwaccel_id = hwaccels[i].id;
+ break;
+ }
+ }
+
+ if (!ist->hwaccel_id) {
+ av_log(NULL, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n",
+ hwaccel);
+ av_log(NULL, AV_LOG_FATAL, "Supported hwaccels: ");
+ for (i = 0; hwaccels[i].name; i++)
+ av_log(NULL, AV_LOG_FATAL, "%s ", hwaccels[i].name);
+ av_log(NULL, AV_LOG_FATAL, "\n");
+ exit_program(1);
+ }
+ }
+ }
+
+ MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st);
+ if (hwaccel_device) {
+ ist->hwaccel_device = av_strdup(hwaccel_device);
+ if (!ist->hwaccel_device)
+ exit_program(1);
+ }
+
break;
case AVMEDIA_TYPE_AUDIO:
guess_input_channel_layout(ist);
@@ -2282,6 +2320,12 @@ const OptionDef options[] = {
{ "force_key_frames", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(forced_key_frames) },
"force key frames at specified timestamps", "timestamps" },
+ { "hwaccel", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
+ OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccels) },
+ "use HW accelerated decoding", "hwaccel name" },
+ { "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" },
/* audio options */
{ "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },