[FFmpeg-devel] [PATCH 03/20] lavc: Add coded bitstream read/write API

Mark Thompson sw at jkqxz.net
Fri Oct 13 17:00:43 EEST 2017


On 13/10/17 12:28, Michael Niedermayer wrote:
> On Thu, Oct 12, 2017 at 12:35:35AM +0100, Mark Thompson wrote:
>> On 11/10/17 23:34, Michael Niedermayer wrote:
>>> Hi
>>>
>>> On Mon, Oct 09, 2017 at 08:04:47PM +0100, Mark Thompson wrote:
>>> [...]
>>>
>>>> diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
>>>> new file mode 100644
>>>> index 0000000000..e35175fc74
>>>> --- /dev/null
>>>> +++ b/libavcodec/cbs.h
>>>> @@ -0,0 +1,283 @@
>>>> +/*
>>>> + * This file is part of FFmpeg.
>>>> + *
>>>> + * FFmpeg is free software; you can redistribute it and/or
>>>> + * modify it under the terms of the GNU Lesser General Public
>>>> + * License as published by the Free Software Foundation; either
>>>> + * version 2.1 of the License, or (at your option) any later version.
>>>> + *
>>>> + * FFmpeg is distributed in the hope that it will be useful,
>>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>>> + * Lesser General Public License for more details.
>>>> + *
>>>> + * You should have received a copy of the GNU Lesser General Public
>>>> + * License along with FFmpeg; if not, write to the Free Software
>>>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>>>> + */
>>>> +
>>>> +#ifndef AVCODEC_CBS_H
>>>> +#define AVCODEC_CBS_H
>>>> +
>>>> +#include <stddef.h>
>>>> +#include <stdint.h>
>>>> +
>>>> +#include "avcodec.h"
>>>> +
>>
>> (Here)
>>
>>>> +
>>>> +struct CodedBitstreamType;
>>>> +
>>>
>>>> +/**
>>>> + * The codec-specific type of a bitstream unit.
>>>> + */
>>>> +typedef uint32_t CodedBitstreamUnitType;
>>>
>>> Whats a bitstream unit ? (no iam not asking you to explain me but it
>>> should be documeted)
>>
>> See the comment ten lines below this one.
>>
>>> Is there some high level overview of this API and its components ?
>>> I mean without having to search terms in dispersed documentation.
>>>
>>> The high level documentation should also explain what this API does
>>> in a terse and clear way.
>>> Maybe something like: (if thats correct)
>>> Converts between a bit/byte stream and object tree representation of
>>> a frame.
>>> The (serialized) bitstream representation is what is commonly stored
>>> in containers and passed around on networks. The object tree
>>> representation allows easier modification of individual elements.
>>
>> Inserted at "Here" above:
>>
>> /*
>>  * This defines a framework for converting between a coded bitstream
>>  * and structures defining all individual syntax elements found in
>>  * such a stream.
>>  *
>>  * Conversion in both directions is possible.  Given a coded bitstream
>>  * (any meaningful fragment), it can be parsed and decomposed into
>>  * syntax elements stored in a set of codec-specific structures.
>>  * Similarly, given a set of those same codec-specific structures the
>>  * syntax elements can be serialised and combined to create a coded
>>  * bitstream.
>>  */
> 
> [...]
> 
>>>> +/**
>>>> + * Read the data bitstream from a packet into a fragment, then
>>>> + * split into units and decompose.
>>>> + */
>>>> +int ff_cbs_read_packet(CodedBitstreamContext *ctx,
>>>> +                       CodedBitstreamFragment *frag,
>>>> +                       const AVPacket *pkt);
> 
> maybe ff_cbs_decompose_packet() would be a better name ?

It's more than decomposition, though, because it also reads the metadata to update the coded bitstream context state (e.g. saves parameter sets to be able to read subsequent packets).

Added to comment (as with the extradata one):

 * This also updates the internal state of the coded bitstream context
 * with any persistent data from the fragment which may be required to
 * read following fragments (e.g. parameter sets).

and similarly on write.

- Mark


More information about the ffmpeg-devel mailing list