summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_h2645.c
Commit message (Collapse)AuthorAge
* avcodec/cbs_h265: add support for 3D Reference Displays Information SEIJames Almer22 hours
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h265: add support for SPS Multilayer extension fieldsJames Almer22 hours
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h266: move decoded_picture_hash to CBS SEIJames Almer2024-06-28
| | | | | | It's defined in H.274 as a common SEI message type and not in H.266 Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_sei: add support for Frame Packing Arrangement SEI parsingJames Almer2024-06-28
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/vvc: Invalidate PPSs which refer to a changed SPSFrank Plowman2024-06-20
| | | | | | | | | | When the SPS associated with a particular SPS ID changes, invalidate all the PPSs which use that SPS ID. Fixes crashes with illegal bitstreams. This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS ID reuse validation, as parts of the CBS parsing process for PPSs depend on the SPS being referred to. Signed-off-by: Frank Plowman <post@frankplowman.com>
* lavc/hevc*: move to hevc/ subdirAnton Khirnov2024-06-04
|
* avcodec/cbs_h2645: Check NAL spaceMichael Niedermayer2024-04-24
| | | | | | | Found-by-reviewing: CID1419833 Untrusted loop bound Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | 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>
* avcodec/cbs_h2645: Avoid function pointer casts, fix UBAndreas Rheinhardt2024-02-25
| | | | | | | | | | | | | | | | | The SEI message read/write functions are called via function pointers where the SEI message-specific context is passed as void*. But the actual function definitions use a pointer to their proper context in place of void*, making the calls undefined behaviour. Clang UBSan 17 warns about this. This commit fixes this by adding wrapper functions (created via macros) that have the right type that call the actual functions. This reduced the number of failing FATE tests with UBSan from 164 to 85 here. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/vvc: Fix emulation prevention byte handlingFrank Plowman2024-01-27
| | | | | | | | | | | | | | | nal->skipped_bytes_pos contains the positions of errors relative to the start of the slice header, whereas the position they were tested against is relative to the start of the slice data, i.e. one byte after the end of the slice header. Patch fixes this by storing the size of the slice header in H266RawSlice and adding it to the position given by the GetBitContext before comparing to skipped_bytes_pos. This fixes AVERROR_INVALIDDATAs for various valid bitstreams, such as the LMCS_B_Dolby_2 conformance bitstream. Signed-off-by: Frank Plowman <post@frankplowman.com>
* avcodec/cbs_h2645: Fix leak of SPS VUI extension dataAndreas Rheinhardt2023-11-04
| | | | | | | | | Fixes: VUI extension leak Fixes: 63004/clusterfuzz-testcase-minimized-ffmpeg_BSF_VVC_METADATA_fuzzer-4928832253329408 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs_h2645: Fix showing bits at the end in cbs_read_se_golomb()Michael Niedermayer2023-10-16
| | | | | | | | Fixes: Assertion n>0 && n<=25 failed at libavcodec/get_bits.h:375 Fixes: 62618/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_REDUNDANT_PPS_fuzzer-5145745046765568 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cbs_h2645: Fix showing bits at the end in cbs_read_ue_golomb()Michael Niedermayer2023-10-16
| | | | | | | | Fixes: Assertion n>0 && n<=25 failed at libavcodec/get_bits.h:375 Fixes: 62617/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5156555663998976 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cbs_sei: Use RefStruct API for SEI messagesAndreas Rheinhardt2023-10-07
| | | | | | | | | | | | | | | | | | | | | The SEI message code uses the AVBuffer API for its SEI messages and contained buffers (like the extension buffer for HEVC or the user data (un)registered payload buffers). Contrary to the ordinary CBS code (where some of these contained buffer references are actually references to the provided AVPacket's data so that one can't replace them with the RefStruct API), the CBS SEI code never uses outside buffers at all and can therefore be switched entirely to the RefStruct API. This avoids the overhead inherent in the AVBuffer API (namely the separate allocations etc.). Notice that the refcounting here is actually currently unused; the refcounts are always one (or zero in case of no refcounting); its only advantage is the flexibility provided by custom free functions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs: Use RefStruct-API for unit contentAndreas Rheinhardt2023-10-07
| | | | | | | | | | | | | | | This avoids allocations and error checks etc. as well as duplicate pointer lists in the CodedBitstreamFooContexts. It also avoids casting const away for use as opaque, as the RefStruct API supports const opaques. The fact that some of the units are not refcounted (i.e. they are sometimes part of an encoding context like VAAPIEncodeH264Context) meant that CodedBitstreamUnit still contains two pointers, one to the content and another ownership pointer, replacing the AVBufferRef* pointer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* cbs: Make tracing more generalMark Thompson2023-09-22
| | | | | | | | | | Turn tracing into callbacks for each syntax element, with default callbacks to match current trace_headers behaviour for debug. Move the construction of bit strings into the trace callback, which simplifies all of the read and write functions. Signed-off-by: Fei Wang <fei.w.wang@intel.com> Reviewed-by: Neal Gompa <ngompa13@gmail.com>
* avcodec/cbs: Add specialization for ff_cbs_(read|write)_unsigned()Andreas Rheinhardt2023-07-30
| | | | | | | | | | | | | | | | | | These functions allow not only to read and write unsigned values, but also to check ranges and to emit trace output which can be beautified when processing arrays (indices like "[i]" are replaced by their actual numbers). Yet lots of callers actually only need something simpler: Their range is only implicitly restricted by the amount of bits used and they are not part of arrays, hence don't need this beautification. This commit adds specializations for these callers; this is very beneficial size-wise (it reduced the size of .text by 23312 bytes here), as a call is now cheaper. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs_h2645: Avoid an unchecked bytesteram readMichael Niedermayer2023-07-25
| | | | | | | | | | | | The unchecked read caused the 2nd subsequent tell call to move backward resulting in a negative length Fixes: assertion failure Fixes: 60276/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5434126636023808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cbs_h266: add support for Adaptation parameter set NALU typeJames Almer2023-07-06
| | | | | Reviewed-by: Nuo Mi <nuomi2021@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h266: add support for Decoding capability information NALU typeJames Almer2023-07-05
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h266: add support for Operating point information NALU typeJames Almer2023-07-05
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h2645: fix parsing and storing Picture Header references in the ↵James Almer2023-06-30
| | | | | | context Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: add cbs implementation for H266/VVCNuo Mi2023-06-29
| | | | | | | | | | Add CodedBitstreamContext to parse VPS,SPS,PPS in VVC nal units. Implement parsing and writing of SPS,PPS,VPS,PH,AUD,SEI and slices. Add ff_cbs_type_h266 to cbs types tables and AV_CODEC_ID_H266 to cbs codec ids. Co-authored-by: Thomas Siedel <thomas.ff@spin-digital.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h2645: add discard_unit implementation for H.265Zhao Zhili2023-06-19
|
* avcodec/cbs_h2645: add discarded_unit implementation for H.264Zhao Zhili2023-06-19
|
* avcodec/cbs_{h2645,sei}: add support for Ambient Viewing Environment SEIJan Ekström2023-01-13
| | | | | | Defined by H.274, this SEI message is utilized by iPhones to save the nominal ambient viewing environment for the display of recorded HDR content.
* avcodec/cbs_h2645: Remove always-false checkAndreas Rheinhardt2022-08-08
| | | | | | | | | | The functions to replace parameter sets are only called after the respective parameter set has just been read or has just been written; all of these functions check that the id field is within the appropriate range. So the checks in the replace-functions can be removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs: Remove ff_cbs_alloc_unit_contentAndreas Rheinhardt2022-08-08
| | | | | | | It is no longer used. Also rename ff_cbs_alloc_unit_content2 to ff_cbs_alloc_unit_content. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs_internal, cbs_h2645: Add and use new descriptor macrosAndreas Rheinhardt2022-08-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs_h2645: Remove unnecessary (h264|hevc)_sei.h inclusionsAndreas Rheinhardt2022-07-02
| | | | | | | They are unnecessary since the SEI enum has been moved to sei.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/cbs: Make ff_cbs_insert_unit_data() always append the new unitAndreas Rheinhardt2022-02-08
| | | | | | | All split functions (the only users of this function) only append units. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* cbs_h265: add support for Film Grain Characteristics SEI messageJames Almer2021-08-06
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* cbs_h264: add support for Film Grain Characteristics SEI messagesJames Almer2021-07-23
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* cbs_h2645: Merge SEI message handling in common between codecsMark Thompson2021-01-21
|
* hevc: Use common SEI typesMark Thompson2021-01-21
|
* h264: Use common SEI typesMark Thompson2021-01-21
|
* cbs_h2645: Merge SEI messages in common between codecsMark Thompson2021-01-21
| | | | | Make a new template file for common SEI messages - this will also apply to H.266.
* avcodec/cbs_h2645: Move zero_byte check to its own functionNuo Mi2021-01-11
| | | | Signed-off-by: Mark Thompson <sw@jkqxz.net>
* avcodec/cbs_h2645: remove dead code in cbs_h2645_replace_ps()James Almer2020-12-01
| | | | | | | Missed in 0720e15c0330f0f101c02d5c2c6548e964079f6d. PS units are now guaranteed to always be reference counter. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h2645: implement CodedBitstreamType.flush() callbacksJames Almer2020-09-29
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* cbs_h265: Use table-based alloc/freeMark Thompson2020-09-02
|
* cbs_h2645: Ensure that non-refcounted parameter sets are fully copiedMark Thompson2020-09-02
| | | | | Only copying the main structure is not necessarily sufficient - there could be references to substructures.
* cbs_h264: Use table-based alloc/freeMark Thompson2020-09-02
|
* avcodec/cbs: Remove unused function parametersAndreas Rheinhardt2020-07-07
| | | | | | | | Several cbs-functions had an unused CodedBitstreamContext parameter. This commit removes these. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs_h2645: abort when written inferred values don't matchJames Almer2020-06-14
| | | | | | | | | | If this happens, it's a sign of parsing issues earlier in the process, or misuse by the calling module. Prevents writing invalid bitstreams. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h265: add missing support for reserved_payload_extension_data ↵James Almer2020-05-03
| | | | | | | | | | SEI bits Fixes ticket #8622 Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_h265: move the payload_extension_present check into its own functionJames Almer2020-05-03
| | | | | | Will be reused in the following patch. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: Avoid leaving the ... out in calls to variadic macrosAndreas Rheinhardt2020-04-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to C99, there has to be at least one argument for every ... in a variadic function-like macro. In practice most (all?) compilers also allow to leave it completely out, but it is nevertheless required: In a variadic macro "there shall be more arguments in the invocation than there are parameters in the macro definition (excluding the ...)." (C99, 6.10.3.4). CBS (not the framework itself, but the macros used in the cbs_*_syntax_template.c files) relies on the compiler allowing to leave a variadic macro argument out. This leads to warnings when compiling in -pedantic mode, e.g. "warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]" from Clang. Most of these warnings can be easily avoided: The syntax_templates mostly contain helper macros that expand to more complex variadic macros and these helper macros often omit an argument for the .... Modifying them to always expand to complex macros with an empty argument for the ... at the end fixes most of these warnings: The number of warnings went down from 400 to 0 for cbs_av1, from 1114 to 32 for cbs_h2645, from 38 to 0 for cbs_jpeg, from 166 to 0 for cbs_mpeg2 and from 110 to 8 for cbs_vp9. These eight remaining warnings for cbs_vp9 have been fixed by switching to another macro in cbs_vp9_syntax_template: The fixed values for the sync bytes as well as the trailing bits for byte-alignment are now read via the fixed() macro (this also adds a check to ensure that trailing bits are indeed zero as they have to be). Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/cbs_h2645: Treat slices without data as invalidAndreas Rheinhardt2020-03-10
| | | | | | | | | | | Slices that end after their header (meaning slices after the header without any data before the rbsp_stop_one_bit or possibly without any rbsp_stop_one_bit at all) are invalid and are now dropped. This ensures that one doesn't run into two asserts in cbs_h2645_write_slice_data(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Fixes: 19629/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5676822528524288 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/cbs_h2645: Remove dead code to delete trailing zeroesAndreas Rheinhardt2020-03-10
| | | | | | | | Trailing zeroes are already discarded when splitting a fragment, which makes the code to remove them when decomposing slices dead code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>