Commit Graph

13 Commits

Author SHA1 Message Date
Andreas Rheinhardt c2a91645c5 mpeg2_metadata, cbs_mpeg2: Fix handling of colour_description
If a sequence display extension is read with colour_description equal to
zero, but a user wants to add one or more of the colour_description
elements, then the colour_description elements the user did not explicitly
request to be set are set to zero and not to the value equal to
unknown/unspecified (namely 2). A value of zero is not only inappropriate,
but explicitly forbidden. This is fixed by inferring the right default
values during the reading process if the elements are absent; moreover,
changing any of the colour_description elements to zero is now no longer
possible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-27 22:00:43 +01:00
Andreas Rheinhardt 42114094da mpeg2_metadata: Localize inserting of sequence display extensions
If a new sequence display extension had to be added, this was up until
now done at two places: One where a sequence display extension was
initialized with default values and one where the actual sequence
display extension was inserted into the fragment. This division of
labour is unnecessary and pointless; it has been changed.

Furthermore, if a sequence display extension has to be added, the
earlier code set some fields to their default value twice. This has been
changed, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-07-07 23:04:27 +01:00
Andreas Rheinhardt dd5ce54d2a mpeg2_metadata: Avoid allocations and copies of packet structures
This commit changes mpeg2_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>
2019-07-07 22:59:25 +01:00
Andreas Rheinhardt b8c45bbcbc libavcodec/cbs: Stop needlessly reallocating the units array
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>
2019-02-25 21:40:13 +00:00
James Almer 2aac5ad2f7 avcodec/mpeg2_metadata: unref output packet on failure
Move the check and unref call to the end to be consistent with other
bsfs.

Reviewed-by: jkqxz
Signed-off-by: James Almer <jamrial@gmail.com>
2018-03-20 18:26:38 -03:00
Jun Zhao dd21f02a04 lavc/mpeg2_metadata_bsf: support dump options.
Signed-off-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2018-03-18 20:32:45 +00:00
Mark Thompson 0cc8e34a94 Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'
* commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2':
  cbs: Refcount all the things!

Some changes for bitstream API.

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 22:22:54 +00:00
Mark Thompson ce5870a3a8 cbs: Refcount all the things!
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).
2018-02-20 22:04:12 +00:00
Mark Thompson 2651352988 cbs: Allocate the context inside the init function
... instead of making callers allocate it themselves.  This is more
consistent with other APIs in libav.
2018-02-20 22:04:12 +00:00
James Almer a7e7abf849 avcodec/mpeg2_metadata_bsf: fix the AVClass version number
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: jkqxz
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-12 12:49:37 -03:00
Mark Thompson 569721ac8d lavc: Add mpeg2_metadata bitstream filter
(cherry picked from commit b78c30d7ec)
2017-10-17 20:56:30 +01:00
Mark Thompson b5859e0b04 mpeg12: Move finding the best frame rate to common code
Previously in the mpeg2_metadata filter.  Also adds a test.
2017-09-12 22:11:56 +01:00
Mark Thompson b78c30d7ec lavc: Add mpeg2_metadata bitstream filter 2017-08-20 15:14:33 +01:00