summaryrefslogtreecommitdiff
path: root/libavcodec/cbs_mpeg2.h
Commit message (Collapse)AuthorAgeFilesLines
* cbs: Ensure that reference fields always follow the associated pointerMark Thompson2020-09-021-5/+5
| | | | | Having these together allows us to find both pointers given the address of only one of them.
* avcodec/cbs: Factor out common code for writing unitsAndreas Rheinhardt2019-11-171-4/+0
| | | | | | | | | | | | | | | | | All cbs-functions to write units share a common pattern: 1. They check whether they have a write buffer (that is used to store the unit's data until the needed size becomes known after writing the unit when a dedicated buffer will be allocated). 2. They use this buffer for a PutBitContext. 3. The (codec-specific) writing takes place through the PutBitContext. 4. The return value is checked. AVERROR(ENOSPC) here always indicates that the buffer was too small and leads to a reallocation of said buffer. 5. The final buffer will be allocated and the data copied. This commit factors this common code out in a single function in cbs.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs_mpeg2: Decompose Sequence EndAndreas Rheinhardt2019-07-291-0/+4
| | | | | | | | | Sequence End units (or actually, sequence_end_codes) have up until now not been decomposed; in fact due to a bug in cbs_mpeg2_split_fragment they have mostly been treated as part of the preceding unit. So implement decomposing them as preparation for fixing said bug. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs_mpeg2: Fix parsing of picture and slice headersAndreas Rheinhardt2019-07-271-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The extra information in slice headers was parsed incorrectly: In the first reading pass to derive the length of the extra information, one should look at bits n, n + 9, n + 18, ... and check whether they equal one (further extra information) or zero (end of extra information), but instead bits n, n + 8, n + 16, ... were inspected. The second pass of reading (where the length is already known and the bytes between the length-determining bits are copied into a buffer) did not record what was in bits n, n + 9, n + 18, ..., presuming they equal one. And during writing, the bytes in the buffer are interleaved with set bits and written. This means that if the detected length of the extra information was greater than the real length, the output was corrupted. Fortunately no sample is known that made use of this mechanism: The extra information in slices is still marked as reserved in the specifications. cbs_mpeg2 is now ready in case this changes. 2. Furthermore, the buffer is now padded and slightly different, but very similar code for reading resp. writing has been replaced by code used for both. This was made possible by a new macro, the equivalent to cbs_h2645's fixed(). 3. These changes also made it possible to remove the extra_bit_slice element from the MPEG2RawSliceHeader structure. Said element was always zero except when the detected length of the extra information was less than the real length. 4. The extra information in picture headers (which uses essentially the same syntax as the extra information in slice headers) has simply been forgotten. This meant that if this extra information was present, it was discarded during reading; and unfortunately writing created invalid bitstreams in this case (an extra_bit_picture - the last set bit of the whole unit - indicated that there would be a further byte of data, although the output didn't contain said data). This has been fixed; both types of extra information are now parsed via the same code and essentially passed through. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs_mpeg2: Fix storage type for frame_centre_*_offsetAndreas Rheinhardt2019-05-291-2/+2
| | | | | | | | | | | | | | | | | The frame_centre_horizontal/vertical_offset values contained in picture display extensions are actually signed values (i.e. it is possible to indicate that the display device should add black bars/pillars). The files sony-ct3.bs and tcela-6.bits (which are both used in fate tests for mpeg2_metadata) contain picture display extensions; the former even contains a negative frame_centre_vertical_offset. Fortunately, the old code did not damage the picture display extensions when one did a cycle of reading and writing. For the same reason the fate tests needn't be updated either. Furthermore these fields now use the trace output for matrices. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* cbs_mpeg2: Correct and use enum valuesAndreas Rheinhardt2019-05-281-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'Mark Thompson2018-02-211-0/+5
|\ | | | | | | | | | | | | | | | | * 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-201-0/+5
| | | | | | | | | | | | | | | | 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_mpeg2: Add support for picture display extensionMark Thompson2017-09-121-0/+8
| |
| * lavc: Add coded bitstream read/write support for MPEG-2Mark Thompson2017-08-201-0/+216
| | | | Also enable MPEG-2 support in the trace_headers filter.
* lavc: Add coded bitstream read/write support for MPEG-2Mark Thompson2017-10-171-0/+224
(cherry picked from commit 2bc9ba8d3c41f3a8e56484bd67b05040c7909a01) (cherry picked from commit a41b69b5eb950c10d8ede472bcc4e88ce4246db9)