From gitlab at videolan.org Tue Oct 22 18:24:17 2019 From: gitlab at videolan.org (Christophe Massiot) Date: Tue, 22 Oct 2019 18:24:17 +0200 Subject: [bTSstream-devel] [Git][videolan/bitstream][master] 2 commits: Add ATSC A52 service information Message-ID: <5daf2d31b85b8_851e3f9868ae15d811206bc@gitlab.mail> Christophe Massiot pushed to branch master at VideoLAN / bitstream Commits: 8232e05c by Arnaud de Turckheim at 2019-10-22T14:06:24Z Add ATSC A52 service information - - - - - df8d1d1f by Christophe Massiot at 2019-10-22T16:24:14Z Merge branch 'quarium-a52' - - - - - 6 changed files: - Makefile - + atsc/si.h - + atsc/si/desc_81.h - + atsc/si/desc_cc.h - + atsc/si/descs_list.h - mpeg/psi/descs_print.h Changes: ===================================== Makefile ===================================== @@ -23,6 +23,8 @@ install: bitstream.pc @install -m 644 common.h $(INCLUDE)/ @install -d $(INCLUDE)/atsc @install -m 644 atsc/*.h $(INCLUDE)/atsc + @install -d $(INCLUDE)/atsc/si + @install -m 644 atsc/si/*.h $(INCLUDE)/atsc/si @install -d $(INCLUDE)/dvb @install -m 644 dvb/*.h $(INCLUDE)/dvb @install -d $(INCLUDE)/dvb/si ===================================== atsc/si.h ===================================== @@ -0,0 +1,37 @@ +/***************************************************************************** + * si.h: ATSC Service Information + ***************************************************************************** + * Copyright (C) 2019 OpenHeadend + * + * Authors: Arnaud de Turckheim + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#ifndef __BITSTREAM_ATSC_SI_H__ +#define __BITSTREAM_ATSC_SI_H__ + +#include +#include +#include +#include +#include + +#endif ===================================== atsc/si/desc_81.h ===================================== @@ -0,0 +1,258 @@ +/***************************************************************************** + * desc_81.h: ATSC A/52 Descriptor 0x81: AC-3 descriptor + ***************************************************************************** + * Copyright (C) 2019 OpenHeadend + * + * Authors: Arnaud de Turckheim + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#ifndef __BITSTREAM_ATSC_DESC_81_H__ +#define __BITSTREAM_ATSC_DESC_81_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define DESC81_HEADER_SIZE (DESC_HEADER_SIZE + 3) + +static inline void desc81_init(uint8_t *p_desc) +{ + desc_set_tag(p_desc, 0x81); +} + +#define DESC81_SAMPLE_RATE_CODE_48 0x00 +#define DESC81_SAMPLE_RATE_CODE_44_1 0x01 +#define DESC81_SAMPLE_RATE_CODE_32 0x02 +#define DESC81_SAMPLE_RATE_CODE_48_OR_44_1 0x04 +#define DESC81_SAMPLE_RATE_CODE_48_OR_32 0x05 +#define DESC81_SAMPLE_RATE_CODE_44_1_OR_32 0x06 +#define DESC81_SAMPLE_RATE_CODE_48_OR_44_1_OR_32 0x07 + +static inline void desc81_set_sample_rate_code(uint8_t *p_desc, + uint8_t sample_rate) +{ + p_desc[2] = (p_desc[2] & 0x3f) | (sample_rate << 5); +} + +static inline uint8_t desc81_get_sample_rate_code(const uint8_t *p_desc) +{ + return p_desc[2] >> 5; +} + +static inline void desc81_set_bsid(uint8_t *p_desc, uint8_t bsid) +{ + p_desc[2] = (p_desc[2] & 0xd0) | (bsid & 0x1f); +} + +static inline uint8_t desc81_get_bsid(const uint8_t *p_desc) +{ + return p_desc[2] & 0x1f; +} + +static inline uint8_t desc81_bit_rate_code_from_octetrate(uint64_t octetrate) +{ + unsigned table[19] = { + 32, 40, 48, 56, 64, 80, + 96, 112, 128, 160, 192, 224, + 256, 320, 384, 448, 512, 576, + 640, + }; + for (unsigned i = 0; i < 19; i++) { + if (octetrate * 8 == table[i]) + return i; + else if (octetrate * 8 < table[i]) + return 0x20 | i; + } + return 0xff; +} + +static inline void desc81_set_bit_rate_code(uint8_t *p_desc, + uint8_t bit_rate_code) +{ + p_desc[3] = (p_desc[3] & 0x03) | (bit_rate_code << 2); +} + +static inline uint8_t desc81_get_bit_rate_code(const uint8_t *p_desc) +{ + return p_desc[3] >> 2; +} + +static inline void desc81_set_surround_mode(uint8_t *p_desc, + uint8_t surround_mode) +{ + p_desc[3] = (p_desc[3] & 0xfc) | (surround_mode & 0x03); +} + +static inline uint8_t desc81_get_surround_mode(const uint8_t *p_desc) +{ + return p_desc[3] & 0x03; +} + +static inline void desc81_set_bsmod(uint8_t *p_desc, uint8_t bsmod) +{ + p_desc[4] = (p_desc[4] & 0x1f) | (bsmod << 5); +} + +static inline uint8_t desc81_get_bsmod(const uint8_t *p_desc) +{ + return p_desc[4] >> 5; +} + +static inline void desc81_set_num_channels(uint8_t *p_desc, + uint8_t num_channels) +{ + p_desc[4] = (p_desc[4] & 0xe1) | ((num_channels & 0x0f) << 1); +} + +static inline uint8_t desc81_get_num_channels(const uint8_t *p_desc) +{ + return (p_desc[4] & 0x1e) >> 1; +} + +static inline void desc81_set_full_svc(uint8_t *p_desc, uint8_t full_svc) +{ + p_desc[4] = (p_desc[4] & 0xfe) | (full_svc & 0x01); +} + +static inline uint8_t desc81_get_full_svc(const uint8_t *p_desc) +{ + return p_desc[4] & 0x1; +} + +static inline void desc81_set_langcod(uint8_t *p_desc, uint8_t langcod) +{ + p_desc[5] = langcod; +} + +static inline uint8_t desc81_get_langcod(const uint8_t *p_desc) +{ + return p_desc[5]; +} + +static inline void desc81_set_langcod2(uint8_t *p_desc, uint8_t langcod2) +{ + if (desc81_get_num_channels(p_desc) == 0) + p_desc[6] = langcod2; +} + +static inline uint8_t desc81_get_langcod2(const uint8_t *p_desc) +{ + return p_desc[6]; +} + +static inline void desc81_set_mainid(uint8_t *p_desc, uint8_t mainid) +{ + if (desc81_get_bsmod(p_desc) < 2) + p_desc[7] = (p_desc[7] & 0x1f) | (mainid << 5); +} + +static inline uint8_t desc81_get_mainid(const uint8_t *p_desc) +{ + return p_desc[7] >> 5; +} + +static inline void desc81_set_priority(uint8_t *p_desc, uint8_t priority) +{ + p_desc[7] = (p_desc[7] & 0xe7) | ((priority & 0x3) << 3); +} + +static inline uint8_t desc81_get_priority(const uint8_t *p_desc) +{ + return (p_desc[7] & 0x18) >> 3; +} + +static inline void desc81_set_asvcflags(uint8_t *p_desc, uint8_t asvcflags) +{ + p_desc[7] = asvcflags; +} + +static inline uint8_t desc81_get_asvcflags(const uint8_t *p_desc) +{ + return p_desc[7]; +} + +static inline bool desc81_validate(const uint8_t *p_desc) +{ + uint8_t i_size = (DESC81_HEADER_SIZE - DESC_HEADER_SIZE); + return desc_get_length(p_desc) >= i_size; +} + +static inline void desc81_print(const uint8_t *p_desc, f_print pf_print, + void *opaque, print_type_t i_print_type) +{ + uint8_t sample_rate_code = desc81_get_sample_rate_code(p_desc); + uint8_t bsid = desc81_get_bsid(p_desc); + uint8_t bit_rate_code = desc81_get_bit_rate_code(p_desc); + uint8_t surround_mode = desc81_get_surround_mode(p_desc); + uint8_t bsmod = desc81_get_bsmod(p_desc); + uint8_t num_channels = desc81_get_num_channels(p_desc); + uint8_t full_svc = desc81_get_full_svc(p_desc); + + switch (i_print_type) { + case PRINT_XML: + pf_print(opaque, + "", + sample_rate_code, + bsid, + bit_rate_code, + surround_mode, + bsmod, + num_channels, + full_svc); + break; + default: + pf_print(opaque, + " - desc 81 ac-3" + " sample_rate=\"0x%02x\"" + " bsid=\"0x%02x\"" + " bit_rate=\"0x%02x\"" + " surround_mode=\"0x%02x\"" + " bsmod=\"0x%02x\"" + " num_channels=\"0x%02x\"" + " full_svc=\"%u\"", + sample_rate_code, + bsid, + bit_rate_code, + surround_mode, + bsmod, + num_channels, + full_svc); + break; + } +} + +#ifdef __cplusplus +} +#endif + +#endif ===================================== atsc/si/desc_cc.h ===================================== @@ -0,0 +1,229 @@ +/***************************************************************************** + * desc_cc.h: ATSC A/52 Descriptor 0xcc: Enhanced AC-3 descriptor + ***************************************************************************** + * Copyright (C) 2019 OpenHeadend + * + * Authors: Arnaud de Turckheim + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#ifndef __BITSTREAM_ATSC_DESC_CC_H__ +#define __BITSTREAM_ATSC_DESC_CC_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define DESCCC_HEADER_SIZE (DESC_HEADER_SIZE + 2) + +static inline void desccc_init(uint8_t *p_desc) +{ + desc_set_tag(p_desc, 0xcc); + desc_set_length(p_desc, DESCCC_HEADER_SIZE - DESC_HEADER_SIZE); + p_desc[2] = 0x80; + p_desc[3] = 0xc0; +} + +static inline void desccc_clear_flags(uint8_t *p_desc) +{ + p_desc[2] = 0x80; + p_desc[3] = 0xc0; +} + +static inline void desccc_set_bsid_flag(uint8_t *p_desc, uint8_t bsid_flag) +{ + p_desc[2] = (p_desc[2] & 0xbf) | ((bsid_flag & 0x1) << 6); +} + +static inline uint8_t desccc_get_bsid_flag(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x40) >> 6; +} + +static inline void desccc_set_mainid_flag(uint8_t *p_desc, uint8_t mainid_flag) +{ + p_desc[2] = (p_desc[2] & 0xdf) | ((mainid_flag & 0x1) << 5); +} + +static inline uint8_t desccc_get_mainid_flag(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x20) >> 5; +} + +static inline void desccc_set_asvc_flag(uint8_t *p_desc, uint8_t asvc_flag) +{ + p_desc[2] = (p_desc[2] & 0xef) | ((asvc_flag & 0x1) << 4); +} + +static inline uint8_t desccc_get_asvc_flag(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x10) >> 4; +} + +static inline void desccc_set_mixinfoexists(uint8_t *p_desc, + uint8_t mixinfoexists) +{ + p_desc[2] = (p_desc[2] & 0xf7) | ((mixinfoexists & 0x1) << 3); +} + +static inline uint8_t desccc_get_mixinfoexists(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x08) >> 3; +} + +static inline void desccc_set_substream1_flag(uint8_t *p_desc, + uint8_t substream1_flag) +{ + p_desc[2] = (p_desc[2] & 0xfb) | ((substream1_flag & 0x1) << 2); +} + +static inline uint8_t desccc_get_substream1_flag(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x04) >> 2; +} + +static inline void desccc_set_substream2_flag(uint8_t *p_desc, + uint8_t substream2_flag) +{ + p_desc[2] = (p_desc[2] & 0xfd) | ((substream2_flag & 0x1) << 1); +} + +static inline uint8_t desccc_get_substream2_flag(const uint8_t *p_desc) +{ + return (p_desc[2] & 0x02) >> 1; +} + +static inline void desccc_set_substream3_flag(uint8_t *p_desc, + uint8_t substream3_flag) +{ + p_desc[2] = (p_desc[2] & 0xfe) | (substream3_flag & 0x1); +} + +static inline uint8_t desccc_get_substream3_flag(const uint8_t *p_desc) +{ + return p_desc[2] & 0x01; +} + +static inline void desccc_set_full_service_flag(uint8_t *p_desc, + uint8_t full_service_flag) +{ + p_desc[3] = (p_desc[3] & 0xbf) | ((full_service_flag & 0x01) << 6); +} + +static inline uint8_t desccc_get_full_service_flag(const uint8_t *p_desc) +{ + return (p_desc[3] & 0x40) >> 6; +} + +static inline void desccc_set_audio_service_type(uint8_t *p_desc, + uint8_t audio_service_type) +{ + p_desc[3] = (p_desc[3] & 0xc7) | ((audio_service_type & 0x07) << 3); +} + +static inline uint8_t desccc_get_audio_service_type(const uint8_t *p_desc) +{ + return (p_desc[3] & 0x38) >> 3; +} + +static inline void desccc_set_number_of_channels(uint8_t *p_desc, + uint8_t number_of_channels) +{ + p_desc[3] = (p_desc[3] & 0xf8) | number_of_channels; +} + +static inline uint8_t desccc_get_number_of_channels(const uint8_t *p_desc) +{ + return p_desc[3] & 0x07; +} + +static inline bool desccc_validate(const uint8_t *p_desc) +{ + uint8_t i_size = (DESCCC_HEADER_SIZE - DESC_HEADER_SIZE); + return desc_get_length(p_desc) >= i_size; +} + +static inline void desccc_print(const uint8_t *p_desc, f_print pf_print, + void *opaque, print_type_t i_print_type) +{ + switch (i_print_type) { + case PRINT_XML: + pf_print(opaque, + "", + desccc_get_bsid_flag(p_desc) , + desccc_get_mainid_flag(p_desc) , + desccc_get_asvc_flag(p_desc) , + desccc_get_mixinfoexists(p_desc) , + desccc_get_substream1_flag(p_desc) , + desccc_get_substream2_flag(p_desc) , + desccc_get_substream3_flag(p_desc) , + desccc_get_full_service_flag(p_desc) , + desccc_get_audio_service_type(p_desc), + desccc_get_number_of_channels(p_desc)); + break; + + default: + pf_print(opaque, + " - desc cc eac3" + " bsid_flag=\"%u\"" + " mainid_flag=\"%u\"" + " asvc_flag=\"%u\"" + " mixinfoexists=\"%u\"" + " substream1_flag=\"%u\"" + " substream2_flag=\"%u\"" + " substream3_flag=\"%u\"" + " full_service_flag=\"%u\"" + " audio_service_type=\"0x%02x\"" + " number_of_channels=\"0x%02x\"", + desccc_get_bsid_flag(p_desc) , + desccc_get_mainid_flag(p_desc) , + desccc_get_asvc_flag(p_desc) , + desccc_get_mixinfoexists(p_desc) , + desccc_get_substream1_flag(p_desc) , + desccc_get_substream2_flag(p_desc) , + desccc_get_substream3_flag(p_desc) , + desccc_get_full_service_flag(p_desc) , + desccc_get_audio_service_type(p_desc), + desccc_get_number_of_channels(p_desc) + ); + } +} + +#ifdef __cplusplus +} +#endif + +#endif ===================================== atsc/si/descs_list.h ===================================== @@ -0,0 +1,34 @@ +/***************************************************************************** + * descs_list.h: All supported ATSC descriptors + ***************************************************************************** + * Copyright (C) 2019 OpenHeadend + * + * Authors: Arnaud de Turckheim + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + *****************************************************************************/ + +#ifndef __BITSTREAM_ATSC_DESCS_LIST_H__ +#define __BITSTREAM_ATSC_DESCS_LIST_H__ + +#include +#include + +#endif ===================================== mpeg/psi/descs_print.h ===================================== @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" @@ -183,6 +184,8 @@ static inline void descl_print(uint8_t *p_descl, uint16_t i_length, CASE_DESC(7a) CASE_DESC(7b) CASE_DESC(7c) + CASE_DESC(81) + CASE_DESC(cc) #undef CASE_DESC #undef CASE_DESC_ICONV View it on GitLab: https://code.videolan.org/videolan/bitstream/compare/0fd094c9ca5119738419718acb39d3d8aa7da16d...df8d1d1fb1583784f5c1d92760fb71cca83d184c -- View it on GitLab: https://code.videolan.org/videolan/bitstream/compare/0fd094c9ca5119738419718acb39d3d8aa7da16d...df8d1d1fb1583784f5c1d92760fb71cca83d184c You're receiving this email because of your account on code.videolan.org.