aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/itut35: rename some provider codesMaryla Ustarroz-Calonge43 hours1-1/+1
| | | | | | | | | | | | | | | | | | In general, a provider code corresponds to a company/organization, and the name should be that of the company, not of a given feature. The feature is signalled in the "provider oriented code". The exception is HDR Vivid, where the code 0x0004 indicates the HDR Vivid feature itself rather than CUVA (China UHD Video Industry Alliance), according to the UHD World Associations 'HDR Video Technology Part 2-1 Application Guide to System Integration' document. ITU_T_T35_PROVIDER_CODE_CUVA -> ITU_T_T35_PROVIDER_CODE_HDR_VIVID ITU_T_T35_PROVIDER_CODE_LCEVC-> ITU_T_T35_PROVIDER_CODE_VNOVA ITU_T_T35_PROVIDER_CODE_SMTPE -> ITU_T_T35_PROVIDER_CODE_SAMSUNG Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/matroskaenc: Use native id V_FFV1 instead of V_MS/VFW/FOURCCAndreas Rheinhardt2025-05-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, our muxer wrote FFV1 in video-for-windows compatibility mode out of concern for old demuxers that only support that (whereas the demuxer accepts V_FFV1). This commit switches to using native mode, because a) V_FFV1 is around long enough so that old demuxers should not be an issue (support in FFmpeg has been added in commit 9ae762da7e256aa4d3b645c614fcd1959e1cbb8d in March 2017/FFmpeg 3.3), b) using native mode uses fewer bytes for the CodecPrivate, c) the VfW extradata is zero-padded to an even length if necessary, but our demuxer forgot to undo the padding until very recently (92e310eb82e04713e55d248b65c22f0eb95afada), so that there are many versions of our demuxer around that are buggy wrt VFW, but not V_FFV1. This affects the FFV1 extradata checksums, specifically the (experimental) version 4 files with error check version 2* as created by ffmpeg -i ../fate-suite/mpeg2/sony-ct3.bs -c:v ffv1 \ -slices 16 -frames 1 -level 4 -strict experimental ffv1.mkv VFW files like the above created by this muxer before this patch would not work with an old demuxer. *: Without error check version 2, the CRC for the whole extradata is zero, which is not changed by appending a zero byte. Reviewed-by: compn <ff@hawaiiantel.net> Reviewed-by: Dave Rice <dave@dericed.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroska: Support JPEG2000 for demuxingAndreas Rheinhardt2025-05-281-2/+2
| | | | | | | | | | Legal since commit 1cd0a9be4b2d1e7c60184ec68404e00e46e3123e (Jan 4) in the Cellar Matroska specification git repo. We still hold out on muxing it due to compatibility with old demuxers. Reviewed-by: compn <ff@hawaiiantel.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: remove deprecated FF_API_ALLOW_FLUSHJames Almer2025-03-281-13/+0
| | | | | | Deprecated since 2023-10-02. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: log unsupported subtitle codec nameZhao Zhili2025-02-041-1/+2
| | | | | | | It's more user friendly than codec ID. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> Reviewed-by: Marth64 <marth64@proxyid.net>
* avformat/matroska: add support for VVC streamsJames Almer2025-01-121-2/+8
| | | | | | As defined in https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md#v_mpegiisovvc Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hevc: add a log context to ff_isom_write_{hvcc,lhvc}James Almer2024-12-081-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: Avoid indirection via st->codecparAndreas Rheinhardt2024-07-081-16/+18
| | | | | | | | Use the already available AVCodecParameters pointer instead. Shortens lines. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Only write useful cropping valuesAndreas Rheinhardt2024-07-081-4/+8
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Fix and simplify check for invalid crop valuesAndreas Rheinhardt2024-07-081-4/+2
| | | | | | | | | | | | | | | The check "left >= INT_MAX - right" is supposed to check for whether left + right does not overflow/wraparound, but given that left and top are uint32_t INT_MAX - right can already wraparound for big values of right (and ordinary 32-bit ints): If right == UINT32_MAX, INT_MAX - right is INT_MAX + 1; for left in 0..par->width both checks will be passed. Fix this and simplify the check by using 64-bit types, where the addition is guaranteed not to overflow. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Fix potential stack-buffer-overflowAndreas Rheinhardt2024-07-081-1/+1
| | | | | | | Forgotten in f194f291d8082134cdce625b0ca3548067428ea9 Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: support writing cropping valuesJames Almer2024-07-081-7/+37
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: split off generic NAL function helpers into their own fileJames Almer2024-06-201-0/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: Check ff_put_wav_header() failureAndreas Rheinhardt2024-05-251-1/+3
| | | | | | Fixes Coverity issue #1506706. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/matroskaenc: apply consistent style to options descriptionsStefano Sabatini2024-04-191-13/+13
|
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Rename FF_FMT_ALLOW_FLUSH->FF_OFMT_FLAG_ALLOW_FLUSHAndreas Rheinhardt2024-03-221-3/+3
| | | | | | | It better reflects that this is a muxer-only flag. Also document the flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroska: use named constants for ITU-T T.35 metadataJames Almer2024-03-191-2/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* avformat/matroska: Add support for A_ATRAC/AT1asivery2024-02-131-0/+1
| | | | | Signed-off-by: asivery <asivery@protonmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: use the side data from AVStream.codecparJames Almer2023-10-061-20/+35
| | | | | | | | | | | | Deprecate AVStream.side_data and its helpers in favor of the AVStream's codecpar.coded_side_data. This will considerably simplify the propagation of global side data to decoders and from encoders. Instead of having to do it inside packets, it will be available during init(). Global and frame specific side data will therefore be distinct. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/avformat: Deprecate AVFMT_ALLOW_FLUSHAndreas Rheinhardt2023-10-031-0/+15
| | | | | | | | | | | | | | | It is of no value to the user, because every muxer can always be flushed with a NULL packet. As its documentation shows ("If not set, the muxer will not receive a NULL packet in the write_packet function") it is actually an internal flag that has been publically exposed because there was no internal flags field for output formats for a long time. But now there is and so use it by replacing the public flag with a private one. Reviewed-by: James Almer <jamrial@gmail.com> Reviewed-by: Anton Khirnov <anton@khirnov.net> Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Write default duration for audioAndreas Rheinhardt2023-10-021-0/+7
| | | | | | | This is easily possible for those codecs with a fixed frame-size (in samples). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't create wrong packet durationsAndreas Rheinhardt2023-10-021-10/+30
| | | | | | | | | | | | | | | | | | | | | | | | | We have to write an explicit BlockDuration element (and use a BlockGroup instead of a SimpleBlock) in case the Track has a DefaultDuration that is inconsistent with the duration of the packet. The matroska-h264-remux test uses a file with coded fields where the duration of a Block is the duration of a field, not of a frame, therefore this patch writes said BlockDuration elements. (When using a BlockGroup, one has to add ReferenceBlock elements to distinguish keyframes from non-keyframes. Unfortunately, the AV1 codec mapping [1] requires us to reference all references and to really use the real references, which requires a lot of effort for basically no gain. When BlockGroups are used with AV1, the created files are most likely invalid, both before and after this patch, but this patch makes this more likely to happen.) [1]: https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec/av1.md Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* definesAndreas Rheinhardt2023-09-071-3/+3
| | | | | | | | | These defines are also used in other contexts than just AVCodecContext ones, e.g. in libavformat. Furthermore, given that these defines are public, the AV-prefix is the right one, so deprecate (and not just move) the FF-macros. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroska(dec|enc): Rename macro to avoid clash with winbase.hAndreas Rheinhardt2023-09-021-2/+2
| | | | | | | | winbase.h defines IGNORE and is included via bzlib.h when compiling for Windows. So rename this macro to NOTHING. Also rename the muxer macro for consistency. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Improve message for WebM-incompatible StereoModesAndreas Rheinhardt2023-08-301-1/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't add side-data to input streamAndreas Rheinhardt2023-08-301-65/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When muxing, the AVStreams' side-data is typically set by the caller before avformat_write_header(); it is not documented to be else. Yet the Matroska muxer added an AVStereo3D side data if certain metadata was present: Since commit 4d686fb721b485ebbc4c7779d927d876c1e630f7 (adding support for AVStereo3D stream side-data), the Matroska muxer checked certain stream tags that contain Matroska's StereoMode and (if they are present) converted this value into an AVStereo3D struct that gets attached to the AVStream (reusing a function from the demuxer). Afterwards the AVStereo3D side data struct (whether it has just been added by the muxer or not) gets parsed and converted back into a Matroska StereoMode. Besides being an API violation this change broke StereoMode values without a corresponding AVStereo3D (namely the anaglyph ones). This commit fixes this: A StereoMode given via tags is now used-as-is; if no such tag exists and an AVStereo3D side data exists, it is converted into the corresponding StereoMode (if possible). This approach also fixes handling of the anaglyph ones; the changes to the matroska-stereo_mode are due to this. The new STEREOMODE_STEREO3D_MAPPING has been put to good use for this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Avoid atoi()Andreas Rheinhardt2023-08-301-6/+5
| | | | | | | | | | It has undefined behaviour in case the value does not fit into an int. Also stop allowing to override a stream level "alpha_mode" tag by an AVFormatContext one and properly check that the stereo_mode number given via a tag is actually in the range 0..14: Negative values would have been treated as zero before this patch. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Fix writing of markersSteinar H. Gunderson2023-08-291-1/+1
| | | | | | | | | | | | | When the marker writing code was merged from libav to FFmpeg in dc62016c, it failed to take into account that the meaning of cluster_pos had changed in bda5b662; in particular, the special value for “I'm not currently working on a cluster” had changed from 0 to -1. This makes the avio_write_marker() call never be called. Update the if statement to fix it. Fixes: Ticket9843 Signed-off-by: Steinar H. Gunderson <steinar+ffmpeg@gunderson.no> Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/matroskaenc: Don't write \0 unnecessarilyAndreas Rheinhardt2023-08-101-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | Writing the duration SimpleTag is special: It's size is reserved in advance via an EBML Void element (if seekable) and this reserved space is overwritten when writing the trailer; it does not use put_ebml_string(). The string to write is created via snprintf on a buffer of size 20; this buffer is then written via put_ebml_binary() with a size of 20. EBML strings need not be zero-terminated; if not, they are implicitly terminated by the element's length field. snprintf() always zero-terminates the buffer, i.e. the last byte can be discarded when using an EBML string. This patch does this. The FATE changes are as expected: One byte saved for every track; the only exception is the matroska-qt-mode test: An additional byte is saved because an additional byte could be saved from the enclosing Tags length field. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Reindent after the previous commitAndreas Rheinhardt2023-08-101-24/+25
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't reserve space for HDR10+ when unnecessaryAndreas Rheinhardt2023-08-101-2/+7
| | | | | | | | | | Do it only for video (the only thing for type for which HDR10+ makes sense). This effectively reverts changes to several FATE ref-files made in bda44f0f39e8ee646e54f15989d7845f4bf58d26. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Add const where appropriateAndreas Rheinhardt2023-08-101-4/+5
| | | | | | Also move getting the DOVI side data immediately before its use. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Avoid allocations when writing Dynamic HDR10+Andreas Rheinhardt2023-08-101-19/+7
| | | | | | Possible since 61b27b15fc924d7fa35baa61cfbc91568945f5db. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Use dedicated pointer for accessesAndreas Rheinhardt2023-08-101-7/+13
| | | | | | Improves readability; also split overlong lines. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Use proper AVIOContextAndreas Rheinhardt2023-08-101-1/+1
| | | | | | | | These two AVIOContexts currently coincide, but this is not guaranteed to remain so (in fact, I have plans to write each TrackEntry into its own AVIOContext). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Remove unnecessary checkAndreas Rheinhardt2023-08-101-2/+2
| | | | | | | It is only WebVTT which is special in WebM; hypothetical future subtitle codecs in WebM will presumably use the ordinary code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Hoist check out of loopAndreas Rheinhardt2023-08-101-2/+6
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't pretend to be able to mux RV30Andreas Rheinhardt2023-08-101-7/+3
| | | | | | | | | | | | | The demuxer uses a extradata offset of 26, so we would need to recreate the missing 26 bytes somehow in the muxer, but we just don't. Remuxed files (like real/rv30.rm from the FATE-suite) don't work due to missing extradata. (The extradata offset also applies to RV40 and the extradata is indeed lost upon remuxing, yet remuxing real/spygames-2MB.rmvb works; our RV40 decoder does not use extradata at all.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't pretend to support unsupported codecsAndreas Rheinhardt2023-08-101-4/+0
| | | | | | | | | | | RV10 and RV20 are unsupported because creating the correct CodecPrivate is unsupported (the demuxer uses a codecpriv_offset of 26, so one would need to recreate the missing 26 bytes); COOK and SIPR are unsupported, because Matroska uses a packetization mode that is different from what FFmpeg uses in its packets (see matroska_parse_rm_audio() in the demuxer). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't reserve unnecessarily many EBML elementsAndreas Rheinhardt2023-08-101-1/+1
| | | | | | | | | bda44f0f39e8ee646e54f15989d7845f4bf58d26 added code that potentially added another BlockMore master and BlockAdditional data as well as BlockAddID number, yet it bumped the number of EBML elements by four instead of only three. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Support rotationsAndreas Rheinhardt2023-08-101-17/+83
| | | | | | | | | | | | | | | | | Matroska supports orthogonal transformations (both pure rotations as well as reflections) via its 3D-projection elements, namely ProjectionPoseYaw (for a horizontal reflection) as well as ProjectionPoseRoll (for rotations). This commit adds support for this. Support for this in the demuxer has been added in 937bb6bbc1e8654633737e69e403e95a37113058 and the sample used in the matroska-dovi-write-config8 FATE-test includes a displaymatrix indicating a rotation which is now properly written and read, thereby providing coverage for the relevant code in the muxer as well as the demuxer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: remove accidental variable shadowingJames Almer2023-05-201-2/+2
| | | | | | Should fix use of uninitialized value in a failure path. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: fix memory leak in fail codepathJames Almer2023-04-101-1/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: support writing Dynamic HDR10+ packet side dataJames Almer2023-04-081-13/+66
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: write a MaxBlockAdditionID elementJames Almer2023-04-051-4/+31
| | | | | | A non zero value is mandatory for Matroska if the track has blocks with BlockAdditions. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroska: add a few more Block Addition ID Type enum valuesJames Almer2023-04-051-3/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>