Commit Graph

43 Commits

Author SHA1 Message Date
nanahi 71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
Guido Cella addf4ad023 Revert "demux: put type2format into codec_tags with helper functions"
This reverts commit be0a979a0b.

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.
2024-02-06 18:08:53 +01:00
Dudemanguy 289b3a432e Revert "demux_mkv: check if the video codec is an image"
This reverts commit 4709a94aec.
2024-02-01 22:12:22 +00:00
Leo Izen e9d0a31dfe demux/codec_tags: add jxl/jpegxl extension mapping to image codecs
Add .jxl as a file extension that maps to an image codec. Note that
this will include animated JXL files, but .gif is also on that list so
they are not different in that regard.
2023-12-14 12:36:42 +01:00
Guido Cella 040622f6b7 various: remove trailing whitespace 2023-10-30 16:45:47 +00:00
Dudemanguy 4709a94aec demux_mkv: check if the video codec is an image
Add a simple helper to codec_tags to check if the codec name matches one
of the images. If so, then we set still_image and image in the stream as
true (slightly different semanatics).
2023-10-23 19:32:53 +00:00
Dudemanguy be0a979a0b demux: put type2format into codec_tags with helper functions
demux_mf has a big const struct which is essentially a nice list handy
list of codecs that are considered images. This is generally useful for
all demuxers (demux_mkv could use this), so instead of making yet
another list, lift it out and put it in a common place. Some things
slightly changed so it matches the very similiar mimetype mapping struct
below it. demux_mf calls a helper mapping function instead.
2023-10-23 19:32:53 +00:00
Dudemanguy 05d79298b8 codec_tags: map some more image mimetypes
This only had jpeg and png in it strangely enough. Fixes #11592.
2023-10-02 17:49:48 +00:00
Leo Izen 3875312e41 demux/codec_tags: support more WAVEFORMATEXTENSIBLE tags
This patch adds support for two extra WAVEFORMATEXTENSIBLE GUID tags
that can appear inside RIFF headers. It also adds support for extra
codec IDs that may appear as their own unique wSubFormats inside RIFF
headers, such as ATRAC9 inside matroska, as one example.

Fixes #10757.
2022-11-01 09:52:27 -04:00
wm4 7d11eda72e Remove remains of Libav compatibility
Libav seems rather dead: no release for 2 years, no new git commits in
master for almost a year (with one exception ~6 months ago). From what I
can tell, some developers resigned themselves to the horrifying idea to
post patches to ffmpeg-devel instead, while the rest of the developers
went on to greener pastures.

Libav was a better project than FFmpeg. Unfortunately, FFmpeg won,
because it managed to keep the name and website. Libav was pushed more
and more into obscurity: while there was initially a big push for Libav,
FFmpeg just remained "in place" and visible for most people. FFmpeg was
slowly draining all manpower and energy from Libav. A big part of this
was that FFmpeg stole code from Libav (regular merges of the entire
Libav git tree), making it some sort of Frankenstein mirror of Libav,
think decaying zombie with additional legs ("features") nailed to it.
"Stealing" surely is the wrong word; I'm just aping the language that
some of the FFmpeg members used to use. All that is in the past now, I'm
probably the only person left who is annoyed by this, and with this
commit I'm putting this decade long problem finally to an end. I just
thought I'd express my annoyance about this fucking shitshow one last
time.

The most intrusive change in this commit is the resample filter, which
originally used libavresample. Since the FFmpeg developer refused to
enable libavresample by default for drama reasons, and the API was
slightly different, so the filter used some big preprocessor mess to
make it compatible to libswresample. All that falls away now. The
simplification to the build system is also significant.
2020-02-16 15:14:55 +01:00
wm4 c379950ce0 codec_tags: fix wrong buffer size
Obvious mistake. This reported 44 bytes more data than what was
available. Could cause out of bounds reads. Security researchers would
claim a major victory if they found something like this in more popular
software, and would create a website for it.
2019-07-03 17:47:24 +03:00
wm4 ace16fcfff demux_mkv: simplify avi compat. codec_tags.c GUID lookup
The redundancy here always annoyed me. Back then I didn't change it
because it's hard to test and I just had fixed something. This doesn't
matter anymore, so simplify it, without testing and with the risk that
something breaks (why care).
2018-12-06 10:31:59 +01:00
wm4 fdd75f90ae demux_mkv: remove incorrect comment
In the previous commit, I claimed that this GUID stuff was a libavformat
extension, but that seems to be completely wrong. (LATM might be an
extension of some kind, though.)

