[FFmpeg-devel] [PATCH 2/5] avcodec/cbs_mpeg2: Change assertion from bytes to bits

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Dec 9 13:52:45 EET 2019


On Mon, Dec 9, 2019 at 2:54 AM James Almer <jamrial at gmail.com> wrote:

> On 12/8/2019 6:31 PM, Michael Niedermayer wrote:
> > This allows writing empty slices
>
> Are empty slices valid in mpeg2 to begin with? Or is that the result of
> invalid/truncated data exclusively?
>
> It's invalid data, unless data partitioning (which we do not and IMO
should never support) is in use. Data partitioning allows to split the
bitstream into two that can be sent independently (and over channels of
different reliability) and it allows the slice in the base layer to only
contain everything excluding the macroblocks (i.e. everything that we put
into the slice header).

But if data partitioning is not in use, there has to be a macroblock after
the extra_information_slice and a macroblock consists of more than zero
bits; in fact, there always has to be a bit set to 1 among the first eight
bits (which is not meant to imply that every macroblock needs to contain
eight bits at all).

I will add a check to error out if slices without data beyond the slice
header are encountered upon reading. And also similar patches for cbs_h2645.

- Andreas


More information about the ffmpeg-devel mailing list