[vlc-devel] [vlc-commits] packetizer: add AV1 packetizer

Steve Lhomme robux4 at ycbcr.xyz
Thu Oct 18 16:28:38 CEST 2018


On 01/10/2018 16:59, Francois Cartegnie wrote:
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Sep 26 14:37:47 2018 +0200| [489384ea50ebe57b5e4d2524c1b5cba2bbe806c4] | committer: Francois Cartegnie
>
> packetizer: add AV1 packetizer
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=489384ea50ebe57b5e4d2524c1b5cba2bbe806c4
> ---
>
>   modules/MODULES_LIST           |   1 +
>   modules/packetizer/Makefile.am |   5 +
>   modules/packetizer/av1.c       | 551 +++++++++++++++++++++++++++++++++++++++++
>   po/POTFILES.in                 |   1 +
>   4 files changed, 558 insertions(+)
>
> diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST
> index 73e73ed545..79161ae3ed 100644
> --- a/modules/MODULES_LIST
> +++ b/modules/MODULES_LIST
> @@ -58,6 +58,7 @@ $Id$
>    * avcodec: libavcodec audio/video decoder
>    * avformat: libavformat demuxer
>    * avi: AVI file stream demuxer
> + * av1: AV1 packetizer
>    * avio: Access and Stream output module using libavformat network
>    * ball: Augmented reality ball video filter module
>    * bandlimited_resampler: Bandlimited interpolation audio resampler
> diff --git a/modules/packetizer/Makefile.am b/modules/packetizer/Makefile.am
> index 0551c4d0a7..d54152b33b 100644
> --- a/modules/packetizer/Makefile.am
> +++ b/modules/packetizer/Makefile.am
> @@ -1,5 +1,9 @@
>   packetizerdir = $(pluginsdir)/packetizer
>   
> +libpacketizer_av1_plugin_la_SOURCES = packetizer/av1.c \
> +                                      packetizer/av1.h \
> +                                      packetizer/av1_obu.c \
> +                                      packetizer/av1_obu.h
>   libpacketizer_copy_plugin_la_SOURCES = packetizer/copy.c
>   libpacketizer_mpegvideo_plugin_la_SOURCES = packetizer/mpegvideo.c \
>                                               packetizer/iso_color_tables.h
> @@ -42,6 +46,7 @@ libpacketizer_avparser_plugin_la_LIBADD = $(AVCODEC_LIBS) $(AVUTIL_LIBS) $(LIBM)
>   noinst_HEADERS += packetizer/packetizer_helper.h packetizer/startcode_helper.h
>   
>   packetizer_LTLIBRARIES = \
> +	libpacketizer_av1_plugin.la \
>   	libpacketizer_mpegvideo_plugin.la \
>   	libpacketizer_mpeg4video_plugin.la \
>   	libpacketizer_mjpeg_plugin.la \
> diff --git a/modules/packetizer/av1.c b/modules/packetizer/av1.c
> new file mode 100644
> index 0000000000..d303277c3b
> --- /dev/null
> +++ b/modules/packetizer/av1.c
> @@ -0,0 +1,551 @@
> +/*****************************************************************************
> + * av1.c: AV1 video packetizer
> + *****************************************************************************
> + * Copyright (C) 2018 VideoLabs, VLC authors and VideoLAN
> + *
> + * This program 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.
> + *
> + * This program 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 this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + *****************************************************************************/
> +
> +/*****************************************************************************
> + * Preamble
> + *****************************************************************************/
> +
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +#endif
> +
> +#include <vlc_common.h>
> +#include <vlc_plugin.h>
> +#include <vlc_codec.h>
> +#include <vlc_block.h>
> +#include <vlc_bits.h>
> +
> +#include <vlc_block_helper.h>
> +
> +#include "av1.h"
> +#include "av1_obu.h"
> +
> +#include <limits.h>
> +
> +//#define DEBUG_AV1_PACKETIZER
> +
> +/****************************************************************************
> + * Local prototypes
> + ****************************************************************************/
> +typedef struct
> +{
> +    struct
> +    {
> +        block_t *p_chain;
> +        block_t **pp_chain_last;
> +    } obus;
> +
> +    block_t *p_sequence_header_block;
> +    av1_OBU_sequence_header_t *p_sequence_header;
> +    struct
> +    {
> +        bool b_has_visible_frame;
> +        struct
> +        {
> +            block_t *p_chain;
> +            block_t **pp_chain_last;
> +        } pre, frame, post;
> +        vlc_tick_t dts;
> +        vlc_tick_t pts;
> +    } tu;
> +    uint32_t i_seen;
> +    int i_next_block_flags;
> +
> +} av1_sys_t;
> +
> +#define BLOCK_FLAG_DROP (1 << BLOCK_FLAG_PRIVATE_SHIFT)
> +
> +/****************************************************************************
> + * Helpers
> + ****************************************************************************/
> +static inline void InitQueue(block_t **pp_head, block_t ***ppp_tail)
> +{
> +    *pp_head = NULL;
> +    *ppp_tail = pp_head;
> +}
> +
> +static bool block_Differs(const block_t *a, const block_t *b)
> +{
> +    return (a->i_buffer != b->i_buffer ||
> +            memcmp(a->p_buffer, b->p_buffer, a->i_buffer));
> +}
> +
> +#define INITQ(name) InitQueue(&p_sys->name.p_chain, &p_sys->name.pp_chain_last)
> +#define PUSHQ(name,b) \
> +{\
> +    block_ChainLastAppend(&p_sys->name.pp_chain_last, b);\
> +    if(p_sys->tu.dts == VLC_TICK_INVALID)\
> +        p_sys->tu.dts = b->i_dts; p_sys->tu.pts = b->i_pts;\

This seems odd. Either you're missing curly braces or the second part of 
this line should be on a new line with less indentation.


More information about the vlc-devel mailing list