[FFmpeg-devel] [PATCH 00/11 v3] cbs (mostly MPEG-2) patches

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Wed May 22 04:04:30 EEST 2019


Hello,

this patchset is an updated and expanded version of my patchset [1] from
April. Changes include:

1. I have found more elements in MPEG-2 with forbidden values. And it
was always zero that was forbidden. Therefore the macro for ranges has
been simplified to simply disallow the value 0.
2. colour_description elements with the forbidden value zero will be
automatically patched to 2 (meaning unknown) during reading.
3. The frame_centre_vertical/horizontal_offset elements in picture
display extensions are actually signed. I have fixed this. The
sample sony-ct3.bs (part of the fate suite and already used for a test
for cbs_mpeg2) actually has a negative frame_centre_vertical_offset
entry.
4. All over cbs, reading involved useless initializations. They have
been removed.
5. Not only the extra information that can be part of picture headers is
parsed wrongly, but also the extra information from slice headers: The
wrong number of bits were skipped when deriving the number of extra
information bytes. If extra information in slice headers had been used
in the wild, the output would have been corrupted after a roundtrip
through cbs_mpeg2.
6. The picture headers are now parsed correctly; i.e. the extra
information is passed through. Although there are already defined
structures for the extra information in picture headers, no attempt has
been made to actually decompose it.
7. And finally I add a patch to remove zero byte stuffing in MPEG-2. The
situation here is more complicated than H2645, because some trailing
zero bits can be part of a slice. Nevertheless, it is possible to
derive an upper bound for the number of such trailing zero bits so
that it is possible to strip some trailing zeroes away.

I have also added James' patch regarding the memleak in
extra_information_slice.

- Andreas


[1] https://ffmpeg.org/pipermail/ffmpeg-devel/2019-April/242964.html

Andreas Rheinhardt (10):
  cbs_mpeg2: Correct and use enum values
  cbs_mpeg2: Improve checks for invalid values
  mpeg2_metadata, cbs_mpeg2: Fix handling of colour_description
  cbs_mpeg2: Fix storage type for frame_centre_*_offset
  cbs_mpeg2: Correct error codes
  cbs, cbs_mpeg2, cbs_jpeg: Don't av_freep local variables
  cbs: Remove useless initializations
  cbs_mpeg2: Fix parsing of slice headers
  cbs_mpeg2: Fix parsing of picture headers
  cbs_mpeg2: Remove zero byte stuffing

James Almer (1):
  avcodec/cbs_mpeg2: fix leak of extra_information_slice buffer in
    cbs_mpeg2_read_slice_header()

 libavcodec/cbs.c                       |   2 +-
 libavcodec/cbs_av1.c                   |  14 +--
 libavcodec/cbs_h2645.c                 |   8 +-
 libavcodec/cbs_jpeg.c                  |  10 +-
 libavcodec/cbs_mpeg2.c                 | 140 +++++++++++++++++------
 libavcodec/cbs_mpeg2.h                 |  20 ++--
 libavcodec/cbs_mpeg2_syntax_template.c | 149 +++++++++++++++----------
 libavcodec/cbs_vp9.c                   |   8 +-
 libavcodec/mpeg2_metadata_bsf.c        |  18 ++-
 tests/ref/fate/cbs-mpeg2-sony-ct3      |   2 +-
 10 files changed, 236 insertions(+), 135 deletions(-)

-- 
2.21.0



More information about the ffmpeg-devel mailing list