summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux_mkv: add HDMV Text subtitles to subtitle codec listDudemanguy2023-12-161-0/+1
| | | | | Such subtitles will not actually work since FFmpeg doesn't yet have a decoder for them, but this prevents some error message spam at least.
* demux_mkv: check that subtitle type is set before accessing itDudemanguy2023-12-161-1/+1
| | | | | | | | Fixes crashes in case of unknown subtitle track being found, as the original ARIB caption logic added in 0da0acdae8e729eecfb2498ac11cb86a7fe3360d did not attempt to take into mention tracks with unknown type. Fixes #13106
* demux/codec_tags: add jxl/jpegxl extension mapping to image codecsLeo Izen2023-12-141-0/+1
| | | | | | 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.
* demux: add missing NULL checkKacper Michajłow2023-11-181-0/+1
| | | | It is assigned to NULL above is !stream.
* demux_playlist: simplify ini parsingDudemanguy2023-11-141-7/+8
| | | | | | | | | | | | | | In acac614032529997e0a8d89d35a8613b505e04fb, I sort of cargoculted what I had to do for m3u, but it's actually not needed. bstr_split_tok unexpectedly doesn't modify the original string. So the line_dup business in the ini parsing is not needed. Remove it. The part in parse_ref_init isn't wrong but naming the variable "line_dup" instead of "value" is stupid so adjust that. And finally, you can actually force a codepage in mpv (add "+" before the codepage) which will cause every line to be allocated memory including the header lines even though those are obviously valid utf8 that should never need conversion. This wasn't taken into account so add an extra pl_free_line in a couple of places to make sure they are freed.
* demux: always update the cache on initDudemanguy2023-11-121-1/+1
| | | | | | | | | | | | | cd59ea8afab6381951a3ae19a43e422906d02164 removed an arbitrary start offset added to the timer. However, it turns out that demux secretly depends on this. When updating cache to actually read bytes from the stream, there's a diff >= MP_TIME_S_TO_NS(1) check to make it only update once every second. With the old MP_START_TIME macro, the initial time value would always be at least 1e10, so this would also be true. Since we don't have that offset anymore, now the initial time is less than that so it is not updated and properties like file-size are 0. Just be sure to always update if the last_speed_query is 0 (i.e. we just started the player). Fixes #12869.
* demux/lavf: don't use deprecated side dataKacper Michajłow2023-11-091-5/+26
| | | | | | | Fixes rotation metadata no longer works. See: https://github.com/FFmpeg/FFmpeg/commit/5432d2aacad5fa7420fe2d9369ed061d521e92d6 Fixes: #12836
* ALL: use pl_hdr_metadata and nuke sig_peakKacper Michajłow2023-11-051-3/+0
| | | | | | | | This commit replaces all uses of sig_peak and maps all HDR metadata. Form notable changes mixed usage of maxCLL and max_luma is resolved and not always max_luma is used which makes vo_gpu and vo_gpu_next behave the same way.
* demux_mkv: parse mastering metadataKacper Michajłow2023-11-051-5/+47
|
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-052-101/+98
|
* demux: make hysteresis-secs respect cache-secsNRK2023-10-301-1/+3
| | | | | | | | | | | | currently hysteresis-secs only works when the demuxer-max-bytes fills up. but it's possible for the cache-secs/demuxer-readahead-secs to be reached first. in those cases, hysteresis-secs doesn't work and keeps buffering non-stop. but the goal of this option was to save power by avoiding non-stop buffering so go ahead and make it respect cache-secs as well. additionally remove some redundant repetition from the docs.
* demux: cosmeticsNRK2023-10-301-6/+5
| | | | | - brace goes to next line for multi-line conditional - sort standard headers some more
* various: remove trailing whitespaceGuido Cella2023-10-301-4/+4
|
* options: rename --fps to --container-fps-overrideDudemanguy2023-10-251-1/+1
| | | | | | This better reflects what it actually does. As a bonus, script writers won't be misled into thinking that fps displays the actual video or display fps.
* demux_mkv: check if the video codec is an imageDudemanguy2023-10-233-0/+16
| | | | | | 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).
* demux: put type2format into codec_tags with helper functionsDudemanguy2023-10-233-61/+68
| | | | | | | | | 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.
* Revert "demux_mkv: PAR should be calculated after applying crop"Kacper Michajłow2023-10-211-10/+7
| | | | | | | | | | | Matroska spec says that DisplayWidth and DisplayHeight should be applied after cropping, but this doesn't adhere to the real files which does not follow this rule. Revert the change and we can re-evaluate if someone complains with spec compliant files. See: https://datatracker.ietf.org/doc/draft-ietf-cellar-matroska/ This reverts commit f8db02b59db08f1013dfb9411bd04c6a80dc72ff.
* demux_mkv: don't set codec crop rect when there is no cropDudemanguy2023-10-211-14/+16
| | | | | | | | | | | | Unfortunately there are files out there with broken tags where the width/height doesn't match the actual width/height of the file. That means the cropping logic which normally should be a no-op resulting in (0, 0, w, h) ends up being a crop which is probably not wanted by the user. Workaround this by simply keeping the entire crop rect as 0 when there is no container cropping. All zeros is internally treated the same as (0, 0, w, h) and avoids bad container data messing up the width or height of the window. Also simplify the logic a bit and get rid of some superflorous bools that had no real use. Fixes #12680.
* various: sort some standard headersNRK2023-10-201-5/+5
| | | | | | | | | | | | since i was going to fix the include order of stdatomic, might as well sort the surrouding includes in accordance with the project's coding style. some headers can sometime require specific include order. standard library headers usually don't. but mpv might "hack into" the standard headers (e.g pthreads) so that complicates things a bit more. hopefully nothing breaks. if it does, the style guide is to blame.
* osdep: remove atomic.hNRK2023-10-201-1/+1
| | | | | | | replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with explicit _Atomic qualified types. also add missing config.h includes on some files.
* demux_mkv: PAR should be calculated after applying cropKacper Michajłow2023-10-201-10/+10
| | | | DisplayWidth/DisplayHeight applies to the video frame after cropping (PixelCrop* Elements).
* demux/lavf: move tags instead of copyingClaude Heiland-Allen2023-10-181-5/+5
| | | | | | | | | | | Use mp_tags_move_from_av_dictionary() in place of mp_tags_copy_from_av_dictionary(). This ensures that when lavf appends metadata that occurs later in the stream, it starts from empty each time. Fixes: <https://github.com/mpv-player/mpv/issues/12559>
* demux: convert cache updates to nanosecondsDudemanguy2023-10-161-6/+6
| | | | As a bonus, we can remove the awkward and horribly named MP_SECOND_US.
* demux_playlist: use --metacode-codepage when parsing playlist filesDudemanguy2023-10-071-22/+63
| | | | | | | | | | | | It's 2023 and people don't use UTF-8 for their m3u, ini, etc. files. Well mpv already has the tools in place to try and guess other codepages, so we might as well use it I guess. This change is pretty awkward since we have to read line-by-line but mp_iconv_to_utf8 may sometimes allocate memory. So sometimes the bstr needs to be freed and sometimes not for every line. Also we need to make another copy of the line on the stack since splitting by tokens and such will mess up the original line which may possibly be allocated memory. The ugliness is mostly hidden in pl_free_line, but it's still weird. Fixes #10911.
* demux: change the default of metadata-codepage to autoDudemanguy2023-10-071-1/+1
| | | | | | | There's really no reason not to do this especially since sub-codepage already defaults to auto. Also change logging in charset_conv since telling us that the data is UTF-8 if the passed codepage value is "auto" or "utf-8" is really not useful information (that's the expectation).
* demux_cue: deprecate --demuxer-cue-codepage for --metadata-codepageDudemanguy2023-10-071-15/+6
| | | | | | | | | What are cue sheets not metadata or something? No reason this needs to be a separate option so just deprecate it. This does mean that the default value changes from "auto" to "utf-8" for this obscure fringe case. I really hope people don't use non-UTF-8 cuesheets, but the next commit will change the default of --metadata-codepage to "auto" so there's no actual change in behavior to users.
* codec_tags: map some more image mimetypesDudemanguy2023-10-021-0/+7
| | | | This only had jpeg and png in it strangely enough. Fixes #11592.
* demux: move parent_stream_info before the gotoDudemanguy2023-10-011-9/+9
| | | | | | Previously if the demuxer didn't exist, then it could jump down and try to free sinfo.filename before it was ever set thus segfaulting. Just always set the struct unconditionally so we're always sure to free it.
* Revert "demux: constify a struct member"Dudemanguy2023-10-011-2/+3
| | | | | | | | | | Some demuxers actually close the stream right after they are finished opening like cue. Since the stream->url is no longer copied with this commit, that means it gets thrown away after the stream closes. This leads to a use after free. We still need to allocate stream->url so fix this another way. This reverts commit 3e85df3b2d89d6a27806d677b6b8a99055cb1fcc.
* demux: fix erroneous condition in lazy_stream_needs_waitDudemanguy2023-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Yeah another try at this. So when inspecting lazy_stream_needs_wait, I realized it had a curious !ds->reader_head condition. Actually, this is what is messing everything up. This was originally added in cf2b7a4997299ff9e0ff91d4273cd294686b001f for showing large negative sub delay values correctly. It worked because the packet will eventually be discarded during playback causing ds->reader_head not exist and thus the next one will correctly be read ahead as needed. But for the "switching subtitle tracks while paused" case, this is actually bad. As the stream is read, eventually you'll find a packet and set the reader_head. But it's not going to be the correct packet (unless you're looking for the very first one), so you need to read more. This won't happen because of the !ds->reader_head check and unlike the sub delay case, nothing will eventually discard that packet since playback isn't occuring. So read_packet exits earlier than it should and isn't tried again, so the subtitle that you want won't show since the returned packet has the wrong pts. All that needs to be done here is to delete this one condition. There's already checks in place to make sure that it's not read past the desired timestamp and for the sub delay case (the only other time this logic is used), it makes no difference since you won't read past the specified pts in the first place.
* Revert "demux: improve stream selection state"Dudemanguy2023-09-304-13/+12
| | | | | | | | The stream selection state wasn't improved. I didn't realize this messed with caches. All in all, just not a good idea. Back to drawing board I guess. This reverts commit f40bbfec4fcd2d9a787a4d98ec7698a646e5607e.
* win32/pthread: define _POSIX_TIMERS to notify they are not supportedKacper Michajłow2023-09-291-0/+1
|
* timer: rename mp_time_us_to_timespec to reflect what it actually doesKacper Michajłow2023-09-291-1/+1
|
* demux: improve stream selection stateDudemanguy2023-09-274-12/+13
| | | | | | | | | | | | | | | | | | | | | | | This replaces the previous commit and makes more sense. The internal demux marked tracks as eager depending on their type and for subtitles it would always lazily read them unless there happened to be no available av stream. However, we want the sub stream to be eager if the player is paused. The existing subtitle is still preserved on the screen, but if the user changes tracks that's when the problem occurs. So to handle this case, propagate the mpctx->paused down to the stream selection logic. This modifies both demuxer_refresh_track and demuxer_select_track to take that boolean value. A few other parts of the player use this, but we can just assume false there (no change in behavior from before) since they should never be related to subtitles. The core player code is aware of its own state naturally, and can always pass the appropriate value so go ahead and do so. When we change the pause state, a refresh seek is done on all existing subtitle tracks to make sure their eager state is the appropriate value (i.e. so it's not still set to eager after a pause and a track switch). Slightly invasive change, but it works with the existing logic instead of going around it so ultimately it should be a better approach. We can additionally remove the old force boolean from sub_read_packets since it is no longer needed.
* Revert "demux: eagerly read subtitle streams when switching tracks while paused"Dudemanguy2023-09-272-9/+4
| | | | | | | Actually, I thought of a better way of handling this shortly after merging this. Revert it and redo it in the next commit. This reverts commit c2c157ebeca3d072d4f48ff36228d01ebe888699.
* demux: eagerly read subtitle streams when switching tracks while pausedDudemanguy2023-09-272-4/+9
| | | | | | | | | | | | | | | | | a323dfae426e43451f4d3e08a9a63cb7d1c1ace9 almost fixed subtitle tracks disappearing when paused but it actually missed one part: the behavior of demux_read_packet_async_until. It's a bit unintuitive, but for subtitle streams, that function would only return the very first packet regardless of whatever pts you pass to it. So the previous commit worked on the very first subtitle, but not actually any of the others (oops). This is because subtitle streams never marked as eager and thus never actually read farther ahead. While the video is playing, this is OK, but if we're paused and switching subtitle tracks then the stream should be eagerly read. Luckily, the logic is already there in the function for this. All we have to do add an extra argument to demux_read_packet_async_until to force the stream to be read eagerly and then it just works. Be sure to unset the eager flag when we're done. Actually fixes the bug for real this time.
* demuxer: remove several mp_read_option_raw callsDudemanguy2023-09-223-25/+12
| | | | | | | With the previous commit, we can just access option values directly now and avoid a lot of complication. Note that the mp_read_option_raw call for edition requires calling mp_get_config_group since that option needs to live in MPOpts.
* demux: make demux opts publicDudemanguy2023-09-222-43/+47
| | | | | | | Several parts of the code need to access options here. There's no point in hiding it demux.c so just expose it in the demux.h header. This means pulling it out of demux_internal and putting it in the demuxer struct instead.
* options: move some demux-specific opts to demux optsDudemanguy2023-09-221-0/+8
| | | | | These options are only ever accessed by the demuxer and have no need to be in MPOpts. Move them to demux.c instead.
* demux_lavf: set duration to -1 if unknownllyyr2023-09-221-3/+3
| | | | | | | | | | | | | `demux->duration` is set to -1 on initialization, and some checks rely on it being -1 when unknown. Before this commit, we set `demux->duration` to 0 when unknown. This is incorrect and breaks rtsp logic for disabling seeking outside of cached regions. To fix these issues, initialize `total_duration` and `av_duration` at -1. They're only changed if a real duration is detected, so in cases where the duration is unknown, demux->duration is set to -1 correctly. Fixes: e6afc53e7c ("demux_lavf: get total duration from track durations")
* options: remove a few options marked with .deprecation_messageDudemanguy2023-09-211-4/+1
| | | | | | | | | | | A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the options still possibly do something but they have a deprecation message. Most of these are old and have no real usage. The only potentially controversial ones are the removal of --oaffset and --ovoffset which were deprecated years ago and seemingly have no real replacement. There's a cryptic message about --audio-delay but who knows. The less encoding mode code we have, the better so just chuck it.
* demux_playlist: add --directory-mode=autoGuido Cella2023-09-211-1/+11
| | | | This is a more useful default with --shuffle.
* various: add missing include in header fllesllyyr2023-09-211-0/+1
| | | | Mostly cosmetic
* demux_mf: detect svgGuido Cella2023-09-211-0/+1
| | | | | This allows playing svgs without having to specify --demuxer-lavf-format=svg_pipe.
* demux: prepend some cache options with demuxerDudemanguy2023-09-181-2/+4
| | | | | | --cache-dir is an awful name that leads to confusion (see #12418). Change the name to --demuxer-cache-dir and --demuxer-cache-unlink-files instead.
* demux_mkv: support ProjectionPoseRoll elementKacper Michajłow2023-09-171-0/+23
|
* demux_mkv: support PixelCrop* elementsKacper Michajłow2023-09-171-0/+29
| | | | Fixes #6017
* demux: add crop to mp_codec_paramsKacper Michajłow2023-09-171-0/+1
|
* demux_lavf: get total duration from track durationsllyyr2023-09-021-18/+18
| | | | | | | | | | | | | | | | | | | | | | | Before this change, mpv used to get the total duration from `avformat_find_stream_info` and used the per-track duration as a fallback. This change reverses this order of preference. The timestamps returned by `avformat_find_stream_info` are truncated or rounded or floored (depending on the decoder) at the 6th decimal place. For e.g. `avformat_find_stream_info` may return us a duration like 44.138667, whereas the duration we get from the per-track struct has a higher degree of precision like 44.13866666666... and so on. This caused various problems such as the playback_pts being a bigger value than the duration, which would cause time-remaining to be a negative value in some cases. Or cause you to reach a negative starting timestamp when looping on an audio file with `gapless-audio`. Moreover, we already skipped calling `avformat_find_stream_info` for mp4, so we had already been utilizing this per-track fallback method for finding the duration for mp4 files. It should be noted that while this change is only required for audio-only formats, there is no harm in doing this for videos as well.
* demux_playlist: default to --directory-mode=lazyGuido Cella2023-08-301-3/+3
| | | | | | 64959c450d solved the problems with resuming playback, so default to --directory-mode=lazy because it's faster, especially on slow drives, and results in smaller playlists.
* demux_mf: utilize stdbool bool for if a format specifier was badJan Ekström2023-08-201-2/+4
| | | | | It is not an iterator, thus while the ++ is completely correct, it is somewhat weird.
* demux_mf: early exit with the '%%' caseJan Ekström2023-08-201-11/+23
|
* demux_playlist: remove len restriction on headerless m3uDudemanguy2023-08-151-1/+1
| | | | | | | | | | | | | Discovered by @christoph-heinrich in IRC. 09c701b797c44293dc0e22874b4acf0246b3d148 added a fallback for headerless m3u files. However, it requires that the bstr len be greater than 10. This means that a m3u playlist with a single entry with a very short filename (such as "test.flac") will not be recognized as a playlist since the amount of data is too small. The reason for this restriction is unexplained and really shouldn't matter given that the important thing mpv should be doing is checking if the data is text. Instead, loosen the check so that it only needs to be 2 or greater. This covers a single byte filename and a line terminator.
* build: remove outdated generated directoryDudemanguy2023-07-312-2/+2
| | | | | | | | | | | | | | | | This only existed as essentially a workaround for meson's behavior and to maintain compatibility with the waf build. Since waf put everything in a generated subdirectory, we had to put make a subdirectory called "generated" in the source for meson so stuff could go to the right place. Well now we don't need to do that anymore. Move the meson.build files around so they go in the appropriate place in the subdirectory of the source tree and change the paths of the headers accordingly. A couple of important things to note. 1. mpv.com now gets made in build/player/mpv.com (necessary because of a meson limitation) 2. The macos icon generation path is shortened to TOOLS/osxbundle/icon.icns.inc.
* demux_mkv: add missing space to log msgsfan52023-07-261-1/+1
|
* demux_playlist: sort files before directoriesChristoph Heinrich2023-07-061-22/+45
|
* demux_playlist: add option to control recursive directory loadingChristoph Heinrich2023-07-061-9/+40
| | | | | | | | | | | Directories were always loaded recursively, which can be slow (e.g. one of the subdirectories is a mounting point to a slow device) and can unexpectedly expand into a massive playlist. Due to the problems described in 503dada42f1ea1007768da0dc6a41b67cdf89400, this defaults to recursive loading. ref. https://github.com/mpv-player/mpv/issues/9652
* various: correctly ignore cache files with --no-configDudemanguy2023-07-061-1/+4
| | | | | | | | | | | | --no-config should prevent loading user files of any type: configs, cache, etc. For cache files, this case wasn't properly handled and it was assumed they would always get something. vo_gpu's shader cache actually already handles this, so it was left untouched. In theory, demuxer cache should never have this issue because saving it to disk is disabled by default (and likely that will never change), but go ahead and change it for consistency's sake. Fixes some segfaults with --no-config and various combinations of settings (particularly --vo=gpu-next).
* demux/demux_lavf: avoid leaking AVFormatContext during demux_open_lavfLeo Izen2023-06-181-12/+18
| | | | |