summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2024-02-05 10:34:12 +0100
committersfan5 <sfan5@live.de>2024-02-06 18:08:53 +0100
commitaddf4ad023dc55c10bd794baa86c16f7249e6cfb (patch)
tree5824817826099edd3cc839529505ea0a33b40523 /demux
parent343a5fd345a84572ea5693a805119067d5b0fbc8 (diff)
downloadmpv-addf4ad023dc55c10bd794baa86c16f7249e6cfb.tar.bz2
mpv-addf4ad023dc55c10bd794baa86c16f7249e6cfb.tar.xz
Revert "demux: put type2format into codec_tags with helper functions"
This reverts commit be0a979a0b17b49f8535ee2542cca7df4c35b04d. The list of images codecs is no longer used by demux_mkv.c because 26a51464b6 made it check the number of blocks instead to not misdetect animations in image codecs, so move it back to demux_mf.c since it is its only user, so it is easier to understand how it is used, keeping the jxl addition from e9d0a31dfe.
Diffstat (limited to 'demux')
-rw-r--r--demux/codec_tags.c65
-rw-r--r--demux/codec_tags.h1
-rw-r--r--demux/demux_mf.c65
3 files changed, 62 insertions, 69 deletions
diff --git a/demux/codec_tags.c b/demux/codec_tags.c
index c4f07b5393..33241db3bc 100644
--- a/demux/codec_tags.c
+++ b/demux/codec_tags.c
@@ -180,71 +180,6 @@ void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
c->codec = talloc_strdup(c, codec);
}
-// map file extension/type to an image codec name
-static const char *const type_to_codec[][2] = {
- { "bmp", "bmp" },
- { "dpx", "dpx" },
- { "j2c", "jpeg2000" },
- { "j2k", "jpeg2000" },
- { "jp2", "jpeg2000" },
- { "jpc", "jpeg2000" },
- { "jpeg", "mjpeg" },
- { "jpg", "mjpeg" },
- { "jps", "mjpeg" },
- { "jls", "ljpeg" },
- { "thm", "mjpeg" },
- { "db", "mjpeg" },
- { "pcd", "photocd" },
- { "pfm", "pfm" },
- { "phm", "phm" },
- { "hdr", "hdr" },
- { "pcx", "pcx" },
- { "png", "png" },
- { "pns", "png" },
- { "ptx", "ptx" },
- { "tga", "targa" },
- { "tif", "tiff" },
- { "tiff", "tiff" },
- { "sgi", "sgi" },
- { "sun", "sunrast" },
- { "ras", "sunrast" },
- { "rs", "sunrast" },
- { "ra", "sunrast" },
- { "im1", "sunrast" },
- { "im8", "sunrast" },
- { "im24", "sunrast" },
- { "im32", "sunrast" },
- { "sunras", "sunrast" },
- { "xbm", "xbm" },
- { "pam", "pam" },
- { "pbm", "pbm" },
- { "pgm", "pgm" },
- { "pgmyuv", "pgmyuv" },
- { "ppm", "ppm" },
- { "pnm", "ppm" },
- { "gif", "gif" },
- { "pix", "brender_pix" },
- { "exr", "exr" },
- { "pic", "pictor" },
- { "qoi", "qoi" },
- { "xface", "xface" },
- { "xwd", "xwd" },
- { "svg", "svg" },
- { "jxl", "jpegxl" },
- {0}
-};
-
-const char *mp_map_type_to_image_codec(const char *type)
-{
- if (type) {
- for (int n = 0; type_to_codec[n][0]; n++) {
- if (strcasecmp(type_to_codec[n][0], type) == 0)
- return type_to_codec[n][1];
- }
- }
- return NULL;
-};
-
static const char *const mimetype_to_codec[][2] = {
{"image/apng", "apng"},
{"image/avif", "av1"},
diff --git a/demux/codec_tags.h b/demux/codec_tags.h
index 694f4c64d4..147760b0fe 100644
--- a/demux/codec_tags.h
+++ b/demux/codec_tags.h
@@ -28,7 +28,6 @@ void mp_set_codec_from_tag(struct mp_codec_params *c);
void mp_set_pcm_codec(struct mp_codec_params *c, bool sign, bool is_float,
int bits, bool is_be);
-const char *mp_map_type_to_image_codec(const char *type);
const char *mp_map_mimetype_to_video_codec(const char *mimetype);
#endif
diff --git a/demux/demux_mf.c b/demux/demux_mf.c
index 3ab6683cfd..0beac75261 100644
--- a/demux/demux_mf.c
+++ b/demux/demux_mf.c
@@ -282,6 +282,64 @@ static bool demux_mf_read_packet(struct demuxer *demuxer,
return true;
}
+// map file extension/type to a codec name
+
+static const struct {
+ const char *type;
+ const char *codec;
+} type2format[] = {
+ { "bmp", "bmp" },
+ { "dpx", "dpx" },
+ { "j2c", "jpeg2000" },
+ { "j2k", "jpeg2000" },
+ { "jp2", "jpeg2000" },
+ { "jpc", "jpeg2000" },
+ { "jpeg", "mjpeg" },
+ { "jpg", "mjpeg" },
+ { "jps", "mjpeg" },
+ { "jls", "ljpeg" },
+ { "thm", "mjpeg" },
+ { "db", "mjpeg" },
+ { "pcd", "photocd" },
+ { "pfm", "pfm" },
+ { "phm", "phm" },
+ { "hdr", "hdr" },
+ { "pcx", "pcx" },
+ { "png", "png" },
+ { "pns", "png" },
+ { "ptx", "ptx" },
+ { "tga", "targa" },
+ { "tif", "tiff" },
+ { "tiff", "tiff" },
+ { "sgi", "sgi" },
+ { "sun", "sunrast" },
+ { "ras", "sunrast" },
+ { "rs", "sunrast" },
+ { "ra", "sunrast" },
+ { "im1", "sunrast" },
+ { "im8", "sunrast" },
+ { "im24", "sunrast" },
+ { "im32", "sunrast" },
+ { "sunras", "sunrast" },
+ { "xbm", "xbm" },
+ { "pam", "pam" },
+ { "pbm", "pbm" },
+ { "pgm", "pgm" },
+ { "pgmyuv", "pgmyuv" },
+ { "ppm", "ppm" },
+ { "pnm", "ppm" },
+ { "gif", "gif" }, // usually handled by demux_lavf
+ { "pix", "brender_pix" },
+ { "exr", "exr" },
+ { "pic", "pictor" },
+ { "qoi", "qoi" },
+ { "xface", "xface" },
+ { "xwd", "xwd" },
+ { "svg", "svg" },
+ { "jxl", "jpegxl" },
+ {0}
+};
+
static const char *probe_format(mf_t *mf, char *type, enum demux_check check)
{
if (check > DEMUX_CHECK_REQUEST)
@@ -292,9 +350,10 @@ static const char *probe_format(mf_t *mf, char *type, enum demux_check check)
if (p)
type = p + 1;
}
- const char *codec = mp_map_type_to_image_codec(type);
- if (codec)
- return codec;
+ for (int i = 0; type2format[i].type; i++) {
+ if (type && strcasecmp(type, type2format[i].type) == 0)
+ return type2format[i].codec;
+ }
if (check == DEMUX_CHECK_REQUEST) {
if (!org_type) {
MP_ERR(mf, "file type was not set! (try --mf-type=ext)\n");