Skip to content
Permalink
Browse files

ffmpeg: Set default output format to hwaccel's native format

I think this is usually what the user wants - if they are using
an hwaccel, they probably want full hardware transcoding to
work.
  • Loading branch information
philipl committed Jun 17, 2017
1 parent 34d2841 commit e4772ef21eb148f54076e5ff9b9be0f5b249a5d5
Showing with 12 additions and 8 deletions.
  1. +1 −0 ffmpeg.h
  2. +11 −8 ffmpeg_opt.c
@@ -77,6 +77,7 @@ typedef struct HWAccel {
enum HWAccelID id;
enum AVPixelFormat pix_fmt;
enum AVHWDeviceType device_type;
int pix_fmt_is_default;
} HWAccel;

typedef struct HWDevice {
@@ -68,31 +68,31 @@
const HWAccel hwaccels[] = {
#if HAVE_VDPAU_X11
{ "vdpau", hwaccel_decode_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU,
AV_HWDEVICE_TYPE_VDPAU },
AV_HWDEVICE_TYPE_VDPAU, FALSE },
#endif
#if HAVE_DXVA2_LIB
{ "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD,
AV_HWDEVICE_TYPE_NONE },
AV_HWDEVICE_TYPE_NONE, FALSE },
#endif
#if CONFIG_VDA
{ "vda", videotoolbox_init, HWACCEL_VDA, AV_PIX_FMT_VDA,
AV_HWDEVICE_TYPE_NONE },
AV_HWDEVICE_TYPE_NONE, FALSE },
#endif
#if CONFIG_VIDEOTOOLBOX
{ "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX,
AV_HWDEVICE_TYPE_NONE },
AV_HWDEVICE_TYPE_NONE, FALSE },
#endif
#if CONFIG_LIBMFX
{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV,
AV_HWDEVICE_TYPE_NONE },
AV_HWDEVICE_TYPE_NONE, TRUE },
#endif
#if CONFIG_VAAPI
{ "vaapi", hwaccel_decode_init, HWACCEL_VAAPI, AV_PIX_FMT_VAAPI,
AV_HWDEVICE_TYPE_VAAPI },
AV_HWDEVICE_TYPE_VAAPI, FALSE },
#endif
#if CONFIG_CUVID
{ "cuvid", hwaccel_decode_init, HWACCEL_CUDA, AV_PIX_FMT_CUDA,
AV_HWDEVICE_TYPE_CUDA },
AV_HWDEVICE_TYPE_CUDA, TRUE },
#endif
{ 0 },
};
@@ -708,6 +708,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
char *discard_str = NULL;
const AVClass *cc = avcodec_get_class();
const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL, 0, 0);
enum AVPixelFormat default_pix_fmt = AV_PIX_FMT_NONE;

if (!ist)
exit_program(1);
@@ -805,6 +806,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
for (i = 0; hwaccels[i].name; i++) {
if (!strcmp(hwaccels[i].name, hwaccel)) {
ist->hwaccel_id = hwaccels[i].id;
if (hwaccels[i].pix_fmt_is_default)
default_pix_fmt = hwaccels[i].pix_fmt;
break;
}
}
@@ -837,7 +840,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
"format: %s", hwaccel_output_format);
}
} else {
ist->hwaccel_output_format = AV_PIX_FMT_NONE;
ist->hwaccel_output_format = default_pix_fmt;
}

ist->hwaccel_pix_fmt = AV_PIX_FMT_NONE;

0 comments on commit e4772ef

Please sign in to comment.