diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-03-04 08:18:28 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-03-04 08:18:28 +0000 |
| commit | faf333e4b8b504609c5b721f6752005f071769be (patch) | |
| tree | f81a4d09a46683feab005c5f0eca5627e1a34ad7 /src/lib/ffmpeg_image_proxy.cc | |
| parent | e14f261a6a0ec1c3047db37ce55655fa095a6b08 (diff) | |
Make the FFmpeg proxy more likely to fall back to trying targa rather than pressing on with a possibly-incorrect autodetection.v2.13.124
Diffstat (limited to 'src/lib/ffmpeg_image_proxy.cc')
| -rw-r--r-- | src/lib/ffmpeg_image_proxy.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index 87925dabc..3548117ff 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -134,21 +134,19 @@ FFmpegImageProxy::image (optional<dcp::Size>) const av_dict_set (&options, "probesize", raw_convert<string>(5 * 60 * 1000000).c_str(), 0); int e = avformat_open_input (&format_context, 0, 0, &options); + if ((e < 0 && e == AVERROR_INVALIDDATA) || (e >= 0 && format_context->probe_score <= 25)) { + /* Hack to fix loading of .tga files through AVIOContexts (rather then + directly from the file). This code just does enough to allow the + probe code to take a hint from "foo.tga" and so try targa format. + */ + AVInputFormat* f = av_find_input_format ("image2"); + format_context = avformat_alloc_context (); + format_context->pb = avio_context; + format_context->iformat = f; + e = avformat_open_input (&format_context, "foo.tga", f, &options); + } if (e < 0) { - if (e == AVERROR_INVALIDDATA) { - /* Hack to fix loading of .tga files through AVIOContexts (rather then - directly from the file). This code just does enough to allow the - probe code to take a hint from "foo.tga" and so try targa format. - */ - AVInputFormat* f = av_find_input_format ("image2"); - format_context = avformat_alloc_context (); - format_context->pb = avio_context; - format_context->iformat = f; - e = avformat_open_input (&format_context, "foo.tga", f, &options); - } - if (e < 0) { - throw OpenFileError (_path->string(), e, true); - } + throw OpenFileError (_path->string(), e, true); } if (avformat_find_stream_info(format_context, 0) < 0) { |
