Commit 106569f3 authored by Sebastian Ramacher's avatar Sebastian Ramacher

New upstream version 1.3

parent 8d8f7dcc
PREFIX ?= /usr/local
INCLUDE = $(subst //,/,$(DESTDIR)/$(PREFIX)/include/bitstream)
VERSION = 1.2
INCLUDEDIR = $(PREFIX)/include
LIBDIR = $(PREFIX)/lib
INCLUDE = $(DESTDIR)$(INCLUDEDIR)/bitstream
PKGCONFIG = $(DESTDIR)$(LIBDIR)/pkgconfig
VERSION = 1.3
all:
@echo "Run \"make install\" to install biTStream into $(INCLUDE)"
ln -nsf .. examples/bitstream
$(MAKE) -C examples
install:
bitstream.pc: bitstream.pc.in
@echo "GEN $@"
@sed -e 's|@PREFIX@|$(PREFIX)|' \
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
-e 's|@VERSION@|$(VERSION)|' \
$< > $@
install: bitstream.pc
@echo "INSTALL $(INCLUDE)"
@install -d $(INCLUDE)
@install -m 644 common.h $(INCLUDE)/
......@@ -29,12 +40,42 @@ install:
@install -m 644 scte/*.h $(INCLUDE)/scte
@install -d $(INCLUDE)/smpte
@install -m 644 smpte/*.h $(INCLUDE)/smpte
@echo "INSTALL $(PKGCONFIG)/bitstream.pc"
@install -d $(PKGCONFIG)
@install -m 644 bitstream.pc $(PKGCONFIG)
uninstall:
@echo "REMOVE $(INCLUDE)"
@rm -rf $(INCLUDE)
@$(RM) -r $(INCLUDE)
@echo "REMOVE $(PKGCONFIG)/bitstream.pc"
@$(RM) $(PKGCONFIG)/bitstream.pc
dist:
git archive --format=tar --prefix=bitstream-$(VERSION)/ master | bzip2 -9 > bitstream-$(VERSION).tar.bz2
git archive --format=tar --prefix=bitstream-$(VERSION)/ master | \
bzip2 -9 > bitstream-$(VERSION).tar.bz2
clean:
$(RM) bitstream bitstream.pc
$(MAKE) -C examples clean
# if you want to check only particular headers,
# use make check HEADER_LIST="dvb/sim.h ietf/rtp.h"
HEADER_LIST = $$(find * -name '*.h')
FLAGS = -I. -Werror -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2
compiler_c = $(CC) $(FLAGS) $(CFLAGS)
compiler_c++ = $(CXX) $(FLAGS) $(CXXFLAGS)
compile = $(compiler_$1) -include "$$header" -c -x $1 /dev/null -o /dev/null
check:
@ln -nsf . bitstream
@for header in $(HEADER_LIST); do \
$(if $(V),set -x;) \
$(call compile,c) || exit 1; \
$(call compile,c++) || exit 1; \
echo "PASS: $$header"; \
done
.PHONY: install uninstall distcheck
.PHONY: all install uninstall dist clean check
1.3 (29 Jan 2018)
=================
- Add support for avcC and hvcC structures
- Add support for LOAS AAC
- Improve support for RTP
- Use ISO 6937 as default DVB charset
- Ship pkg-config file
1.2 (31 Jan 2017)
=================
- Add partial support for ITU-T H.265
......
prefix=@PREFIX@
includedir=@INCLUDEDIR@
Name: bitstream
Description: Binary structures for MPEG, DVB, IETF, SMPTE, IEEE, SCTE, etc.
Version: @VERSION@
Cflags: -I${includedir}
......@@ -124,7 +124,7 @@ static inline uint32_t dvb_time_encode_duration(unsigned int duration_sec)
}
#undef dec2bcd
static time_t dvb_time_format_UTC(uint64_t UTC_time, struct tm *tm, char *output) {
static inline time_t dvb_time_format_UTC(uint64_t UTC_time, struct tm *tm, char *output) {
struct tm tm_local;
if (tm == NULL)
tm = &tm_local;
......
......@@ -128,14 +128,14 @@ static inline void desc44_print(const uint8_t *p_desc, f_print pf_print,
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque,
"<CABLE_DESC frequency=\"%"PRIu64"\" fecouter=\"%s\" modulation=\"%s\" symbolrate=\"%u\" fecinner=\"%s\"/>",
"<CABLE_DESC frequency=\"%" PRIu64 "\" fecouter=\"%s\" modulation=\"%s\" symbolrate=\"%u\" fecinner=\"%s\"/>",
desc44_get_frequency(p_desc), psz_fecouter, psz_modulation,
desc44_get_symbolrate(p_desc),
dvb_delivery_get_fec(desc43_get_fecinner(p_desc)));
break;
default:
pf_print(opaque,
" - desc 44 dvb-c frequency=%"PRIu64" Hz fecouter=%s modulation=%s symbolrate=%u fecinner=%s",
" - desc 44 dvb-c frequency=%" PRIu64 " Hz fecouter=%s modulation=%s symbolrate=%u fecinner=%s",
desc44_get_frequency(p_desc), psz_fecouter, psz_modulation,
desc44_get_symbolrate(p_desc),
dvb_delivery_get_fec(desc43_get_fecinner(p_desc)));
......
......@@ -247,7 +247,7 @@ static inline void desc5a_print(const uint8_t *p_desc, f_print pf_print,
switch (i_print_type) {
case PRINT_XML:
pf_print(opaque,
"<TERRESTRIAL_DESC frequency=\"%"PRIu64"\" bandwidth=\"%u\" priority=\"%s\" timeslicing=\"%d\" mpefec=\"%d\" constellation=\"%s\" hierarchy=\"%s\" coderatehp=\"%s\" coderatelp=\"%s\" guard=\"%s\" transmission=\"%s\" otherfrequency=\"%d\"/>",
"<TERRESTRIAL_DESC frequency=\"%" PRIu64 "\" bandwidth=\"%u\" priority=\"%s\" timeslicing=\"%d\" mpefec=\"%d\" constellation=\"%s\" hierarchy=\"%s\" coderatehp=\"%s\" coderatelp=\"%s\" guard=\"%s\" transmission=\"%s\" otherfrequency=\"%d\"/>",
desc5a_get_frequency(p_desc), i_bandwidth,
desc5a_get_priority(p_desc) ? "HP" : "LP",
desc5a_get_timeslicing(p_desc) ? 1 : 0,
......@@ -260,7 +260,7 @@ static inline void desc5a_print(const uint8_t *p_desc, f_print pf_print,
break;
default:
pf_print(opaque,
" - desc 5a dvb-t frequency=%"PRIu64" Hz bandwidth=%u MHz priority=%s timeslicing=%d mpefec=%d constellation=%s hierarchy=%s coderatehp=%s coderatelp=%s guard=%s transmission=%s otherfrequency=%d",
" - desc 5a dvb-t frequency=%" PRIu64 " Hz bandwidth=%u MHz priority=%s timeslicing=%d mpefec=%d constellation=%s hierarchy=%s coderatehp=%s coderatelp=%s guard=%s transmission=%s otherfrequency=%d",
desc5a_get_frequency(p_desc), i_bandwidth,
desc5a_get_priority(p_desc) ? "HP" : "LP",
desc5a_get_timeslicing(p_desc) ? 1 : 0,
......
......@@ -63,15 +63,18 @@ static const char *ppsz_dvb_encodings10[] = {
};
static inline const char *dvb_string_get_encoding(const uint8_t **pp_string,
size_t *pi_length)
size_t *pi_length, const char *psz_default_encoding)
{
uint8_t i_first;
if (!*pi_length) return NULL;
if (!*pi_length)
return NULL;
i_first = (*pp_string)[0];
if (!i_first) return NULL;
if (i_first >= 0x20) return "ISO-8859-1";
if (!i_first)
return NULL;
if (i_first >= 0x20)
return psz_default_encoding;
(*pp_string)++;
(*pi_length)--;
......@@ -96,15 +99,17 @@ static inline const char *dvb_string_get_encoding(const uint8_t **pp_string,
return ppsz_dvb_encodings[i_first];
}
static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
const char *psz_encoding,
size_t *pi_out_length)
static inline uint8_t *dvb_string_set_inner(const uint8_t *p_string,
size_t i_length, const char *psz_encoding, size_t *pi_out_length,
const char *psz_default_encoding)
{
int i;
if (!strcmp(psz_encoding, "ISO-8859-9")) {
if (!strcmp(psz_encoding, psz_default_encoding)) {
uint8_t *p_encoded = (uint8_t *)malloc(i_length);
*pi_out_length = i_length;
return (uint8_t *)strdup((const char *)p_string);
memcpy(p_encoded, p_string, i_length);
return p_encoded;
}
for (i = 0; ppsz_dvb_encodings[i] != NULL; i++) {
......@@ -133,13 +138,33 @@ static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
return NULL;
}
static inline uint8_t *dvb_string_set(const uint8_t *p_string, size_t i_length,
const char *psz_encoding,
size_t *pi_out_length)
{
return dvb_string_set_inner(p_string, i_length, psz_encoding,
pi_out_length, "ISO6937");
}
static inline uint8_t *dvb_string_set_quirks(const uint8_t *p_string,
size_t i_length, const char *psz_encoding, size_t *pi_out_length,
const char *psz_provider)
{
if (psz_provider != NULL && !strcmp(psz_provider, "CSAT"))
return dvb_string_set_inner(p_string, i_length, psz_encoding,
pi_out_length, "ISO-8859-1");
return dvb_string_set_inner(p_string, i_length, psz_encoding,
pi_out_length, "ISO6937");
}
/* simpler API because this one doesn't output to multibyte charsets */
static inline char *dvb_string_get(const uint8_t *p_string, size_t i_length,
f_iconv pf_iconv, void *iconv_opaque)
static inline char *dvb_string_get_inner(const uint8_t *p_string,
size_t i_length, f_iconv pf_iconv, void *iconv_opaque,
const char *psz_default_encoding)
{
if (i_length) {
const char *psz_encoding = dvb_string_get_encoding(&p_string,
&i_length);
const char *psz_encoding =
dvb_string_get_encoding(&p_string, &i_length, psz_default_encoding);
if (psz_encoding == NULL || !i_length) {
/* try one-byte charset */
char *psz_string = (char *)malloc(i_length + 1);
......@@ -148,13 +173,30 @@ static inline char *dvb_string_get(const uint8_t *p_string, size_t i_length,
return psz_string;
}
return pf_iconv(iconv_opaque, psz_encoding,
(char *)p_string, i_length);
return pf_iconv(iconv_opaque, psz_encoding, (char *)p_string, i_length);
}
return strdup("");
}
static inline char *dvb_string_get(const uint8_t *p_string, size_t i_length,
f_iconv pf_iconv, void *iconv_opaque)
{
return dvb_string_get_inner(p_string, i_length, pf_iconv, iconv_opaque,
"ISO6937");
}
static inline char *dvb_string_get_quirks(const uint8_t *p_string,
size_t i_length, f_iconv pf_iconv, void *iconv_opaque,
const char *psz_provider)
{
if (psz_provider != NULL && !strcmp(psz_provider, "CSAT"))
return dvb_string_get_inner(p_string, i_length, pf_iconv, iconv_opaque,
"ISO-8859-1");
return dvb_string_get_inner(p_string, i_length, pf_iconv, iconv_opaque,
"ISO6937");
}
static inline char *dvb_string_xml_escape(char *psz_input)
{
char *psz_output, *psz2;
......
......@@ -203,9 +203,9 @@ static inline bool intf##_append_##name(uint8_t *p_tlv, type i_##name) \
static inline type intf##_find_##name(uint8_t *p_tlv, uint16_t n) \
{ \
const uint8_t *p_tlv_n = tlv_find_param(p_tlv, param, n); \
type i_##name = (type)(p_tlv_n[4]) << 8 * (sizeof(type) - 1); \
type i_##name = 0; \
int i; \
for (i = 1; i < sizeof(type); i++) \
for (i = 0; i < sizeof(type); i++) \
i_##name |= (utype)(p_tlv_n[4 + i]) << 8 * (sizeof(type) - i - 1); \
return i_##name; \
}
......
CFLAGS = -Wall -O2 -g
CFLAGS_LOCAL = -Wall -O2 -g -I. -I../..
LDFLAGS = -lrt
PREFIX ?= /usr/local
WARN = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare
CPPFLAGS = -I.
CFLAGS := $(WARN) -O2 -g $(CFLAGS)
LDFLAGS := -lrt $(LDFLAGS)
OBJ = dvb_print_si dvb_gen_si dvb_ecmg dvb_ecmg_test mpeg_print_pcr rtp_check_seqnum mpeg_restamp
ifeq "$(shell uname -s)" "Darwin"
LDFLAGS += -liconv
LDLIBS += -liconv
# Prevent generation of .dSYM debug directories
CFLAGS += -gstabs
CFLAGS_LOCAL += -gstabs
endif
all: $(OBJ)
%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
local: CFLAGS = $(CFLAGS_LOCAL)
local: all
install: $(OBJ)
install -d "$(DESTDIR)$(PREFIX)/bin"
install -m 755 $(OBJ) "$(DESTDIR)$(PREFIX)/bin"
clean:
rm -rf $(OBJ)
$(RM) $(OBJ)
......@@ -164,8 +164,8 @@ static char *iconv_wrapper(void *_unused, const char *psz_encoding,
if (iconv_handle == (iconv_t)-1)
iconv_handle = iconv_open(psz_native_encoding, psz_encoding);
if (iconv_handle == (iconv_t)-1) {
fprintf(stderr, "couldn't convert from %s to %s (%m)\n", psz_encoding,
psz_native_encoding);
fprintf(stderr, "couldn't initiate conversion from %s to %s (%m)\n",
psz_encoding, psz_native_encoding);
return iconv_append_null(p_string, i_length);
}
psz_current_encoding = psz_encoding;
......
#!/bin/sh
# Test if each header can be used standalone
# Copyright (C) 2011 Unix Solutions Ltd.
#
# License: MIT
# Authors: Georgi Chorbadzhiyski <georgi@unixsol.org>
#
HEADER_LIST="dvb/sim.h ietf/rtp.h"
# Find is used in such a way in order to work on OS X as well as Linux
# If you want to test only particular headers comment the line bellow
HEADER_LIST=$(find * | grep \\.h$ | sort | sed -e 's|^\./||')
for suffix in "c" "cpp"
do
case $suffix in
"cpp")
compiler="g++"
;;
*)
compiler="gcc"
;;
esac
for HDR in $HEADER_LIST
do
test_file=$(echo $HDR | sed -e 's|/|_|g;s|\.h$||')
echo "Testing ($compiler): $HDR"
printf "#include \"$HDR\"\n\nint main(void) { return 0; }\n" > $test_file.$suffix
$compiler -I.. -Werror -Wall -Wextra -Wno-unused -Wno-sign-compare -Wformat-security $test_file.$suffix -o $test_file
[ $? != 0 ] && exit 1
rm $test_file $test_file.$suffix
done
done
......@@ -33,6 +33,7 @@
#ifndef __BITSTREAM_IETF_RTP_H__
#define __BITSTREAM_IETF_RTP_H__
#include <stdlib.h>
#include <stdint.h> /* uint8_t, uint16_t, etc... */
#include <stdbool.h> /* bool */
......@@ -71,6 +72,16 @@ static inline bool rtp_check_hdr(const uint8_t *p_rtp)
return (p_rtp[0] & 0xc0) == 0x80;
}
static inline void rtp_set_padding(uint8_t *p_rtp)
{
p_rtp[0] |= 0x20;
}
static inline bool rtp_check_padding(const uint8_t *p_rtp)
{
return !!(p_rtp[0] & 0x20);
}
static inline void rtp_set_extension(uint8_t *p_rtp)
{
p_rtp[0] |= 0x10;
......@@ -193,6 +204,16 @@ static inline uint8_t *rtp_payload(uint8_t *p_rtp)
return p_rtp + i_size;
}
static inline size_t rtp_payload_size(uint8_t *p_rtp, size_t i_rtp_size)
{
size_t i_payload_size = i_rtp_size - (rtp_payload(p_rtp) - p_rtp);
uint8_t i_padding_size = 0;
if (rtp_check_padding(p_rtp))
i_padding_size = p_rtp[i_rtp_size - 1];
return i_payload_size - i_padding_size;
}
#ifdef __cplusplus
}
#endif
......
......@@ -80,7 +80,8 @@ extern "C"
/* Unassigned 35-71 */
/* Reserved 72-76 */
/* Unassigned 77-95 */
/* Dynamic 96-127 */
#define RTP_TYPE_DYNAMIC_FIRST 96
#define RTP_TYPE_DYNAMIC_LAST 127
static inline uint32_t rtp_3551_get_clock_rate(uint8_t i_type)
{
......
/*****************************************************************************
* rtp3640.h: RTP Payload Format for Transport of MPEG-4 Elementary Streams
*****************************************************************************
* Copyright (C) 2017 VideoLAN
*
* Authors: Christophe Massiot
*
* 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.
*****************************************************************************/
/*
* Normative references:
* - IETF RFC 3640 RTP Payload Format for Transport of MPEG-4 ES
*/
#ifndef __BITSTREAM_IETF_RTP3640_H__
# define __BITSTREAM_IETF_RTP3640_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define RTP3640_AU_HEADERS_LENGTH_SIZE 2
#define RTP3640_AU_HEADER_AAC_HBR_SIZE 2
static inline void rtp3640_set_au_headers_length(uint8_t *header, uint16_t size)
{
header[0] = size >> 8;
header[1] = size & 0xff;
}
static inline uint16_t rtp3640_get_au_headers_length(const uint8_t *header)
{
return (header[0] << 8) | header[1];
}
static inline void rtp3640_set_aac_hbr_au_size(uint8_t *header, uint16_t size)
{
header[0] = (size >> 5) & 0xff;
header[1] &= ~0xf8;
header[1] |= (size << 3) & 0xf8;
}
static inline uint16_t rtp3640_get_aac_hbr_au_size(const uint8_t *header)
{
return (header[0] << 5) | (header[1] >> 3);
}
static inline void rtp3640_set_aac_hbr_au_index(uint8_t *header, uint8_t index)
{
header[1] &= ~0x7;
header[1] |= index & 0x7;
}
static inline uint8_t rtp3640_get_aac_hbr_au_index(const uint8_t *header)
{
return (header[1] & 0x7);
}
#ifdef __cplusplus
}
#endif
#endif /* !__BITSTREAM_IETF_RTP3640_H__ */
/*****************************************************************************
* rtp6184.h: RTP Payload Format for H.264 Video
*****************************************************************************
* Copyright (c) 2015 Arnaud de Turckheim <quarium@gmail.com>
* Copyright (C) 2017 VideoLAN
*
* Authors: Arnaud de Turckheim
* Christophe Massiot
*
* 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.
*****************************************************************************/
/*
* RTP Payload Format for H.264 Video
* Normative references:
* - IETF RFC 6184 RTP Payload Format for H.264 Video (May 2011)
*/
#ifndef __BITSTREAM_IETF_RTP6184_H__
# define __BITSTREAM_IETF_RTP6184_H__
#define RTP_6184_CLOCKRATE 90000
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define RTP_6184_CLOCKRATE 90000
#define RTP_6184_STAP_A 24
#define RTP_6184_STAP_B 25
#define RTP_6184_MTAP16 26
#define RTP_6184_MTAP24 27
#define RTP_6184_FU_A 28
#define RTP_6184_FU_B 29
#define RTP_6184_STAP_HEADER_SIZE 2
static inline void rtp_6184_stap_set_size(uint8_t *header, uint16_t size)
{
header[0] = size >> 8;
header[1] = size & 0xff;
}
static inline uint16_t rtp_6184_stap_get_size(const uint8_t *header)
{
return (header[0] << 8) | header[1];
}
static inline void rtp_6184_fu_set_start(uint8_t *header)
{
header[0] |= 0x80;
}
static inline bool rtp_6184_fu_check_start(uint8_t header)
{
return header & 0x80;
}
static inline void rtp_6184_fu_set_end(uint8_t *header)
{
header[0] |= 0x40;
}
static inline bool rtp_6184_fu_check_end(uint8_t header)
{
return header & 0x40;
}
#ifdef __cplusplus
}
#endif
#endif /* !__BITSTREAM_IETF_RTP6184_H__ */
......@@ -28,6 +28,7 @@
/*
* Normative references:
* - ITU-T H.265 (high efficiency video coding)
* - ISO/IEC 14496-15 2013 (AVC file format)
*/
#ifndef __BITSTREAM_ITU_H265_H__
......@@ -332,6 +333,331 @@ static inline void h265eob_init(uint8_t *p_h265eob)
#define H265SLI_TYPE_P 1
#define H265SLI_TYPE_I 2
/*****************************************************************************
* H265 hvcC structure
*****************************************************************************/
#define H265HVCC_HEADER 22
#define H265HVCC_ARRAY_HEADER 3
#define H265HVCC_NALU_HEADER 2
static inline void h265hvcc_init(uint8_t *p)
{
p[0] = 1; /* version */
p[1] = 0;
p[2] = 0;
p[3] = 0;
p[4] = 0;
p[5] = 0;
p[6] = 0;
p[7] = 0;
p[8] = 0;
p[9] = 0;
p[10] = 0;
p[11] = 0;
p[12] = 0;
p[13] = 0xf0;
p[14] = 0xfc;
p[15] = 0xfc;
p[16] = 0xf8;
p[17] = 0xf8;
p[18] = 0;
p[19] = 0;
p[20] = 0;
p[21] = 0;
}
static inline void h265hvcc_set_profile_space(uint8_t *p, uint8_t val)
{
p[1] &= ~0xc0;
p[1] |= val << 6;
}
static inline uint8_t h265hvcc_get_profile_space(const uint8_t *p)
{
return p[1] >> 6;
}
static inline void h265hvcc_set_tier(uint8_t *p)
{
p[1] |= 0x40;
}
static inline bool h265hvcc_get_tier(const uint8_t *p)
{
return p[1] & 0x40;
}
static inline void h265hvcc_set_profile_idc(uint8_t *p, uint8_t val)
{
p[1] &= ~0x1f;
p[1] |= val & 0x1f;
}
static inline uint8_t h265hvcc_get_profile_idc(const uint8_t *p)
{
return p[1] & 0x1f;
}
static inline void h265hvcc_set_profile_compatibility(uint8_t *p, uint32_t val)
{
p[2] = val >> 24;
p[3] = (val >> 16) & 0xff;
p[4] = (val >> 8) & 0xff;
p[5] = val & 0xff;
}
static inline uint32_t h265hvcc_get_profile_compatibility(const uint8_t *p)
{
return (p[2] << 24) | (p[3] << 16) | (p[4] << 8) | p[5];
}
static inline void h265hvcc_set_constraint_indicator(uint8_t *p, uint64_t val)
{
p[6] = val >> 40;
p[7] = (val >> 32) & 0xff;
p[8] = (val >> 24) & 0xff;
p[9] = (val >> 16) & 0xff;
p[10] = (val >> 8) & 0xff;
p[11] = val & 0xff;
}
static inline uint64_t h265hvcc_get_constraint_indicator(const uint8_t *p)
{
return ((uint64_t)p[6] << 40) |
((uint64_t)p[7] << 32) |
((uint64_t)p[8] << 24) |
((uint64_t)p[9] << 16) |
((uint64_t)p[10] << 8) |
(uint64_t)p[11];
}
static inline void h265hvcc_set_level_idc(uint8_t *p, uint8_t val)
{
p[12] = val;
}
static inline uint8_t h265hvcc_get_level_idc(const uint8_t *p)
{
return p[12];
}
static inline void h265hvcc_set_min_spatial_segmentation_idc(uint8_t *p, uint8_t val)
{
p[13] = 0xf0 | val;
}
static inline uint8_t h265hvcc_get_min_spatial_segmentation_idc(const uint8_t *p)
{
return p[13] & 0xf;
}
static inline void h265hvcc_set_parallelism_type(uint8_t *p, uint8_t val)
{
p[14] = 0xfc | val;
}
static inline uint8_t h265hvcc_get_parallelism_type(const uint8_t *p)
{
return p[14] & 0x3;
}
static inline void h265hvcc_set_chroma_format(uint8_t *p, uint8_t val)
{
p[15] = 0xfc | val;
}
static inline uint8_t h265hvcc_get_chroma_format(const uint8_t *p)
{
return p[15] & 0x3;
}
static inline void h265hvcc_set_bitdepth_luma_8(uint8_t *p, uint8_t val)
{
p[16] = 0xf8 | val;
}
static inline uint8_t h265hvcc_get_bitdepth_luma_8(const uint8_t *p)
{
return p[16] & 0x7;
}
static inline void h265hvcc_set_bitdepth_chroma_8(uint8_t *p, uint8_t val)
{
p[17] = 0xf8 | val;