[vlc-devel] [vlc-commits] demux: ts: add support for ARIBchannels logos

liyoubdu liyoubdu at qq.com
Thu Jun 22 03:23:26 CEST 2017


how to test it?




------------------ Original ------------------
From:  "Jean-Baptiste Kempf";<jb at videolan.org>;
Send time: Thursday, Jun 22, 2017 5:32 AM
To: "vlc-devel"<vlc-devel at videolan.org>; 

Subject:  Re: [vlc-devel] [vlc-commits] demux: ts: add support for ARIBchannels logos



Does this not deserve a NEWS entry?

On Wed, 21 Jun 2017, at 21:34, Francois Cartegnie wrote:
> vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jun 20
> 15:26:12 2017 +0200| [de5e761dea395471fe5fbda2a5e7212bb309843a] |
> committer: Francois Cartegnie
> 
> demux: ts: add support for ARIB channels logos
> 
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=de5e761dea395471fe5fbda2a5e7212bb309843a
> ---
> 
>  modules/demux/Makefile.am               |   1 +
>  modules/demux/mpeg/ts_arib.c            | 212
>  ++++++++++++++++++++++++++++++++
>  modules/demux/mpeg/ts_arib.h            |  54 ++++++++
>  modules/demux/mpeg/ts_si.c              | 122 +++++++++++++++++-
>  modules/demux/mpeg/ts_streams.c         |   8 ++
>  modules/demux/mpeg/ts_streams_private.h |   7 ++
>  6 files changed, 403 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
> index d0839a1198..5a3a84b691 100644
> --- a/modules/demux/Makefile.am
> +++ b/modules/demux/Makefile.am
> @@ -248,6 +248,7 @@ libts_plugin_la_SOURCES = demux/mpeg/ts.c
> demux/mpeg/ts.h \
>          demux/mpeg/ts_scte.h demux/mpeg/ts_scte.c \
>          demux/mpeg/sections.c demux/mpeg/sections.h \
>          demux/mpeg/mpeg4_iod.c demux/mpeg/mpeg4_iod.h \
> +        demux/mpeg/ts_arib.c demux/mpeg/ts_arib.h \
>          demux/mpeg/ts_sl.c demux/mpeg/ts_sl.h \
>          demux/mpeg/ts_metadata.c demux/mpeg/ts_metadata.h \
>          demux/mpeg/ts_hotfixes.c demux/mpeg/ts_hotfixes.h \
> diff --git a/modules/demux/mpeg/ts_arib.c b/modules/demux/mpeg/ts_arib.c
> new file mode 100644
> index 0000000000..432c31a6d0
> --- /dev/null
> +++ b/modules/demux/mpeg/ts_arib.c
> @@ -0,0 +1,212 @@
> +/*****************************************************************************
> + * ts_arib.c : TS demux ARIB specific handling
> +
> *****************************************************************************
> + * Copyright (C) 2017 - VideoLAN Authors
> + *
> + * 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 General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> *****************************************************************************/
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +#endif
> +
> +#include <vlc_common.h>
> +#include <vlc_demux.h>
> +
> +#include "ts_pid.h"
> +#include "ts.h"
> +
> +#include "ts_arib.h"
> +
> +/*
> + * ARIB TR-B21
> + * Logo PNG is 8 bit indexed dans the palette is missing,
> + * provided as a CLUT. We need to reinject the CLUT as a
> + * split palette + transparency (as PNG only allows split alpha table)
> +*/
> +
> +/* ARIB TR-B14-1 Appendix 1 */
> +static const unsigned char CLUT_to_chunks[] = {
> +    /* size + PLTE */
> +    0x00, 0x00, 0x01, 0x80, 0x50, 0x4c, 0x54, 0x45,
> +    /* DATA ARIB TR-B14-1 Appendix 1 */
> +    0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff,
> 0x00, /* 0-7 */
> +    0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +
> +    0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff,
> 0x00, /* 8-15 */
> +    0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +
> +    0x00, 0x00, 0x55, 0x00, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x55,
> 0xaa, /* 16-23 */
> +    0x00, 0x55, 0xff, 0x00, 0xaa, 0x55, 0x00, 0xaa, 0xff, 0x00, 0xff,
> 0x55,
> +
> +    0x00, 0xff, 0xaa, 0x55, 0x00, 0x00, 0x55, 0x00, 0x55, 0x55, 0x00,
> 0xaa, /* 24-31 */
> +    0x55, 0x00, 0xff, 0x55, 0x55, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55,
> 0xaa,
> +
> +    0x55, 0x55, 0xff, 0x55, 0xaa, 0x00, 0x55, 0xaa, 0x00, 0x55, 0xaa,
> 0x55, /* 32-39 */
> +    0x55, 0xaa, 0xaa, 0x55, 0xaa, 0xff, 0x55, 0xff, 0x00, 0x55, 0xff,
> 0x55,
> +
> +    0x55, 0xff, 0xff, 0xaa, 0x00, 0x55, 0xaa, 0x00, 0xff, 0xaa, 0x55,
> 0x00, /* 40-47 */
> +    0xaa, 0x55, 0x55, 0xaa, 0x55, 0xaa, 0xaa, 0x55, 0xff, 0xaa, 0xaa,
> 0x55,
> +
> +    0xaa, 0xaa, 0xff, 0xaa, 0xff, 0x00, 0xaa, 0xff, 0x55, 0xaa, 0xff,
> 0xaa, /* 48-55 */
> +    0xaa, 0xff, 0xff, 0xff, 0x00, 0x55, 0xff, 0x00, 0xaa, 0xff, 0x55,
> 0x00,
> +
> +    0xff, 0x55, 0x55, 0xff, 0x55, 0xaa, 0xff, 0x55, 0xff, 0xff, 0xaa,
> 0x00, /* 56-63 */
> +    0xff, 0xaa, 0x55, 0xff, 0xaa, 0xaa, 0xff, 0xaa, 0xff, 0xff, 0xff,
> 0x55,
> +
> +    0xff, 0xff, 0xaa, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff,
> 0x00, /* 64-71 */
> +    0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff,
> 0xff,
> +
> +    0xff, 0xff, 0xff, 0xaa, 0x00, 0x00, 0x00, 0xaa, 0x00, 0xaa, 0xaa,
> 0x00, /* 72-79 */
> +    0x00, 0x00, 0xaa, 0xaa, 0x00, 0xaa, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
> 0xaa,
> +
> +    0x00, 0x00, 0x55, 0x00, 0x55, 0x00, 0x00, 0x55, 0x55, 0x00, 0x55,
> 0xaa, /* 80-87 */
> +    0x00, 0x55, 0xff, 0x00, 0xaa, 0x55, 0x00, 0xaa, 0xff, 0x00, 0xff,
> 0x55,
> +
> +    0x00, 0xff, 0xaa, 0x55, 0x00, 0x00, 0x55, 0x00, 0x55, 0x55, 0x00,
> 0xaa, /* 88-95 */
> +    0x55, 0x00, 0xff, 0x55, 0x55, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55,
> 0xaa,
> +
> +    0x55, 0x55, 0xff, 0x55, 0xaa, 0x00, 0x55, 0xaa, 0x55, 0x55, 0xaa,
> 0xaa, /* 96-103 */
> +    0x55, 0xaa, 0xff, 0x55, 0xff, 0x00, 0x55, 0xff, 0x55, 0x55, 0xff,
> 0xaa,
> +
> +    0x55, 0xff, 0xff, 0xaa, 0x00, 0x55, 0xaa, 0x00, 0xff, 0xaa, 0x55,
> 0x00, /* 104-111 */
> +    0xaa, 0x55, 0x55, 0xaa, 0x55, 0xaa, 0xaa, 0x55, 0xff, 0xaa, 0xaa,
> 0x55,
> +
> +    0xaa, 0xaa, 0xff, 0xaa, 0xff, 0x00, 0xaa, 0xff, 0x55, 0xaa, 0xff,
> 0xaa, /* 112-119 */
> +    0xaa, 0xff, 0xff, 0xff, 0x00, 0x55, 0xff, 0x00, 0xaa, 0xff, 0x55,
> 0x00,
> +
> +    0xff, 0x55, 0x55, 0xff, 0x55, 0xaa, 0xff, 0x55, 0xff, 0xff, 0xaa,
> 0x00, /* 120-127 */
> +    0xff, 0xaa, 0x55, 0xff, 0xaa, 0xaa, 0xff, 0xaa, 0xff, 0xff, 0xff,
> 0x55,
> +
> +    /* CRC32 (all data including type, without length and crc) .
> pngcheck output being the lazy way */
> +    0x4f, 0xed, 0xfc, 0x8d,
> +
> +    /* Second Chunk */
> +
> +    /* size + tRNS */
> +    0x00, 0x00, 0x00, 0x80, 0x74, 0x52, 0x4e, 0x53,
> +
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff, /* 0-63 */
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
> 0xff,
> +    0xff, 0xff, 0xff, 0xff,
> +
> +    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80, /* 64-127 */
> +    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80,
> +    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80,
> +    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80,
> +    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
> 0x80,
> +    0x80, 0x80, 0x80, 0x80,
> +
> +    /* CRC32 */
> +    0xfa, 0xe9, 0x51, 0x40,
> +};
> +static const unsigned int CLUT_to_chunks_len = sizeof(CLUT_to_chunks);
> +
> +bool ts_arib_inject_png_palette( const uint8_t *p_in, size_t i_in,
> uint8_t **pp_out, size_t *pi_out )
> +{
> +    const uint8_t *p_data = p_in;
> +    const uint8_t *p_idat = NULL;
> +    size_t i_data = i_in - 8;
> +    p_data += 8;
> +    i_data -= 8;
> +
> +    while( i_data > 11 )
> +    {
> +        uint32_t i_len = GetDWBE( p_data );
> +        if( i_len > 0x7FFFFFFFU || i_len > i_data - 12 )
> +            break;
> +
> +        uint32_t i_chunk = VLC_FOURCC(p_data[4], p_data[5], p_data[6],
> p_data[7]);
> +        if( i_chunk == VLC_FOURCC('I', 'D', 'A', 'T') )
> +        {
> +            p_idat = p_data;
> +            break;
> +        }
> +
> +        p_data += i_len + 12;
> +        i_data -= i_len + 12;
> +    }
> +
> +    if( !p_idat )
> +        return false;
> +
> +    {
> +        uint8_t *p_out = *pp_out = malloc( i_in + CLUT_to_chunks_len );
> +        if( !p_out )
> +            return false;
> +        *pi_out = i_in + CLUT_to_chunks_len;
> +
> +        const size_t i_head = p_data - p_in;
> +        memcpy( p_out, p_in, i_head );
> +        memcpy( &p_out[i_head], CLUT_to_chunks, CLUT_to_chunks_len );
> +        memcpy( &p_out[i_head + CLUT_to_chunks_len], p_data, i_in -
> i_head );
> +    }
> +
> +    return true;
> +}
> +
> +
> +void ts_arib_logo_dr_Delete( ts_arib_logo_dr_t *p_dr )
> +{
> +    free( p_dr->p_logo_char );
> +    free( p_dr );
> +}
> +
> +ts_arib_logo_dr_t * ts_arib_logo_dr_Decode( const uint8_t *p_data,
> size_t i_data )
> +{
> +    if( i_data < 2 )
> +        return NULL;
> +
> +    ts_arib_logo_dr_t *p_dr = calloc( 1, sizeof(*p_dr) );
> +    if( p_dr )
> +    {
> +        p_dr->i_logo_version = p_data[0];
> +        switch( p_data[0] )
> +        {
> +            case 1:
> +                if( i_data == 7 )
> +                {
> +                    p_dr->i_logo_id = ((p_data[1] & 0x01) << 8) |
> p_data[2];
> +                    p_dr->i_logo_version = ((p_data[3] & 0x0F) << 8) |
> p_data[4];
> +                    p_dr->i_download_data_id = (p_data[5] << 8) |
> p_data[6];
> +                    return p_dr;
> +                }
> +                break;
> +            case 2:
> +                if( i_data == 3 )
> +                {
> +                    p_dr->i_logo_id = ((p_data[1] & 0x01) << 8) |
> p_data[2];
> +                    return p_dr;
> +                }
> +                break;
> +            case 3:
> +                if( i_data > 2 )
> +                {
> +                    p_dr->p_logo_char = malloc( i_data - 1 );
> +                    if( p_dr->p_logo_char )
> +                    {
> +                        p_dr->i_logo_char = i_data - 1;
> +                        memcpy( p_dr->p_logo_char, &p_data[1],
> p_dr->i_logo_char );
> +                        return p_dr;
> +                    }
> +                }
> +            default:
> +                break;
> +        }
> +        ts_arib_logo_dr_Delete( p_dr );
> +    }
> +    return NULL;
> +}
> diff --git a/modules/demux/mpeg/ts_arib.h b/modules/demux/mpeg/ts_arib.h
> new file mode 100644
> index 0000000000..26502496a7
> --- /dev/null
> +++ b/modules/demux/mpeg/ts_arib.h
> @@ -0,0 +1,54 @@
> +/*****************************************************************************
> + * ts_arib.h : TS demux ARIB specific handling
> +
> *****************************************************************************
> + * Copyright (C) 2017 - VideoLAN Authors
> + *
> + * 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 General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> *****************************************************************************/
> +#ifndef VLC_TS_ARIB_H
> +#define VLC_TS_ARIB_H
> +
> +#define TS_ARIB_CDT_PID                                0x29
> +
> +#define TS_ARIB_CDT_TABLE_ID                           0xC8
> +
> +#define TS_ARIB_DR_LOGO_TRANSMISSION                   0xCF
> +
> +#define TS_ARIB_CDT_DATA_TYPE_LOGO      0x01
> +
> +#define TS_ARIB_LOGO_TYPE_HD_LARGE      0x05
> +#define TS_ARIB_LOGO_TYPE_HD_SMALL      0x02
> +#define TS_ARIB_LOGO_TYPE_SD43_LARGE    0x03
> +#define TS_ARIB_LOGO_TYPE_SD43_SMALL    0x00
> +#define TS_ARIB_LOGO_TYPE_SD169_LARGE   0x04
> +#define TS_ARIB_LOGO_TYPE_SD169_SMALL   0x01
> +
> +/* logo_transmission_descriptor */
> +typedef struct
> +{
> +    uint8_t  i_transmission_mode;
> +    uint16_t i_logo_id;
> +    uint16_t i_logo_version;
> +    uint16_t i_download_data_id;
> +    uint8_t *p_logo_char;
> +    size_t   i_logo_char;
> +} ts_arib_logo_dr_t;
> +
> +ts_arib_logo_dr_t * ts_arib_logo_dr_Decode( const uint8_t *, size_t );
> +void ts_arib_logo_dr_Delete( ts_arib_logo_dr_t * );
> +
> +bool ts_arib_inject_png_palette( const uint8_t *p_in, size_t i_in,
> +                                 uint8_t **pp_out, size_t *pi_out );
> +
> +#endif
> diff --git a/modules/demux/mpeg/ts_si.c b/modules/demux/mpeg/ts_si.c
> index 5bfeee5e02..f28b7253c4 100644
> --- a/modules/demux/mpeg/ts_si.c
> +++ b/modules/demux/mpeg/ts_si.c
> @@ -25,6 +25,7 @@
>  #include <vlc_meta.h>
>  #include <vlc_epg.h>
>  #include <vlc_charset.h>   /* FromCharset, for EIT */
> +#include <vlc_input.h>
>  
>  #ifndef _DVBPSI_DVBPSI_H_
>   #include <dvbpsi/dvbpsi.h>
> @@ -35,8 +36,11 @@
>  #include <dvbpsi/eit.h> /* EIT support */
>  #include <dvbpsi/tot.h> /* TDT support */
>  #include <dvbpsi/dr.h>
> +#include <dvbpsi/psi.h>
>  
>  #include "ts_si.h"
> +#include "ts_arib.h"
> +#include "ts_decoders.h"
>  
>  #include "ts_pid.h"
>  #include "ts_streams_private.h"
> @@ -152,6 +156,7 @@ static void SDTCallBack( demux_t *p_demux,
> dvbpsi_sdt_t *p_sdt )
>  {
>      demux_sys_t          *p_sys = p_demux->p_sys;
>      ts_pid_t             *sdt = GetPID(p_sys, TS_SI_SDT_PID);
> +    ts_pat_t             *p_pat = ts_pid_Get(&p_sys->pids, 0)->u.p_pat;
>      dvbpsi_sdt_service_t *p_srv;
>  
>      msg_Dbg( p_demux, "SDTCallBack called" );
> @@ -169,9 +174,11 @@ static void SDTCallBack( demux_t *p_demux,
> dvbpsi_sdt_t *p_sdt )
>      {
>          attach_SI_decoders( TS_SI_EIT_PID, "EIT", eitpid );
>          attach_SI_decoders( TS_SI_TDT_PID, "TDT", tdtpid );
> -
> +        if( p_sys->standard == TS_STANDARD_ARIB )
> +            attach_SI_decoders( TS_ARIB_CDT_PID, "CDT", cdtpid );
>      }
>  
> +
>      msg_Dbg( p_demux, "new SDT ts_id=%"PRIu16" version=%"PRIu8"
>      current_next=%d "
>               "network_id=%"PRIu16,
>               p_sdt->i_extension,
> @@ -182,6 +189,7 @@ static void SDTCallBack( demux_t *p_demux,
> dvbpsi_sdt_t *p_sdt )
>  
>      for( p_srv = p_sdt->p_first_service; p_srv; p_srv = p_srv->p_next )
>      {
> +        ts_pmt_t            *p_pmt = ts_pat_Get_pmt( p_pat,
> p_srv->i_service_id );
>          vlc_meta_t          *p_meta;
>          dvbpsi_descriptor_t *p_dr;
>  
> @@ -271,6 +279,42 @@ static void SDTCallBack( demux_t *p_demux,
> dvbpsi_sdt_t *p_sdt )
>                  free( str1 );
>                  free( str2 );
>              }
> +            else if( p_sys->standard == TS_STANDARD_ARIB &&
> +                     p_dr->i_tag == TS_ARIB_DR_LOGO_TRANSMISSION &&
> p_pmt )
> +            {
> +                ts_arib_logo_dr_t *p_logodr = ts_arib_logo_dr_Decode(
> p_dr->p_data, p_dr->i_length );
> +                if( p_logodr )
> +                {
> +                    if( p_logodr->i_transmission_mode == 0 )
> +                    {
> +                        p_pmt->arib.i_logo_id = p_logodr->i_logo_id;
> +                        p_pmt->arib.i_download_id =
> p_logodr->i_download_data_id;
> +                    }
> +                    else if( p_logodr->i_transmission_mode == 1 )
> +                    {
> +                        p_pmt->arib.i_logo_id = p_logodr->i_logo_id;
> +                    }
> +                    else /* TODO simple logo identifier */
> +                    {
> +
> +                    }
> +
> +                    if( p_pmt->arib.i_logo_id > -1 )
> +                    {
> +                        char *psz_name;
> +                        if( asprintf( &psz_name,
> "attachment://onid[%"PRIx16"]_channel_logo_id[%"PRIx16"]q[%d]",
> +                                      p_sdt->i_network_id,
> p_logodr->i_logo_id,
> +                                      TS_ARIB_LOGO_TYPE_HD_LARGE ) > -1
> )
> +                        {
> +                            vlc_meta_SetArtURL( p_meta, psz_name );
> +                            vlc_meta_AddExtra( p_meta, "ARTURL",
> psz_name );
> +                            free( psz_name );
> +                        }
> +                    }
> +
> +                    ts_arib_logo_dr_Delete( p_logodr );
> +                }
> +            }
>          }
>  
>          if( p_srv->i_running_status >= 0x01 && p_srv->i_running_status
>          <= 0x04 )
> @@ -606,6 +650,76 @@ static void EITCallBack( demux_t *p_demux,
> dvbpsi_eit_t *p_eit )
>      dvbpsi_eit_delete( p_eit );
>  }
>  
> +static void ARIB_CDT_RawCallback( dvbpsi_t *p_handle, const
> dvbpsi_psi_section_t* p_section,
> +                                  void *p_cdtpid )
> +{
> +    VLC_UNUSED(p_cdtpid);
> +    demux_t *p_demux = (demux_t *) p_handle->p_sys;
> +    demux_sys_t *p_sys = p_demux->p_sys;
> +    const ts_pat_t *p_pat = GetPID(p_demux->p_sys, 0)->u.p_pat;
> +
> +    while( p_section )
> +    {
> +        const uint8_t *p_data = p_section->p_payload_start;
> +        size_t i_data = p_section->p_payload_end -
> p_section->p_payload_start;
> +
> +        if( i_data < (6U + 7 + 1) || p_data[2] !=
> TS_ARIB_CDT_DATA_TYPE_LOGO )
> +            continue;
> +
> +        uint16_t i_onid = (p_data[0] << 8) | p_data[1];
> +        uint16_t i_dr_len = ((p_data[3] & 0x0F) << 4) | p_data[4];
> +        if( i_data < i_dr_len + (6U + 7 + 1) )
> +            continue;
> +
> +        /* STD-B21 A.5.4 (Japanese spec only) */
> +
> +        const uint8_t *p_dmb = &p_data[5 + i_dr_len];
> +        size_t i_dmb = i_data - 5 - i_dr_len;
> +
> +        while( i_dmb > 7 )
> +        {
> +            uint8_t i_logo_type = p_dmb[0];
> +            uint16_t i_logo_id = ((p_dmb[1] & 0x01) << 8) | p_dmb[2];
> +            uint16_t i_size = (p_dmb[5] << 8) | p_dmb[6];
> +
> +            if( 7U + i_size > i_dmb )
> +                break;
> +
> +            for( int i=0; i<p_pat->programs.i_size; i++ )
> +            {
> +                ts_pmt_t *p_pmt = p_pat->programs.p_elems[i]->u.p_pmt;
> +                if( p_pmt->arib.i_logo_id == i_logo_id && i_logo_type ==
> TS_ARIB_LOGO_TYPE_HD_LARGE )
> +                {
> +                    char *psz_name;
> +                    if( asprintf( &psz_name,
> "onid[%"PRIx16"]_channel_logo_id[%"PRIx16"]q[%d]",
> +                                  i_onid, i_logo_id, i_logo_type ) > -1
> )
> +                    {
> +                        uint8_t *p_png; size_t i_png;
> +                        if( !vlc_dictionary_has_key(
> &p_sys->attachments, psz_name ) &&
> +                            ts_arib_inject_png_palette( &p_dmb[7],
> i_size, &p_png, &i_png ) )
> +                        {
> +                            input_attachment_t *p_att =
> vlc_input_attachment_New(
> +                                                        psz_name,
> "image/png", NULL, p_png, i_png );
> +                            if( p_att )
> +                            {
> +                                vlc_dictionary_insert(
> &p_sys->attachments, psz_name, p_att );
> +                                p_demux->info.i_update |=
> INPUT_UPDATE_META;
> +                            }
> +                            free( p_png );
> +                        }
> +                        free( psz_name );
> +                    }
> +                }
> +            }
> +
> +            i_dmb -= 7 + i_size;
> +            p_dmb += 7 + i_size;
> +        }
> +
> +        p_section = p_section->p_next;
> +    }
> +}
> +
>  static void SINewTableCallBack( dvbpsi_t *h, uint8_t i_table_id,
>                                  uint16_t i_extension, void *p_pid_cbdata
>                                  )
>  {
> @@ -639,6 +753,12 @@ static void SINewTableCallBack( dvbpsi_t *h, uint8_t
> i_table_id,
>          if( !dvbpsi_tot_attach( h, i_table_id, i_extension,
>          (dvbpsi_tot_callback)TDTCallBack, p_demux ) )
>              msg_Err( p_demux, "SINewTableCallback: failed attaching
>              TDTCallback" );
>      }
> +    else if( p_pid->i_pid == TS_ARIB_CDT_PID && i_table_id ==
> TS_ARIB_CDT_TABLE_ID )
> +    {
> +        if( dvbpsi_demuxGetSubDec( (dvbpsi_demux_t *) h->p_decoder,
> i_table_id, i_extension ) == NULL &&
> +            !ts_dvbpsi_AttachRawSubDecoder( h, i_table_id, i_extension,
> ARIB_CDT_RawCallback, p_pid ) )
> +            msg_Err( p_demux, "SINewTableCallback: failed attaching
> ARIB_CDT_RawCallback" );
> +    }
>  }
>  
>  bool ts_attach_SI_Tables_Decoders( ts_pid_t *p_pid )
> diff --git a/modules/demux/mpeg/ts_streams.c
> b/modules/demux/mpeg/ts_streams.c
> index 3b86e7e7e7..9b5ec2d8d9 100644
> --- a/modules/demux/mpeg/ts_streams.c
> +++ b/modules/demux/mpeg/ts_streams.c
> @@ -40,6 +40,7 @@
>  #include <vlc_demux.h>
>  #include <vlc_es.h>
>  #include <vlc_es_out.h>
> +#include <vlc_input.h>
>  
>  #include "sections.h"
>  #include "ts_pid.h"
> @@ -137,6 +138,9 @@ ts_pmt_t *ts_pmt_New( demux_t *p_demux )
>      pmt->eit.i_event_length = 0;
>      pmt->eit.i_event_start = 0;
>  
> +    pmt->arib.i_download_id = -1;
> +    pmt->arib.i_logo_id = -1;
> +
>      return pmt;
>  }
>  
> @@ -159,6 +163,7 @@ void ts_pmt_Del( demux_t *p_demux, ts_pmt_t *pmt )
>      ARRAY_RESET( pmt->od.objects );
>      if( pmt->i_number > -1 )
>          es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, pmt->i_number );
> +
>      free( pmt );
>  }
>  
> @@ -324,6 +329,7 @@ ts_si_t *ts_si_New( demux_t *p_demux )
>      si->i_version  = -1;
>      si->eitpid = NULL;
>      si->tdtpid = NULL;
> +    si->cdtpid = NULL;
>  
>      return si;
>  }
> @@ -337,6 +343,8 @@ void ts_si_Del( demux_t *p_demux, ts_si_t *si )
>          PIDRelease( p_demux, si->eitpid );
>      if( si->tdtpid )
>          PIDRelease( p_demux, si->tdtpid );
> +    if( si->cdtpid )
> +        PIDRelease( p_demux, si->cdtpid );
>      free( si );
>  }
>  
> diff --git a/modules/demux/mpeg/ts_streams_private.h
> b/modules/demux/mpeg/ts_streams_private.h
> index 29642531af..d1bfe3e8f8 100644
> --- a/modules/demux/mpeg/ts_streams_private.h
> +++ b/modules/demux/mpeg/ts_streams_private.h
> @@ -74,6 +74,12 @@ struct ts_pmt_t
>      mtime_t i_last_dts;
>      uint64_t i_last_dts_byte;
>  
> +    /* ARIB specific */
> +    struct
> +    {
> +        int i_logo_id;
> +        int i_download_id;
> +    } arib;
>  };
>  
>  struct ts_es_t
> @@ -141,6 +147,7 @@ struct ts_si_t
>      /* Track successfully set pid */
>      ts_pid_t *eitpid;
>      ts_pid_t *tdtpid;
> +    ts_pid_t *cdtpid;
>  };
>  
>  typedef struct ts_psip_context_t ts_psip_context_t;
> 
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170622/06650894/attachment.html>


More information about the vlc-devel mailing list