[FFmpeg-devel] [PATCH 2/2] img2dec: Add mime_type to image formats
Derek Buitenhuis
derek.buitenhuis at gmail.com
Fri Feb 26 15:56:05 CET 2016
On 2/26/2016 2:44 PM, Carl Eugen Hoyos wrote:
> Derek Buitenhuis <derek.buitenhuis <at> gmail.com> writes:
>
>> On 2/25/2016 4:30 PM, Carl Eugen Hoyos wrote:
> You misunderstand:
> Most "imageauto" demuxers return a score of 51. In all cases
> when 51 is returned, the detection is nearly certain. Your
> patch disables the detection for all these cases (although
> it is nearly certain) in favour of the mime type.
>
> (That is how I understand the patch, please correct me if
> setting mime_type actually has another effect than
> returning 75 in case of conformance.)
>
> I don't think the solution is to increase the score for
> these probe functions: mpeg streams may start with any
> bytes and 32 bit accordance should not return maximum
> (or nearly maximum) score.
See below. The scoring should be fixed.
> My argument is: Let's please improve the jpeg auto-detection
> (the only one that shows issues) instead of disabling it.
Forgot what this particular patch does for a second.
I'm not saying it should be disabled. I'm saying scoring should be
as such:
1) Probing the file file itself: Highest score.
2) Mime-type: Medium score.
3) File extension: Lower score.
Mime-type is a *much* better mechanism for detection than file
extension over HTTP(S), and it will not affect detection in local
files at all. Mime-type should be tried before e.g. mp3 probing,
which seems to have a lot of misdirections.
This can only be a net improvement, IMO.
> (You should be slightly more careful with your arguments:
> I originally thought that there might be one or two probe
> functions that should sometimes return a score instead of
> 0 because the decoders may accept invalid files but that
> is not the case except for the case without mime_type.)
>
> There are 14 "imageauto" demuxers with image type
> auto-detection. Three (png, dds, webp) return a score of 99,
> I don't know if they would be effected by the patch in
> question or not but all three decoders do not work if the
> respective probe function fails.
>
> The qdraw decoder fails for samples that fail auto-detection.
>
> Of the nine image format types with probe functions that
> return 51, the following fail decoding if the probe
> function returns 0:
> bmp, dpx, exr, j2k, sgi, sunrast, tiff
>
> The pictor decoder fails for images that are not
> auto-detected.
>
> That leaves only the jpegls autodetection that may not
> return a score for images that can be decoded: Since the
> patch you provided does not add a mime_type for jpegls,
> I don't think it can be used as an argument here.
>
> So let's improve the jpeg auto-detection, I know it isn't
> perfect yet.
See above. It's not meant to replace, it's meant to augment.
> I am sorry if I misunderstand this (who does "the push"?):
> Are you arguing user-set mime_types are (except for jpeg)
> more plausible than an autodetection that never returns 0
> for images that can be decoded?
Again, see above where I have laid out the scoring I think
would be appropriate.
However, mime-type is far, far more likely to be accurate
than the file extension. I am arguing that it's better than
that, for URLs.
- Derek
More information about the ffmpeg-devel
mailing list