1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

25 Commits

Author SHA1 Message Date
Anton Khirnov
9dbdabe0e0 lavc/cbs_internal: clean up headers
Include all required headers explicitly, avoid avcodec.h dependency.
2021-06-10 16:51:44 +02:00
James Almer
9caf132462 avcodec/cbs: add an AVClass to CodedBitstreamType for option handling
So unit parsing may be configured with caller set options.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
James Almer
515b6419ca avcodec/cbs: add a flush callback to CodedBitstreamType
Used to reset the codec's private internal state.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-29 21:38:27 -03:00
Mark Thompson
42daac1c74 cbs: Add support functions for handling unit content references
Use the unit type table to determine what we need to do to clone the
internals of the unit content when making copies for refcounting or
writeability.  (This will still fail for units with complex content
if they do not have a defined clone function.)

Setup and naming from a patch by Andreas Rheinhardt
<andreas.rheinhardt@gmail.com>, but with the implementation changed
to use the unit type information if possible rather than requiring a
codec-specific function.
2020-09-02 00:00:57 +01:00
Mark Thompson
225f287885 cbs: Add macros to support defining unit type tables 2020-09-02 00:00:57 +01:00
Mark Thompson
bc7a7e0d65 cbs: Describe allocate/free methods in tabular form
Unit types are split into three categories, depending on how their
content is managed:
* POD structure - these require no special treatment.
* Structure containing references to refcounted buffers - these can use
  a common free function when the offsets of all the internal references
  are known.
* More complex structures - these still require ad-hoc treatment.

For each codec we can then maintain a table of descriptors for each set of
equivalent unit types, defining the mechanism needed to allocate/free that
unit content.  This is not required to be used immediately - a new alloc
function supports this, but does not replace the old one which works without
referring to these tables.
2020-09-02 00:00:57 +01:00
Andreas Rheinhardt
7c92eaace2 avcodec/cbs: Factor out common code for writing units
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>
2019-11-17 23:31:44 +00:00
James Almer
5006dcdf9a avcodec/cbs: add helper functions and macros to read and write signed values
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-04-16 20:31:18 -03:00
Mark Thompson
c8c81ac502 lavc: Add coded bitstream read/write support for AV1 2018-09-26 23:27:53 +01:00
Mark Thompson
525de2000b lavc/cbs: Add JPEG support 2018-09-23 14:42:34 +01:00
Mark Thompson
b5df289eb7 lavc: Add coded bitstream read/write support for VP9 2018-05-02 01:21:33 +01:00
Mark Thompson
300ef25314 cbs: Add support for array subscripts in trace output
This makes the trace output for arrays significantly nicer.
2018-05-02 01:20:45 +01:00
Mark Thompson
0e782661d6 cbs_h264: Fix overflow in shifts
The type of the result of a shift operation is unaffected by the type of
the right operand, so some existing code overflows with undefined behaviour
when the element length is 32.  Add a helper macro to calculate the maximum
value correctly and then use it everywhere this pattern appears.

Found-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com>
2018-03-18 17:54:55 +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
7dc8752e61 Merge commit '254e728d207c173a3714e6a01c9d68fcb3af8b73'
* commit '254e728d207c173a3714e6a01c9d68fcb3af8b73':
  cbs: Minor comment fixes / cosmetics

Mostly already present, one small fix.

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 21:36:08 +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
254e728d20 cbs: Minor comment fixes / cosmetics 2018-02-20 22:04:12 +00:00
Mark Thompson
686e388bbb lavc: Add coded bitstream read/write support for MPEG-2
(cherry picked from commit 2bc9ba8d3c)
(cherry picked from commit a41b69b5eb)
2017-10-17 20:56:29 +01:00
Mark Thompson
9b0c7aa0e4 lavc: Add coded bitstream read/write support for H.265
(cherry picked from commit 867381b8b5)
(cherry picked from commit f763489364)
(cherry picked from commit 067a9ddeb8)
2017-10-17 20:56:29 +01:00
Mark Thompson
b4c915f4b3 lavc: Add coded bitstream read/write support for H.264
(cherry picked from commit acf06f4544)
(cherry picked from commit 768eb9182e)
(cherry picked from commit e7f64191b2)
2017-10-17 20:56:29 +01:00
Mark Thompson
6734eef6b8 lavc: Add coded bitstream read/write API
(cherry picked from commit 18f1706f33)
(cherry picked from commit 44cde38c8a)
2017-10-17 20:56:29 +01:00
Mark Thompson
2bc9ba8d3c lavc: Add coded bitstream read/write support for MPEG-2
Also enable MPEG-2 support in the trace_headers filter.
2017-08-20 13:59:17 +01:00
Mark Thompson
867381b8b5 lavc: Add coded bitstream read/write support for H.265 2017-08-12 22:17:20 +01:00
Mark Thompson
acf06f4544 lavc: Add coded bitstream read/write support for H.264 2017-08-12 22:17:20 +01:00
Mark Thompson
18f1706f33 lavc: Add coded bitstream read/write API 2017-08-12 22:17:20 +01:00