[FFmpeg-devel] [PATCH] Adding support for parsing BlockAdditional

Michael Niedermayer michaelni at gmx.at
Fri Feb 8 02:24:21 CET 2013


On Tue, Feb 05, 2013 at 12:07:17PM -0800, Vignesh Venkatasubramanian wrote:
> Matroska specification lists support for BlockAdditional element
> which is not supported by ffmpeg's matroska parser. This patch
> adds grammar definitions for parsing that element (and few other
> related elements) and then puts the data in AVPacket.side_data
> with new AVPacketSideDataType AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL.
> 
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> ---
>  libavcodec/avcodec.h      |   8 +++
>  libavformat/matroska.h    |   4 ++
>  libavformat/matroskadec.c |  41 ++++++++++++++--
>  tests/fate/vpx.mak        |   3 ++
>  tests/ref/fate/vp8-alpha  | 121 ++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 173 insertions(+), 4 deletions(-)
>  create mode 100644 tests/ref/fate/vp8-alpha
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ca7764a..2ed63e2 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -983,6 +983,14 @@ enum AVPacketSideDataType {
>       * @endcode
>       */
>      AV_PKT_DATA_SUBTITLE_POSITION,
> +
> +    /**
> +     * Data found in BlockAdditional element of matroska container. There is
> +     * no end marker for the data, so it is required to rely on the side data 
> +     * size to recognize the end. 8 byte id (as found in BlockAddId) followed 
> +     * by data.
> +     */
> +    AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
[...]
> @@ -2111,6 +2127,17 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
>      pkt->flags = is_keyframe;
>      pkt->stream_index = st->index;
>  
> +    if (additional_size > 0) {
> +        uint8_t *side_data = av_packet_new_side_data(pkt,
> +                                                     AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, 
> +                                                     additional_size + sizeof(additional_id));
> +        if(side_data == NULL) {
> +            return AVERROR(ENOMEM);
> +        }
> +        memcpy(side_data, &additional_id, sizeof(additional_id));
> +        memcpy(side_data + sizeof(additional_id), additional, additional_size);
> +    }

additional_id is a 64bit integer and this stores endian specifific
values in side data. Side data should be portable between different
platforms, so it can be generically stored in containers ...

rest of the patch looks good

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130208/c10579e2/attachment.asc>


More information about the ffmpeg-devel mailing list