I don't know what Microsoft calls this GUID "suffix" though. It's
generally used to wrap wav format tags and video FourCCs as GUIDs.
I guess you could grep Microsoft headers for it to find its name,
or something.
2017-06-03 23:23:35 +02:00
wm4 eae693fc46 demux_mkv: support FFmpeg A_MS/ACM extensions
Indeed, FFmpeg found a way to maximize the misery around VfW/AVI-style
muxing. It appears it can mux a number of random codecs by using random
format tags. To make this even more stranger, it has a probably custom
GUID for signaling them, although for unknown reasons this is done only
"sometimes" (judging from FFmpeg's riffenc.c).

Whatever, it's not too hard to support it. Also apparently fix the
incorrect interpretation of extended formats - there's absolutely no
reason to assume they're always PCM. Instead, check for the correct
GUIDs. Also while we're at it, move the channel mask handling also to
codec_tag.c, so all WAVEFORMATEXTENSIBLE handling is in one place. (With
the normal wav header handling strangely still in demux_mkv.c.)

The case I was looking at (aac_latm muxing) decodes now. While I'm not
entirely sure about its correctness (libavformat has a weird
special-case for SBR), it certainly doesn't try to play it as PCM,
which is much of an improvement.

The extradata mess in the demux_mkv.c A_MS/ACM code path is unfortunate
and ugly, but has less impact than refactoring all the code to make
this specific case nicer.

Did I mention yet that I hate VfW-style mkv muxing?
2017-06-03 22:49:15 +02:00
wm4 e335e33239 codec_tags: minor simplification
At least this doesn't duplicate the libavcodec PCM codec names.
2017-04-18 05:35:50 +02:00
wm4 080b930742 codec_tags: remove some more leftovers
I think these became redundant some time ago, and would only matter if
someone put QT tags into WAVEFORMATEX headers using mkv avi muxing.
2017-04-18 05:34:16 +02:00
wm4 8a9b64329c Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.

There are probably more files to which this applies, but I'm being
conservative here.

A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).

common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.

codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.

From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).

misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.

screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 18:36:06 +01:00
wm4 671df54e4d demux: merge sh_video/sh_audio/sh_sub
This is mainly a refactor. I'm hoping it will make some things easier
in the future due to cleanly separating codec metadata and stream
metadata.

Also, declare that the "codec" field can not be NULL anymore. demux.c
will set it to "" if it's NULL when added. This gets rid of a corner
case everything had to handle, but which rarely happened.
2016-01-12 23:48:19 +01:00
wm4 dbbac7b3e1 demux: mime types are case-insensitive
This one is used for demux_mf and for dmeux_mkv image attachments.
2015-06-21 18:21:21 +02:00
wm4 2b64eee8d5 demux: rename sh_stream.format to sh_stream.codec_tag
Why not. "format" sounds too misleading for the actual importance and
meaning of this field.
2015-06-21 16:56:35 +02:00
wm4 0641ec0525 demux_mkv: remove FourCCs from audio codec handling
This removes the last traces of the old MPlayer FourCC-based codec
mapping code. Forcing all codec IDs through a FourCC table and then
back to codec names was confusing at best, so this is a nice cleanup.

Handling of PCM (non-VfW case) is redone to some degree.

