On 12/11/18 20:20, Michael Niedermayer wrote: > On Sun, Nov 11, 2018 at 02:54:41PM +0000, Mark Thompson wrote: >> Fixes #7519. >> --- >> I've had this lying around for a bit with intent to use it to support >> non-hwaccel hardware decoders (in particular, v4l2m2m), but it actually >> fixes the force-hwaccel use-case too in a sensible way. >> >> >> doc/ffmpeg.texi | 12 ++++++++++++ >> fftools/ffmpeg.c | 4 ++++ >> fftools/ffmpeg.h | 4 ++++ >> fftools/ffmpeg_opt.c | 15 +++++++++++++++ >> 4 files changed, 35 insertions(+) >> >> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi >> index 3717f22d42..9f9e693898 100644 >> --- a/doc/ffmpeg.texi >> +++ b/doc/ffmpeg.texi >> @@ -920,6 +920,18 @@ would be more efficient. >> When doing stream copy, copy also non-key frames found at the >> beginning. >> >> +@item -decode_format[:@var{stream_specifier}] @var{pixfmt} >> (@emph{input,per-stream}) >> +Set the output format to be used by the decoder for this stream. If the >> +decoder does not natively support this format for the input stream then >> +decoding will fail rather than continuing with a different format. >> + >> +In general this should not be set - the decoder will select an output >> +format based on the input stream parameters and available components, and >> +that will be automatically converted to whatever the output requires. It >> +may be useful to force a hardware decoder supporting output in multiple >> +different memory types to pick the desired one, or to ensure that a >> +hardware decoder is used when software fallback is also available. >> + >> @item -init_hw_device >> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]] >> Initialise a new hardware device of type @var{type} called @var{name}, >> using the >> given device parameters. >> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c >> index 38c21e944a..73bed55e4d 100644 >> --- a/fftools/ffmpeg.c >> +++ b/fftools/ffmpeg.c >> @@ -2800,6 +2800,10 @@ static enum AVPixelFormat get_format(AVCodecContext >> *s, const enum AVPixelFormat >> const AVCodecHWConfig *config = NULL; >> int i; >> >> + if (ist->decode_format != AV_PIX_FMT_NONE && >> + ist->decode_format != *p) >> + continue; >> + >> if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) >> break; >> >> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h >> index eb1eaf6363..88e0aa60ea 100644 >> --- a/fftools/ffmpeg.h >> +++ b/fftools/ffmpeg.h >> @@ -125,6 +125,8 @@ typedef struct OptionsContext { >> int nb_ts_scale; >> SpecifierOpt *dump_attachment; >> int nb_dump_attachment; >> + SpecifierOpt *decode_formats; >> + int nb_decode_formats; >> SpecifierOpt *hwaccels; >> int nb_hwaccels; >> SpecifierOpt *hwaccel_devices; > >> @@ -334,6 +336,8 @@ typedef struct InputStream { >> int top_field_first; >> int guess_layout_max; >> >> + enum AVPixelFormat decode_format; >> + > > I think this should be a list and not a single format
Yes, I agree; that's a very good idea. New patch to follow. Thanks, - Mark _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel