summaryrefslogtreecommitdiff
path: root/libavcodec/h264_metadata_bsf.c
Commit message (Collapse)AuthorAge
* avcodec/bsf: Add FFBitStreamFilter, hide internals of BSFsAndreas Rheinhardt2022-03-23
| | | | | | | | | | This patch is analogous to 20f972701806be20a77f808db332d9489343bb78: It hides the internal part of AVBitStreamFilter by adding a new internal structure FFBitStreamFilter (declared in bsf_internal.h) that has an AVBitStreamFilter as its first member; the internal part of AVBitStreamFilter is moved to this new structure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavc/{av1, h264, h265}_metadata_bsf: fix description of tick_rateZhao Zhili2022-01-01
| | | | | | | | Users may take the description literally which leads to inverted results. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> Reviewed-by: Jun Zhao <barryjzhao@tencent.com
* avcodec/h2645: Fix SEI->display matrix transformationAndreas Rheinhardt2021-12-23
| | | | | | | | | | | The earlier code did not account for the fact that av_display_rotation_set() wants the angle in the anticlockwise direction (despite what its documentation stated for a long time); furthermore, the H.2645 spec wants the flips applied first, whereas our code did it the other way around. This can be fixed by negating the angle once for every flip. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264_metadata_bsf: Allow zeroing constraint_set4_flag and ↵Derek Buitenhuis2021-06-29
| | | | | | | | | | | constraint_set5_flag These bits are reserved in earlier versions of the H.264 spec, and some poor hardware decoders require they are zero. Thus, it is useful to be able to zero these on streams that may have them set. The result is still a valid H.264 bitstream. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-27
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_metadata_bsf: Don't add AUD to extradataAndreas Rheinhardt2021-04-02
| | | | | | | This is a regression since switching to the generic CBS BSF code. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/h264_metadata_bsf: Check nb_units before accessing the first in ↵Michael Niedermayer2021-03-13
| | | | | | | | | | h264_metadata_update_fragment() Fixes: null pointer dereference Fixes: 29835/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-4712125383704576 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_metadata_bsf: Don't use unitialized valueAndreas Rheinhardt2021-01-22
| | | | | Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* h264_metadata_bsf: Use common cbs bsf implementationMark Thompson2021-01-21
|
* h264_metadata_bsf: Improve interpretation of input display matricesMark Thompson2021-01-21
| | | | The previous code here only worked in more limited cases.
* h264_metadata_bsf: Refactor the filter function into smaller partsMark Thompson2021-01-21
|
* cbs_h2645: Merge SEI message handling in common between codecsMark Thompson2021-01-21
|
* h264: Use common SEI typesMark Thompson2021-01-21
|
* h264_metadata_bsf: Move SEI user data parsing to init timeMark 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/h26[45]_metadata_bsf: Use separate contexts for reading/writingAndreas Rheinhardt2020-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, both bsfs used the same CodedBitstreamContext for reading and writing; as a consequence, the state of the writer's context at the beginning of writing a fragment is exactly the state of the reader after having read the fragment; in particular, the writer might not have encountered one of its active parameter sets yet. This is not nice and may lead to invalid output even when the input is completely spec-compliant: Think of an access unit containing a primary coded picture referencing a PPS with id id (that is known from an earlier access unit/from extradata), then a new version of the PPS with id id and then a redundant coded picture that is also referencing the PPS with id id. This is spec-compliant, as the standard allows to overwrite a PPS with a different PPS in between coded pictures and not only at the beginning of an access unit. In this scenario, the reader would read the primary coded picture with the old PPS and the redundant coded picture with the new PPS (as it should); yet the writer would write both with the new PPS as extradata which might lead to errors or to invalid data being output without any error (e.g. if the two PPS differed in redundant_pic_cnt_present_flag). The above scenario does not directly translate to HEVC as long as one restricts oneself to input with nuh_layer_id == 0 only (as cbs_h265 does: it currently strips away any NAL unit with nuh_layer_id > 0 when decomposing); if one doesn't the same issue as above can happen. If one also allowed input packets to contain more than one access unit, issues like the above can happen even without redundant coded pictures/multiple layers. Therefore this commit uses separate contexts for reader and writer. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* 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/h264_metadata_bsf: Fix invalid av_freepAndreas Rheinhardt2020-07-04
| | | | | | | This bug was introduced in 3c8a2a1180f03ca6b299ebc27eef21ae86635ca0. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec.h: split bitstream filters API into its own headerAnton Khirnov2020-05-22
|
* lavc: rename bsf.h to bsf_internal.hAnton Khirnov2020-05-22
| | | | This will allow adding a public header named bsf.h
* avcodec/h264_metadata: filter parameter sets in packet side dataJames Almer2020-05-03
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/h264_metadata_bsf: Fix for the incorrect user data with hyphensLimin Wang2020-01-08
| | | | | | | | | | | | | | | | How to reproduce: ./ffmpeg -f lavfi -i testsrc -c:v libx264 -g 25 -bsf:v h264_metadata=sei_user_data=186f3693-b7b3-4f2c-9653-21492feee5b8+hello -frames:v 1 h264.mp4 master: [Parsed_showinfo_0 @ 0x7fc8a0703180] UUID=186f3693-7030-4f2c-6030-21492feee5b8 [Parsed_showinfo_0 @ 0x7fc8a0703180] User Data=hello Applied the patch: [Parsed_showinfo_0 @ 0x7f969d408e00] UUID=186f3693-b7b3-4f2c-9653-21492feee5b8 [Parsed_showinfo_0 @ 0x7f969d408e00] User Data=hello Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* h264_metadata: Support overscan_appropriate_flagMark Thompson2019-07-29
| | | | Fixes #8041.
* av1/h264_metadata: Don't reinitialize dataAndreas Rheinhardt2019-07-28
| | | | | | | | | | If the relevant elements (the color description elements for AV1 and the VUI elements in general for H.264 (since 1156b507)) are absent, then their correct values (usually meaning unknown) have already been inferred by the reading process, so that it is unnecessary to initialize them again in the av1/h264_metadata filters even when they were initially absent. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs_h264, h264_metadata: Deleting SEI messages never failsAndreas Rheinhardt2019-07-08
| | | | | | | | | | | | Given the recent changes to ff_cbs_delete_unit, it is no longer sensible to use a return value for ff_cbs_h264_delete_sei_message; instead, use asserts to ensure that the required conditions are met and remove the callers' checks for the return value. Also, document said conditions. An assert that is essentially equivalent to the one used in ff_cbs_delete_unit has been removed, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs: ff_cbs_delete_unit: Replace return value with assertAndreas Rheinhardt2019-07-08
| | | | | | | | | | ff_cbs_delete_unit never fails if the index of the unit to delete is valid, as it is with all current callers of the function. So just assert in ff_cbs_delete_unit that the index is valid and change the return value to void in order to remove the callers' checks for whether ff_cbs_delete_unit failed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* h264_metadata: Localize code for display orientationAndreas Rheinhardt2019-07-07
| | | | | | | | | | | | | | | The recent changes to h264_metadata (enabled by the recent changes to ff_cbs_write_packet) made it possible to add side_data to the output packet at any place, not only after the output packet has been written and the properties of the input packet copied. This means that one can now localize the code to add display orientation side-data to the packet to the place dealing with said display-orientation. Furthermore, the documentation of av_display_rotation_set states that the matrix will be fully overwritten by it, so there is no need to allocate it with av_mallocz. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* h264_metadata: Avoid allocations and copies of packet structuresAndreas Rheinhardt2019-07-07
| | | | | | | | | | | This commit changes h264_metadata to (a) use ff_bsf_get_packet_ref instead of ff_bsf_get_packet (thereby avoiding one malloc and free per filtered packet) and (b) to use only one packet structure at all, thereby avoiding a call to av_packet_copy_props. (b) has been made possible by the recent changes to ff_cbs_write_packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* av1/h264_metadata, filter_units: Count down when deleting unitsAndreas Rheinhardt2019-07-07
| | | | | | | | | | | | | | When testing whether a particular unit should be kept or discarded, it is best to start at the very last unit of a fragment and count down, because that way a unit that will eventually be deleted won't be memmoved during earlier deletions; and frag/au->nb_units need only be evaluated once in this case and the counter is automatically correct when a unit got deleted. It also works for double loops, i.e. when looping over all SEI messages in all SEI units of an access unit. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc/h264_levels: add MaxMBPS checking and update fate test.Decai Lin2019-03-27
| | | | | | | | | 1. add MaxMBPS checking for level idc setting to align with AVC spec AnnexA table A-1/A-6 level limits. 2. update h264 level fate test. Signed-off-by: Decai Lin <decai.lin@intel.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* libavcodec/cbs: Stop needlessly reallocating the units arrayAndreas Rheinhardt2019-02-25
| | | | | | | | | | | | | | | | | Currently, a fragment's unit array is constantly reallocated during splitting of a packet. This commit changes this: One can keep the units array by distinguishing between the number of allocated and the number of valid units in the units array. The more units a packet is split into, the bigger the benefit. So MPEG-2 benefits the most; for a video coming from an NTSC-DVD (usually 32 units per frame) the average cost of cbs_insert_unit (for a single unit) went down from 6717 decicycles to 450 decicycles (based upon 10 runs with 4194304 runs each); if each packet consists of only one unit, it went down from 2425 to 448; for a H.264 video where most packets contain nine units, it went from 4431 to 450. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
* h264_metadata: Don't use inferred value of buffering framesAndreas Rheinhardt2018-11-13
| | | | | | | | Using the value of buffering frames inferred from the old level is not a sensible approach when one wants to guess the level. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* h264_levels, h264_metadata_bsf: Fix levels typoAndreas Rheinhardt2018-11-13
| | | | | | | profile_idc for level 1b should be 11, not 10. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* h264_metadata: Avoid integer overflow in bitrateMark Thompson2018-09-24
| | | | Fixes CID #1439664.
* h264_metadata: Add option to set the level of the streamMark Thompson2018-09-23
|
* h264_metadata: Fix AUD writingMark Thompson2018-05-10
| | | | | The aud structure exists on the stack, so the variable was previously out-of-scope when the unit is written.
* h264_metadata: Remove redundant setting of SEI payload sizeMark Thompson2018-05-10
| | | | This should be derived from the data length rather than set explicitly.
* avcodec/h264_metadata: fix memory leak in case of output packet creation failureJames Almer2018-03-20
| | | | | | | Some function calls may fail after the output packet is initialized. Reviewed-by: jkqxz Signed-off-by: James Almer <jamrial@gmail.com>
* h264_metadata: Fix memory leak on multiple display orientation messagesMark Thompson2018-03-19
| | | | Fixes CID #1430176.
* lavc/h264_metadata_bsf: support dump options.Jun Zhao2018-03-18
| | | | | Signed-off-by: Jun Zhao <mypopydev@gmail.com> Signed-off-by: Mark Thompson <sw@jkqxz.net>
* h264_metadata: Remove unused fieldsMark Thompson2018-03-18
| | | | | The SEI NAL is unused since 69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb, while the AUD NAL is small and would more sensibly be on the stack.
* h264_metadata: Add support for display orientation SEI messagesMark Thompson2018-03-18
|
* h264_metadata: Actually fail when sei_user_data option is invalidMark Thompson2018-03-06
|
* Merge commit '6d5a6dde5301c81e221a37b3f39bb03149492b98'Mark Thompson2018-02-21
|\ | | | | | | | | | | | | | | | | * commit '6d5a6dde5301c81e221a37b3f39bb03149492b98': h264_metadata: Add option to delete filler data Fixes #6899. Merged-by: Mark Thompson <sw@jkqxz.net>
| * h264_metadata: Add option to delete filler dataMark Thompson2018-02-20
| | | | | | | | | | Deletes both filler NAL units and filler SEI messages. (Annex B zero_bytes between NAL units are already discarded by the read/write process.)
* | Merge commit '78fa0b9033c0834c049e2aedf71a8c613fed87ab'Mark Thompson2018-02-21
|\| | | | | | | | | | | | | | | | | | | * commit '78fa0b9033c0834c049e2aedf71a8c613fed87ab': h264_metadata: Always add the SEI user data to the first access unit Mostly already present from a308872b049e33f69f4b629a06f47e3681906b93, one cosmetic change applied. Merged-by: Mark Thompson <sw@jkqxz.net>
| * h264_metadata: Always add the SEI user data to the first access unitMark Thompson2018-02-20
| | | | | | | | | | This should be added even if the first access unit does not contain parameter sets.
* | Merge commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb'Mark Thompson2018-02-21
|\| | | | | | | | | | | | | | | | | * commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb': h264_metadata: Use common SEI addition function Minor changes because the following patch is already present. Merged-by: Mark Thompson <sw@jkqxz.net>
| * h264_metadata: Use common SEI addition functionMark Thompson2018-02-20
| |