Handling of AC3 is moved below realaudio handling, since "A_REAL/DNET"
is apparently AC3, and we must not skip realaudio-specific handling.
(It seems unlikely that anything would actually break, but on the other
hand I don't have any A_REAL/DNET samples for testing.)

Instead of explicitly matching all the specific AAC codec names, just
match them all as prefix.

Some codecs don't need special handling other than their mapping
entries, so they fall away (like Vorbis and Opus).

The prores check in mkv_parse_and_add_packet() is not strictly related
to this, but is done for consistency with the wavpack check above.
2015-06-19 21:39:59 +02:00
wm4 fd88fb70af demux_mkv: remove FourCCs from video codec handling
Inherited from MPlayer times, we used FourCCs to identify video codecs.
This was later changed to libavcodec codec names (which made life a
whole lot simpler). But demux_mkv still uses FourCCs a lot.

Change this for video. It's pretty simple, because some preparation was
done in the past. We just have to replace some "internal" FourCCs with
different handling.

One potentially complicated issue is that there is no natural way to
set the sh->format (AVCodecContext.codec_tag) field anymore. Most
decoders do not need it, though mjpeg is an exception.

Note that the AVI compatibility code still requires codec mappings, but
these are provided by FFmpeg. Also, the audio code is not changed.

For the MKV_V_MPEG2 -> mpeg1video thing see next commit.
2015-06-13 22:34:23 +02:00
wm4 c31e5da734 Remove some FFmpeg/Libav compatibility hacks
All of these are now in the supported FFmpeg and Libav versions.

The 3 remaining API checks are for FFmpeg-only things.
2015-03-03 12:28:46 +01:00
wm4 1ef56e9d08 demux_mkv: support embedded coverart
The code could as well be in demux.c, but it's better to avoid
accidental clashes with demux_lavf.c.

FFmpeg provides no way yet to map a mime type to a codec, so do it
manually. (It _can_ map a mime type to an "input format", but not a
codec.)

Fixes #1374.
2014-12-22 12:53:51 +01:00
wm4 9a3333e765 demux_mkv: remove ancient codec mapping leftovers
All of this is basically due to how MPlayer's codecs.conf worked. It
had a demuxer-interface based an AVI, using FourCCs and data structures
found in AVI. FourCCs were used to map streams to decoders. For codecs
not supported by AVI, "MPlayer internal" FourCCs were made up.

codec_tags.c is there to bridge demuxers written against the old API to
the mpv one. By now, only demux_mkv.c needs this (because demux_mkv is
the only serious demuxer left - preferably, we should use libavformat
for mkv too, but I can't see this happening any time soon, because
libavformat _still_ doesn't support segment linking). But the codec
tables are full of weird stuff automatically extracted from the old
codecs.conf tables. Most of it isn't needed for mkv.

Remove all custom tags, readd those used by demux_mkv.c internally
(see vinfo and mkv_audio_tag tables). The rest is handled by the
tables provided by libavformat, which includes AVI and QT tags.
2014-11-28 20:54:51 +01:00
wm4 26bc6b4831 Add some missing "const"s
The one in msg.c was mistakenly removed with commit e99a37f6.

I didn't actually test the change in ao_sndio.c (but obviously "ap"
shouldn't be static).
2014-10-10 13:44:08 +02:00
wm4 9c3c199558 audio: remove WAVEFORMATEX from internal demuxer API
Same as with the previous commit. A bit more involved due to how the
code is written.
2014-09-25 01:56:51 +02:00
wm4 e977624d87 audio: confine demux_mkv audio PCM hack
Let codec_tags.c do the messy mapping.

In theory we could simplify further by makign demux_mkv.c directly use
codec names instead of the MPlayer-inherited "internal FourCC" business,
but I'd rather not touch this - it would just break things.
2014-09-24 23:33:21 +02:00
wm4 9ac86d9e99 audio: decouple demux and audio decoder/filter sample formats
For a while, we used this to transfer PCM from demuxer to the filter
chain. We had a special "codec" that mapped what MPlayer used to do
(MPlayer passes the AF sample format over an extra field to ad_pcm,
which specially interprets it).

Do this by providing a mp_set_pcm_codec() function, which describes a
sample format in a generic way, and sets the appropriate demuxer header
fields so that libavcodec interprets it correctly. We use the fact that
libavcodec has separate PCM decoders for each format. These are
systematically named, so we can easily map them.

This has the advantage that we can change the audio filter chain as we
like, without losing features from the "rawaudio" demuxer. In fact, this
commit also gets rid of the audio filter chain formats completely.
Instead have an explicit list of PCM formats. (We could even just have
the user pass libavcodec PCM decoder names directly, but that would be
annoying in other ways.)
2014-09-24 22:55:50 +02:00
Vika Apelsinova 77a2d79edb demux: add "BIKb" FourCC
More support for the worst codec ever.

Signed-off-by: wm4 <wm4@nowhere>
2014-04-08 22:59:53 +02:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 904c73d2d2 demux: remove gsh field from sh_audio/sh_video/sh_sub
This used to be needed to access the generic stream header from the
specific headers, which in turn was needed because the decoders had
access only to the specific headers. This is not the case anymore, so
this can finally be removed again.

Also move the "format" field from the specific headers to sh_stream.
2013-11-23 21:37:56 +01:00
wm4 d8882bbfb7 demux_mkv: support some raw PCM variants
This affects 64 bit floats and big endian integer PCM variants
(basically crap nobody uses). Possibly not all MS-muxed files work, but
I couldn't get or produce any samples.

Remove a bunch of format tags that are not needed anymore. Most of these
were used by demux_mov, which is long gone. Repurpose/abuse 'twos' as
mpv-internal tag for dealing with the PCM variants mentioned above.
2013-11-11 18:40:59 +01:00
wm4 d3c140bbf2 demux_mkv: add support for HEVC
Note that you still need --vd-lavc-o='strict=-2' to enable the decoder.

Also, there's no guarantee that all required features for HEVC demuxing
are actually implemented, nor that the current muxing schema is the
final one.
2013-10-16 00:47:52 +02:00
wm4 f5195cc4e7 demux_mkv: support V_PRORES
Why not...

Code for demangling Matroska-style prores video packets inspired by
libavformat's Matroska demuxer.
2013-09-08 23:05:18 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 4ee0d08820 demux: fix big endian PCM in mkv with demux_mkv 2013-05-11 20:19:08 +02:00
wm4 80d0ab1058 demux_mkv: support vp9
Note that ffmpeg doesn't provide a decoder by default yet.
2013-04-20 23:28:24 +02:00
wm4 e837d8ddac demux_mkv: support ALAC
Test sample was produced with ffmpeg. Extradata handling closely follows
libavformat/matroskadec.c.
2013-03-15 12:17:39 +01:00
Stephen Hutchinson 1877d7933e demux_mkv: Support playing Opus streams in Matroska
FFmpeg recently changed how it writes Opus-in-Matroska to match
the A_OPUS/EXPERIMENTAL name that mkvmerge uses, with the caveat
that things will change and compatibility with old files can get
worked out when the spec is finalized.

This adds both A_OPUS and A_OPUS/EXPERIMENTAL so that *hopefully*
it can play both the newer files that use A_OPUS/EXPERIMENTAL, and
older ones muxed by FFmpeg that were simply A_OPUS, since this is
also what FFmpeg seems to be doing to handle the situation.
2013-03-14 00:07:28 +01:00
wm4 d8bde114fd Prefix CODEC_ID_ with AV_
The old names have been deprecated a while ago, but were needed for
supporting older ffmpeg/libav versions. The deprecated identifiers
have been removed from recent Libav and FFmpeg git.

This change breaks compatibility with Libav 0.8.x and equivalent
FFmpeg releases.
2013-03-13 23:51:30 +01:00
wm4 10ed11eefa demux_mf: map to codecs directly
Instead of going through FourCCs and codec_tags.c.
2013-02-24 16:31:43 +01:00
wm4 4d016a92c8 core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)

The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)

demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.

Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.

Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-10 17:25:56 +01:00