summaryrefslogtreecommitdiffstats
path: root/sub/lavc_conv.c
Commit message (Collapse)AuthorAgeFilesLines
* sub/lavc_conv: don't override style of converted teletext pagesKacper Michajłow10 days1-0/+9
| | | | | This fixes teletext pages rendering, while keeping the same default style for subtitles and other converted formats.
* sub/lavc_conv: don't strip ASS style headerKacper Michajłow10 days1-15/+0
| | | | | | | | | This fixes converted subtitles that are styled. This reverts commit 5e2c211a4e1d67748348295b191acb2dfb76d024. Most of the subtitle decoders in libavcodec sets meaningful style values. For the rest we can conditionally strip style.
* sub/lavc_conv: set dvb teletext and arib caption output type to ASSKacper Michajłow2024-04-171-0/+23
| | | | Also set teletext page while at it.
* sub/lavc_conv: take sd context as a parameter for lavc_conv_createKacper Michajłow2024-04-171-5/+4
| | | | Will be useful for future commits.
* sub/lavc_conv: properly fill avctx with codecpar values at initJan Ekström2023-03-141-5/+6
| | | | | | This way we receive such minor details as the profile (necessary for ARIB captions, among others) during init. This enables decoders to switch between ARIB caption profile A and profile C streams.
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-201-2/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* ffmpeg: update to handle deprecation of `av_init_packet`Philip Langdale2022-12-031-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been a long standing annoyance - ffmpeg is removing sizeof(AVPacket) from the API which means you cannot stack-allocate AVPacket anymore. However, that is something we take advantage of because we use short-lived AVPackets to bridge from native mpv packets in our main decoding paths. We don't think that switching these to `av_packet_alloc` is desirable, given the cost of heap allocation, so this change takes a different approach - allocating a single packet in the relevant context and reusing it over and over. That's fairly straight-forward, with the main caveat being that re-initialising the packet is unintuitive. There is no function that does exactly what we need (what `av_init_packet` did). The closest is `av_packet_unref`, which additionally frees buffers and side-data. However, we don't copy those things - we just assign them in from our own packet, so we have to explicitly clear the pointers before calling `av_packet_unref`. But at least we can make a wrapper function for that. The weirdest part of the change is the handling of the vtt subtitle conversion. This requires two packets, so I had to pre-allocate two in the context struct. That sounds excessive, but if allocating the primary packet is too expensive, then allocating the secondary one for vtt subtitles must also be too expensive. This change is not conditional as heap allocated AVPackets were available for years and years before the deprecation.
* sub/lavc_conv: only set subtitle text format when requiredJan Ekström2021-12-051-0/+3
| | | | | | | | | | | | | Since libavcodec major version 59, the requested "ass" format became the default as the old timing-included format was disabled starting with that version. Additionally, this option by itself has since been deprecated as it no longer serves any purpose. References: FFmpeg/FFmpeg@1f63665ca567fbc49fa80166d468a822c2999efa FFmpeg/FFmpeg@176b8d785bf7531b6eb8e3d6e8c03f75cb29de1e Fixes #9413
* build: address AVCodec, AVInputFormat, AVOutputFormat const warningssfan52021-05-011-1/+1
| | | | FFmpeg recently changed these to be const on their side.
* Remove remains of Libav compatibilitywm42020-02-161-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sub/lavc_conv: skip ReadOrder reset when subtitle decoder gets flushedJan Ekström2019-09-211-0/+1
| | | | | | | | | | | During initial testing with US closed captions, ARIB captions, timed text in MP4 or the specific external SRT files I tested with there were no hints that this flag would be needed for seeking to work. Unfortunately, that result seems to have been incorrect. Fixes #6970
* sub/sd_ass: utilize UINT32_MAX subtitle duration for unknownJan Ekström2019-09-191-3/+5
| | | | | US closed captions, teletext and ARIB caption decoders utilize this value.
* sub/lavc_conv: switch to the newer "ass" subtitle decoding modeJan Ekström2019-09-191-2/+12
| | | | | Existing since 2016, this removes timestamps from the lines, and gives more precision in the timestamps (1:1000).
* lavc_conv: do not allow libavcodec to drop subtitles with broken UTF-8wm42018-03-261-0/+1
| | | | | | | libavcodec normally drops subtitle lines that fail a check for invalid UTF-8 (their check is slightly broken too, by the way). This was always annoying and inconvenient, but now there is a mechanism to prevent it from doing this. Requires newst libavcodec.
* lavc_conv: make disable_styles fasterOleg Oshmyan2017-10-301-2/+3
| | | | | | | | | | | | | | The current invocation of bstr_cut is as good as no cutting at all. Almost the entire header is reread in every iteration of the loop. I don't know how many styles libavcodec tends to generate, but if (now or in the future) it generates many, then this loop is slow for no good reason. If anything, the code would be more clear and have the same performance if it didn't call bstr_cut at all. The intention here (and the sensible thing regardless) seems to be to skip the part of the string that bstr_find has already looked through and found nothing. This commit additionally skips the whole substring, because overlapping matches are impossible.
* lavc_conv: clamp timestamps to positive, fixes idiotic ffmpeg issuewm42017-10-271-0/+2
| | | | | | | | | | | In some cases, demux_mkv will detect a start time slightly above 0, but there might still be a subtitle starting at exactly 0. When the player rebases the timestamps to assumed start time, the subtitle will have a slightly negative timestamp in the end. libavcodec's subtitle converter turns this into a larger number due to underflow. Fix by clamping subtitles always to 0, which may or may not be what you want. At least it fixes #5047.
* lavc_conv: pass pkt_timebase to ffmpegAman Gupta2017-02-181-0/+3
| | | | Similar to code used everywhere else we create a lavc context.
* Remove compatibility thingswm42016-12-071-3/+0
| | | | | | Possible with bumped FFmpeg/Libav. These are just the simple cases.
* sub: interpret "text" subtitles as srtwm42016-04-061-0/+3
| | | | | Most players will interpret HTML-style tags (aka srt) in almost any kind of text subtitles; make mpv do this too.
* lavc_conv: fix Libav srt subtitleswm42016-02-291-4/+1
| | | | | | | | Use the mp_lavc_set_extradata() function instead of setting up the extradata manually. This takes care of the corner case when extradata_len is 0. This apparently fixes #2888.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* lavc_conv: pass real_time=1 option to ffmpeg for eia_608 decoderAman Gupta2016-01-181-1/+7
|
* sub: fix memory leakswm42016-01-181-3/+6
| | | | | | | | | demux_lavf.c leaked the complete subtitle data if it was put through iconv. lavc_conv.c leaked AVCodecContext.subtitle_header (set by libavcodec), which is fixed by using avcodec_free_context(). It also leaked the subtitle that was decoded last.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* sub: refactor initializationwm42015-12-271-9/+0
| | | | | | | | Just simplify by removing parts not needed anymore. This includes merging dec_sub allocation and initialization (since things making initialization complicated were removed), or format support queries (it simply tries to create a decoder, and if that fails, tries the next one).
* lavc_conv: fix invalid writewm42015-12-191-3/+2
| | | | | Well shit. Restructure it such that the returned list is always NULL- terminated with the same mechanism.
* sub: rename sd_lavc_conv.c to lavc_conv.cwm42015-12-181-0/+280
The previous commit turned sd_lavc_conv from a sd_driver to free-standing functions. Do the rename to reflect this change separately to avoid confusing git's content tracking. (Or did git solve this, making separating renames and content changes unnecessary?)