diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-11-23 14:26:27 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-11-23 14:31:15 +0100 |
commit | 62e10c375968d9cbbe2a0bc321e00eef52d32917 (patch) | |
tree | 8c8a3a4b025d3cf54abb44a3ab988c58c2c9e615 /ffmpeg_opt.c | |
parent | 94194bdcd7bfc2137ccd13e5c149567b9a917f4f (diff) | |
parent | 07fd0a22192805d56c635eb294dc26b0a54ae325 (diff) | |
download | ffmpeg-62e10c375968d9cbbe2a0bc321e00eef52d32917.tar.gz |
Merge commit '07fd0a22192805d56c635eb294dc26b0a54ae325'
* commit '07fd0a22192805d56c635eb294dc26b0a54ae325':
avconv: add infrastructure for using hwaccels
Conflicts:
ffmpeg.c
ffmpeg.h
ffmpeg_filter.c
ffmpeg_opt.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg_opt.c')
-rw-r--r-- | ffmpeg_opt.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 8da1ce43a6..8e01c685d1 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -62,6 +62,11 @@ outvar = o->name[i].u.type;\ }\ } + +const HWAccel hwaccels[] = { + { 0 }, +}; + char *vstats_filename; float audio_drift_threshold = 0.1; @@ -557,7 +562,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); @@ -612,6 +617,40 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) ist->top_field_first = -1; MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st); + 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: ist->guess_layout_max = INT_MAX; @@ -2835,6 +2874,12 @@ const OptionDef options[] = { "force key frames at specified timestamps", "timestamps" }, { "b", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate }, "video bitrate (please use -b:v)", "bitrate" }, + { "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 }, |