summaryrefslogtreecommitdiffstats
path: root/demux
Commit message (Collapse)AuthorAgeFilesLines
* demux/cache: fix -Wtype-limits warningsnanahi2024-03-191-5/+2
| | | | | warning: comparison of unsigned expression >= 0 is always true warning: comparison is always false due to limited range of data type
* demux: add a format-name propertyDudemanguy2024-03-172-4/+8
| | | | | It can be useful to know the underlying format of any entry in the track list. Only applicable to the lavf demuxer.
* demux_lavf: always find stream info for avif filesDudemanguy2024-03-021-0/+4
| | | | | | | | | | | avif files will commonly be probed as "mov,mp4,m4a,3gp,3g2,mj2" by ffmpeg, but demux_lavf currently has some logic to skip avformat_find_stream_info for these kinds of files. It was introduced in 6f8c953042a7a964686e5923f5c61025ef6b842e. Presumably, the optimization of mentioned in that commit is still valid however for avif we specifically need to do the avformat_find_stream_info call. Without it, several codec proprieties like width, height, etc. are unavailable. So just check the extension type and disable the skipinfo optimization.
* player: change insert_next to insert_atDavid Vaughan2024-02-262-5/+5
| | | | | | | | | | Change the `playlist_insert_next` function to `playlist_insert_at` (ie, insert at the location of an entry, rather than after it, and rename to be clearer that it doesn't have anything to do with the currently-playing entry). Also, replace calls to `playlist_add` with calls to `playlist_insert_at`, since the former has become redundant.
* osdep/io: move I/O utility functions to misc/io_utilsnanahi2024-02-231-0/+1
| | | | | | | The purpose of osdep/io is to provide a wrapper for POSIX I/O functions on Windows. The last 2 functions are utility functions which don't serve this purpose. Move them to a separate file.
* demux_mkv: don't return null bstr with size specifiedKacper Michajłow2024-02-151-0/+6
| | | | | | Such bstr object are not valid. Also reject empty blocks. Found by fuzzing.
* demux_mkv: error if needed compression settings were not foundKacper Michajłow2024-02-151-0/+4
| | | | | | | Mode 3 is header stripping and we need ContentCompSettings to reconstruct the data. Found by fuzzing.
* demux_mkv: fix memory leak on invalid blocksKacper Michajłow2024-02-151-4/+6
| | | | | | | It is possible to have data with empty block that contains additions. In which case the block would not be added and the additions would leak. Found by fuzzing.
* player/sub: attempt to detect animated subtitlesDudemanguy2024-02-151-0/+3
| | | | | | | | | | | The previous commits optimized sub redrawing on still images/terminal so mpv wouldn't redraw so much. There is a gap though. It only assumes static subtitles. Since ASS can be animated, those types of subtitles will always need redraws so we need to build in specific detection for this. We need to build a whitelist of events in ASS that are considered animations and then flag the packet. Additionally, there's a bunch of annoying bookkeeping that has to be done since packets can be dropped on seeks and so on.
* player/sub: avoid wasteful subtitle redrawsDudemanguy2024-02-151-0/+3
| | | | | | | | | | | | | | | | | This only affects two special cases: printing subtitles to the terminal and printing subtitles on a still picture. Previously, mpv was very dumb here and spammed this logic on every single loop. For terminal subtitles, this isn't as big of a deal, but for the image case this is pretty bad. The entire VO constantly redrew even when there was no need to which can be very expensive depending on user settings. Instead, let's rework sub_read_packets so that it also tells us whether or not the subtitle packets update in some way in addition to telling us whether or not to read more. Since we cache all packets thanks to the previous commit, we can leverage this information to make a guess whether or not the current subtitle packet is supposed to be visible on the screen. Because the redraw now only happens when it is needed, the mp_set_timeout_hack can be removed.
* various: replace dead links in commentsnanahi2024-02-111-2/+2
| | | | | Replace various dead links with live replacements or archives. Less friction for anyone who wants to look up these references.
* demux: clarify the meaning of still_imageGuido Cella2024-02-112-2/+2
| | | | | Clarify that ffmpeg sets AV_DISPOSITION_STILL_IMAGE for sparse videos like https://s3.amazonaws.com/tmm1/music-choice.ts, not for images.
* demux_mkv: add tags for A_MPEG/L1(mp1) audio1nsane0002024-02-101-1/+2
|
* demux_mkv: set only image flag and ignore still_imageKacper Michajłow2024-02-081-4/+2
| | | | Also check if stream is already image to avoid probing.
* demux_mkv: increase probing size for still imageKacper Michajłow2024-02-081-1/+1
| | | | | | | Some files, especially with quite a few audio tracks have video blocks further away, which made them false detected as still images. Fixes: 26a5146
* demux_mf: detect webpGuido Cella2024-02-061-0/+1
| | | | | This lets you play mf://*.webp. It is not necessary to play webp normally because they are already detected by demux_lavf.
* Revert "demux: put type2format into codec_tags with helper functions"Guido Cella2024-02-063-69/+62
| | | | | | | | | | 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.
* demux_mf: explain why a printf format is unsupportedGuido Cella2024-02-021-1/+3
|
* demux_mf: remove code repetitionGuido Cella2024-02-021-5/+1
|
* demux_mkv: detect images by reading blocks and timecodesDudemanguy2024-02-011-0/+36
| | | | | | | | | | | 4709a94aec5b16534b1d6b0d6738caeaf692e9c9 along with some related commits added a way to detect image codecs embedded into mkv streams that weren't tagged with attached picture (arguably a broken file anyways, but maybe not the worst thing to workaround). Unfortunately, this has some false positives particularly with mjpeg playback. So, as usual, revert and rewrite. Instead, we can probe the file and count blocks in the stream. If the video stream has only 1 block and 1 timecode, then assume it's a still image.
* Revert "demux_mkv: check if the video codec is an image"Dudemanguy2024-02-013-16/+0
| | | | This reverts commit 4709a94aec5b16534b1d6b0d6738caeaf692e9c9.
* csputils: replace more primitives with pl_Kacper Michajłow2024-01-221-1/+1
| | | | | We can go deeper, but need to stop somewhere to not reimplement vo_gpu using libplacebo...
* csputils: replace mp_colorspace with pl_color_spaceKacper Michajłow2024-01-222-11/+15
|
* demux_lavf: detect ico as imagesGuido Cella2024-01-191-0/+1
|
* demux_lavf: remove `fix_editlists` hack for mp4llyyr2024-01-111-8/+1
| | | | | | | | | | Remove this "hack" from 2017 which disabled `advanced_editlist` while demuxing mov/mp4. See: b7b12c36af96af14b8371d16c5a7f98a7a17915f as well as b86a2316df260de70012fb05dbddf06118b00611 At present, advanced edit list support seems to be mature enough that it doesn't need to be disabled by us and disabling it seems to break more files based on testing with `elist` files in FFmpeg's FATE suite.
* 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 switc