summaryrefslogtreecommitdiff
path: root/libavcodec/h264_metadata_bsf.c
Commit message (Collapse)AuthorAge
* 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
| |
* | Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'Mark Thompson2018-02-21
|\| | | | | | | | | | | | | | | | | * commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2': cbs: Refcount all the things! Some changes for bitstream API. Merged-by: Mark Thompson <sw@jkqxz.net>
| * cbs: Refcount all the things!Mark Thompson2018-02-20
| | | | | | | | | | | | | | | | This makes it easier for users of the CBS API to get alloc/free right - all subelements use the buffer API so that it's clear how to free them. It also allows eliding some redundant copies: the packet -> fragment copy disappears after this change if the input packet is refcounted, and more codec-specific cases are now possible (but not included in this patch).
| * cbs: Allocate the context inside the init functionMark Thompson2018-02-20
| | | | | | | | | | ... instead of making callers allocate it themselves. This is more consistent with other APIs in libav.
| * h264_metadata: Fix clearing SEI payload in error caseMark Thompson2017-11-12
| |
| * h264_metadata: Fix double-freeMark Thompson2017-09-12
| | | | | | | | | | | | Whether the udu string should be freed depends on whether the SEI it gets added to was created internally by cbs or externally by the bsf. The current code frees it twice in the former case.
| * lavc: Add h264_metadata bitstream filterMark Thompson2017-08-13
| | | | | This is able to modify some header metadata found in the SPS/VUI, and can also add/remove AUDs and insert user data in SEI NAL units.
* avcodec/h264_metadata_bsf: fix the AVClass version numberJames Almer2017-11-12
| | | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: jkqxz Signed-off-by: James Almer <jamrial@gmail.com>
* h264_metadata: Fix clearing SEI payload in error caseMark Thompson2017-10-18
| | | | Fixes CID 1419832, 1419835.
* lavc: Add h264_metadata bitstream filterMark Thompson2017-10-17
This is able to modify some header metadata found in the SPS/VUI, and can also add/remove AUDs and insert user data in SEI NAL units. (cherry picked from commit 9e93001b6135a23fe4e200196c08fb4fbffed6fc) (cherry picked from commit c42b62d1f9641f10ffc23cad9abbe47d8a4a165b)