New upstream version 18.0.1+dfsg1
This commit is contained in:
parent
6efda2859e
commit
a03541a0f8
763 changed files with 69366 additions and 2632 deletions
9
deps/CMakeLists.txt
vendored
9
deps/CMakeLists.txt
vendored
|
|
@ -8,6 +8,15 @@ add_subdirectory(ipc-util)
|
|||
add_subdirectory(libff)
|
||||
add_subdirectory(file-updater)
|
||||
|
||||
if(WIN32)
|
||||
add_subdirectory(blake2)
|
||||
add_subdirectory(lzma)
|
||||
endif()
|
||||
|
||||
if(BUILD_CAPTIONS)
|
||||
add_subdirectory(libcaption)
|
||||
endif()
|
||||
|
||||
find_package(Jansson 2.5 QUIET)
|
||||
|
||||
if(NOT JANSSON_FOUND)
|
||||
|
|
|
|||
32
deps/blake2/CMakeLists.txt
vendored
Normal file
32
deps/blake2/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(blake2)
|
||||
|
||||
set(BLAKE2_INCLUDE_DIR
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||
CACHE PATH "blake2 include path")
|
||||
|
||||
include_directories(
|
||||
${LIBblake2_INCLUDE_DIRS}
|
||||
src
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
|
||||
endif()
|
||||
add_definitions(
|
||||
-Dinline=_inline
|
||||
-Drestrict=__restrict)
|
||||
endif()
|
||||
|
||||
set(blake2_SOURCES
|
||||
src/blake2b-ref.c)
|
||||
|
||||
set(blake2_HEADERS
|
||||
src/blake2.h
|
||||
src/blake2-impl.h)
|
||||
|
||||
add_library(blake2 STATIC
|
||||
${blake2_SOURCES}
|
||||
${blake2_HEADERS})
|
||||
160
deps/blake2/src/blake2-impl.h
vendored
Normal file
160
deps/blake2/src/blake2-impl.h
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#ifndef BLAKE2_IMPL_H
|
||||
#define BLAKE2_IMPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
||||
#if defined(_MSC_VER)
|
||||
#define BLAKE2_INLINE __inline
|
||||
#elif defined(__GNUC__)
|
||||
#define BLAKE2_INLINE __inline__
|
||||
#else
|
||||
#define BLAKE2_INLINE
|
||||
#endif
|
||||
#else
|
||||
#define BLAKE2_INLINE inline
|
||||
#endif
|
||||
|
||||
static BLAKE2_INLINE uint32_t load32( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint32_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint32_t )( p[0] ) << 0) |
|
||||
(( uint32_t )( p[1] ) << 8) |
|
||||
(( uint32_t )( p[2] ) << 16) |
|
||||
(( uint32_t )( p[3] ) << 24) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t load64( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint64_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint64_t )( p[0] ) << 0) |
|
||||
(( uint64_t )( p[1] ) << 8) |
|
||||
(( uint64_t )( p[2] ) << 16) |
|
||||
(( uint64_t )( p[3] ) << 24) |
|
||||
(( uint64_t )( p[4] ) << 32) |
|
||||
(( uint64_t )( p[5] ) << 40) |
|
||||
(( uint64_t )( p[6] ) << 48) |
|
||||
(( uint64_t )( p[7] ) << 56) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint16_t load16( const void *src )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
uint16_t w;
|
||||
memcpy(&w, src, sizeof w);
|
||||
return w;
|
||||
#else
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint16_t )( p[0] ) << 0) |
|
||||
(( uint16_t )( p[1] ) << 8) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
*p++ = ( uint8_t )w; w >>= 8;
|
||||
*p++ = ( uint8_t )w;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
|
||||
{
|
||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
||||
memcpy(dst, &w, sizeof w);
|
||||
#else
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
p[4] = (uint8_t)(w >> 32);
|
||||
p[5] = (uint8_t)(w >> 40);
|
||||
p[6] = (uint8_t)(w >> 48);
|
||||
p[7] = (uint8_t)(w >> 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t load48( const void *src )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )src;
|
||||
return (( uint64_t )( p[0] ) << 0) |
|
||||
(( uint64_t )( p[1] ) << 8) |
|
||||
(( uint64_t )( p[2] ) << 16) |
|
||||
(( uint64_t )( p[3] ) << 24) |
|
||||
(( uint64_t )( p[4] ) << 32) |
|
||||
(( uint64_t )( p[5] ) << 40) ;
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE void store48( void *dst, uint64_t w )
|
||||
{
|
||||
uint8_t *p = ( uint8_t * )dst;
|
||||
p[0] = (uint8_t)(w >> 0);
|
||||
p[1] = (uint8_t)(w >> 8);
|
||||
p[2] = (uint8_t)(w >> 16);
|
||||
p[3] = (uint8_t)(w >> 24);
|
||||
p[4] = (uint8_t)(w >> 32);
|
||||
p[5] = (uint8_t)(w >> 40);
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 32 - c ) );
|
||||
}
|
||||
|
||||
static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
|
||||
{
|
||||
return ( w >> c ) | ( w << ( 64 - c ) );
|
||||
}
|
||||
|
||||
/* prevents compiler optimizing out memset() */
|
||||
static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
|
||||
{
|
||||
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
|
||||
memset_v(v, 0, n);
|
||||
}
|
||||
|
||||
#endif
|
||||
195
deps/blake2/src/blake2.h
vendored
Normal file
195
deps/blake2/src/blake2.h
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
#ifndef BLAKE2_H
|
||||
#define BLAKE2_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
||||
#else
|
||||
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum blake2s_constant
|
||||
{
|
||||
BLAKE2S_BLOCKBYTES = 64,
|
||||
BLAKE2S_OUTBYTES = 32,
|
||||
BLAKE2S_KEYBYTES = 32,
|
||||
BLAKE2S_SALTBYTES = 8,
|
||||
BLAKE2S_PERSONALBYTES = 8
|
||||
};
|
||||
|
||||
enum blake2b_constant
|
||||
{
|
||||
BLAKE2B_BLOCKBYTES = 128,
|
||||
BLAKE2B_OUTBYTES = 64,
|
||||
BLAKE2B_KEYBYTES = 64,
|
||||
BLAKE2B_SALTBYTES = 16,
|
||||
BLAKE2B_PERSONALBYTES = 16
|
||||
};
|
||||
|
||||
typedef struct blake2s_state__
|
||||
{
|
||||
uint32_t h[8];
|
||||
uint32_t t[2];
|
||||
uint32_t f[2];
|
||||
uint8_t buf[BLAKE2S_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
size_t outlen;
|
||||
uint8_t last_node;
|
||||
} blake2s_state;
|
||||
|
||||
typedef struct blake2b_state__
|
||||
{
|
||||
uint64_t h[8];
|
||||
uint64_t t[2];
|
||||
uint64_t f[2];
|
||||
uint8_t buf[BLAKE2B_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
size_t outlen;
|
||||
uint8_t last_node;
|
||||
} blake2b_state;
|
||||
|
||||
typedef struct blake2sp_state__
|
||||
{
|
||||
blake2s_state S[8][1];
|
||||
blake2s_state R[1];
|
||||
uint8_t buf[8 * BLAKE2S_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
size_t outlen;
|
||||
} blake2sp_state;
|
||||
|
||||
typedef struct blake2bp_state__
|
||||
{
|
||||
blake2b_state S[4][1];
|
||||
blake2b_state R[1];
|
||||
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
|
||||
size_t buflen;
|
||||
size_t outlen;
|
||||
} blake2bp_state;
|
||||
|
||||
|
||||
BLAKE2_PACKED(struct blake2s_param__
|
||||
{
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint32_t leaf_length; /* 8 */
|
||||
uint32_t node_offset; /* 12 */
|
||||
uint16_t xof_length; /* 14 */
|
||||
uint8_t node_depth; /* 15 */
|
||||
uint8_t inner_length; /* 16 */
|
||||
/* uint8_t reserved[0]; */
|
||||
uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
|
||||
uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
|
||||
});
|
||||
|
||||
typedef struct blake2s_param__ blake2s_param;
|
||||
|
||||
BLAKE2_PACKED(struct blake2b_param__
|
||||
{
|
||||
uint8_t digest_length; /* 1 */
|
||||
uint8_t key_length; /* 2 */
|
||||
uint8_t fanout; /* 3 */
|
||||
uint8_t depth; /* 4 */
|
||||
uint32_t leaf_length; /* 8 */
|
||||
uint32_t node_offset; /* 12 */
|
||||
uint32_t xof_length; /* 16 */
|
||||
uint8_t node_depth; /* 17 */
|
||||
uint8_t inner_length; /* 18 */
|
||||
uint8_t reserved[14]; /* 32 */
|
||||
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
||||
});
|
||||
|
||||
typedef struct blake2b_param__ blake2b_param;
|
||||
|
||||
typedef struct blake2xs_state__
|
||||
{
|
||||
blake2s_state S[1];
|
||||
blake2s_param P[1];
|
||||
} blake2xs_state;
|
||||
|
||||
typedef struct blake2xb_state__
|
||||
{
|
||||
blake2b_state S[1];
|
||||
blake2b_param P[1];
|
||||
} blake2xb_state;
|
||||
|
||||
/* Padded structs result in a compile-time error */
|
||||
enum {
|
||||
BLAKE2_DUMMY_1 = 1/(int)(sizeof(blake2s_param) == BLAKE2S_OUTBYTES),
|
||||
BLAKE2_DUMMY_2 = 1/(int)(sizeof(blake2b_param) == BLAKE2B_OUTBYTES)
|
||||
};
|
||||
|
||||
/* Streaming API */
|
||||
int blake2s_init( blake2s_state *S, size_t outlen );
|
||||
int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
|
||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
|
||||
int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
|
||||
int blake2s_final( blake2s_state *S, void *out, size_t outlen );
|
||||
|
||||
int blake2b_init( blake2b_state *S, size_t outlen );
|
||||
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
|
||||
int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
|
||||
int blake2b_final( blake2b_state *S, void *out, size_t outlen );
|
||||
|
||||
int blake2sp_init( blake2sp_state *S, size_t outlen );
|
||||
int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen );
|
||||
int blake2sp_update( blake2sp_state *S, const void *in, size_t inlen );
|
||||
int blake2sp_final( blake2sp_state *S, void *out, size_t outlen );
|
||||
|
||||
int blake2bp_init( blake2bp_state *S, size_t outlen );
|
||||
int blake2bp_init_key( blake2bp_state *S, size_t outlen, const void *key, size_t keylen );
|
||||
int blake2bp_update( blake2bp_state *S, const void *in, size_t inlen );
|
||||
int blake2bp_final( blake2bp_state *S, void *out, size_t outlen );
|
||||
|
||||
/* Variable output length API */
|
||||
int blake2xs_init( blake2xs_state *S, const size_t outlen );
|
||||
int blake2xs_init_key( blake2xs_state *S, const size_t outlen, const void *key, size_t keylen );
|
||||
int blake2xs_update( blake2xs_state *S, const void *in, size_t inlen );
|
||||
int blake2xs_final(blake2xs_state *S, void *out, size_t outlen);
|
||||
|
||||
int blake2xb_init( blake2xb_state *S, const size_t outlen );
|
||||
int blake2xb_init_key( blake2xb_state *S, const size_t outlen, const void *key, size_t keylen );
|
||||
int blake2xb_update( blake2xb_state *S, const void *in, size_t inlen );
|
||||
int blake2xb_final(blake2xb_state *S, void *out, size_t outlen);
|
||||
|
||||
/* Simple API */
|
||||
int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
int blake2xs( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
/* This is simply an alias for blake2b */
|
||||
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
379
deps/blake2/src/blake2b-ref.c
vendored
Normal file
379
deps/blake2/src/blake2b-ref.c
vendored
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
/*
|
||||
BLAKE2 reference source code package - reference C implementations
|
||||
|
||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
||||
your option. The terms of these licenses can be found at:
|
||||
|
||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
More information about the BLAKE2 hash function can be found at
|
||||
https://blake2.net.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "blake2.h"
|
||||
#include "blake2-impl.h"
|
||||
|
||||
static const uint64_t blake2b_IV[8] =
|
||||
{
|
||||
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
|
||||
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
|
||||
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
|
||||
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
|
||||
};
|
||||
|
||||
static const uint8_t blake2b_sigma[12][16] =
|
||||
{
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }
|
||||
};
|
||||
|
||||
|
||||
static void blake2b_set_lastnode( blake2b_state *S )
|
||||
{
|
||||
S->f[1] = (uint64_t)-1;
|
||||
}
|
||||
|
||||
/* Some helper functions, not necessarily useful */
|
||||
static int blake2b_is_lastblock( const blake2b_state *S )
|
||||
{
|
||||
return S->f[0] != 0;
|
||||
}
|
||||
|
||||
static void blake2b_set_lastblock( blake2b_state *S )
|
||||
{
|
||||
if( S->last_node ) blake2b_set_lastnode( S );
|
||||
|
||||
S->f[0] = (uint64_t)-1;
|
||||
}
|
||||
|
||||
static void blake2b_increment_counter( blake2b_state *S, const uint64_t inc )
|
||||
{
|
||||
S->t[0] += inc;
|
||||
S->t[1] += ( S->t[0] < inc );
|
||||
}
|
||||
|
||||
static void blake2b_init0( blake2b_state *S )
|
||||
{
|
||||
size_t i;
|
||||
memset( S, 0, sizeof( blake2b_state ) );
|
||||
|
||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i];
|
||||
}
|
||||
|
||||
/* init xors IV with input parameter block */
|
||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P )
|
||||
{
|
||||
const uint8_t *p = ( const uint8_t * )( P );
|
||||
size_t i;
|
||||
|
||||
blake2b_init0( S );
|
||||
|
||||
/* IV XOR ParamBlock */
|
||||
for( i = 0; i < 8; ++i )
|
||||
S->h[i] ^= load64( p + sizeof( S->h[i] ) * i );
|
||||
|
||||
S->outlen = P->digest_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int blake2b_init( blake2b_state *S, size_t outlen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
P->digest_length = (uint8_t)outlen;
|
||||
P->key_length = 0;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store32( &P->node_offset, 0 );
|
||||
store32( &P->xof_length, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
return blake2b_init_param( S, P );
|
||||
}
|
||||
|
||||
|
||||
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen )
|
||||
{
|
||||
blake2b_param P[1];
|
||||
|
||||
if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1;
|
||||
|
||||
if ( !key || !keylen || keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
P->digest_length = (uint8_t)outlen;
|
||||
P->key_length = (uint8_t)keylen;
|
||||
P->fanout = 1;
|
||||
P->depth = 1;
|
||||
store32( &P->leaf_length, 0 );
|
||||
store32( &P->node_offset, 0 );
|
||||
store32( &P->xof_length, 0 );
|
||||
P->node_depth = 0;
|
||||
P->inner_length = 0;
|
||||
memset( P->reserved, 0, sizeof( P->reserved ) );
|
||||
memset( P->salt, 0, sizeof( P->salt ) );
|
||||
memset( P->personal, 0, sizeof( P->personal ) );
|
||||
|
||||
if( blake2b_init_param( S, P ) < 0 ) return -1;
|
||||
|
||||
{
|
||||
uint8_t block[BLAKE2B_BLOCKBYTES];
|
||||
memset( block, 0, BLAKE2B_BLOCKBYTES );
|
||||
memcpy( block, key, keylen );
|
||||
blake2b_update( S, block, BLAKE2B_BLOCKBYTES );
|
||||
secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+0]]; \
|
||||
d = rotr64(d ^ a, 32); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 24); \
|
||||
a = a + b + m[blake2b_sigma[r][2*i+1]]; \
|
||||
d = rotr64(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = rotr64(b ^ c, 63); \
|
||||
} while(0)
|
||||
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
|
||||
static void blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] )
|
||||
{
|
||||
uint64_t m[16];
|
||||
uint64_t v[16];
|
||||
size_t i;
|
||||
|
||||
for( i = 0; i < 16; ++i ) {
|
||||
m[i] = load64( block + i * sizeof( m[i] ) );
|
||||
}
|
||||
|
||||
for( i = 0; i < 8; ++i ) {
|
||||
v[i] = S->h[i];
|
||||
}
|
||||
|
||||
v[ 8] = blake2b_IV[0];
|
||||
v[ 9] = blake2b_IV[1];
|
||||
v[10] = blake2b_IV[2];
|
||||
v[11] = blake2b_IV[3];
|
||||
v[12] = blake2b_IV[4] ^ S->t[0];
|
||||
v[13] = blake2b_IV[5] ^ S->t[1];
|
||||
v[14] = blake2b_IV[6] ^ S->f[0];
|
||||
v[15] = blake2b_IV[7] ^ S->f[1];
|
||||
|
||||
ROUND( 0 );
|
||||
ROUND( 1 );
|
||||
ROUND( 2 );
|
||||
ROUND( 3 );
|
||||
ROUND( 4 );
|
||||
ROUND( 5 );
|
||||
ROUND( 6 );
|
||||
ROUND( 7 );
|
||||
ROUND( 8 );
|
||||
ROUND( 9 );
|
||||
ROUND( 10 );
|
||||
ROUND( 11 );
|
||||
|
||||
for( i = 0; i < 8; ++i ) {
|
||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
||||
}
|
||||
}
|
||||
|
||||
#undef G
|
||||
#undef ROUND
|
||||
|
||||
int blake2b_update( blake2b_state *S, const void *pin, size_t inlen )
|
||||
{
|
||||
const unsigned char * in = (const unsigned char *)pin;
|
||||
if( inlen > 0 )
|
||||
{
|
||||
size_t left = S->buflen;
|
||||
size_t fill = BLAKE2B_BLOCKBYTES - left;
|
||||
if( inlen > fill )
|
||||
{
|
||||
S->buflen = 0;
|
||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
||||
blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES );
|
||||
blake2b_compress( S, S->buf ); /* Compress */
|
||||
in += fill; inlen -= fill;
|
||||
while(inlen > BLAKE2B_BLOCKBYTES) {
|
||||
blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES);
|
||||
blake2b_compress( S, in );
|
||||
in += BLAKE2B_BLOCKBYTES;
|
||||
inlen -= BLAKE2B_BLOCKBYTES;
|
||||
}
|
||||
}
|
||||
memcpy( S->buf + S->buflen, in, inlen );
|
||||
S->buflen += inlen;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blake2b_final( blake2b_state *S, void *out, size_t outlen )
|
||||
{
|
||||
uint8_t buffer[BLAKE2B_OUTBYTES] = {0};
|
||||
size_t i;
|
||||
|
||||
if( out == NULL || outlen < S->outlen )
|
||||
return -1;
|
||||
|
||||
if( blake2b_is_lastblock( S ) )
|
||||
return -1;
|
||||
|
||||
blake2b_increment_counter( S, S->buflen );
|
||||
blake2b_set_lastblock( S );
|
||||
memset( S->buf + S->buflen, 0, BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */
|
||||
blake2b_compress( S, S->buf );
|
||||
|
||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
||||
store64( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
||||
|
||||
memcpy( out, buffer, S->outlen );
|
||||
secure_zero_memory(buffer, sizeof(buffer));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* inlen, at least, should be uint64_t. Others can be size_t. */
|
||||
int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen )
|
||||
{
|
||||
blake2b_state S[1];
|
||||
|
||||
/* Verify parameters */
|
||||
if ( NULL == in && inlen > 0 ) return -1;
|
||||
|
||||
if ( NULL == out ) return -1;
|
||||
|
||||
if( NULL == key && keylen > 0 ) return -1;
|
||||
|
||||
if( !outlen || outlen > BLAKE2B_OUTBYTES ) return -1;
|
||||
|
||||
if( keylen > BLAKE2B_KEYBYTES ) return -1;
|
||||
|
||||
if( keylen > 0 )
|
||||
{
|
||||
if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( blake2b_init( S, outlen ) < 0 ) return -1;
|
||||
}
|
||||
|
||||
blake2b_update( S, ( const uint8_t * )in, inlen );
|
||||
blake2b_final( S, out, outlen );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen ) {
|
||||
return blake2b(out, outlen, in, inlen, key, keylen);
|
||||
}
|
||||
|
||||
#if defined(SUPERCOP)
|
||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
||||
{
|
||||
return blake2b( out, BLAKE2B_OUTBYTES, in, inlen, NULL, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BLAKE2B_SELFTEST)
|
||||
#include <string.h>
|
||||
#include "blake2-kat.h"
|
||||
int main( void )
|
||||
{
|
||||
uint8_t key[BLAKE2B_KEYBYTES];
|
||||
uint8_t buf[BLAKE2_KAT_LENGTH];
|
||||
size_t i, step;
|
||||
|
||||
for( i = 0; i < BLAKE2B_KEYBYTES; ++i )
|
||||
key[i] = ( uint8_t )i;
|
||||
|
||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
||||
buf[i] = ( uint8_t )i;
|
||||
|
||||
/* Test simple API */
|
||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
||||
{
|
||||
uint8_t hash[BLAKE2B_OUTBYTES];
|
||||
blake2b( hash, BLAKE2B_OUTBYTES, buf, i, key, BLAKE2B_KEYBYTES );
|
||||
|
||||
if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) )
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* Test streaming API */
|
||||
for(step = 1; step < BLAKE2B_BLOCKBYTES; ++step) {
|
||||
for (i = 0; i < BLAKE2_KAT_LENGTH; ++i) {
|
||||
uint8_t hash[BLAKE2B_OUTBYTES];
|
||||
blake2b_state S;
|
||||
uint8_t * p = buf;
|
||||
size_t mlen = i;
|
||||
int err = 0;
|
||||
|
||||
if( (err = blake2b_init_key(&S, BLAKE2B_OUTBYTES, key, BLAKE2B_KEYBYTES)) < 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
while (mlen >= step) {
|
||||
if ( (err = blake2b_update(&S, p, step)) < 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
mlen -= step;
|
||||
p += step;
|
||||
}
|
||||
if ( (err = blake2b_update(&S, p, mlen)) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
if ( (err = blake2b_final(&S, hash, BLAKE2B_OUTBYTES)) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (0 != memcmp(hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES)) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts( "ok" );
|
||||
return 0;
|
||||
fail:
|
||||
puts("error");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
4
deps/ipc-util/CMakeLists.txt
vendored
4
deps/ipc-util/CMakeLists.txt
vendored
|
|
@ -22,6 +22,10 @@ else()
|
|||
ipc-util/pipe-posix.c)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
|
||||
endif()
|
||||
|
||||
add_library(ipc-util STATIC
|
||||
${ipc-util_SOURCES}
|
||||
${ipc-util_HEADERS})
|
||||
|
|
|
|||
57
deps/libcaption/.gitignore
vendored
Normal file
57
deps/libcaption/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
|
||||
# cmake files
|
||||
Makefile
|
||||
CMakeFiles
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
|
||||
# Bin
|
||||
scc2srt
|
||||
srt2vtt
|
||||
flv2srt
|
||||
ts2srt
|
||||
flv+srt
|
||||
srtdump
|
||||
party
|
||||
rtmpspit
|
||||
|
||||
# Autogenerated files
|
||||
# src/eia608.c
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
||||
#Doc
|
||||
Doxyfile
|
||||
34
deps/libcaption/CMakeLists.txt
vendored
Normal file
34
deps/libcaption/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(libcaption)
|
||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||
if (WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
# Don't need to prefix local includes with "caption/*"
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/caption)
|
||||
|
||||
set(CAPTION_SOURCES
|
||||
src/utf8.c
|
||||
src/srt.c
|
||||
src/scc.c
|
||||
src/avc.c
|
||||
src/xds.c
|
||||
src/cea708.c
|
||||
src/caption.c
|
||||
src/eia608_charmap.c
|
||||
src/eia608.c
|
||||
)
|
||||
|
||||
set(CAPTION_HEADERS
|
||||
caption/utf8.h
|
||||
caption/sei.h
|
||||
caption/scc.h
|
||||
caption/avc.c
|
||||
caption/cea708.h
|
||||
caption/eia608.h
|
||||
caption/caption.h
|
||||
caption/eia608_charmap.h
|
||||
)
|
||||
|
||||
add_library(caption STATIC ${CAPTION_SOURCES})
|
||||
2406
deps/libcaption/Doxyfile.in
vendored
Normal file
2406
deps/libcaption/Doxyfile.in
vendored
Normal file
File diff suppressed because it is too large
Load diff
21
deps/libcaption/LICENSE.txt
vendored
Normal file
21
deps/libcaption/LICENSE.txt
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License
|
||||
|
||||
Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved.
|
||||
|
||||
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.
|
||||
99
deps/libcaption/README.md
vendored
Normal file
99
deps/libcaption/README.md
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
# version
|
||||
v0.6
|
||||
Matthew Szatmary m3u8@twitch.tv / matt@szatmary.org
|
||||
|
||||
# libcaption
|
||||
|
||||
libcaption is a small library written in C to aid in the creating and parsing of closed caption data for use in the twitch player, open sourced to use within community developed broadcast tools. To maintain consistency across platforms libcaption aims to implement a subset of EIA608, CEA708 as supported by the Apple iOS platform.
|
||||
|
||||
608 support is currently limited to encoding and decoding the necessary control and preamble codes as well as support for the Basic North American, Special North American and Extended Western European character sets.
|
||||
|
||||
708 support is limited to encoding the 608 data in NTSC field 1 user data type structure.
|
||||
|
||||
In addition, utility functions to create h.264 SEI (Supplementary enhancement information) NALUs (Network Abstraction Layer Unit) for inclusion into an h.264 elementary stream are provided.
|
||||
|
||||
H.264 utility functions are limited to wrapping the 708 payload into a SEI NALU. This is accomplished by prepending the 708 payload with 3 bytes (nal_unit_type = 6, payloadType = 4, and PayloadSize = variable), and appending a stop bit encoded into a full byte (with a value of 127). In addition if the 708 payload contains an emulated start code, a three byte sequence equaling 0,0,1 an emulation prevention byte (3) is inserted. Functions to reverse this operation are also provided.
|
||||
|
||||
## Characters
|
||||
| | | | | | | | | | | | | | | | | |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
|BNA| |!|"|#|$|%|&|’|(|)|á|+|,|-|.|/|
|
||||
|BNA|0|1|2|3|4|5|6|7|8|9|:|;|<|=|>|?|
|
||||
|BNA|@|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|
|
||||
|BNA|P|Q|R|S|T|U|V|W|X|Y|Z|[|é|]|í|ó|
|
||||
|BNA|ú|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|
|
||||
|BNA|p|q|r|s|t|u|v|w|x|y|z|ç|÷|Ñ|ñ|█|
|
||||
|SNA|®|°|½|¿|™|¢|£|♪|à| |è|â|ê|î|ô|û|
|
||||
|WES|Á|É|Ó|Ú|Ü|ü|‘|¡|*|'|—|©|℠|•|“|”|
|
||||
|WEF|À|Â|Ç|È|Ê|Ë|ë|Î|Ï|ï|Ô|Ù|ù|Û|«|»|
|
||||
|WEP|Ã|ã|Í|Ì|ì|Ò|ò|Õ|õ|{|}|\\|^|_|\||~|
|
||||
|WEG|Ä|ä|Ö|ö|ß|¥|¤|¦|Å|å|Ø|ø|┌|┐|└|┘|
|
||||
|
||||
* BNA = Basic North American character set
|
||||
* SNA = Special North American character set
|
||||
* WES = Extended Western European character set : Extended Spanish/Miscellaneous
|
||||
* WEF = Extended Western European character set : Extended French
|
||||
* WEP = Extended Western European character set : Portuguese
|
||||
* WEG = Extended Western European character set : German/Danish
|
||||
|
||||
|
||||
------
|
||||
eia608_screen_t is the default internal representation. `screens` can be
|
||||
converted to and from SEI messages 608/708 buffers and SRT files
|
||||
|
||||
## JSON format
|
||||
A JSON rendered format is provided for convenience of integration. The JSON
|
||||
format is as follows:
|
||||
|
||||
```
|
||||
{
|
||||
"format": "eia608",
|
||||
"mode": "pop-on",
|
||||
"roll-up": 0,
|
||||
"data": [
|
||||
{ "row":0, "col":0, "char":"A", "style":"white" },
|
||||
{ "row":0, "col":1, "char":"B", "style":"white" },
|
||||
// ...
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `format`
|
||||
The only current valid value is `"eia608"`. This field exists for
|
||||
future expansion. Any values other than `"eia608"`, and the object should be
|
||||
ignored for now.
|
||||
|
||||
### `mode`
|
||||
Defines the method by which screen contents are adjusted in response to
|
||||
new data, such as content in excess of the normal grid size.
|
||||
|
||||
Possible modes are:
|
||||
|
||||
`"clear"`: Generated when a screen is initialized, but not entered a "loading"
|
||||
state. `"clear"` mode occurs frequently when the display is to be erased.
|
||||
|
||||
`"pop-on"`: Normally used for pre recorded content where. A pop-on screen should
|
||||
completely replace all previous screen contents.
|
||||
|
||||
`"paint-on"`: Normally used for live content. In this mode, new characters
|
||||
appear one or two at a time. The `data` array does include the complete state of
|
||||
the screen. In practice, it may not be different that `"pop-on"`.
|
||||
|
||||
An internal "loading" mode also exists.
|
||||
|
||||
### `roll-up`
|
||||
Normally used for live content such as news broadcasts. Text is moved up the
|
||||
screen as new rows appear. The number of rows to be displayed is also encoded in
|
||||
the JSON key `"roll-up"` where value is an integer of `0`, `1`, `2`, `3`, or `4`.
|
||||
Like `"paint-on"`, the `data` array does include the complete state of the screen.
|
||||
|
||||
### `data`
|
||||
Contains a object for every character to be displayed. The screen is a grid of
|
||||
15 rows and 32 columns. The position of the character is available in the `row`
|
||||
and `col` fields. The character itself is in the `char` field. The full
|
||||
character set is available in the document, but any valid UTF-8 should be
|
||||
supported for future. The style field will contain one of the following values:
|
||||
|
||||
`"white"`, `"green"`, `"blue"`, `"cyan"`, `"red"`, `"yellow"`, `"magenta"`, `"italics"`
|
||||
|
||||
Characters with the `"italics"` style should be displayed in white.
|
||||
198
deps/libcaption/caption/avc.h
vendored
Normal file
198
deps/libcaption/caption/avc.h
vendored
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_AVC_H
|
||||
#define LIBCAPTION_AVC_H
|
||||
#include "cea708.h"
|
||||
#include "caption.h"
|
||||
#include <float.h>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define MAX_NALU_SIZE (4*1024*1024)
|
||||
typedef struct {
|
||||
size_t size;
|
||||
uint8_t data[MAX_NALU_SIZE];
|
||||
} avcnalu_t;
|
||||
|
||||
void avcnalu_init (avcnalu_t* nalu);
|
||||
int avcnalu_parse_annexb (avcnalu_t* nalu, const uint8_t** data, size_t* size);
|
||||
static inline uint8_t avcnalu_type (avcnalu_t* nalu) { return nalu->data[0] & 0x1F; }
|
||||
static inline uint8_t* avcnalu_data (avcnalu_t* nalu) { return &nalu->data[0]; }
|
||||
static inline size_t avcnalu_size (avcnalu_t* nalu) { return nalu->size; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct _sei_message_t sei_message_t;
|
||||
|
||||
typedef enum {
|
||||
sei_type_buffering_period = 0,
|
||||
sei_type_pic_timing = 1,
|
||||
sei_type_pan_scan_rect = 2,
|
||||
sei_type_filler_payload = 3,
|
||||
sei_type_user_data_registered_itu_t_t35 = 4,
|
||||
sei_type_user_data_unregistered = 5,
|
||||
sei_type_recovery_point = 6,
|
||||
sei_type_dec_ref_pic_marking_repetition = 7,
|
||||
sei_type_spare_pic = 8,
|
||||
sei_type_scene_info = 9,
|
||||
sei_type_sub_seq_info = 10,
|
||||
sei_type_sub_seq_layer_characteristics = 11,
|
||||
sei_type_sub_seq_characteristics = 12,
|
||||
sei_type_full_frame_freeze = 13,
|
||||
sei_type_full_frame_freeze_release = 14,
|
||||
sei_type_full_frame_snapshot = 15,
|
||||
sei_type_progressive_refinement_segment_start = 16,
|
||||
sei_type_progressive_refinement_segment_end = 17,
|
||||
sei_type_motion_constrained_slice_group_set = 18,
|
||||
sei_type_film_grain_characteristics = 19,
|
||||
sei_type_deblocking_filter_display_preference = 20,
|
||||
sei_type_stereo_video_info = 21,
|
||||
} sei_msgtype_t;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// time in seconds
|
||||
typedef struct {
|
||||
double dts;
|
||||
double cts;
|
||||
sei_message_t* head;
|
||||
sei_message_t* tail;
|
||||
} sei_t;
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void sei_init (sei_t* sei);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void sei_free (sei_t* sei);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline double sei_dts (sei_t* sei) { return sei->dts; }
|
||||
static inline double sei_cts (sei_t* sei) { return sei->cts; }
|
||||
static inline double sei_pts (sei_t* sei) { return sei->dts + sei->cts; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int sei_parse_nalu (sei_t* sei, const uint8_t* data, size_t size, double dts, double cts);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
// TODO add dts,cts to nalu
|
||||
static inline int sei_parse_avcnalu (sei_t* sei, avcnalu_t* nalu, double dts, double cts) { return sei_parse_nalu (sei,avcnalu_data (nalu),avcnalu_size (nalu),dts,cts); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int sei_finish (sei_t* sei) { return sei_parse_nalu (sei,0,0,0.0,DBL_MAX); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline sei_message_t* sei_message_head (sei_t* sei) { return sei->head; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline sei_message_t* sei_message_tail (sei_t* sei) { return sei->tail; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
sei_message_t* sei_message_next (sei_message_t* msg);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
sei_msgtype_t sei_message_type (sei_message_t* msg);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
size_t sei_message_size (sei_message_t* msg);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint8_t* sei_message_data (sei_message_t* msg);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
sei_message_t* sei_message_new (sei_msgtype_t type, uint8_t* data, size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline sei_message_t* sei_message_copy (sei_message_t* msg)
|
||||
{
|
||||
return sei_message_new (sei_message_type (msg), sei_message_data (msg), sei_message_size (msg));
|
||||
}
|
||||
/**
|
||||
Free message and all accoiated data. Messaged added to sei_t by using sei_append_message MUST NOT be freed
|
||||
These messages will be freed by calling sei_free()
|
||||
*/
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void sei_message_free (sei_message_t* msg);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int sei_decode_cea708 (sei_message_t* msg, cea708_t* cea708)
|
||||
{
|
||||
if (sei_type_user_data_registered_itu_t_t35 == sei_message_type (msg)) {
|
||||
return cea708_parse (sei_message_data (msg), sei_message_size (msg), cea708);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
size_t sei_render_size (sei_t* sei);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
size_t sei_render (sei_t* sei, uint8_t* data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void sei_dump (sei_t* sei);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void sei_dump_messages (sei_message_t* head);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int sei_from_caption_frame (sei_t* sei, caption_frame_t* frame);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
libcaption_stauts_t sei_to_caption_frame (sei_t* sei, caption_frame_t* frame);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int nalu_to_caption_frame (caption_frame_t* frame, const uint8_t* data, size_t size, double pts, double dts)
|
||||
{
|
||||
sei_t sei;
|
||||
sei_init (&sei);
|
||||
sei_parse_nalu (&sei, data, size, pts, dts);
|
||||
sei_to_caption_frame (&sei,frame);
|
||||
sei_free (&sei);
|
||||
return 1;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
141
deps/libcaption/caption/caption.h
vendored
Normal file
141
deps/libcaption/caption/caption.h
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_H
|
||||
#define LIBCAPTION_H
|
||||
#include "utf8.h"
|
||||
#include "xds.h"
|
||||
#include "eia608.h"
|
||||
|
||||
// ssize_t is POSIX and does not exist on Windows
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_WIN64)
|
||||
typedef signed long ssize_t;
|
||||
#else
|
||||
typedef signed int ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
LIBCAPTION_OK = 1,
|
||||
LIBCAPTION_ERROR = 0,
|
||||
LIBCAPTION_READY = 2
|
||||
} libcaption_stauts_t;
|
||||
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline libcaption_stauts_t libcaption_status_update (libcaption_stauts_t old_stat, libcaption_stauts_t new_stat) { return (LIBCAPTION_ERROR == old_stat || LIBCAPTION_ERROR == new_stat) ? LIBCAPTION_ERROR : (LIBCAPTION_READY == old_stat) ? LIBCAPTION_READY : new_stat; }
|
||||
|
||||
#define SCREEN_ROWS 15
|
||||
#define SCREEN_COLS 32
|
||||
|
||||
typedef struct {
|
||||
unsigned int uln : 1; //< underline
|
||||
unsigned int sty : 3; //< style
|
||||
utf8_char_t data[5]; //< 4 byte utf8 values plus null term
|
||||
} caption_frame_cell_t;
|
||||
|
||||
typedef struct {
|
||||
caption_frame_cell_t cell[SCREEN_ROWS][SCREEN_COLS];
|
||||
} caption_frame_buffer_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned int uln : 1; //< underline
|
||||
unsigned int sty : 3; //< style
|
||||
unsigned int mod : 3; //< current mode
|
||||
unsigned int rup : 2; //< roll-up line count minus 1
|
||||
uint16_t row, col, cc_data;
|
||||
} caption_frame_state_t;
|
||||
|
||||
// timestamp and duration are in seconds
|
||||
typedef struct {
|
||||
double timestamp;
|
||||
double duration;
|
||||
xds_t xds;
|
||||
caption_frame_state_t state;
|
||||
caption_frame_buffer_t front;
|
||||
caption_frame_buffer_t back;
|
||||
} caption_frame_t;
|
||||
|
||||
// typedef enum {
|
||||
// eia608_paint_on = 0,
|
||||
// eia608_pop_on = 1,
|
||||
// eia608_rollup_2 = 2,
|
||||
// eia608_rollup_3 = 3,
|
||||
// eia608_rollup_4 = 4,
|
||||
// } eia608_display_mode_t;
|
||||
// eia608_display_mode_t caption_frame_mode (caption_frame_t* frame);
|
||||
|
||||
|
||||
/*!
|
||||
\brief Initializes an allocated caption_frame_t instance
|
||||
\param frame Pointer to prealocated caption_frame_t object
|
||||
*/
|
||||
void caption_frame_init (caption_frame_t* frame);
|
||||
/*! \brief Writes a single charcter to a caption_frame_t object
|
||||
\param frame A pointer to an allocted and initialized caption_frame_t object
|
||||
\param row Row position to write charcter, must be between 0 and SCREEN_ROWS-1
|
||||
\param col Column position to write charcter, must be between 0 and SCREEN_ROWS-1
|
||||
\param style Style to apply to charcter
|
||||
\param underline Set underline attribute, 0 = off any other value = on
|
||||
\param c pointer to a single valid utf8 charcter. Bytes are automatically determined, and a NULL terminator is not required
|
||||
*/
|
||||
int caption_frame_write_char (caption_frame_t* frame, int row, int col, eia608_style_t style, int underline, const utf8_char_t* c);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
const utf8_char_t* caption_frame_read_char (caption_frame_t* frame, int row, int col, eia608_style_t* style, int* underline);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
libcaption_stauts_t caption_frame_decode (caption_frame_t* frame, uint16_t cc_data, double timestamp);
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int caption_frame_from_text (caption_frame_t* frame, const utf8_char_t* data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
#define CAPTION_FRAME_TEXT_BYTES (((2+SCREEN_ROWS)*SCREEN_COLS*4)+1)
|
||||
void caption_frame_to_text (caption_frame_t* frame, utf8_char_t* data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
#define CAPTION_FRAME_DUMP_BUF_SIZE 4096
|
||||
size_t caption_frame_dump_buffer (caption_frame_t* frame, utf8_char_t* buf);
|
||||
void caption_frame_dump (caption_frame_t* frame);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
#define CAPTION_FRAME_JSON_BUF_SIZE 32768
|
||||
size_t caption_frame_json (caption_frame_t* frame, utf8_char_t* buf);
|
||||
|
||||
#endif
|
||||
110
deps/libcaption/caption/cea708.h
vendored
Normal file
110
deps/libcaption/caption/cea708.h
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_CEA708_H
|
||||
#define LIBCAPTION_CEA708_H
|
||||
|
||||
#include "caption.h"
|
||||
#define CEA608_MAX_SIZE (255)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
cc_type_ntsc_cc_field_1 = 0,
|
||||
cc_type_ntsc_cc_field_2 = 1,
|
||||
cc_type_dtvcc_packet_data = 2,
|
||||
cc_type_dtvcc_packet_start = 3,
|
||||
} cea708_cc_type_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int marker_bits : 5;
|
||||
unsigned int cc_valid : 1;
|
||||
unsigned int cc_type : 2; // castable to cea708_cc_type_t
|
||||
unsigned int cc_data : 16;
|
||||
} cc_data_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int process_em_data_flag : 1;
|
||||
unsigned int process_cc_data_flag : 1;
|
||||
unsigned int additional_data_flag : 1;
|
||||
unsigned int cc_count : 5;
|
||||
unsigned int em_data : 8;
|
||||
cc_data_t cc_data[32];
|
||||
} user_data_t;
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
cc_data_t cea708_encode_cc_data (int cc_valid, cea708_cc_type_t type, uint16_t cc_data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int cea708_cc_count (user_data_t* data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t cea708_cc_data (user_data_t* data, int index, int* valid, cea708_cc_type_t* type);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
country_united_states = 181,
|
||||
} itu_t_t35_country_code_t;
|
||||
|
||||
typedef enum {
|
||||
t35_provider_direct_tv = 47,
|
||||
t35_provider_atsc = 49,
|
||||
} itu_t_t35_provider_code_t;
|
||||
|
||||
typedef struct {
|
||||
itu_t_t35_country_code_t country;
|
||||
itu_t_t35_provider_code_t provider;
|
||||
uint32_t user_identifier;
|
||||
uint8_t atsc1_data_user_data_type_code;
|
||||
uint8_t directv_user_data_length;
|
||||
user_data_t user_data;
|
||||
} cea708_t;
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int cea708_init (cea708_t* cea708); // will confgure using HLS compatiable defaults
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int cea708_parse (uint8_t* data, size_t size, cea708_t* cea708);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
libcaption_stauts_t cea708_to_caption_frame (caption_frame_t* frame, cea708_t* cea708, double pts);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int cea708_add_cc_data (cea708_t* cea708, int valid, cea708_cc_type_t type, uint16_t cc_data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int cea708_render (cea708_t* cea708, uint8_t* data, size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void cea708_dump (cea708_t* cea708);
|
||||
#endif
|
||||
206
deps/libcaption/caption/eia608.h
vendored
Normal file
206
deps/libcaption/caption/eia608.h
vendored
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_EIA608_H
|
||||
#define LIBCAPTION_EIA608_H
|
||||
|
||||
#include "utf8.h"
|
||||
#include "eia608_charmap.h"
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Parity
|
||||
#define EIA608_BX(B,X) (((B)>>X)&0x01)
|
||||
#define EIA608_BP(B) ((B)&0x7F) | ((EIA608_BX((B),0)^EIA608_BX(B,1)^EIA608_BX((B),2)^EIA608_BX((B),3)^EIA608_BX((B),4)^EIA608_BX((B),5)^EIA608_BX((B),6)^(0x01))<<7)
|
||||
#define EIA608_B2(B) EIA608_BP((B)+0), EIA608_BP((B)+1), EIA608_BP((B)+2), EIA608_BP((B)+3), EIA608_BP((B)+4), EIA608_BP((B)+5), EIA608_BP((B)+6), EIA608_BP((B)+7)
|
||||
#define EIA608_B1(B) EIA608_B2((B)+0), EIA608_B2((B)+8), EIA608_B2((B)+16), EIA608_B2((B)+24), EIA608_B2((B)+32), EIA608_B2((B)+40), EIA608_B2((B)+48), EIA608_B2((B)+56)
|
||||
|
||||
static const uint8_t eia608_parity_table[] = { EIA608_B1 (0), EIA608_B1 (64) };
|
||||
extern const char* eia608_mode_map[];
|
||||
extern const char* eia608_style_map[];
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline uint8_t eia608_parity_byte (uint8_t cc_data) { return eia608_parity_table[0x7F & cc_data]; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline uint16_t eia608_parity_word (uint16_t cc_data) { return (uint16_t) ( (eia608_parity_byte ( (uint8_t) (cc_data>>8)) <<8) | eia608_parity_byte ( (uint8_t) cc_data)); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline uint16_t eia608_parity (uint16_t cc_data) { return eia608_parity_word (cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_parity_varify (uint16_t cc_data) { return eia608_parity_word (cc_data) == cc_data ? 1 : 0; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_parity_strip (uint16_t cc_data) { return cc_data & 0x7F7F; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_test_second_channel_bit (uint16_t cc_data) { return (cc_data & 0x0800); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// cc_data types
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_basicna (uint16_t cc_data) { return 0x0000 != (0x6000 & cc_data); /*&& 0x1F00 < (0x7F00 & cc_data);*/ }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_preamble (uint16_t cc_data) { return 0x1040 == (0x7040 & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_midrowchange (uint16_t cc_data) { return 0x1120 == (0x7770 & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_specialna (uint16_t cc_data) { return 0x1130 == (0x7770 & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_xds (uint16_t cc_data) { return 0x0000 == (0x7070 & cc_data) && 0x0000 != (0x0F0F & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_westeu (uint16_t cc_data) { return 0x1220 == (0x7660 & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_control (uint16_t cc_data) { return 0x1420 == (0x7670 & cc_data) || 0x1720 == (0x7770 & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_norpak (uint16_t cc_data) { return 0x1724 == (0x777C & cc_data) || 0x1728 == (0x777C & cc_data); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline int eia608_is_padding (uint16_t cc_data) { return 0x8080 == cc_data; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// preamble
|
||||
typedef enum {
|
||||
eia608_style_white = 0,
|
||||
eia608_style_green = 1,
|
||||
eia608_style_blue = 2,
|
||||
eia608_style_cyan = 3,
|
||||
eia608_style_red = 4,
|
||||
eia608_style_yellow = 5,
|
||||
eia608_style_magenta = 6,
|
||||
eia608_style_italics = 7,
|
||||
} eia608_style_t;
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int eia608_parse_preamble (uint16_t cc_data, int* row, int* col, eia608_style_t* style, int* chan, int* underline);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int eia608_parse_midrowchange (uint16_t cc_data, int* chan, eia608_style_t* style, int* underline);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t eia608_row_column_pramble (int row, int col, int chan, int underline);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t eia608_row_style_pramble (int row, eia608_style_t style, int chan, int underline);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// control command
|
||||
typedef enum { // yes, no?
|
||||
eia608_tab_offset_0 = 0x1720,
|
||||
eia608_tab_offset_1 = 0x1721,
|
||||
eia608_tab_offset_2 = 0x1722,
|
||||
eia608_tab_offset_3 = 0x1723,
|
||||
eia608_control_resume_caption_loading = 0x1420,
|
||||
eia608_control_backspace = 0x1421,
|
||||
eia608_control_alarm_off = 0x1422,
|
||||
eia608_control_alarm_on = 0x1423,
|
||||
eia608_control_delete_to_end_of_row = 0x1424,
|
||||
eia608_control_roll_up_2 = 0x1425,
|
||||
eia608_control_roll_up_3 = 0x1426,
|
||||
eia608_control_roll_up_4 = 0x1427,
|
||||
eia608_control_resume_direct_captioning = 0x1429,
|
||||
eia608_control_text_restart = 0x142A,
|
||||
eia608_control_text_resume_text_display = 0x142B,
|
||||
eia608_control_erase_display_memory = 0x142C,
|
||||
eia608_control_carriage_return = 0x142D,
|
||||
eia608_control_erase_non_displayed_memory = 0x142E,
|
||||
eia608_control_end_of_caption = 0x142F,
|
||||
} eia608_control_t;
|
||||
|
||||
#define eia608_control_popon eia608_control_resume_caption_loading
|
||||
#define eia608_control_painton eia608_control_resume_direct_captioning
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t eia608_control_command (eia608_control_t cmd, int cc);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline uint16_t eia608_tab (int size, int cc) { return eia608_control_command ( (eia608_control_t) (eia608_tab_offset_0 | (size&0x0F)),cc); }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
eia608_control_t eia608_parse_control (uint16_t cc_data, int* cc);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// text
|
||||
/*! \brief
|
||||
\param c
|
||||
*/
|
||||
uint16_t eia608_from_utf8_1 (const utf8_char_t* c, int chan);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t eia608_from_utf8_2 (const utf8_char_t* c1, const utf8_char_t* c2);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
uint16_t eia608_from_basicna (uint16_t bna1, uint16_t bna2);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int eia608_to_utf8 (uint16_t c, int* chan, utf8_char_t* char1, utf8_char_t* char2);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void eia608_dump (uint16_t cc_data);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#endif
|
||||
230
deps/libcaption/caption/eia608_charmap.h
vendored
Normal file
230
deps/libcaption/caption/eia608_charmap.h
vendored
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_EIA608_CHARMAP_H
|
||||
#define LIBCAPTION_EIA608_CHARMAP_H
|
||||
|
||||
#define EIA608_CHAR_COUNT 176
|
||||
extern const char* eia608_char_map[EIA608_CHAR_COUNT];
|
||||
|
||||
// Helper char
|
||||
#define EIA608_CHAR_NULL ""
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_SPACE "\x20"
|
||||
#define EIA608_CHAR_EXCLAMATION_MARK "\x21"
|
||||
#define EIA608_CHAR_QUOTATION_MARK "\x22"
|
||||
#define EIA608_CHAR_NUMBER_SIGN "\x23"
|
||||
#define EIA608_CHAR_DOLLAR_SIGN "\x24"
|
||||
#define EIA608_CHAR_PERCENT_SIGN "\x25"
|
||||
#define EIA608_CHAR_AMPERSAND "\x26"
|
||||
#define EIA608_CHAR_LEFT_SINGLE_QUOTATION_MARK "\xE2\x80\x98"
|
||||
#define EIA608_CHAR_LEFT_PARENTHESIS "\x28"
|
||||
#define EIA608_CHAR_RIGHT_PARENTHESIS "\x29"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_ACUTE "\xC3\xA1"
|
||||
#define EIA608_CHAR_PLUS_SIGN "\x2B"
|
||||
#define EIA608_CHAR_COMMA "\x2C"
|
||||
#define EIA608_CHAR_HYPHEN_MINUS "\x2D"
|
||||
#define EIA608_CHAR_FULL_STOP "\x2E"
|
||||
#define EIA608_CHAR_SOLIDUS "\x2F"
|
||||
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_DIGIT_ZERO "\x30"
|
||||
#define EIA608_CHAR_DIGIT_ONE "\x31"
|
||||
#define EIA608_CHAR_DIGIT_TWO "\x32"
|
||||
#define EIA608_CHAR_DIGIT_THREE "\x33"
|
||||
#define EIA608_CHAR_DIGIT_FOUR "\x34"
|
||||
#define EIA608_CHAR_DIGIT_FIVE "\x35"
|
||||
#define EIA608_CHAR_DIGIT_SIX "\x36"
|
||||
#define EIA608_CHAR_DIGIT_SEVEN "\x37"
|
||||
#define EIA608_CHAR_DIGIT_EIGHT "\x38"
|
||||
#define EIA608_CHAR_DIGIT_NINE "\x39"
|
||||
#define EIA608_CHAR_COLON "\x3A"
|
||||
#define EIA608_CHAR_SEMICOLON "\x3B"
|
||||
#define EIA608_CHAR_LESS_THAN_SIGN "\x3C"
|
||||
#define EIA608_CHAR_EQUALS_SIGN "\x3D"
|
||||
#define EIA608_CHAR_GREATER_THAN_SIGN "\x3E"
|
||||
#define EIA608_CHAR_QUESTION_MARK "\x3F"
|
||||
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_COMMERCIAL_AT "\x40"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A "\x41"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_B "\x42"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_C "\x43"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_D "\x44"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E "\x45"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_F "\x46"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_G "\x47"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_H "\x48"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I "\x49"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_J "\x4A"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_K "\x4B"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_L "\x4C"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_M "\x4D"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_N "\x4E"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O "\x4F"
|
||||
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_P "\x50"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Q "\x51"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_R "\x52"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_S "\x53"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_T "\x54"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U "\x55"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_V "\x56"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_W "\x57"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_X "\x58"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Y "\x59"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_Z "\x5A"
|
||||
#define EIA608_CHAR_LEFT_SQUARE_BRACKET "\x5B"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_ACUTE "\xC3\xA9"
|
||||
#define EIA608_CHAR_RIGHT_SQUARE_BRACKET "\x5D"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_ACUTE "\xC3\xAD"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_ACUTE "\xC3\xB3"
|
||||
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_ACUTE "\xC3\xBA"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A "\x61"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_B "\x62"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_C "\x63"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_D "\x64"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_E "\x65"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_F "\x66"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_G "\x67"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_H "\x68"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_I "\x69"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_J "\x6A"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_K "\x6B"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_L "\x6C"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_M "\x6D"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_N "\x6E"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O "\x6F"
|
||||
|
||||
// Basic North American character set
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_P "\x70"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_Q "\x71"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_R "\x72"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_S "\x73"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_T "\x74"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_U "\x75"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_V "\x76"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_W "\x77"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_X "\x78"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_Y "\x79"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_Z "\x7A"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_C_WITH_CEDILLA "\xC3\xA7"
|
||||
#define EIA608_CHAR_DIVISION_SIGN "\xC3\xB7"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_N_WITH_TILDE "\xC3\x91"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_N_WITH_TILDE "\xC3\xB1"
|
||||
#define EIA608_CHAR_FULL_BLOCK "\xE2\x96\x88"
|
||||
|
||||
// Special North American character set[edit]
|
||||
#define EIA608_CHAR_REGISTERED_SIGN "\xC2\xAE"
|
||||
#define EIA608_CHAR_DEGREE_SIGN "\xC2\xB0"
|
||||
#define EIA608_CHAR_VULGAR_FRACTION_ONE_HALF "\xC2\xBD"
|
||||
#define EIA608_CHAR_INVERTED_QUESTION_MARK "\xC2\xBF"
|
||||
#define EIA608_CHAR_TRADE_MARK_SIGN "\xE2\x84\xA2"
|
||||
#define EIA608_CHAR_CENT_SIGN "\xC2\xA2"
|
||||
#define EIA608_CHAR_POUND_SIGN "\xC2\xA3"
|
||||
#define EIA608_CHAR_EIGHTH_NOTE "\xE2\x99\xAA"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_GRAVE "\xC3\xA0"
|
||||
#define EIA608_CHAR_NO_BREAK_SPACE "\xC2\xA0"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_GRAVE "\xC3\xA8"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX "\xC3\xA2"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX "\xC3\xAA"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX "\xC3\xAE"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX "\xC3\xB4"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX "\xC3\xBB"
|
||||
|
||||
// Extended Western European character set : Extended Spanish/Miscellaneous
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_ACUTE "\xC3\x81"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_ACUTE "\xC3\x89"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_ACUTE "\xC3\x93"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_ACUTE "\xC3\x9A"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS "\xC3\x9C"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_DIAERESIS "\xC3\xBC"
|
||||
#define EIA608_CHAR_RIGHT_SINGLE_QUOTATION_MARK "\xE2\x80\x99"
|
||||
#define EIA608_CHAR_INVERTED_EXCLAMATION_MARK "\xC2\xA1"
|
||||
#define EIA608_CHAR_ASTERISK "\x2A"
|
||||
#define EIA608_CHAR_APOSTROPHE "\x27"
|
||||
#define EIA608_CHAR_EM_DASH "\xE2\x80\x94"
|
||||
#define EIA608_CHAR_COPYRIGHT_SIGN "\xC2\xA9"
|
||||
#define EIA608_CHAR_SERVICE_MARK "\xE2\x84\xA0"
|
||||
#define EIA608_CHAR_BULLET "\xE2\x80\xA2"
|
||||
#define EIA608_CHAR_LEFT_DOUBLE_QUOTATION_MARK "\xE2\x80\x9C"
|
||||
#define EIA608_CHAR_RIGHT_DOUBLE_QUOTATION_MARK "\xE2\x80\x9D"
|
||||
|
||||
// Extended Western European character set : Extended French
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_GRAVE "\xC3\x80"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX "\xC3\x82"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_C_WITH_CEDILLA "\xC3\x87"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_GRAVE "\xC3\x88"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX "\xC3\x8A"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS "\xC3\x8B"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_DIAERESIS "\xC3\xAB"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX "\xC3\x8E"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS "\xC3\x8F"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_DIAERESIS "\xC3\xAF"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX "\xC3\x94"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_GRAVE "\xC3\x99"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_GRAVE "\xC3\xB9"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX "\xC3\x9B"
|
||||
#define EIA608_CHAR_LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK "\xC2\xAB"
|
||||
#define EIA608_CHAR_RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK "\xC2\xBB"
|
||||
|
||||
// Extended Western European character set : Portuguese
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_TILDE "\xC3\x83"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_TILDE "\xC3\xA3"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_ACUTE "\xC3\x8D"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_GRAVE "\xC3\x8C"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_GRAVE "\xC3\xAC"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_GRAVE "\xC3\x92"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_GRAVE "\xC3\xB2"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_TILDE "\xC3\x95"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_TILDE "\xC3\xB5"
|
||||
#define EIA608_CHAR_LEFT_CURLY_BRACKET "\x7B"
|
||||
#define EIA608_CHAR_RIGHT_CURLY_BRACKET "\x7D"
|
||||
#define EIA608_CHAR_REVERSE_SOLIDUS "\x5C"
|
||||
#define EIA608_CHAR_CIRCUMFLEX_ACCENT "\x5E"
|
||||
#define EIA608_CHAR_LOW_LINE "\x5F"
|
||||
#define EIA608_CHAR_VERTICAL_LINE "\x7C"
|
||||
#define EIA608_CHAR_TILDE "\x7E"
|
||||
|
||||
// Extended Western European character set : German/Danish
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS "\xC3\x84"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_DIAERESIS "\xC3\xA4"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS "\xC3\x96"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_DIAERESIS "\xC3\xB6"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_SHARP_S "\xC3\x9F"
|
||||
#define EIA608_CHAR_YEN_SIGN "\xC2\xA5"
|
||||
#define EIA608_CHAR_CURRENCY_SIGN "\xC2\xA4"
|
||||
#define EIA608_CHAR_BROKEN_BAR "\xC2\xA6"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE "\xC3\x85"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_RING_ABOVE "\xC3\xA5"
|
||||
#define EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_STROKE "\xC3\x98"
|
||||
#define EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_STROKE "\xC3\xB8"
|
||||
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT "\xE2\x94\x8C" // top left
|
||||
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT "\xE2\x94\x90" // top right
|
||||
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT "\xE2\x94\x94" // lower left
|
||||
#define EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT "\xE2\x94\x98" // bottom right
|
||||
|
||||
#endif
|
||||
31
deps/libcaption/caption/scc.h
vendored
Normal file
31
deps/libcaption/caption/scc.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_SCC_H
|
||||
#define LIBCAPTION_SCC_H
|
||||
|
||||
#include "eia608.h"
|
||||
|
||||
int scc_to_608 (const char* line, double* pts, uint16_t* cc, int cc_max);
|
||||
|
||||
#endif
|
||||
87
deps/libcaption/caption/srt.h
vendored
Normal file
87
deps/libcaption/caption/srt.h
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_SRT_H
|
||||
#define LIBCAPTION_SRT_H
|
||||
|
||||
#include "eia608.h"
|
||||
#include "caption.h"
|
||||
|
||||
// timestamp and duration are in seconds
|
||||
typedef struct _srt_t {
|
||||
struct _srt_t* next;
|
||||
double timestamp;
|
||||
double duration;
|
||||
size_t aloc;
|
||||
} srt_t;
|
||||
|
||||
|
||||
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
srt_t* srt_new (const utf8_char_t* data, size_t size, double timestamp, srt_t* prev, srt_t** head);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
srt_t* srt_free_head (srt_t* head);
|
||||
// returns the head of the link list. must bee freed when done
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
srt_t* srt_parse (const utf8_char_t* data, size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void srt_free (srt_t* srt);
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline srt_t* srt_next (srt_t* srt) { return srt->next; }
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
static inline utf8_char_t* srt_data (srt_t* srt) { return (utf8_char_t*) (srt) + sizeof (srt_t); }
|
||||
// This only converts teh surrent SRT, It does not walk the list
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int srt_to_caption_frame (srt_t* srt, caption_frame_t* frame);
|
||||
|
||||
// returns teh new srt. Head is not tracher internally.
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
srt_t* srt_from_caption_frame (caption_frame_t* frame, srt_t* prev, srt_t** head);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void srt_dump (srt_t* srt);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
void vtt_dump (srt_t* srt);
|
||||
|
||||
#endif
|
||||
97
deps/libcaption/caption/utf8.h
vendored
Normal file
97
deps/libcaption/caption/utf8.h
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_UTF8_H
|
||||
#define LIBCAPTION_UTF8_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
// These types exist to make the code more self dcoumenting
|
||||
// utf8_char_t point is a null teminate string of utf8 encodecd chars
|
||||
//
|
||||
// utf8_size_t is the length of a string in chars
|
||||
// size_t is bytes
|
||||
typedef char utf8_char_t;
|
||||
typedef size_t utf8_size_t;
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
Skiped continuation bytes
|
||||
*/
|
||||
const utf8_char_t* utf8_char_next (const char* s);
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returnes the length of the char in bytes
|
||||
*/
|
||||
size_t utf8_char_length (const utf8_char_t* c);
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returns length of the string in bytes
|
||||
size is number of charcter to count (0 to count until NULL term)
|
||||
*/
|
||||
size_t utf8_string_length (const utf8_char_t* data, utf8_size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
size_t utf8_char_copy (utf8_char_t* dst, const utf8_char_t* src);
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returnes the number of utf8 charcters in a string givne the numbe of bytes
|
||||
to coutn until the a null terminator, pass 0 for size
|
||||
*/
|
||||
utf8_size_t utf8_char_count (const char* data, size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returnes the length of the line in bytes triming not printable charcters at the end
|
||||
*/
|
||||
size_t utf8_trimmed_length (const char* data, size_t size);
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returns the length in bytes of the line including the new line charcter(s)
|
||||
auto detects between windows(CRLF), unix(LF), mac(CR) and riscos (LFCR) line endings
|
||||
*/
|
||||
size_t utf8_line_length (const char* data);
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returns number of chars to include before split
|
||||
*/
|
||||
utf8_size_t utf8_wrap_length (const utf8_char_t* data, utf8_size_t size);
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
returns number of new lins in teh string
|
||||
*/
|
||||
int utf8_line_count (const utf8_char_t* data);
|
||||
|
||||
|
||||
#endif
|
||||
32
deps/libcaption/caption/xds.h
vendored
Normal file
32
deps/libcaption/caption/xds.h
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**********************************************************************************************/
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file */
|
||||
/* except in compliance with the License. A copy of the License is located at */
|
||||
/* */
|
||||
/* http://aws.amazon.com/apache2.0/ */
|
||||
/* */
|
||||
/* or in the "license" file accompanying this file. This file is distributed on an "AS IS" */
|
||||
/* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the */
|
||||
/* License for the specific language governing permissions and limitations under the License. */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#ifndef LIBCAPTION_XDS_H
|
||||
#define LIBCAPTION_XDS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef struct {
|
||||
int state;
|
||||
uint8_t class;
|
||||
uint8_t type;
|
||||
uint32_t size;
|
||||
uint8_t content[32];
|
||||
uint8_t checksum;
|
||||
} xds_t;
|
||||
|
||||
void xds_init (xds_t* xds);
|
||||
int xds_decode (xds_t* xds, uint16_t cc);
|
||||
|
||||
#endif
|
||||
29
deps/libcaption/examples/add_captions.sh
vendored
Normal file
29
deps/libcaption/examples/add_captions.sh
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -lt 2 ]
|
||||
then
|
||||
echo "Need at least 2 arguments."
|
||||
echo "$0 InputVideo InputSRT [OutputFilename]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VIDEO=$1
|
||||
SRT=$2
|
||||
|
||||
if [ -z "$3" ]
|
||||
then
|
||||
OUTFILE="out.flv"
|
||||
else
|
||||
OUTFILE="$3"
|
||||
fi
|
||||
|
||||
echo "Video=$VIDEO"
|
||||
echo "Captions=$SRT"
|
||||
echo "Outfile=$OUTFILE"
|
||||
|
||||
# ffmpeg -i $VIDEO -acodec copy -vcodec copy -f flv - | ./flv+srt - $SRT - | ffmpeg -i - -acodec copy -vcodec copy $OUTFILE
|
||||
ffmpeg -i $VIDEO -threads 0 -vcodec libx264 -profile:v main -preset:v medium \
|
||||
-r 30 -g 60 -keyint_min 60 -sc_threshold 0 -b:v 4000k -maxrate 4000k \
|
||||
-bufsize 4000k -filter:v scale="trunc(oh*a/2)*2:720" \
|
||||
-sws_flags lanczos+accurate_rnd -strict -2 -acodec aac -b:a 96k -ar 48000 -ac 2 \
|
||||
-f flv - | ./flv+srt - $SRT - | ffmpeg -i - -acodec copy -vcodec copy -y $OUTFILE
|
||||
117
deps/libcaption/examples/captioner.c
vendored
Normal file
117
deps/libcaption/examples/captioner.c
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <linux/input.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "caption.h"
|
||||
#include "flv.h"
|
||||
|
||||
char charcode[] = {
|
||||
0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0,
|
||||
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']','\n', 0, 'A', 'S',
|
||||
'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'', '`', 0, '\\', 'Z', 'X', 'C', 'V',
|
||||
'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
int data_ready (int fd)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout = {0,0};
|
||||
FD_ZERO (&set);
|
||||
FD_SET (fd,&set);
|
||||
int cnt = select (fd+1, &set, 0, 0, &timeout);
|
||||
FD_ZERO (&set);
|
||||
return (0 < cnt);
|
||||
}
|
||||
|
||||
#define MAX_CAP_LENGTH (SCREEN_ROWS*SCREEN_COLS)
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
int fd;
|
||||
ssize_t n;
|
||||
flvtag_t tag;
|
||||
struct input_event ev;
|
||||
int has_audio, has_video;
|
||||
const char* dev = argv[1];
|
||||
char text[MAX_CAP_LENGTH+1];
|
||||
memset (text,0,MAX_CAP_LENGTH+1);
|
||||
|
||||
FILE* flv = flv_open_read ("-");
|
||||
FILE* out = flv_open_write ("-");
|
||||
fd = open (dev, O_RDONLY);
|
||||
|
||||
if (fd == -1) {
|
||||
fprintf (stderr, "Cannot open %s: %s.\n", dev, strerror (errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!flv_read_header (flv,&has_audio,&has_video)) {
|
||||
fprintf (stderr,"%s is not an flv file\n", argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!flv_write_header (out,has_audio,has_video)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
flvtag_init (&tag);
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
if (flvtag_avcpackettype_nalu == flvtag_avcpackettype (&tag)) {
|
||||
if (data_ready (fd)) {
|
||||
n = read (fd, &ev, sizeof ev);
|
||||
|
||||
if (n == (ssize_t)-1) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (n != sizeof ev) {
|
||||
errno = EIO;
|
||||
break;
|
||||
}
|
||||
|
||||
int len = strlen (text);
|
||||
char c = (EV_KEY == ev.type && 1 == ev.value && ev.code < 64) ? charcode[ev.code] : 0;
|
||||
|
||||
if (0 < len && '\n' == c) {
|
||||
fprintf (stderr,"='%s'\n", text);
|
||||
flvtag_addcaption (&tag, text);
|
||||
memset (text,0,MAX_CAP_LENGTH+1);
|
||||
} else if (0 != c && len < MAX_CAP_LENGTH) {
|
||||
text[len] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flv_write_tag (out,&tag);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
23
deps/libcaption/examples/flv+scc.c
vendored
Normal file
23
deps/libcaption/examples/flv+scc.c
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
96
deps/libcaption/examples/flv+srt.c
vendored
Normal file
96
deps/libcaption/examples/flv+srt.c
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "srt.h"
|
||||
#include "flv.h"
|
||||
#include "avc.h"
|
||||
// #include "sei.h"
|
||||
|
||||
#define MAX_SRT_SIZE (10*1024*1024)
|
||||
#define MAX_READ_SIZE 4096
|
||||
|
||||
srt_t* srt_from_file (const char* path)
|
||||
{
|
||||
srt_t* head = 0;
|
||||
size_t read, totl = 0;
|
||||
FILE* file = fopen (path,"r");
|
||||
|
||||
if (file) {
|
||||
char* srt_data = malloc (MAX_SRT_SIZE);
|
||||
size_t srt_size = 0;
|
||||
size_t size = MAX_SRT_SIZE;
|
||||
char* data = srt_data;
|
||||
|
||||
while (0 < (read = fread (data,1,size,file))) {
|
||||
totl += read; data += read; size -= read; srt_size += read;
|
||||
}
|
||||
|
||||
head = srt_parse (srt_data,srt_size);
|
||||
free (srt_data);
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
flvtag_t tag;
|
||||
FILE* flv = flv_open_read (argv[1]);
|
||||
FILE* out = flv_open_write (argv[3]);
|
||||
|
||||
int has_audio, has_video;
|
||||
flvtag_init (&tag);
|
||||
|
||||
if (!flv_read_header (flv,&has_audio,&has_video)) {
|
||||
fprintf (stderr,"%s is not an flv file\n", argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
srt_t* head = srt_from_file (argv[2]);
|
||||
srt_t* srt = head;
|
||||
|
||||
if (! head) {
|
||||
fprintf (stderr,"%s is not an srt file\n", argv[2]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
flv_write_header (out,has_audio,has_video);
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
// TODO handle B freame!
|
||||
if (srt && flvtag_pts_seconds (&tag) >= srt->timestamp && flvtag_avcpackettype_nalu == flvtag_avcpackettype (&tag)) {
|
||||
fprintf (stderr,"%f: %s\n", srt->timestamp, srt_data (srt));
|
||||
flvtag_addcaption (&tag, srt_data (srt));
|
||||
srt = srt->next;
|
||||
}
|
||||
|
||||
flv_write_tag (out,&tag);
|
||||
// Write tag out here
|
||||
}
|
||||
|
||||
srt_free (head);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
383
deps/libcaption/examples/flv.c
vendored
Normal file
383
deps/libcaption/examples/flv.c
vendored
Normal file
|
|
@ -0,0 +1,383 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "flv.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void flvtag_init (flvtag_t* tag)
|
||||
{
|
||||
memset (tag,0,sizeof (flvtag_t));
|
||||
}
|
||||
|
||||
void flvtag_free (flvtag_t* tag)
|
||||
{
|
||||
if (tag->data) {
|
||||
free (tag->data);
|
||||
}
|
||||
|
||||
flvtag_init (tag);
|
||||
}
|
||||
|
||||
int flvtag_reserve (flvtag_t* tag, uint32_t size)
|
||||
{
|
||||
size += FLV_TAG_HEADER_SIZE + FLV_TAG_FOOTER_SIZE;
|
||||
|
||||
if (size > tag->aloc) {
|
||||
tag->data = realloc (tag->data,size);
|
||||
tag->aloc = size;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* flv_open_read (const char* flv)
|
||||
{
|
||||
if (0 == flv || 0 == strcmp ("-",flv)) {
|
||||
return stdin;
|
||||
}
|
||||
|
||||
return fopen (flv,"rb");
|
||||
}
|
||||
|
||||
FILE* flv_open_write (const char* flv)
|
||||
{
|
||||
if (0 == flv || 0 == strcmp ("-",flv)) {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
return fopen (flv,"wb");
|
||||
}
|
||||
|
||||
FILE* flv_close (FILE* flv)
|
||||
{
|
||||
fclose (flv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int flv_read_header (FILE* flv, int* has_audio, int* has_video)
|
||||
{
|
||||
uint8_t h[FLV_HEADER_SIZE];
|
||||
|
||||
if (FLV_HEADER_SIZE != fread (&h[0],1,FLV_HEADER_SIZE,flv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ('F' != h[0] || 'L' != h[1] || 'V' != h[2]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
(*has_audio) = h[4]&0x04;
|
||||
(*has_video) = h[4]&0x01;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int flv_write_header (FILE* flv, int has_audio, int has_video)
|
||||
{
|
||||
uint8_t h[FLV_HEADER_SIZE] = {'F', 'L', 'V', 1, (has_audio?0x04:0x00) | (has_video?0x01:0x00), 0, 0, 0, 9, 0, 0, 0, 0 };
|
||||
return FLV_HEADER_SIZE == fwrite (&h[0],1,FLV_HEADER_SIZE,flv);
|
||||
}
|
||||
|
||||
int flv_read_tag (FILE* flv, flvtag_t* tag)
|
||||
{
|
||||
uint32_t size;
|
||||
uint8_t h[FLV_TAG_HEADER_SIZE];
|
||||
|
||||
if (FLV_TAG_HEADER_SIZE != fread (&h[0],1,FLV_TAG_HEADER_SIZE,flv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = ( (h[1]<<16) | (h[2]<<8) |h[3]);
|
||||
flvtag_reserve (tag, size);
|
||||
// copy header to buffer
|
||||
memcpy (tag->data,&h[0],FLV_TAG_HEADER_SIZE);
|
||||
|
||||
if (size+FLV_TAG_FOOTER_SIZE != fread (&tag->data[FLV_TAG_HEADER_SIZE],1,size+FLV_TAG_FOOTER_SIZE,flv)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int flv_write_tag (FILE* flv, flvtag_t* tag)
|
||||
{
|
||||
size_t size = flvtag_raw_size (tag);
|
||||
return size == fwrite (flvtag_raw_data (tag),1,size,flv);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t flvtag_header_size (flvtag_t* tag)
|
||||
{
|
||||
switch (flvtag_type (tag)) {
|
||||
case flvtag_type_audio:
|
||||
return FLV_TAG_HEADER_SIZE + (flvtag_soundformat_aac != flvtag_soundformat (tag) ? 1 : 2);
|
||||
|
||||
case flvtag_type_video:
|
||||
// CommandFrame does not have a compositionTime
|
||||
return FLV_TAG_HEADER_SIZE + (flvtag_codecid_avc != flvtag_codecid (tag) ? 1 : (flvtag_frametype_commandframe != flvtag_frametype (tag) ? 5 : 2));
|
||||
|
||||
default:
|
||||
return FLV_TAG_HEADER_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
size_t flvtag_payload_size (flvtag_t* tag)
|
||||
{
|
||||
return FLV_TAG_HEADER_SIZE + flvtag_size (tag) - flvtag_header_size (tag);
|
||||
}
|
||||
|
||||
uint8_t* flvtag_payload_data (flvtag_t* tag)
|
||||
{
|
||||
size_t payload_offset = flvtag_header_size (tag);
|
||||
return &tag->data[payload_offset];
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int flvtag_updatesize (flvtag_t* tag, uint32_t size)
|
||||
{
|
||||
tag->data[1] = size>>16; // DataSize
|
||||
tag->data[2] = size>>8; // DataSize
|
||||
tag->data[3] = size>>0; // DataSize
|
||||
size += 11;
|
||||
tag->data[size+0] = size>>24; // PrevTagSize
|
||||
tag->data[size+1] = size>>16; // PrevTagSize
|
||||
tag->data[size+2] = size>>8; // PrevTagSize
|
||||
tag->data[size+3] = size>>0; // PrevTagSize
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define FLVTAG_PREALOC 2048
|
||||
int flvtag_initavc (flvtag_t* tag, uint32_t dts, int32_t cts, flvtag_frametype_t type)
|
||||
{
|
||||
flvtag_init (tag);
|
||||
flvtag_reserve (tag,5+FLVTAG_PREALOC);
|
||||
tag->data[0] = flvtag_type_video;
|
||||
tag->data[4] = dts>>16;
|
||||
tag->data[5] = dts>>8;
|
||||
tag->data[6] = dts>>0;
|
||||
tag->data[7] = dts>>24;
|
||||
tag->data[8] = 0; // StreamID
|
||||
tag->data[9] = 0; // StreamID
|
||||
tag->data[10] = 0; // StreamID
|
||||
// VideoTagHeader
|
||||
tag->data[11] = ( (type<<4) %0xF0) |0x07; // CodecId
|
||||
tag->data[12] = 0x01; // AVC NALU
|
||||
tag->data[13] = cts>>16;
|
||||
tag->data[14] = cts>>8;
|
||||
tag->data[15] = cts>>0;
|
||||
flvtag_updatesize (tag,5);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int flvtag_initamf (flvtag_t* tag, uint32_t dts)
|
||||
{
|
||||
flvtag_init (tag);
|
||||
flvtag_reserve (tag,FLVTAG_PREALOC);
|
||||
tag->data[0] = flvtag_type_scriptdata;
|
||||
tag->data[4] = dts>>16;
|
||||
tag->data[5] = dts>>8;
|
||||
tag->data[6] = dts>>0;
|
||||
tag->data[7] = dts>>24;
|
||||
tag->data[8] = 0; // StreamID
|
||||
tag->data[9] = 0; // StreamID
|
||||
tag->data[10] = 0; // StreamID
|
||||
flvtag_updatesize (tag,0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// shamelessly taken from libtomcrypt, an public domain project
|
||||
static void base64_encode (const unsigned char* in, unsigned long inlen, unsigned char* out, unsigned long* outlen)
|
||||
{
|
||||
static const char* codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
unsigned long i, len2, leven;
|
||||
unsigned char* p;
|
||||
|
||||
/* valid output size ? */
|
||||
len2 = 4 * ( (inlen + 2) / 3);
|
||||
|
||||
if (*outlen < len2 + 1) {
|
||||
*outlen = len2 + 1;
|
||||
fprintf (stderr,"\n\nHERE\n\n");
|
||||
return;
|
||||
}
|
||||
|
||||
p = out;
|
||||
leven = 3* (inlen / 3);
|
||||
|
||||
for (i = 0; i < leven; i += 3) {
|
||||
*p++ = codes[ (in[0] >> 2) & 0x3F];
|
||||
*p++ = codes[ ( ( (in[0] & 3) << 4) + (in[1] >> 4)) & 0x3F];
|
||||
*p++ = codes[ ( ( (in[1] & 0xf) << 2) + (in[2] >> 6)) & 0x3F];
|
||||
*p++ = codes[in[2] & 0x3F];
|
||||
in += 3;
|
||||
}
|
||||
|
||||
if (i < inlen) {
|
||||
unsigned a = in[0];
|
||||
unsigned b = (i+1 < inlen) ? in[1] : 0;
|
||||
|
||||
*p++ = codes[ (a >> 2) & 0x3F];
|
||||
*p++ = codes[ ( ( (a & 3) << 4) + (b >> 4)) & 0x3F];
|
||||
*p++ = (i+1 < inlen) ? codes[ ( ( (b & 0xf) << 2)) & 0x3F] : '=';
|
||||
*p++ = '=';
|
||||
}
|
||||
|
||||
/* return ok */
|
||||
*outlen = p - out;
|
||||
}
|
||||
|
||||
const char onCaptionInfo708[] = { 0x02,0x00,0x0D, 'o','n','C','a','p','t','i','o','n','I','n','f','o',
|
||||
0x08, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x04, 't','y','p','e',
|
||||
0x02, 0x00, 0x03, '7','0','8',
|
||||
0x00, 0x04, 'd','a','t','a',
|
||||
0x02, 0x00,0x00
|
||||
};
|
||||
|
||||
int flvtag_amfcaption_708 (flvtag_t* tag, uint32_t timestamp, sei_message_t* msg)
|
||||
{
|
||||
flvtag_initamf (tag,timestamp);
|
||||
unsigned long size = 1 + (4 * ( (sei_message_size (msg) + 2) / 3));
|
||||
flvtag_reserve (tag, sizeof (onCaptionInfo708) + size + 3);
|
||||
memcpy (flvtag_payload_data (tag),onCaptionInfo708,sizeof (onCaptionInfo708));
|
||||
uint8_t* data = flvtag_payload_data (tag) + sizeof (onCaptionInfo708);
|
||||
base64_encode (sei_message_data (msg), sei_message_size (msg), data, &size);
|
||||
|
||||
// Update the size of the base64 string
|
||||
data[-2] = size >> 8;
|
||||
data[-1] = size >> 0;
|
||||
// write the last array element
|
||||
data[size+0] = 0x00;
|
||||
data[size+1] = 0x00;
|
||||
data[size+2] = 0x09;
|
||||
flvtag_updatesize (tag, sizeof (onCaptionInfo708) + size + 3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char onCaptionInfoUTF8[] = { 0x02,0x00,0x0D, 'o','n','C','a','p','t','i','o','n','I','n','f','o',
|
||||
0x08, 0x00, 0x00, 0x00, 0x02,
|
||||
0x00, 0x04, 't','y','p','e',
|
||||
0x02, 0x00, 0x04, 'U','T','F','8',
|
||||
0x00, 0x04, 'd','a','t','a',
|
||||
0x02, 0x00,0x00
|
||||
};
|
||||
|
||||
#define MAX_AMF_STRING 65636
|
||||
int flvtag_amfcaption_utf8 (flvtag_t* tag, uint32_t timestamp, const utf8_char_t* text)
|
||||
{
|
||||
flvtag_initamf (tag,timestamp);
|
||||
unsigned long size = strlen (text);
|
||||
|
||||
if (MAX_AMF_STRING < size) {
|
||||
size = MAX_AMF_STRING;
|
||||
}
|
||||
|
||||
flvtag_reserve (tag, sizeof (onCaptionInfoUTF8) + size + 3);
|
||||
memcpy (flvtag_payload_data (tag),onCaptionInfoUTF8,sizeof (onCaptionInfoUTF8));
|
||||
uint8_t* data = flvtag_payload_data (tag) + sizeof (onCaptionInfo708);
|
||||
memcpy (data,text,size);
|
||||
// Update the size of the string
|
||||
data[-2] = size >> 8;
|
||||
data[-1] = size >> 0;
|
||||
// write the last array element
|
||||
data[size+0] = 0x00;
|
||||
data[size+1] = 0x00;
|
||||
data[size+2] = 0x09;
|
||||
flvtag_updatesize (tag, sizeof (onCaptionInfoUTF8) + size + 3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define LENGTH_SIZE 4
|
||||
|
||||
int flvtag_avcwritenal (flvtag_t* tag, uint8_t* data, size_t size)
|
||||
{
|
||||
uint32_t flvsize = flvtag_size (tag);
|
||||
flvtag_reserve (tag,flvsize+LENGTH_SIZE+size);
|
||||
uint8_t* payload = tag->data + FLV_TAG_HEADER_SIZE + flvsize;
|
||||
payload[0] = size>>24; // nalu size
|
||||
payload[1] = size>>16;
|
||||
payload[2] = size>>8;
|
||||
payload[3] = size>>0;
|
||||
memcpy (&payload[LENGTH_SIZE],data,size);
|
||||
flvtag_updatesize (tag,flvsize+LENGTH_SIZE+size);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int flvtag_addcaption (flvtag_t* tag, const utf8_char_t* text)
|
||||
{
|
||||
if (flvtag_avcpackettype_nalu != flvtag_avcpackettype (tag)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sei_t sei;
|
||||
caption_frame_t frame;
|
||||
|
||||
sei_init (&sei);
|
||||
caption_frame_init (&frame);
|
||||
caption_frame_from_text (&frame, text);
|
||||
sei_from_caption_frame (&sei, &frame);
|
||||
|
||||
uint8_t* sei_data = malloc (sei_render_size (&sei));
|
||||
size_t sei_size = sei_render (&sei, sei_data);
|
||||
|
||||
// rewrite tag
|
||||
flvtag_t new_tag;
|
||||
flvtag_initavc (&new_tag, flvtag_dts (tag), flvtag_cts (tag), flvtag_frametype (tag));
|
||||
uint8_t* data = flvtag_payload_data (tag);
|
||||
ssize_t size = flvtag_payload_size (tag);
|
||||
|
||||
while (0<size) {
|
||||
uint8_t* nalu_data = &data[LENGTH_SIZE];
|
||||
uint8_t nalu_type = nalu_data[0]&0x1F;
|
||||
uint32_t nalu_size = (data[0]<<24) | (data[1]<<16) | (data[2]<<8) | data[3];
|
||||
data += LENGTH_SIZE + nalu_size;
|
||||
size -= LENGTH_SIZE + nalu_size;
|
||||
|
||||
if (0 < sei_size && 7 != nalu_type && 8 != nalu_type && 9 != nalu_type ) {
|
||||
// fprintf (stderr,"Wrote SEI %d '%d'\n\n", sei_size, sei_data[3]);
|
||||
flvtag_avcwritenal (&new_tag,sei_data,sei_size);
|
||||
sei_size = 0;
|
||||
}
|
||||
|
||||
flvtag_avcwritenal (&new_tag,nalu_data,nalu_size);
|
||||
}
|
||||
|
||||
// On the off chance we have an empty frame,
|
||||
// We still wish to append the sei
|
||||
if (0<sei_size) {
|
||||
// fprintf (stderr,"Wrote SEI %d\n\n", sei_size);
|
||||
flvtag_avcwritenal (&new_tag,sei_data,sei_size);
|
||||
sei_size = 0;
|
||||
}
|
||||
|
||||
if (sei_data) {
|
||||
free (sei_data);
|
||||
}
|
||||
|
||||
free (tag->data);
|
||||
sei_free (&sei);
|
||||
tag->data = new_tag.data;
|
||||
tag->aloc = new_tag.aloc;
|
||||
return 1;
|
||||
}
|
||||
142
deps/libcaption/examples/flv.h
vendored
Normal file
142
deps/libcaption/examples/flv.h
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_FLV_H
|
||||
#define LIBCAPTION_FLV_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#define FLV_HEADER_SIZE 13
|
||||
#define FLV_FOOTER_SIZE 4
|
||||
#define FLV_TAG_HEADER_SIZE 11
|
||||
#define FLV_TAG_FOOTER_SIZE 4
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "avc.h"
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef struct {
|
||||
uint8_t* data;
|
||||
size_t aloc;
|
||||
} flvtag_t;
|
||||
|
||||
void flvtag_init (flvtag_t* tag);
|
||||
void flvtag_free (flvtag_t* tag);
|
||||
void flvtag_swap (flvtag_t* tag1, flvtag_t* tag2);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
flvtag_type_audio = 0x08,
|
||||
flvtag_type_video = 0x09,
|
||||
flvtag_type_scriptdata = 0x12,
|
||||
} flvtag_type_t;
|
||||
|
||||
static inline flvtag_type_t flvtag_type (flvtag_t* tag) { return (flvtag_type_t) tag->data[0]&0x1F; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
flvtag_soundformat_unknown = -1,
|
||||
flvtag_soundformat_linearpcmplatformendian = 0,
|
||||
flvtag_soundformat_adpcm = 1,
|
||||
flvtag_soundformat_mp3 = 2,
|
||||
flvtag_soundformat_linearpcmlittleendian = 3,
|
||||
flvtag_soundformat_nellymoser_16khzmono = 4,
|
||||
flvtag_soundformat_nellymoser_8khzmono = 5,
|
||||
flvtag_soundformat_nellymoser = 6,
|
||||
flvtag_soundformat_g711alawlogarithmicpcm = 7,
|
||||
flvtag_soundformat_g711mulawlogarithmicpcm = 8,
|
||||
flvtag_soundformat_reserved = 9,
|
||||
flvtag_soundformat_aac = 10,
|
||||
flvtag_soundformat_speex = 11,
|
||||
flvtag_soundformat_mp3_8khz = 14,
|
||||
flvtag_soundformat_devicespecificsound = 15
|
||||
} flvtag_soundformat_t;
|
||||
|
||||
static inline flvtag_soundformat_t flvtag_soundformat (flvtag_t* tag) { return (flvtag_type_audio!=flvtag_type (tag)) ?flvtag_soundformat_unknown: (flvtag_soundformat_t) (tag->data[0]>>4) &0x0F; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
flvtag_codecid_unknown = -1,
|
||||
flvtag_codecid_sorensonh263 = 2,
|
||||
flvtag_codecid_screenvideo = 3,
|
||||
flvtag_codecid_on2vp6 = 4,
|
||||
flvtag_codecid_on2vp6withalphachannel = 5,
|
||||
flvtag_codecid_screenvideoversion2 = 6,
|
||||
flvtag_codecid_avc = 7
|
||||
} flvtag_codecid_t;
|
||||
|
||||
static inline flvtag_codecid_t flvtag_codecid (flvtag_t* tag) { return (flvtag_type_video!=flvtag_type (tag)) ? (flvtag_codecid_unknown) : (tag->data[11]&0x0F); }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
flvtag_frametype_unknown = -1,
|
||||
flvtag_frametype_keyframe = 1,
|
||||
flvtag_frametype_interframe = 2,
|
||||
flvtag_frametype_disposableinterframe = 3,
|
||||
flvtag_frametype_generatedkeyframe = 4,
|
||||
flvtag_frametype_commandframe = 5
|
||||
} flvtag_frametype_t;
|
||||
|
||||
static inline flvtag_frametype_t flvtag_frametype (flvtag_t* tag) { return (flvtag_type_video!=flvtag_type (tag)) ?flvtag_frametype_keyframe: ( (tag->data[11]>>4) &0x0F); }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
typedef enum {
|
||||
flvtag_avcpackettype_unknown = -1,
|
||||
flvtag_avcpackettype_sequenceheader = 0,
|
||||
flvtag_avcpackettype_nalu = 1,
|
||||
flvtag_avcpackettype_endofsequence = 2
|
||||
} flvtag_avcpackettype_t;
|
||||
|
||||
static inline flvtag_avcpackettype_t flvtag_avcpackettype (flvtag_t* tag) { return (flvtag_codecid_avc!=flvtag_codecid (tag)) ?flvtag_avcpackettype_unknown:tag->data[12]; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static inline size_t flvtag_size (flvtag_t* tag) { return (tag->data[1]<<16) | (tag->data[2]<<8) | tag->data[3]; }
|
||||
static inline uint32_t flvtag_timestamp (flvtag_t* tag) { return (tag->data[7]<<24) | (tag->data[4]<<16) | (tag->data[5]<<8) | tag->data[6]; }
|
||||
static inline uint32_t flvtag_dts (flvtag_t* tag) { return flvtag_timestamp (tag); }
|
||||
static inline uint32_t flvtag_cts (flvtag_t* tag) { return (flvtag_avcpackettype_nalu!=flvtag_avcpackettype (tag)) ?0: (tag->data[13]<<16) | (tag->data[14]<<8) |tag->data[15]; }
|
||||
static inline uint32_t flvtag_pts (flvtag_t* tag) { return flvtag_dts (tag)+flvtag_cts (tag); }
|
||||
static inline double flvtag_dts_seconds (flvtag_t* tag) { return flvtag_dts (tag) / 1000.0; }
|
||||
static inline double flvtag_cts_seconds (flvtag_t* tag) { return flvtag_cts (tag) / 1000.0; }
|
||||
static inline double flvtag_pts_seconds (flvtag_t* tag) { return flvtag_pts (tag) / 1000.0; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t flvtag_header_size (flvtag_t* tag);
|
||||
size_t flvtag_payload_size (flvtag_t* tag);
|
||||
uint8_t* flvtag_payload_data (flvtag_t* tag);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
FILE* flv_open_read (const char* flv);
|
||||
FILE* flv_open_write (const char* flv);
|
||||
FILE* flv_close (FILE* flv);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static inline const uint8_t* flvtag_raw_data (flvtag_t* tag) { return tag->data; }
|
||||
static inline const size_t flvtag_raw_size (flvtag_t* tag) { return flvtag_size (tag)+FLV_TAG_HEADER_SIZE+FLV_TAG_FOOTER_SIZE; }
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int flv_read_tag (FILE* flv, flvtag_t* tag);
|
||||
int flv_write_tag (FILE* flv, flvtag_t* tag);
|
||||
int flv_read_header (FILE* flv, int* has_audio, int* has_video);
|
||||
int flv_write_header (FILE* flv, int has_audio, int has_video);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// If the tage has more that on sei message, they will be combined into one
|
||||
sei_t* flv_read_sei (FILE* flv, flvtag_t* tag);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int flvtag_initavc (flvtag_t* tag, uint32_t dts, int32_t cts, flvtag_frametype_t type);
|
||||
int flvtag_avcwritenal (flvtag_t* tag, uint8_t* data, size_t size);
|
||||
int flvtag_addcaption (flvtag_t* tag, const utf8_char_t* text);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int flvtag_amfcaption_708 (flvtag_t* tag, uint32_t timestamp, sei_message_t* msg);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// This method is expermental, and not currently available on Twitch
|
||||
int flvtag_amfcaption_utf8 (flvtag_t* tag, uint32_t timestamp, const utf8_char_t* text);
|
||||
#endif
|
||||
92
deps/libcaption/examples/flv2srt.c
vendored
Normal file
92
deps/libcaption/examples/flv2srt.c
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "flv.h"
|
||||
#include "srt.h"
|
||||
#include "avc.h"
|
||||
|
||||
#define LENGTH_SIZE 4
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
const char* path = argv[1];
|
||||
|
||||
sei_t sei;
|
||||
flvtag_t tag;
|
||||
srt_t* srt = 0, *head = 0;
|
||||
int i, has_audio, has_video;
|
||||
caption_frame_t frame;
|
||||
|
||||
flvtag_init (&tag);
|
||||
caption_frame_init (&frame);
|
||||
|
||||
FILE* flv = flv_open_read (path);
|
||||
|
||||
if (!flv_read_header (flv,&has_audio,&has_video)) {
|
||||
fprintf (stderr,"'%s' Not an flv file\n", path);
|
||||
} else {
|
||||
fprintf (stderr,"Reading from '%s'\n", path);
|
||||
}
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
if (flvtag_avcpackettype_nalu == flvtag_avcpackettype (&tag)) {
|
||||
ssize_t size = flvtag_payload_size (&tag);
|
||||
uint8_t* data = flvtag_payload_data (&tag);
|
||||
|
||||
while (0<size) {
|
||||
ssize_t nalu_size = (data[0]<<24) | (data[1]<<16) | (data[2]<<8) | data[3];
|
||||
uint8_t* nalu_data = &data[4];
|
||||
uint8_t nalu_type = nalu_data[0]&0x1F;
|
||||
data += nalu_size + LENGTH_SIZE;
|
||||
size -= nalu_size + LENGTH_SIZE;
|
||||
|
||||
if (6 == nalu_type) {
|
||||
sei_init (&sei);
|
||||
sei_parse_nalu (&sei, nalu_data, nalu_size, flvtag_dts (&tag), flvtag_cts (&tag));
|
||||
|
||||
cea708_t cea708;
|
||||
sei_message_t* msg;
|
||||
cea708_init (&cea708);
|
||||
|
||||
// for (msg = sei_message_head (&sei) ; msg ; msg = sei_message_next (msg)) {
|
||||
// if (sei_type_user_data_registered_itu_t_t35 == sei_message_type (msg)) {
|
||||
// cea708_parse (sei_message_data (msg), sei_message_size (msg), &cea708);
|
||||
// cea708_dump (&cea708);
|
||||
// }
|
||||
// }
|
||||
|
||||
// sei_dump(&sei);
|
||||
sei_to_caption_frame (&sei,&frame);
|
||||
sei_free (&sei);
|
||||
|
||||
// caption_frame_dump (&frame);
|
||||
srt = srt_from_caption_frame (&frame,srt,&head);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
srt_dump (head);
|
||||
srt_free (head);
|
||||
|
||||
return 1;
|
||||
}
|
||||
122
deps/libcaption/examples/party.c
vendored
Normal file
122
deps/libcaption/examples/party.c
vendored
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "flv.h"
|
||||
#include "avc.h"
|
||||
|
||||
#define CAPTION_METHOD_SEI_708 0 // embedded 708
|
||||
#define CAPTION_METHOD_AMF_708 1 // onCaptionInfo type = 708
|
||||
#define CAPTION_METHOD_AMF_UTF8 2 // onCaptionInfo type = utf8
|
||||
#define CAPTION_METHOD CAPTION_METHOD_SEI_708
|
||||
|
||||
void get_dudes (char* str)
|
||||
{
|
||||
sprintf (str, " %s%s %s(-_-)%s %s(-_-)%s.%s(-_-)%s %s%s", EIA608_CHAR_EIGHTH_NOTE, EIA608_CHAR_EIGHTH_NOTE,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT,
|
||||
! (rand() % 2) ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT,
|
||||
EIA608_CHAR_EIGHTH_NOTE, EIA608_CHAR_EIGHTH_NOTE);
|
||||
}
|
||||
|
||||
void write_amfcaptions_708 (FILE* out, uint32_t timestamp, const char* text)
|
||||
{
|
||||
sei_t sei;
|
||||
flvtag_t tag;
|
||||
sei_message_t* msg;
|
||||
caption_frame_t frame;
|
||||
sei_init (&sei);
|
||||
flvtag_init (&tag);
|
||||
caption_frame_init (&frame);
|
||||
caption_frame_from_text (&frame, text);
|
||||
sei_from_caption_frame (&sei, &frame);
|
||||
// caption_frame_dump (&frame);
|
||||
|
||||
for (msg = sei_message_head (&sei); msg; msg=sei_message_next (msg),++timestamp) {
|
||||
flvtag_amfcaption_708 (&tag,timestamp,msg);
|
||||
flv_write_tag (out,&tag);
|
||||
}
|
||||
|
||||
sei_free (&sei);
|
||||
flvtag_free (&tag);
|
||||
}
|
||||
|
||||
|
||||
void write_amfcaptions_utf8 (FILE* out, uint32_t timestamp, const utf8_char_t* text)
|
||||
{
|
||||
flvtag_t tag;
|
||||
flvtag_init (&tag);
|
||||
flvtag_amfcaption_utf8 (&tag,timestamp,text);
|
||||
flv_write_tag (out,&tag);
|
||||
flvtag_free (&tag);
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
flvtag_t tag;
|
||||
uint32_t nextParty = 1000;
|
||||
int has_audio, has_video;
|
||||
FILE* flv = flv_open_read (argv[1]);
|
||||
FILE* out = flv_open_write (argv[2]);
|
||||
char partyDudes[64];
|
||||
|
||||
flvtag_init (&tag);
|
||||
|
||||
if (!flv_read_header (flv,&has_audio,&has_video)) {
|
||||
fprintf (stderr,"%s is not an flv file\n", argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
flv_write_header (out,has_audio,has_video);
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
|
||||
if (flvtag_avcpackettype_nalu == flvtag_avcpackettype (&tag) && nextParty <= flvtag_timestamp (&tag)) {
|
||||
get_dudes (partyDudes);
|
||||
|
||||
if (CAPTION_METHOD == CAPTION_METHOD_SEI_708) {
|
||||
flvtag_addcaption (&tag, partyDudes);
|
||||
} else if (CAPTION_METHOD == CAPTION_METHOD_AMF_708) {
|
||||
write_amfcaptions_708 (out,nextParty,partyDudes);
|
||||
} else if (CAPTION_METHOD == CAPTION_METHOD_AMF_708) {
|
||||
write_amfcaptions_utf8 (out, nextParty, partyDudes);
|
||||
} else {
|
||||
fprintf (stderr,"Unknnow method\n");
|
||||
return EXIT_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
fprintf (stderr,"%d: %s\n",nextParty, partyDudes);
|
||||
nextParty += 500; // party all the time
|
||||
}
|
||||
|
||||
flv_write_tag (out,&tag);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
95
deps/libcaption/examples/rollup.c
vendored
Normal file
95
deps/libcaption/examples/rollup.c
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "flv.h"
|
||||
#include "avc.h"
|
||||
#include "srt.h"
|
||||
#include "wonderland.h"
|
||||
|
||||
#define SECONDS_PER_LINE 3.0
|
||||
srt_t* appennd_caption (const utf8_char_t* data, srt_t* prev, srt_t** head)
|
||||
{
|
||||
|
||||
int r, c, chan = 0;
|
||||
ssize_t size = (ssize_t) strlen (data);
|
||||
size_t char_count, char_length, line_length = 0, trimmed_length = 0;
|
||||
|
||||
for (r = 0 ; 0 < size && SCREEN_ROWS > r ; ++r) {
|
||||
line_length = utf8_line_length (data);
|
||||
trimmed_length = utf8_trimmed_length (data,line_length);
|
||||
char_count = utf8_char_count (data,trimmed_length);
|
||||
|
||||
// If char_count is greater than one line can display, split it.
|
||||
if (SCREEN_COLS < char_count) {
|
||||
char_count = utf8_wrap_length (data,SCREEN_COLS);
|
||||
line_length = utf8_string_length (data,char_count+1);
|
||||
}
|
||||
|
||||
// fprintf (stderr,"%.*s\n", line_length, data);
|
||||
prev = srt_new (data, line_length, prev ? prev->timestamp + SECONDS_PER_LINE : 0, prev, head);
|
||||
|
||||
data += line_length;
|
||||
size -= (ssize_t) line_length;
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
int i = 0;
|
||||
flvtag_t tag;
|
||||
srt_t* head = 0, *tail = 0;
|
||||
int has_audio, has_video;
|
||||
FILE* flv = flv_open_read (argv[1]);
|
||||
FILE* out = flv_open_write (argv[2]);
|
||||
flvtag_init (&tag);
|
||||
|
||||
for (i = 0 ; wonderland[i][0]; ++i) {
|
||||
tail = appennd_caption (wonderland[i], tail, &head);
|
||||
}
|
||||
|
||||
|
||||
if (!flv_read_header (flv,&has_audio,&has_video)) {
|
||||
fprintf (stderr,"%s is not an flv file\n", argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
flv_write_header (out,has_audio,has_video);
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
if (head && flvtag_avcpackettype_nalu == flvtag_avcpackettype (&tag) && head->timestamp <= flvtag_pts_seconds (&tag)) {
|
||||
fprintf (stderr,"%f %s\n", flvtag_pts_seconds (&tag), srt_data (head));
|
||||
flvtag_addcaption (&tag, srt_data (head));
|
||||
head = srt_free_head (head);
|
||||
}
|
||||
|
||||
|
||||
flv_write_tag (out,&tag);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
165
deps/libcaption/examples/rtmpspit.c
vendored
Normal file
165
deps/libcaption/examples/rtmpspit.c
vendored
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
#include "flv.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/select.h>
|
||||
#include <librtmp/log.h>
|
||||
#include <librtmp/rtmp.h>
|
||||
|
||||
|
||||
int MyRTMP_Write (RTMP* r, const char* buf, int size)
|
||||
{
|
||||
RTMPPacket* pkt = &r->m_write;
|
||||
char* enc;
|
||||
int s2 = size, ret, num;
|
||||
|
||||
pkt->m_nChannel = 0x04; /* source channel */
|
||||
pkt->m_nInfoField2 = r->m_stream_id;
|
||||
|
||||
while (s2) {
|
||||
if (!pkt->m_nBytesRead) {
|
||||
if (size < 11) {
|
||||
/* FLV pkt too small */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (buf[0] == 'F' && buf[1] == 'L' && buf[2] == 'V') {
|
||||
buf += 13;
|
||||
s2 -= 13;
|
||||
}
|
||||
|
||||
pkt->m_packetType = *buf++;
|
||||
pkt->m_nBodySize = AMF_DecodeInt24 (buf);
|
||||
buf += 3;
|
||||
pkt->m_nTimeStamp = AMF_DecodeInt24 (buf);
|
||||
buf += 3;
|
||||
pkt->m_nTimeStamp |= *buf++ << 24;
|
||||
buf += 3;
|
||||
s2 -= 11;
|
||||
|
||||
if ( ( (pkt->m_packetType == RTMP_PACKET_TYPE_AUDIO
|
||||
|| pkt->m_packetType == RTMP_PACKET_TYPE_VIDEO) &&
|
||||
!pkt->m_nTimeStamp) || pkt->m_packetType == RTMP_PACKET_TYPE_INFO) {
|
||||
pkt->m_headerType = RTMP_PACKET_SIZE_LARGE;
|
||||
} else {
|
||||
pkt->m_headerType = RTMP_PACKET_SIZE_MEDIUM;
|
||||
}
|
||||
|
||||
if (!RTMPPacket_Alloc (pkt, pkt->m_nBodySize)) {
|
||||
RTMP_Log (RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
enc = pkt->m_body;
|
||||
} else {
|
||||
enc = pkt->m_body + pkt->m_nBytesRead;
|
||||
}
|
||||
|
||||
num = pkt->m_nBodySize - pkt->m_nBytesRead;
|
||||
|
||||
if (num > s2) {
|
||||
num = s2;
|
||||
}
|
||||
|
||||
memcpy (enc, buf, num);
|
||||
pkt->m_nBytesRead += num;
|
||||
s2 -= num;
|
||||
buf += num;
|
||||
|
||||
if (pkt->m_nBytesRead == pkt->m_nBodySize) {
|
||||
ret = RTMP_SendPacket (r, pkt, FALSE);
|
||||
RTMPPacket_Free (pkt);
|
||||
pkt->m_nBytesRead = 0;
|
||||
|
||||
if (!ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf += 4;
|
||||
s2 -= 4;
|
||||
|
||||
if (s2 < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return size+s2;
|
||||
}
|
||||
|
||||
int main (int argc, const char** argv)
|
||||
{
|
||||
FILE* flv;
|
||||
RTMP* rtmp;
|
||||
RTMPPacket rtmpPacket;
|
||||
|
||||
flvtag_t tag;
|
||||
int32_t timestamp = 0;
|
||||
int has_audio, has_video;
|
||||
char* url = 0;
|
||||
|
||||
if (2 >= argc) {
|
||||
fprintf (stderr,"Usage %s [input] [url]\n",argv[0]);
|
||||
}
|
||||
|
||||
url = (char*) argv[2];
|
||||
flv = flv_open_read (argv[1]);
|
||||
|
||||
if (! flv) {
|
||||
fprintf (stderr,"Could not open %s\n",argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (! flv_read_header (flv, &has_audio, &has_video)) {
|
||||
fprintf (stderr,"Not an flv file %s\n",argv[1]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
flvtag_init (&tag);
|
||||
rtmp = RTMP_Alloc();
|
||||
RTMP_Init (rtmp);
|
||||
fprintf (stderr,"Connecting to %s\n", url);
|
||||
RTMP_SetupURL (rtmp, url);
|
||||
RTMP_EnableWrite (rtmp);
|
||||
|
||||
RTMP_Connect (rtmp, NULL);
|
||||
RTMP_ConnectStream (rtmp, 0);
|
||||
memset (&rtmpPacket, 0, sizeof (RTMPPacket));
|
||||
|
||||
if (! RTMP_IsConnected (rtmp)) {
|
||||
fprintf (stderr,"RTMP_IsConnected() Error\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while (flv_read_tag (flv,&tag)) {
|
||||
if (! RTMP_IsConnected (rtmp) || RTMP_IsTimedout (rtmp)) {
|
||||
fprintf (stderr,"RTMP_IsConnected() Error\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (flvtag_timestamp (&tag) > timestamp) {
|
||||
usleep (1000 * (flvtag_timestamp (&tag) - timestamp));
|
||||
timestamp = flvtag_timestamp (&tag);
|
||||
}
|
||||
|
||||
MyRTMP_Write (rtmp, (const char*) flvtag_raw_data (&tag),flvtag_raw_size (&tag));
|
||||
|
||||
// Handle RTMP ping and such
|
||||
fd_set sockset; struct timeval timeout = {0,0};
|
||||
FD_ZERO (&sockset); FD_SET (RTMP_Socket (rtmp), &sockset);
|
||||
register int result = select (RTMP_Socket (rtmp) + 1, &sockset, NULL, NULL, &timeout);
|
||||
|
||||
if (result == 1 && FD_ISSET (RTMP_Socket (rtmp), &sockset)) {
|
||||
RTMP_ReadPacket (rtmp, &rtmpPacket);
|
||||
|
||||
if (! RTMPPacket_IsReady (&rtmpPacket)) {
|
||||
fprintf (stderr,"Received RTMP packet\n");
|
||||
RTMP_ClientPacket (rtmp,&rtmpPacket);
|
||||
RTMPPacket_Free (&rtmpPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
96
deps/libcaption/examples/scc2srt.c
vendored
Normal file
96
deps/libcaption/examples/scc2srt.c
vendored
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "srt.h"
|
||||
#include "scc.h"
|
||||
|
||||
#define MAX_SCC_SIZE (10*1024*1024)
|
||||
#define MAX_READ_SIZE 4096
|
||||
#define MAX_CC 128
|
||||
|
||||
size_t read_file (FILE* file, utf8_char_t* data, size_t size)
|
||||
{
|
||||
size_t read, totl = 0;
|
||||
|
||||
while (0 < (read = fread (data,1,MAX_READ_SIZE<size?MAX_READ_SIZE:size,file))) {
|
||||
totl += read; data += read; size -= read;
|
||||
}
|
||||
|
||||
return totl;
|
||||
}
|
||||
|
||||
srt_t* scc2srt (const char* data)
|
||||
{
|
||||
double pts;
|
||||
size_t line_size = 0;
|
||||
int cc_idx, count, i;
|
||||
srt_t* srt = 0, *head = 0;
|
||||
caption_frame_t frame;
|
||||
uint16_t cc_data[MAX_CC];
|
||||
|
||||
while (0 < (line_size = utf8_line_length (data))) {
|
||||
caption_frame_init (&frame);
|
||||
int cc_count = scc_to_608 (data, &pts, (uint16_t*) &cc_data, MAX_CC);
|
||||
data += line_size;
|
||||
data += utf8_line_length (data); // skip empty line
|
||||
|
||||
// fprintf (stderr,"%f, %d| %.*s\n", pts, cc_count, (int) line_size,data);
|
||||
|
||||
for (cc_idx = 0 ; cc_idx < cc_count ; ++cc_idx) {
|
||||
// eia608_dump (cc_data[cc_idx]);
|
||||
caption_frame_decode (&frame,cc_data[cc_idx],pts);
|
||||
}
|
||||
|
||||
// utf8_char_t buff[CAPTION_FRAME_DUMP_BUF_SIZE];
|
||||
// size_t size = caption_frame_dump (&frame, buff);
|
||||
// fprintf (stderr,"%s\n", buff);
|
||||
srt = srt_from_caption_frame (&frame,srt,&head);
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
char frame_buf[CAPTION_FRAME_DUMP_BUF_SIZE];
|
||||
|
||||
if (argc < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE* file = fopen (argv[1],"r");
|
||||
|
||||
if (! file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
utf8_char_t* data = malloc (MAX_SCC_SIZE);
|
||||
read_file (file,data,MAX_SCC_SIZE);
|
||||
srt_t* srt = scc2srt (data);
|
||||
srt_dump (srt);
|
||||
srt_free (srt);
|
||||
free (data);
|
||||
}
|
||||
64
deps/libcaption/examples/srt2vtt.c
vendored
Normal file
64
deps/libcaption/examples/srt2vtt.c
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "srt.h"
|
||||
|
||||
#define MAX_SRT_SIZE (10*1024*1024)
|
||||
#define MAX_READ_SIZE 4096
|
||||
|
||||
size_t read_file (FILE* file, utf8_char_t* data, size_t size)
|
||||
{
|
||||
size_t read, totl = 0;
|
||||
|
||||
while (0 < (read = fread (data,1,MAX_READ_SIZE<size?MAX_READ_SIZE:size,file))) {
|
||||
totl += read; data += read; size -= read;
|
||||
}
|
||||
|
||||
return totl;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
srt_t* srt;
|
||||
caption_frame_t frame;
|
||||
char frame_buf[CAPTION_FRAME_DUMP_BUF_SIZE];
|
||||
|
||||
if (argc < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE* file = fopen (argv[1],"r");
|
||||
|
||||
if (! file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
utf8_char_t* data = malloc (MAX_SRT_SIZE);
|
||||
size_t size = read_file (file,data,MAX_SRT_SIZE);
|
||||
srt_t* head = srt_parse (data,size);
|
||||
vtt_dump (head);
|
||||
srt_free (head);
|
||||
}
|
||||
71
deps/libcaption/examples/srtdump.c
vendored
Normal file
71
deps/libcaption/examples/srtdump.c
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "srt.h"
|
||||
#include "avc.h"
|
||||
// #include "sei.h"
|
||||
|
||||
#define MAX_SRT_SIZE (10*1024*1024)
|
||||
#define MAX_READ_SIZE 4096
|
||||
|
||||
size_t read_file (FILE* file, utf8_char_t* data, size_t size)
|
||||
{
|
||||
size_t read, totl = 0;
|
||||
|
||||
while (0 < (read = fread (data,1,MAX_READ_SIZE<size?MAX_READ_SIZE:size,file))) {
|
||||
totl += read; data += read; size -= read;
|
||||
}
|
||||
|
||||
return totl;
|
||||
}
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
srt_t* srt;
|
||||
caption_frame_t frame;
|
||||
|
||||
if (argc < 2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE* file = fopen (argv[1],"r");
|
||||
|
||||
if (! file) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
utf8_char_t* data = (utf8_char_t*) malloc (MAX_SRT_SIZE);
|
||||
size_t size = read_file (file,data,MAX_SRT_SIZE);
|
||||
srt_t* head = srt_parse (data,size);
|
||||
|
||||
for (srt = head ; srt ; srt = srt->next) {
|
||||
caption_frame_init (&frame);
|
||||
srt_to_caption_frame (srt,&frame);
|
||||
caption_frame_dump (&frame);
|
||||
}
|
||||
|
||||
srt_free (head);
|
||||
}
|
||||
117
deps/libcaption/examples/ts.c
vendored
Normal file
117
deps/libcaption/examples/ts.c
vendored
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "ts.h"
|
||||
#include <string.h>
|
||||
|
||||
void ts_init (ts_t* ts)
|
||||
{
|
||||
memset (ts,0,sizeof (ts_t));
|
||||
}
|
||||
|
||||
static int64_t ts_parse_pts (const uint8_t* data)
|
||||
{
|
||||
// 0000 1110 1111 1111 1111 1110 1111 1111 1111 1110
|
||||
uint64_t pts = 0;
|
||||
pts |= (uint64_t) (data[0] & 0x0E) << 29;
|
||||
pts |= (uint64_t) (data[1] & 0xFF) << 22;
|
||||
pts |= (uint64_t) (data[2] & 0xFE) << 14;
|
||||
pts |= (uint64_t) (data[3] & 0xFF) << 7;
|
||||
pts |= (uint64_t) (data[4] & 0xFE) >> 1;
|
||||
return pts;
|
||||
}
|
||||
|
||||
int ts_parse_packet (ts_t* ts, const uint8_t* data)
|
||||
{
|
||||
size_t i = 0;
|
||||
int pusi = !! (data[i + 1] & 0x40); // Payload Unit Start Indicator
|
||||
int16_t pid = ( (data[i + 1] & 0x1F) << 8) | data[i + 2]; // PID
|
||||
int adaption_present = !! (data[i + 3] & 0x20); // Adaptation field exist
|
||||
int payload_present = !! (data[i + 3] & 0x10); // Contains payload
|
||||
i += 4;
|
||||
|
||||
ts->data = 0;
|
||||
ts->size = 0;
|
||||
|
||||
if (adaption_present) {
|
||||
uint8_t adaption_length = data[i + 0]; // adaption field length
|
||||
i += 1 + adaption_length;
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
if (payload_present) {
|
||||
// Skip the payload.
|
||||
i += data[i] + 1;
|
||||
}
|
||||
|
||||
ts->pmtpid = ( (data[i + 10] & 0x1F) << 8) | data[i + 11];
|
||||
} else if (pid == ts->pmtpid) {
|
||||
// PMT
|
||||
if (payload_present) {
|
||||
// Skip the payload.
|
||||
i += data[i] + 1;
|
||||
}
|
||||
|
||||
uint16_t section_length = ( (data[i + 1] & 0x0F) << 8) | data[i + 2];
|
||||
int current = data[i + 5] & 0x01;
|
||||
int16_t program_info_length = ( (data[i + 10] & 0x0F) << 8) | data[i + 11];
|
||||
int16_t descriptor_loop_length = section_length - (9 + program_info_length + 4); // 4 for the crc
|
||||
|
||||
i += 12 + program_info_length;
|
||||
|
||||
if (current) {
|
||||
while (descriptor_loop_length >= 5) {
|
||||
uint8_t stream_type = data[i];
|
||||
int16_t elementary_pid = ( (data[i + 1] & 0x1F) << 8) | data[i + 2];
|
||||
int16_t esinfo_length = ( (data[i + 3] & 0x0F) << 8) | data[i + 4];
|
||||
|
||||
if (0x1B == stream_type) {
|
||||
ts->avcpid = elementary_pid;
|
||||
}
|
||||
|
||||
i += 5 + esinfo_length;
|
||||
descriptor_loop_length -= 5 + esinfo_length;
|
||||
}
|
||||
}
|
||||
} else if (payload_present && pid == ts->avcpid) {
|
||||
if (pusi) {
|
||||
// int data_alignment = !! (data[i + 6] & 0x04);
|
||||
int has_pts = !! (data[i + 7] & 0x80);
|
||||
int has_dts = !! (data[i + 7] & 0x40);
|
||||
uint8_t header_length = data[i + 8];
|
||||
|
||||
if (has_pts) {
|
||||
ts->pts = ts_parse_pts (&data[i + 9]);
|
||||
ts->dts = has_dts ? ts_parse_pts (&data[i + 14]) : ts->pts;
|
||||
}
|
||||
|
||||
i += 9 + header_length;
|
||||
}
|
||||
|
||||
ts->data = &data[i];
|
||||
ts->size = TS_PACKET_SIZE-i;
|
||||
return LIBCAPTION_READY;
|
||||
}
|
||||
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
49
deps/libcaption/examples/ts.h
vendored
Normal file
49
deps/libcaption/examples/ts.h
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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 LIBCAPTION_TS_H
|
||||
#define LIBCAPTION_TS_H
|
||||
#include "caption.h"
|
||||
typedef struct {
|
||||
int16_t pmtpid;
|
||||
int16_t avcpid;
|
||||
int64_t pts;
|
||||
int64_t dts;
|
||||
size_t size;
|
||||
const uint8_t* data;
|
||||
} ts_t;
|
||||
|
||||
/*! \brief
|
||||
\param
|
||||
|
||||
Expects 188 byte TS packet
|
||||
*/
|
||||
#define TS_PACKET_SIZE 188
|
||||
void ts_init (ts_t* ts);
|
||||
int ts_parse_packet (ts_t* ts, const uint8_t* data);
|
||||
// return timestamp in seconds
|
||||
static inline double ts_dts_seconds (ts_t* ts) { return ts->dts / 90000.0; }
|
||||
static inline double ts_pts_seconds (ts_t* ts) { return ts->pts / 90000.0; }
|
||||
static inline double ts_cts_seconds (ts_t* ts) { return (ts->dts - ts->pts) / 90000.0; }
|
||||
|
||||
#endif
|
||||
101
deps/libcaption/examples/ts2srt.c
vendored
Normal file
101
deps/libcaption/examples/ts2srt.c
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "ts.h"
|
||||
#include "srt.h"
|
||||
#include "avc.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
const char* path = argv[1];
|
||||
|
||||
ts_t ts;
|
||||
sei_t sei;
|
||||
avcnalu_t nalu;
|
||||
srt_t* srt = 0, *head = 0;
|
||||
caption_frame_t frame;
|
||||
uint8_t pkt[TS_PACKET_SIZE];
|
||||
ts_init (&ts);
|
||||
avcnalu_init (&nalu);
|
||||
caption_frame_init (&frame);
|
||||
|
||||
FILE* file = fopen (path,"rb+");
|
||||
|
||||
while (TS_PACKET_SIZE == fread (&pkt[0],1,TS_PACKET_SIZE, file)) {
|
||||
switch (ts_parse_packet (&ts,&pkt[0])) {
|
||||
case LIBCAPTION_OK:
|
||||
// fprintf (stderr,"read ts packet\n");
|
||||
break;
|
||||
|
||||
case LIBCAPTION_READY: {
|
||||
// fprintf (stderr,"read ts packet DATA\n");
|
||||
while (ts.size) {
|
||||
// fprintf (stderr,"ts.size %d (%02X%02X%02X%02X)\n",ts.size, ts.data[0], ts.data[1], ts.data[2], ts.data[3]);
|
||||
|
||||
switch (avcnalu_parse_annexb (&nalu, &ts.data, &ts.size)) {
|
||||
case LIBCAPTION_OK:
|
||||
break;
|
||||
|
||||
case LIBCAPTION_ERROR:
|
||||
// fprintf (stderr,"LIBCAPTION_ERROR == avcnalu_parse_annexb()\n");
|
||||
avcnalu_init (&nalu);
|
||||
break;
|
||||
|
||||
case LIBCAPTION_READY: {
|
||||
|
||||
if (6 == avcnalu_type (&nalu)) {
|
||||
// fprintf (stderr,"NALU %d (%d)\n", avcnalu_type (&nalu), avcnalu_size (&nalu));
|
||||
sei_init (&sei);
|
||||
sei_parse_avcnalu (&sei, &nalu, ts_dts_seconds (&ts), ts_cts_seconds (&ts));
|
||||
|
||||
// sei_dump (&sei);
|
||||
|
||||
if (LIBCAPTION_READY == sei_to_caption_frame (&sei,&frame)) {
|
||||
// caption_frame_dump (&frame);
|
||||
srt = srt_from_caption_frame (&frame,srt,&head);
|
||||
|
||||
// srt_dump (srt);
|
||||
}
|
||||
|
||||
sei_free (&sei);
|
||||
}
|
||||
|
||||
avcnalu_init (&nalu);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
case LIBCAPTION_ERROR:
|
||||
// fprintf (stderr,"read ts packet ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
srt_dump (head);
|
||||
srt_free (head);
|
||||
|
||||
return 1;
|
||||
}
|
||||
2794
deps/libcaption/examples/wonderland.h
vendored
Normal file
2794
deps/libcaption/examples/wonderland.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
deps/libcaption/format.sh
vendored
Normal file
3
deps/libcaption/format.sh
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
cd "$(dirname "$0")"
|
||||
find . \( -name '*.cpp' -o -name '*.c' -o -name '*.h' -o -name '*.hpp' -o -name '*.re2c' \) -exec astyle --style=stroustrup --attach-extern-c --break-blocks --pad-header --pad-paren-out --unpad-paren --add-brackets --keep-one-line-blocks --keep-one-line-statements --convert-tabs --align-pointer=type --align-reference=type --suffix=none --lineend=linux --max-code-length=180 {} \;
|
||||
595
deps/libcaption/src/avc.c
vendored
Normal file
595
deps/libcaption/src/avc.c
vendored
Normal file
|
|
@ -0,0 +1,595 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include "avc.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// AVC RBSP Methods
|
||||
// TODO move the to a avcutils file
|
||||
static size_t _find_emulation_prevention_byte (const uint8_t* data, size_t size)
|
||||
{
|
||||
size_t offset = 2;
|
||||
|
||||
while (offset < size) {
|
||||
if (0 == data[offset]) {
|
||||
// 0 0 X 3 //; we know X is zero
|
||||
offset += 1;
|
||||
} else if (3 != data[offset]) {
|
||||
// 0 0 X 0 0 3; we know X is not 0 and not 3
|
||||
offset += 3;
|
||||
} else if (0 != data[offset-1]) {
|
||||
// 0 X 0 0 3
|
||||
offset += 2;
|
||||
} else if (0 != data[offset-2]) {
|
||||
// X 0 0 3
|
||||
offset += 1;
|
||||
} else {
|
||||
// 0 0 3
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static size_t _copy_to_rbsp (uint8_t* destData, size_t destSize, const uint8_t* sorcData, size_t sorcSize)
|
||||
{
|
||||
size_t toCopy, totlSize = 0;
|
||||
|
||||
for (;;) {
|
||||
if (destSize >= sorcSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The following line IS correct! We want to look in sorcData up to destSize bytes
|
||||
// We know destSize is smaller than sorcSize because of the previous line
|
||||
toCopy = _find_emulation_prevention_byte (sorcData,destSize);
|
||||
memcpy (destData, sorcData, toCopy);
|
||||
totlSize += toCopy;
|
||||
destData += toCopy;
|
||||
destSize -= toCopy;
|
||||
|
||||
if (0 == destSize) {
|
||||
return totlSize;
|
||||
}
|
||||
|
||||
// skip the emulation prevention byte
|
||||
totlSize += 1;
|
||||
sorcData += toCopy + 1;
|
||||
sorcSize -= toCopy + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static inline size_t _find_emulated (uint8_t* data, size_t size)
|
||||
{
|
||||
size_t offset = 2;
|
||||
|
||||
while (offset < size) {
|
||||
if (3 < data[offset]) {
|
||||
// 0 0 X; we know X is not 0, 1, 2 or 3
|
||||
offset += 3;
|
||||
} else if (0 != data[offset-1]) {
|
||||
// 0 X 0 0 1
|
||||
offset += 2;
|
||||
} else if (0 != data[offset-2]) {
|
||||
// X 0 0 1
|
||||
offset += 1;
|
||||
} else {
|
||||
// 0 0 0, 0 0 1
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t _copy_from_rbsp (uint8_t* data, uint8_t* payloadData, size_t payloadSize)
|
||||
{
|
||||
size_t total = 0;
|
||||
|
||||
while (payloadSize) {
|
||||
size_t bytes = _find_emulated (payloadData,payloadSize);
|
||||
|
||||
if (bytes > payloadSize) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy (data, payloadData, bytes);
|
||||
|
||||
if (bytes == payloadSize) {
|
||||
return total + bytes;
|
||||
}
|
||||
|
||||
data[bytes] = 3; // insert emulation prevention byte
|
||||
data += bytes + 1; total += bytes + 1;
|
||||
payloadData += bytes; payloadSize -= bytes;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
struct _sei_message_t {
|
||||
size_t size;
|
||||
sei_msgtype_t type;
|
||||
struct _sei_message_t* next;
|
||||
};
|
||||
|
||||
sei_message_t* sei_message_next (sei_message_t* msg) { return ( (struct _sei_message_t*) msg)->next; }
|
||||
sei_msgtype_t sei_message_type (sei_message_t* msg) { return ( (struct _sei_message_t*) msg)->type; }
|
||||
size_t sei_message_size (sei_message_t* msg) { return ( (struct _sei_message_t*) msg)->size; }
|
||||
uint8_t* sei_message_data (sei_message_t* msg) { return ( (uint8_t*) msg) + sizeof (struct _sei_message_t); }
|
||||
void sei_message_free (sei_message_t* msg) { if (msg) { free (msg); } }
|
||||
|
||||
sei_message_t* sei_message_new (sei_msgtype_t type, uint8_t* data, size_t size)
|
||||
{
|
||||
struct _sei_message_t* msg = (struct _sei_message_t*) malloc (sizeof (struct _sei_message_t) + size);
|
||||
msg->next = 0; msg->type = type; msg->size = size;
|
||||
|
||||
if (data) {
|
||||
memcpy (sei_message_data (msg), data, size);
|
||||
} else {
|
||||
memset (sei_message_data (msg), 0, size);
|
||||
}
|
||||
|
||||
return (sei_message_t*) msg;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void sei_init (sei_t* sei)
|
||||
{
|
||||
sei->dts = -1;
|
||||
sei->cts = -1;
|
||||
sei->head = 0;
|
||||
sei->tail = 0;
|
||||
}
|
||||
|
||||
void sei_message_append (sei_t* sei, sei_message_t* msg)
|
||||
{
|
||||
if (0 == sei->head) {
|
||||
sei->head = msg;
|
||||
sei->tail = msg;
|
||||
} else {
|
||||
sei->tail->next = msg;
|
||||
sei->tail = msg;
|
||||
}
|
||||
}
|
||||
|
||||
void sei_free (sei_t* sei)
|
||||
{
|
||||
sei_message_t* tail;
|
||||
|
||||
while (sei->head) {
|
||||
tail = sei->head->next;
|
||||
free (sei->head);
|
||||
sei->head = tail;
|
||||
}
|
||||
|
||||
sei_init (sei);
|
||||
}
|
||||
|
||||
void sei_dump (sei_t* sei)
|
||||
{
|
||||
fprintf (stderr,"SEI %p\n", sei);
|
||||
sei_dump_messages (sei->head);
|
||||
}
|
||||
|
||||
void sei_dump_messages (sei_message_t* head)
|
||||
{
|
||||
cea708_t cea708;
|
||||
sei_message_t* msg;
|
||||
cea708_init (&cea708);
|
||||
|
||||
for (msg = head ; msg ; msg = sei_message_next (msg)) {
|
||||
uint8_t* data = sei_message_data (msg);
|
||||
size_t size = sei_message_size (msg);
|
||||
fprintf (stderr,"-- Message %p\n-- Message Type: %d\n-- Message Size: %d\n", data, sei_message_type (msg), (int) size);
|
||||
|
||||
while (size) {
|
||||
fprintf (stderr,"%02X ", *data);
|
||||
++data; --size;
|
||||
}
|
||||
|
||||
fprintf (stderr,"\n");
|
||||
|
||||
if (sei_type_user_data_registered_itu_t_t35 == sei_message_type (msg)) {
|
||||
cea708_parse (sei_message_data (msg), sei_message_size (msg), &cea708);
|
||||
cea708_dump (&cea708);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t sei_render_size (sei_t* sei)
|
||||
{
|
||||
size_t size = 2; // nalu_type + stop bit
|
||||
sei_message_t* msg;
|
||||
|
||||
for (msg = sei_message_head (sei) ; msg ; msg = sei_message_next (msg)) {
|
||||
size += 1 + (msg->type / 255);
|
||||
size += 1 + (msg->size / 255);
|
||||
size += 1 + (msg->size * 4/3);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// we can safely assume sei_render_size() bytes have been allocated for data
|
||||
size_t sei_render (sei_t* sei, uint8_t* data)
|
||||
{
|
||||
size_t escaped_size, size = 2; // nalu_type + stop bit
|
||||
sei_message_t* msg;
|
||||
(*data) = 6; ++data;
|
||||
|
||||
for (msg = sei_message_head (sei) ; msg ; msg = sei_message_next (msg)) {
|
||||
int payloadType = sei_message_type (msg);
|
||||
int payloadSize = (int) sei_message_size (msg);
|
||||
uint8_t* payloadData = sei_message_data (msg);
|
||||
|
||||
while (255 <= payloadType) {
|
||||
(*data) = 255;
|
||||
++data; ++size;
|
||||
payloadType -= 255;
|
||||
}
|
||||
|
||||
(*data) = payloadType;
|
||||
++data; ++size;
|
||||
|
||||
while (255 <= payloadSize) {
|
||||
(*data) = 255;
|
||||
++data; ++size;
|
||||
payloadSize -= 255;
|
||||
}
|
||||
|
||||
(*data) = payloadSize;
|
||||
++data; ++size;
|
||||
|
||||
if (0 >= (escaped_size = _copy_from_rbsp (data,payloadData,payloadSize))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
data += escaped_size;
|
||||
size += escaped_size;
|
||||
}
|
||||
|
||||
// write stop bit and return
|
||||
(*data) = 0x80;
|
||||
return size;
|
||||
}
|
||||
|
||||
uint8_t* sei_render_alloc (sei_t* sei, size_t* size)
|
||||
{
|
||||
size_t aloc = sei_render_size (sei);
|
||||
uint8_t* data = malloc (aloc);
|
||||
(*size) = sei_render (sei, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int sei_parse_nalu (sei_t* sei, const uint8_t* data, size_t size, double dts, double cts)
|
||||
{
|
||||
assert (0<=cts); // cant present before decode
|
||||
sei->dts = dts;
|
||||
sei->cts = cts;
|
||||
int ret = 0;
|
||||
|
||||
if (0 == data || 0 == size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t nal_unit_type = (*data) & 0x1F;
|
||||
++data; --size;
|
||||
|
||||
if (6 != nal_unit_type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SEI may contain more than one payload
|
||||
while (1<size) {
|
||||
int payloadType = 0;
|
||||
int payloadSize = 0;
|
||||
|
||||
while (0 < size && 255 == (*data)) {
|
||||
payloadType += 255;
|
||||
++data; --size;
|
||||
}
|
||||
|
||||
if (0 == size) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
payloadType += (*data);
|
||||
++data; --size;
|
||||
|
||||
while (0 < size && 255 == (*data)) {
|
||||
payloadSize += 255;
|
||||
++data; --size;
|
||||
}
|
||||
|
||||
if (0 == size) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
payloadSize += (*data);
|
||||
++data; --size;
|
||||
|
||||
if (payloadSize) {
|
||||
sei_message_t* msg = sei_message_new ( (sei_msgtype_t) payloadType, 0, payloadSize);
|
||||
uint8_t* payloadData = sei_message_data (msg);
|
||||
size_t bytes = _copy_to_rbsp (payloadData, payloadSize, data, size);
|
||||
sei_message_append (sei, msg);
|
||||
|
||||
if ( (int) bytes < payloadSize) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
data += bytes; size -= bytes;
|
||||
++ret;
|
||||
}
|
||||
}
|
||||
|
||||
// There should be one trailing byte, 0x80. But really, we can just ignore that fact.
|
||||
return ret;
|
||||
error:
|
||||
sei_init (sei);
|
||||
return 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
libcaption_stauts_t sei_to_caption_frame (sei_t* sei, caption_frame_t* frame)
|
||||
{
|
||||
cea708_t cea708;
|
||||
sei_message_t* msg;
|
||||
libcaption_stauts_t status = LIBCAPTION_OK;
|
||||
|
||||
cea708_init (&cea708);
|
||||
|
||||
for (msg = sei_message_head (sei) ; msg ; msg = sei_message_next (msg)) {
|
||||
if (sei_type_user_data_registered_itu_t_t35 == sei_message_type (msg)) {
|
||||
cea708_parse (sei_message_data (msg), sei_message_size (msg), &cea708);
|
||||
status = libcaption_status_update (status, cea708_to_caption_frame (frame, &cea708, sei_pts (sei)));
|
||||
}
|
||||
}
|
||||
|
||||
if (LIBCAPTION_READY == status) {
|
||||
frame->timestamp = sei->dts + sei->cts;
|
||||
frame->duration = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define DEFAULT_CHANNEL 0
|
||||
|
||||
void sei_append_708 (sei_t* sei, cea708_t* cea708)
|
||||
{
|
||||
sei_message_t* msg = sei_message_new (sei_type_user_data_registered_itu_t_t35, 0, CEA608_MAX_SIZE);
|
||||
msg->size = cea708_render (cea708, sei_message_data (msg), sei_message_size (msg));
|
||||
sei_message_append (sei,msg);
|
||||
// cea708_dump (cea708);
|
||||
cea708_init (cea708); // will confgure using HLS compatiable defaults
|
||||
}
|
||||
|
||||
// This should be moved to 708.c
|
||||
// This works for popon, but bad for paint on and roll up
|
||||
// Please understand this function before you try to use it, setting null values have different effects than you may assume
|
||||
void sei_encode_eia608 (sei_t* sei, cea708_t* cea708, uint16_t cc_data)
|
||||
{
|
||||
// This one is full, flush and init a new one
|
||||
// shoudl this be 32? I cant remember
|
||||
if (31 == cea708->user_data.cc_count) {
|
||||
sei_append_708 (sei,cea708);
|
||||
}
|
||||
|
||||
if (0 == cea708->user_data.cc_count) { // This is a new 708 header, but a continuation of a 608 stream
|
||||
cea708_add_cc_data (cea708, 1, cc_type_ntsc_cc_field_1, eia608_control_command (eia608_control_resume_caption_loading, DEFAULT_CHANNEL));
|
||||
}
|
||||
|
||||
if (0 == cc_data) { // Finished
|
||||
sei_encode_eia608 (sei,cea708,eia608_control_command (eia608_control_end_of_caption, DEFAULT_CHANNEL));
|
||||
sei_append_708 (sei,cea708);
|
||||
return;
|
||||
}
|
||||
|
||||
cea708_add_cc_data (cea708, 1, cc_type_ntsc_cc_field_1, cc_data);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO use alternate charcters instead of always using space before extended charcters
|
||||
// TODO rewrite this function with better logic
|
||||
int sei_from_caption_frame (sei_t* sei, caption_frame_t* frame)
|
||||
{
|
||||
int r,c;
|
||||
cea708_t cea708;
|
||||
const char* data;
|
||||
uint16_t prev_cc_data;
|
||||
|
||||
cea708_init (&cea708); // set up a new popon frame
|
||||
cea708_add_cc_data (&cea708, 1, cc_type_ntsc_cc_field_1, eia608_control_command (eia608_control_erase_non_displayed_memory, DEFAULT_CHANNEL));
|
||||
cea708_add_cc_data (&cea708, 1, cc_type_ntsc_cc_field_1, eia608_control_command (eia608_control_resume_caption_loading, DEFAULT_CHANNEL));
|
||||
|
||||
for (r=0; r<SCREEN_ROWS; ++r) {
|
||||
// Calculate preamble
|
||||
for (c=0; c<SCREEN_COLS && 0 == *caption_frame_read_char (frame,r,c,0,0) ; ++c) {}
|
||||
|
||||
// This row is blank
|
||||
if (SCREEN_COLS == c) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write preamble
|
||||
sei_encode_eia608 (sei, &cea708, eia608_row_column_pramble (r,c,DEFAULT_CHANNEL,0));
|
||||
int tab = c % 4;
|
||||
|
||||
if (tab) {
|
||||
sei_encode_eia608 (sei, &cea708, eia608_tab (tab,DEFAULT_CHANNEL));
|
||||
}
|
||||
|
||||
// Write the row
|
||||
for (prev_cc_data = 0, data = caption_frame_read_char (frame,r,c,0,0) ;
|
||||
(*data) && c < SCREEN_COLS ; ++c, data = caption_frame_read_char (frame,r,c,0,0)) {
|
||||
uint16_t cc_data = eia608_from_utf8_1 (data,DEFAULT_CHANNEL);
|
||||
|
||||
if (!cc_data) {
|
||||
// We do't want to write bad data, so just ignore it.
|
||||
} else if (eia608_is_basicna (prev_cc_data)) {
|
||||
if (eia608_is_basicna (cc_data)) {
|
||||
// previous and current chars are both basicna, combine them into current
|
||||
sei_encode_eia608 (sei, &cea708, eia608_from_basicna (prev_cc_data,cc_data));
|
||||
} else if (eia608_is_westeu (cc_data)) {
|
||||
// extended charcters overwrite the previous charcter, so insert a dummy char thren write the extended char
|
||||
sei_encode_eia608 (sei, &cea708, eia608_from_basicna (prev_cc_data,eia608_from_utf8_1 (EIA608_CHAR_SPACE,DEFAULT_CHANNEL)));
|
||||
sei_encode_eia608 (sei, &cea708, cc_data);
|
||||
} else {
|
||||
// previous was basic na, but current isnt; write previous and current
|
||||
sei_encode_eia608 (sei, &cea708, prev_cc_data);
|
||||
sei_encode_eia608 (sei, &cea708, cc_data);
|
||||
}
|
||||
|
||||
prev_cc_data = 0; // previous is handled, we can forget it now
|
||||
} else if (eia608_is_westeu (cc_data)) {
|
||||
// extended chars overwrite the previous chars, so insert a dummy char
|
||||
sei_encode_eia608 (sei, &cea708, eia608_from_utf8_1 (EIA608_CHAR_SPACE,DEFAULT_CHANNEL));
|
||||
sei_encode_eia608 (sei, &cea708, cc_data);
|
||||
} else if (eia608_is_basicna (cc_data)) {
|
||||
prev_cc_data = cc_data;
|
||||
} else {
|
||||
sei_encode_eia608 (sei, &cea708, cc_data);
|
||||
}
|
||||
|
||||
if (eia608_is_specialna (cc_data)) {
|
||||
// specialna are treated as controll charcters. Duplicated controll charcters are discarded
|
||||
// So we for a resume after a specialna as a noop to break repetition detection
|
||||
// TODO only do this if the same charcter is repeated
|
||||
sei_encode_eia608 (sei, &cea708, eia608_control_command (eia608_control_resume_caption_loading, DEFAULT_CHANNEL));
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != prev_cc_data) {
|
||||
sei_encode_eia608 (sei, &cea708, prev_cc_data);
|
||||
}
|
||||
}
|
||||
|
||||
sei_encode_eia608 (sei, &cea708, 0); // flush
|
||||
sei->dts = frame->timestamp; // assumes in order frames
|
||||
// sei_dump (sei);
|
||||
return 1;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static int avc_is_start_code (const uint8_t* data, int size, int* len)
|
||||
{
|
||||
if (3 > size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (1 < data[2]) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (0 != data[1]) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (0 == data[0]) {
|
||||
if (1 == data[2]) {
|
||||
*len = 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (4 <= size && 1 == data[3]) {
|
||||
*len = 4;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int avc_find_start_code (const uint8_t* data, int size, int* len)
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
for (;;) {
|
||||
// is pos pointing to a start code?
|
||||
int isc = avc_is_start_code (data + pos, size - pos, len);
|
||||
|
||||
if (0 < isc) {
|
||||
pos += isc;
|
||||
} else if (0 > isc) {
|
||||
// No start code found
|
||||
return isc;
|
||||
} else {
|
||||
// Start code found at pos
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int avc_find_start_code_increnental (const uint8_t* data, int size, int prev_size, int* len)
|
||||
{
|
||||
int offset = (3 <= prev_size) ? (prev_size - 3) : 0;
|
||||
int pos = avc_find_start_code (data + offset, size - offset, len);
|
||||
|
||||
if (0 <= pos) {
|
||||
return pos + offset;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void avcnalu_init (avcnalu_t* nalu)
|
||||
{
|
||||
memset (nalu,0,sizeof (avcnalu_t));
|
||||
}
|
||||
|
||||
int avcnalu_parse_annexb (avcnalu_t* nalu, const uint8_t** data, size_t* size)
|
||||
{
|
||||
int scpos, sclen;
|
||||
int new_size = (int) (nalu->size + (*size));
|
||||
|
||||
if (new_size > MAX_NALU_SIZE) {
|
||||
(*size) = nalu->size = 0;
|
||||
return LIBCAPTION_ERROR;
|
||||
}
|
||||
|
||||
memcpy (&nalu->data[nalu->size], (*data), (*size));
|
||||
scpos = avc_find_start_code_increnental (&nalu->data[0], new_size, (int) nalu->size, &sclen);
|
||||
|
||||
if (0<=scpos) {
|
||||
(*data) += (scpos - nalu->size) + sclen;
|
||||
(*size) -= (scpos - nalu->size) + sclen;
|
||||
nalu->size = scpos;
|
||||
return 0 < nalu->size ? LIBCAPTION_READY : LIBCAPTION_OK;
|
||||
} else {
|
||||
(*size) = 0;
|
||||
nalu->size = new_size;
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
}
|
||||
491
deps/libcaption/src/caption.c
vendored
Normal file
491
deps/libcaption/src/caption.c
vendored
Normal file
|
|
@ -0,0 +1,491 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "utf8.h"
|
||||
#include "xds.h"
|
||||
#include "eia608.h"
|
||||
#include "caption.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void caption_frame_buffer_clear (caption_frame_buffer_t* buff)
|
||||
{
|
||||
memset (buff,0,sizeof (caption_frame_buffer_t));
|
||||
}
|
||||
|
||||
void caption_frame_state_clear (caption_frame_t* frame)
|
||||
{
|
||||
frame->timestamp = -1;
|
||||
frame->duration = 0;
|
||||
frame->state = (caption_frame_state_t) {0,0,0,0,0,0,0}; // clear global state
|
||||
}
|
||||
|
||||
void caption_frame_init (caption_frame_t* frame)
|
||||
{
|
||||
caption_frame_state_clear (frame);
|
||||
xds_init (&frame->xds);
|
||||
caption_frame_buffer_clear (&frame->back);
|
||||
caption_frame_buffer_clear (&frame->front);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define CAPTION_CLEAR 0
|
||||
#define CAPTION_POP_ON 2
|
||||
#define CAPTION_PAINT_ON 3
|
||||
#define CAPTION_ROLL_UP 4
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
static caption_frame_cell_t* frame_buffer_cell (caption_frame_buffer_t* buff, int row, int col)
|
||||
{
|
||||
return &buff->cell[row][col];
|
||||
}
|
||||
|
||||
static caption_frame_buffer_t* frame_write_buffer (caption_frame_t* frame)
|
||||
{
|
||||
if (CAPTION_POP_ON == frame->state.mod) {
|
||||
return &frame->back;
|
||||
} else if (CAPTION_PAINT_ON == frame->state.mod || CAPTION_ROLL_UP == frame->state.mod) {
|
||||
return &frame->front;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static caption_frame_cell_t* frame_cell (caption_frame_t* frame, int row, int col)
|
||||
{
|
||||
return frame_buffer_cell (&frame->front,row,col);
|
||||
}
|
||||
|
||||
static caption_frame_cell_t* frame_cell_get (caption_frame_t* frame)
|
||||
{
|
||||
return frame_cell (frame, frame->state.row, frame->state.col);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
uint16_t _eia608_from_utf8 (const char* s); // function is in eia608.c.re2c
|
||||
int caption_frame_write_char (caption_frame_t* frame, int row, int col, eia608_style_t style, int underline, const char* c)
|
||||
{
|
||||
caption_frame_buffer_t* buff = frame_write_buffer (frame);
|
||||
|
||||
if (!buff || ! _eia608_from_utf8 (c)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
caption_frame_cell_t* cell = frame_buffer_cell (buff,row,col);
|
||||
|
||||
if (utf8_char_copy (&cell->data[0],c)) {
|
||||
cell->uln = underline;
|
||||
cell->sty = style;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const utf8_char_t* caption_frame_read_char (caption_frame_t* frame, int row, int col, eia608_style_t* style, int* underline)
|
||||
{
|
||||
caption_frame_cell_t* cell = frame_cell (frame, row, col);
|
||||
|
||||
if (!cell) {
|
||||
if (style) {
|
||||
(*style) = eia608_style_white;
|
||||
}
|
||||
|
||||
if (underline) {
|
||||
(*underline) = 0;
|
||||
}
|
||||
|
||||
return EIA608_CHAR_NULL;
|
||||
}
|
||||
|
||||
if (style) {
|
||||
(*style) = cell->sty;
|
||||
}
|
||||
|
||||
if (underline) {
|
||||
(*underline) = cell->uln;
|
||||
}
|
||||
|
||||
return &cell->data[0];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Parsing
|
||||
libcaption_stauts_t caption_frame_carriage_return (caption_frame_t* frame)
|
||||
{
|
||||
caption_frame_buffer_t* buff = frame_write_buffer (frame);
|
||||
|
||||
if (!buff) {
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
int r = frame->state.row - (frame->state.rup-1);
|
||||
|
||||
if (0 >= r || CAPTION_ROLL_UP != frame->state.mod) {
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
for (; r < SCREEN_ROWS; ++r) {
|
||||
uint8_t* dst = (uint8_t*) frame_buffer_cell (buff,r-1,0);
|
||||
uint8_t* src = (uint8_t*) frame_buffer_cell (buff,r-0,0);
|
||||
memcpy (dst,src,sizeof (caption_frame_cell_t) * SCREEN_COLS);
|
||||
}
|
||||
|
||||
memset (frame_buffer_cell (buff,SCREEN_ROWS-1,0), 0,sizeof (caption_frame_cell_t) * SCREEN_COLS);
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
libcaption_stauts_t eia608_write_char (caption_frame_t* frame, char* c)
|
||||
{
|
||||
if (0 == c || 0 == c[0] ||
|
||||
SCREEN_ROWS <= frame->state.row || 0 > frame->state.row ||
|
||||
SCREEN_COLS <= frame->state.col || 0 > frame->state.col) {
|
||||
// NO-OP
|
||||
} else if (caption_frame_write_char (frame,frame->state.row,frame->state.col,frame->state.sty,frame->state.uln, c)) {
|
||||
frame->state.col += 1;
|
||||
}
|
||||
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_end (caption_frame_t* frame)
|
||||
{
|
||||
memcpy (&frame->front,&frame->back,sizeof (caption_frame_buffer_t));
|
||||
caption_frame_state_clear (frame);
|
||||
caption_frame_buffer_clear (&frame->back);
|
||||
return LIBCAPTION_READY;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_decode_preamble (caption_frame_t* frame, uint16_t cc_data)
|
||||
{
|
||||
eia608_style_t sty;
|
||||
int row, col, chn, uln;
|
||||
|
||||
if (eia608_parse_preamble (cc_data, &row, &col, &sty, &chn, &uln)) {
|
||||
frame->state.row = row;
|
||||
frame->state.col = col;
|
||||
frame->state.sty = sty;
|
||||
frame->state.uln = uln;
|
||||
}
|
||||
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_decode_midrowchange (caption_frame_t* frame, uint16_t cc_data)
|
||||
{
|
||||
eia608_style_t sty;
|
||||
int chn, unl;
|
||||
|
||||
if (eia608_parse_midrowchange (cc_data,&chn,&sty,&unl)) {
|
||||
frame->state.sty = sty;
|
||||
frame->state.uln = unl;
|
||||
}
|
||||
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_backspace (caption_frame_t* frame)
|
||||
{
|
||||
// do not reverse wrap (tw 28:20)
|
||||
frame->state.col = (0 < frame->state.col) ? (frame->state.col - 1) : 0;
|
||||
caption_frame_write_char (frame,frame->state.row,frame->state.col,eia608_style_white,0,EIA608_CHAR_NULL);
|
||||
return LIBCAPTION_READY;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_decode_control (caption_frame_t* frame, uint16_t cc_data)
|
||||
{
|
||||
int cc;
|
||||
eia608_control_t cmd = eia608_parse_control (cc_data,&cc);
|
||||
|
||||
switch (cmd) {
|
||||
// PAINT ON
|
||||
case eia608_control_resume_direct_captioning:
|
||||
frame->state.rup = 0;
|
||||
frame->state.mod = CAPTION_PAINT_ON;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_erase_display_memory:
|
||||
caption_frame_buffer_clear (&frame->front);
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
// ROLL-UP
|
||||
case eia608_control_roll_up_2:
|
||||
frame->state.rup = 1;
|
||||
frame->state.mod = CAPTION_ROLL_UP;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_roll_up_3:
|
||||
frame->state.rup = 2;
|
||||
frame->state.mod = CAPTION_ROLL_UP;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_roll_up_4:
|
||||
frame->state.rup = 3;
|
||||
frame->state.mod = CAPTION_ROLL_UP;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_carriage_return:
|
||||
return caption_frame_carriage_return (frame);
|
||||
|
||||
// Corrections (Is this only valid as part of paint on?)
|
||||
case eia608_control_backspace:
|
||||
return caption_frame_backspace (frame);
|
||||
|
||||
case eia608_control_delete_to_end_of_row: {
|
||||
int c;
|
||||
|
||||
for (c = frame->state.col ; c < SCREEN_COLS ; ++c) {
|
||||
caption_frame_write_char (frame,frame->state.row,c,eia608_style_white,0,EIA608_CHAR_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return LIBCAPTION_READY;
|
||||
|
||||
// POP ON
|
||||
case eia608_control_resume_caption_loading:
|
||||
frame->state.rup = 0;
|
||||
frame->state.mod = CAPTION_POP_ON;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_erase_non_displayed_memory:
|
||||
caption_frame_buffer_clear (&frame->back);
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case eia608_control_end_of_caption:
|
||||
return caption_frame_end (frame);
|
||||
|
||||
// cursor positioning
|
||||
case eia608_tab_offset_0:
|
||||
case eia608_tab_offset_1:
|
||||
case eia608_tab_offset_2:
|
||||
case eia608_tab_offset_3:
|
||||
frame->state.col += (cmd - eia608_tab_offset_0);
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
// Unhandled
|
||||
default:
|
||||
case eia608_control_alarm_off:
|
||||
case eia608_control_alarm_on:
|
||||
case eia608_control_text_restart:
|
||||
case eia608_control_text_resume_text_display:
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_decode_text (caption_frame_t* frame, uint16_t cc_data)
|
||||
{
|
||||
int chan;
|
||||
char char1[5], char2[5];
|
||||
size_t chars = eia608_to_utf8 (cc_data, &chan, &char1[0], &char2[0]);
|
||||
|
||||
if (eia608_is_westeu (cc_data)) {
|
||||
// Extended charcters replace the previous charcter for back compatibility
|
||||
caption_frame_backspace (frame);
|
||||
}
|
||||
|
||||
if (0 < chars) {
|
||||
eia608_write_char (frame,char1);
|
||||
}
|
||||
|
||||
if (1 < chars) {
|
||||
eia608_write_char (frame,char2);
|
||||
}
|
||||
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
libcaption_stauts_t caption_frame_decode (caption_frame_t* frame, uint16_t cc_data, double timestamp)
|
||||
{
|
||||
libcaption_stauts_t status = LIBCAPTION_OK;
|
||||
|
||||
if (!eia608_parity_varify (cc_data)) {
|
||||
return LIBCAPTION_ERROR;
|
||||
}
|
||||
|
||||
if (eia608_is_padding (cc_data)) {
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
// skip duplicate controll commands. We also skip duplicate specialna to match the behaviour of iOS/vlc
|
||||
if ( (eia608_is_specialna (cc_data) || eia608_is_control (cc_data)) && cc_data == frame->state.cc_data) {
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
if (0 > frame->timestamp && 0 < timestamp) {
|
||||
frame->timestamp = timestamp;
|
||||
}
|
||||
|
||||
frame->state.cc_data = cc_data;
|
||||
|
||||
if (frame->xds.state) {
|
||||
status = xds_decode (&frame->xds,cc_data);
|
||||
} else if (eia608_is_xds (cc_data)) {
|
||||
status = xds_decode (&frame->xds,cc_data);
|
||||
} else if (eia608_is_control (cc_data)) {
|
||||
status = caption_frame_decode_control (frame,cc_data);
|
||||
} else if (eia608_is_basicna (cc_data) ||
|
||||
eia608_is_specialna (cc_data) ||
|
||||
eia608_is_westeu (cc_data)) {
|
||||
|
||||
// Don't decode text if we dont know what mode we are in.
|
||||
if (CAPTION_CLEAR == frame->state.mod) {
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
|
||||
status = caption_frame_decode_text (frame,cc_data);
|
||||
|
||||
// If we are in paint on mode, display immiditally
|
||||
if (1 == status && (CAPTION_PAINT_ON == frame->state.mod || CAPTION_ROLL_UP == frame->state.mod)) {
|
||||
status = LIBCAPTION_READY;
|
||||
}
|
||||
} else if (eia608_is_preamble (cc_data)) {
|
||||
status = caption_frame_decode_preamble (frame,cc_data);
|
||||
} else if (eia608_is_midrowchange (cc_data)) {
|
||||
status = caption_frame_decode_midrowchange (frame,cc_data);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int caption_frame_from_text (caption_frame_t* frame, const utf8_char_t* data)
|
||||
{
|
||||
int r, c, chan = 0;
|
||||
ssize_t size = (ssize_t) strlen (data);
|
||||
size_t char_count, char_length, line_length = 0, trimmed_length = 0;
|
||||
caption_frame_init (frame);
|
||||
frame->state.mod = CAPTION_POP_ON;
|
||||
|
||||
for (r = 0 ; 0 < size && SCREEN_ROWS > r ; ++r) {
|
||||
const utf8_char_t* cap_data = data;
|
||||
line_length = utf8_line_length (cap_data);
|
||||
trimmed_length = utf8_trimmed_length (cap_data,line_length);
|
||||
char_count = utf8_char_count (cap_data,trimmed_length);
|
||||
|
||||
// If char_count is greater than one line can display, split it.
|
||||
if (SCREEN_COLS < char_count) {
|
||||
char_count = utf8_wrap_length (cap_data,SCREEN_COLS);
|
||||
line_length = utf8_string_length (cap_data,char_count+1);
|
||||
}
|
||||
|
||||
// Write the line
|
||||
for (c = 0 ; c < (int) char_count ; ++c) {
|
||||
caption_frame_write_char (frame,r,c,eia608_style_white,0,&cap_data[0]);
|
||||
char_length = utf8_char_length (cap_data);
|
||||
cap_data += char_length;
|
||||
}
|
||||
|
||||
data += line_length;
|
||||
size -= (ssize_t) line_length;
|
||||
}
|
||||
|
||||
caption_frame_end (frame);
|
||||
return 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void caption_frame_to_text (caption_frame_t* frame, utf8_char_t* data)
|
||||
{
|
||||
int r, c, x, s, uln;
|
||||
eia608_style_t sty;
|
||||
|
||||
data[0] = 0;
|
||||
|
||||
for (r = 0 ; r < SCREEN_ROWS ; ++r) {
|
||||
for (c = 0, x = 0 ; c < SCREEN_COLS ; ++c) {
|
||||
const char* chr = caption_frame_read_char (frame, r, c, &sty, &uln);
|
||||
|
||||
if (0 < (s = (int) utf8_char_copy (data,chr))) {
|
||||
++x; data += s;
|
||||
}
|
||||
}
|
||||
|
||||
if (x) {
|
||||
strcpy ( (char*) data,"\r\n");
|
||||
data += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
size_t caption_frame_dump_buffer (caption_frame_t* frame, utf8_char_t* buf)
|
||||
{
|
||||
int r, c;
|
||||
size_t bytes, total = 0;
|
||||
bytes = sprintf (buf, " row: %d\tcol: %d\n mode: %s\troll-up: %d\n",
|
||||
frame->state.row, frame->state.col,
|
||||
eia608_mode_map[frame->state.mod],frame->state.rup?1+frame->state.rup:0);
|
||||
total += bytes; buf += bytes;
|
||||
bytes = sprintf (buf, " 00000000001111111111222222222233\n 01234567890123456789012345678901\n %s--------------------------------%s\n",
|
||||
EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT, EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT);
|
||||
total += bytes; buf += bytes;
|
||||
|
||||
for (r = 0 ; r < SCREEN_ROWS ; ++r) {
|
||||
bytes = sprintf (buf, "%02d%s", r, EIA608_CHAR_VERTICAL_LINE);
|
||||
total += bytes; buf += bytes;
|
||||
|
||||
for (c = 0 ; c < SCREEN_COLS ; ++c) {
|
||||
caption_frame_cell_t* cell = frame_cell (frame,r,c);
|
||||
bytes = utf8_char_copy (buf, (0==cell->data[0]) ?EIA608_CHAR_SPACE:&cell->data[0]);
|
||||
total += bytes; buf += bytes;
|
||||
}
|
||||
|
||||
bytes = sprintf (buf, "%s\n", EIA608_CHAR_VERTICAL_LINE);
|
||||
total += bytes; buf += bytes;
|
||||
}
|
||||
|
||||
bytes = sprintf (buf, " %s--------------------------------%s\n",
|
||||
EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT, EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT);
|
||||
total += bytes; buf += bytes;
|
||||
return total;
|
||||
}
|
||||
|
||||
void caption_frame_dump (caption_frame_t* frame)
|
||||
{
|
||||
utf8_char_t buff[CAPTION_FRAME_DUMP_BUF_SIZE];
|
||||
size_t size = caption_frame_dump_buffer (frame, buff);
|
||||
fprintf (stderr,"%s\n", buff);
|
||||
}
|
||||
|
||||
size_t caption_frame_json (caption_frame_t* frame, utf8_char_t* buf)
|
||||
{
|
||||
size_t bytes, total = 0;
|
||||
int r,c,count = 0;
|
||||
bytes = sprintf (buf, "{\"format\":\"eia608\",\"mode\":\"%s\",\"rollUp\":%d,\"data\":[",
|
||||
eia608_mode_map[frame->state.mod],frame->state.rup?1+frame->state.rup:0);
|
||||
total += bytes; buf += bytes;
|
||||
|
||||
for (r = 0 ; r < SCREEN_ROWS ; ++r) {
|
||||
for (c = 0 ; c < SCREEN_COLS ; ++c) {
|
||||
caption_frame_cell_t* cell = frame_cell (frame,r,c);
|
||||
|
||||
if (0 != cell->data[0]) {
|
||||
const char* data = ('"' == cell->data[0]) ?"\\\"": (const char*) &cell->data[0]; //escape quote
|
||||
bytes = sprintf (buf, "%s\n{\"row\":%d,\"col\":%d,\"char\":\"%s\",\"style\":\"%s\"}",
|
||||
(0<count?",":""),r,c,data,eia608_style_map[cell->sty]);
|
||||
total += bytes; buf += bytes; ++count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bytes = sprintf (buf, "\n]}\n");
|
||||
total += bytes; buf += bytes;
|
||||
return total;
|
||||
}
|
||||
207
deps/libcaption/src/cea708.c
vendored
Normal file
207
deps/libcaption/src/cea708.c
vendored
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "cea708.h"
|
||||
#include <memory.h>
|
||||
|
||||
int cea708_cc_count (user_data_t* data)
|
||||
{
|
||||
return data->cc_count;
|
||||
}
|
||||
|
||||
uint16_t cea708_cc_data (user_data_t* data, int index, int* valid, cea708_cc_type_t* type)
|
||||
{
|
||||
(*valid) = data->cc_data[index].cc_valid;
|
||||
(*type) = data->cc_data[index].cc_type;
|
||||
return data->cc_data[index].cc_data;
|
||||
}
|
||||
|
||||
|
||||
int cea708_init (cea708_t* cea708)
|
||||
{
|
||||
memset (cea708,0,sizeof (cea708_t));
|
||||
cea708->country = country_united_states;
|
||||
cea708->provider = t35_provider_atsc;
|
||||
cea708->user_identifier = ('G'<<24) | ('A'<<16) | ('9'<<8) | ('4');
|
||||
cea708->atsc1_data_user_data_type_code = 3; //what does 3 mean here?
|
||||
cea708->directv_user_data_length = 0;
|
||||
///////////
|
||||
cea708->user_data.process_em_data_flag = 0;
|
||||
cea708->user_data.process_cc_data_flag = 1;
|
||||
cea708->user_data.additional_data_flag = 0;
|
||||
cea708->user_data.cc_count = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 00 00 00 06 C1 FF FC 34 B9 FF : onCaptionInfo.
|
||||
int cea708_parse (uint8_t* data, size_t size, cea708_t* cea708)
|
||||
{
|
||||
int i;
|
||||
cea708->country = (itu_t_t35_country_code_t) (data[0]);
|
||||
cea708->provider = (itu_t_t35_provider_code_t) ( (data[1] <<8) | data[2]);
|
||||
cea708->atsc1_data_user_data_type_code = 0;
|
||||
cea708->user_identifier = 0;
|
||||
data += 3; size -= 3;
|
||||
|
||||
if (t35_provider_atsc == cea708->provider) {
|
||||
// GA94
|
||||
cea708->user_identifier = (data[0] <<24) | (data[1] <<16) | (data[2] <<8) | data[3];
|
||||
data += 4; size -= 4;
|
||||
}
|
||||
|
||||
// Im not sure what this extra byt is. It sonly seesm to come up in onCaptionInfo
|
||||
// where country and provider are zero
|
||||
if (0 == cea708->provider) {
|
||||
data += 1; size -= 1;
|
||||
} else if (t35_provider_atsc == cea708->provider || t35_provider_direct_tv == cea708->provider) {
|
||||
cea708->atsc1_data_user_data_type_code = data[0];
|
||||
data += 1; size -= 1;
|
||||
}
|
||||
|
||||
if (t35_provider_direct_tv == cea708->provider) {
|
||||
cea708->directv_user_data_length = data[0];
|
||||
data += 1; size -= 1;
|
||||
}
|
||||
|
||||
// TODO I believe this is condational on the above.
|
||||
cea708->user_data.process_em_data_flag = !! (data[0]&0x80);
|
||||
cea708->user_data.process_cc_data_flag = !! (data[0]&0x40);
|
||||
cea708->user_data.additional_data_flag = !! (data[0]&0x20);
|
||||
cea708->user_data.cc_count = (data[0]&0x1F);
|
||||
cea708->user_data.em_data = data[1];
|
||||
data += 2; size -= 2;
|
||||
|
||||
if (size < 3 * cea708->user_data.cc_count) {
|
||||
cea708_init (cea708);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < (int) cea708->user_data.cc_count ; ++i) {
|
||||
cea708->user_data.cc_data[i].marker_bits = data[0]>>3;
|
||||
cea708->user_data.cc_data[i].cc_valid = data[0]>>2;
|
||||
cea708->user_data.cc_data[i].cc_type = data[0]>>0;
|
||||
cea708->user_data.cc_data[i].cc_data = data[1]<<8|data[2];
|
||||
data += 3; size -= 3;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cea708_add_cc_data (cea708_t* cea708, int valid, cea708_cc_type_t type, uint16_t cc_data)
|
||||
{
|
||||
if (31 <= cea708->user_data.cc_count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cea708->user_data.cc_data[cea708->user_data.cc_count].marker_bits = 0x1F;
|
||||
cea708->user_data.cc_data[cea708->user_data.cc_count].cc_valid = valid;
|
||||
cea708->user_data.cc_data[cea708->user_data.cc_count].cc_type = type;
|
||||
cea708->user_data.cc_data[cea708->user_data.cc_count].cc_data = cc_data;
|
||||
++cea708->user_data.cc_count;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cea708_render (cea708_t* cea708, uint8_t* data, size_t size)
|
||||
{
|
||||
int i; size_t total = 0;
|
||||
data[0] = cea708->country;
|
||||
data[1] = cea708->provider>>8;
|
||||
data[2] = cea708->provider>>0;
|
||||
total += 3; data += 3; size -= 3;
|
||||
|
||||
if (t35_provider_atsc == cea708->provider) {
|
||||
|
||||
data[0] = cea708->user_identifier >> 24;
|
||||
data[1] = cea708->user_identifier >> 16;
|
||||
data[2] = cea708->user_identifier >> 8;
|
||||
data[3] = cea708->user_identifier >> 0;
|
||||
total += 4; data += 4; size -= 4;
|
||||
}
|
||||
|
||||
if (t35_provider_atsc == cea708->provider || t35_provider_direct_tv == cea708->provider) {
|
||||
data[0] = cea708->atsc1_data_user_data_type_code;
|
||||
total += 1; data += 1; size -= 1;
|
||||
}
|
||||
|
||||
if (t35_provider_direct_tv == cea708->provider) {
|
||||
data[0] = cea708->directv_user_data_length;
|
||||
total += 1; data += 1; size -= 1;
|
||||
}
|
||||
|
||||
data[1] = cea708->user_data.em_data;
|
||||
data[0] = (cea708->user_data.process_em_data_flag?0x80:0x00)
|
||||
| (cea708->user_data.process_cc_data_flag?0x40:0x00)
|
||||
| (cea708->user_data.additional_data_flag?0x20:0x00)
|
||||
| (cea708->user_data.cc_count & 0x1F);
|
||||
|
||||
total += 2; data += 2; size -= 2;
|
||||
|
||||
for (i = 0 ; i < (int) cea708->user_data.cc_count ; ++i) {
|
||||
data[0] = (cea708->user_data.cc_data[i].marker_bits<<3)
|
||||
| (data[0] = cea708->user_data.cc_data[i].cc_valid<<2)
|
||||
| (data[0] = cea708->user_data.cc_data[i].cc_type);
|
||||
data[1] = cea708->user_data.cc_data[i].cc_data>>8;
|
||||
data[2] = cea708->user_data.cc_data[i].cc_data>>0;
|
||||
total += 3; data += 3; size -= 3;
|
||||
}
|
||||
|
||||
data[0] = 0xFF;
|
||||
return (int) (total + 1);
|
||||
}
|
||||
|
||||
cc_data_t cea708_encode_cc_data (int cc_valid, cea708_cc_type_t type, uint16_t cc_data)
|
||||
{
|
||||
cc_data_t data = { 0x1F, cc_valid,type,cc_data};
|
||||
return data;
|
||||
}
|
||||
|
||||
void cea708_dump (cea708_t* cea708)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < (int) cea708->user_data.cc_count ; ++i) {
|
||||
cea708_cc_type_t type; int valid;
|
||||
uint16_t cc_data = cea708_cc_data (&cea708->user_data, i, &valid, &type);
|
||||
|
||||
if (valid && cc_type_ntsc_cc_field_1 == type) {
|
||||
eia608_dump (cc_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
libcaption_stauts_t cea708_to_caption_frame (caption_frame_t* frame, cea708_t* cea708, double pts)
|
||||
{
|
||||
int i, count = cea708_cc_count (&cea708->user_data);
|
||||
libcaption_stauts_t status = LIBCAPTION_OK;
|
||||
|
||||
for (i = 0 ; i < count ; ++i) {
|
||||
cea708_cc_type_t type; int valid;
|
||||
uint16_t cc_data = cea708_cc_data (&cea708->user_data, i, &valid, &type);
|
||||
|
||||
if (valid && cc_type_ntsc_cc_field_1 == type) {
|
||||
status = libcaption_status_update (status,caption_frame_decode (frame,cc_data, pts));
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
754
deps/libcaption/src/eia608.c
vendored
Normal file
754
deps/libcaption/src/eia608.c
vendored
Normal file
|
|
@ -0,0 +1,754 @@
|
|||
/* Generated by re2c 0.15.3 on Tue Nov 22 15:42:35 2016 */
|
||||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "eia608.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int eia608_row_map[] = {10, -1, 0, 1, 2, 3, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9};
|
||||
int eia608_reverse_row_map[] = {2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 0, 6, 7, 8, 9, 1};
|
||||
|
||||
const char* eia608_mode_map[] = {
|
||||
"clear",
|
||||
"loading",
|
||||
"popOn",
|
||||
"paintOn",
|
||||
"rollUp",
|
||||
};
|
||||
|
||||
const char* eia608_style_map[] = {
|
||||
"white",
|
||||
"green",
|
||||
"blue",
|
||||
"cyan",
|
||||
"red",
|
||||
"yellow",
|
||||
"magenta",
|
||||
"italics",
|
||||
};
|
||||
|
||||
static inline uint16_t eia608_row_pramble (int row, int chan, int x, int underline)
|
||||
{
|
||||
row = eia608_reverse_row_map[row&0x0F];
|
||||
return eia608_parity (0x1040 | (chan?0x0800:0x0000) | ( (row<<7) &0x0700) | ( (row<<5) &0x0020)) | ( (x<<1) &0x001E) | (underline?0x0001:0x0000);
|
||||
}
|
||||
|
||||
uint16_t eia608_row_column_pramble (int row, int col, int chan, int underline) { return eia608_row_pramble (row,chan,0x10| (col/4),underline); }
|
||||
uint16_t eia608_row_style_pramble (int row, eia608_style_t style, int chan, int underline) { return eia608_row_pramble (row,chan,style,underline); }
|
||||
|
||||
int eia608_parse_preamble (uint16_t cc_data, int* row, int* col, eia608_style_t* style, int* chan, int* underline)
|
||||
{
|
||||
(*row) = eia608_row_map[ ( (0x0700 & cc_data) >> 7) | ( (0x0020 & cc_data) >> 5)];
|
||||
(*chan) = !! (0x0800 & cc_data);
|
||||
(*underline) = 0x0001 & cc_data;
|
||||
|
||||
if (0x0010 & cc_data) {
|
||||
(*style) = eia608_style_white;
|
||||
(*col) = 4* ( (0x000E & cc_data) >> 1);
|
||||
} else {
|
||||
(*style) = (0x000E & cc_data) >> 1;
|
||||
(*col) = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int eia608_parse_midrowchange (uint16_t cc_data, int* chan, eia608_style_t* style, int* underline)
|
||||
{
|
||||
(*chan) = !! (0x0800 & cc_data);
|
||||
|
||||
if (0x1120 == (0x7770 & cc_data)) {
|
||||
(*style) = (0x000E & cc_data) >> 1;
|
||||
(*underline) = 0x0001 & cc_data;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// control command
|
||||
eia608_control_t eia608_parse_control (uint16_t cc_data, int* cc)
|
||||
{
|
||||
if (0x0200&cc_data) {
|
||||
(*cc) = (cc_data&0x0800?0x01:0x00);
|
||||
return (eia608_control_t) (0x177F & cc_data);
|
||||
} else {
|
||||
(*cc) = (cc_data&0x0800?0x01:0x00) | (cc_data&0x0100?0x02:0x00);
|
||||
return (eia608_control_t) (0x167F & cc_data);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t eia608_control_command (eia608_control_t cmd, int cc)
|
||||
{
|
||||
uint16_t c = (cc&0x01) ?0x0800:0x0000;
|
||||
uint16_t f = (cc&0x02) ?0x0100:0x0000;
|
||||
|
||||
if (eia608_tab_offset_0 == (eia608_control_t) (cmd&0xFFC0)) {
|
||||
return (eia608_control_t) eia608_parity (cmd|c);
|
||||
} else {
|
||||
return (eia608_control_t) eia608_parity (cmd|c|f);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// text
|
||||
static const char* utf8_from_index (int idx) { return (0<=idx && EIA608_CHAR_COUNT>idx) ? eia608_char_map[idx] : ""; }
|
||||
static int eia608_to_index (uint16_t cc_data, int* chan, int* c1, int* c2)
|
||||
{
|
||||
(*c1) = (*c2) = -1; (*chan) = 0;
|
||||
cc_data &= 0x7F7F; // strip off parity bits
|
||||
|
||||
// Handle Basic NA BEFORE we strip the channel bit
|
||||
if (eia608_is_basicna (cc_data)) {
|
||||
// we got first char, yes. But what about second char?
|
||||
(*c1) = (cc_data>>8) - 0x20;
|
||||
cc_data &= 0x00FF;
|
||||
|
||||
if (0x0020<=cc_data && 0x0080>cc_data) {
|
||||
(*c2) = cc_data - 0x20;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check then strip second channel toggle
|
||||
(*chan) = cc_data & 0x0800;
|
||||
cc_data = cc_data & 0xF7FF;
|
||||
|
||||
if (eia608_is_specialna (cc_data)) {
|
||||
// Special North American character
|
||||
(*c1) = cc_data - 0x1130 + 0x60;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0x1220<=cc_data && 0x1240>cc_data) {
|
||||
// Extended Western European character set, Spanish/Miscellaneous/French
|
||||
(*c1) = cc_data - 0x1220 + 0x70;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0x1320<=cc_data && 0x1340>cc_data) {
|
||||
// Extended Western European character set, Portuguese/German/Danish
|
||||
(*c1) = cc_data - 0x1320 + 0x90;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int eia608_to_utf8 (uint16_t c, int* chan, char* str1, char* str2)
|
||||
{
|
||||
int c1, c2;
|
||||
size_t size = eia608_to_index (c,chan,&c1,&c2);
|
||||
strncpy (str1, utf8_from_index (c1),5);
|
||||
strncpy (str2, utf8_from_index (c2),5);
|
||||
return (int)size;
|
||||
}
|
||||
|
||||
uint16_t eia608_from_basicna (uint16_t bna1, uint16_t bna2)
|
||||
{
|
||||
if (! eia608_is_basicna (bna1) || ! eia608_is_basicna (bna2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return eia608_parity ( ( (0xFF00&bna1) >>0) | ( (0xFF00&bna2) >>8));
|
||||
}
|
||||
|
||||
// prototype for re2c generated function
|
||||
uint16_t _eia608_from_utf8 (const utf8_char_t* s);
|
||||
uint16_t eia608_from_utf8_1 (const utf8_char_t* c, int chan)
|
||||
{
|
||||
uint16_t cc_data = _eia608_from_utf8 (c);
|
||||
|
||||
if (0 == cc_data) {
|
||||
return cc_data;
|
||||
}
|
||||
|
||||
if (chan && ! eia608_is_basicna (cc_data)) {
|
||||
cc_data |= 0x0800;
|
||||
}
|
||||
|
||||
return eia608_parity (cc_data);
|
||||
}
|
||||
|
||||
uint16_t eia608_from_utf8_2 (const utf8_char_t* c1, const utf8_char_t* c2)
|
||||
{
|
||||
uint16_t cc1 = _eia608_from_utf8 (c1);
|
||||
uint16_t cc2 = _eia608_from_utf8 (c2);
|
||||
return eia608_from_basicna (cc1,cc2);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void eia608_dump (uint16_t cc_data)
|
||||
{
|
||||
eia608_style_t style;
|
||||
const char* text = 0;
|
||||
char char1[5], char2[5];
|
||||
char1[0] = char2[0] = 0;
|
||||
int row, col, chan, underline;
|
||||
|
||||
if (!eia608_parity_varify (cc_data)) {
|
||||
text = "parity failed";
|
||||
} else if (0 == eia608_parity_strip (cc_data)) {
|
||||
text = "pad";
|
||||
} else if (eia608_is_basicna (cc_data)) {
|
||||
text = "basicna";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_specialna (cc_data)) {
|
||||
text = "specialna";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_westeu (cc_data)) {
|
||||
text = "westeu";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_xds (cc_data)) {
|
||||
text = "xds";
|
||||
} else if (eia608_is_midrowchange (cc_data)) {
|
||||
text = "midrowchange";
|
||||
} else if (eia608_is_norpak (cc_data)) {
|
||||
text = "norpak";
|
||||
} else if (eia608_is_preamble (cc_data)) {
|
||||
text = "preamble";
|
||||
eia608_parse_preamble (cc_data, &row, &col, &style, &chan, &underline);
|
||||
fprintf (stderr,"preamble %d %d %d %d %d\n", row, col, style, chan, underline);
|
||||
|
||||
} else if (eia608_is_control (cc_data)) {
|
||||
switch (eia608_parse_control (cc_data,&chan)) {
|
||||
|
||||
default: text = "unknown_control"; break;
|
||||
|
||||
case eia608_tab_offset_0: text = "eia608_tab_offset_0"; break;
|
||||
|
||||
case eia608_tab_offset_1: text = "eia608_tab_offset_1"; break;
|
||||
|
||||
case eia608_tab_offset_2:text = "eia608_tab_offset_2"; break;
|
||||
|
||||
case eia608_tab_offset_3: text = "eia608_tab_offset_3"; break;
|
||||
|
||||
case eia608_control_resume_caption_loading: text = "eia608_control_resume_caption_loading"; break;
|
||||
|
||||
case eia608_control_backspace: text = "eia608_control_backspace"; break;
|
||||
|
||||
case eia608_control_alarm_off: text = "eia608_control_alarm_off"; break;
|
||||
|
||||
case eia608_control_alarm_on: text = "eia608_control_alarm_on"; break;
|
||||
|
||||
case eia608_control_delete_to_end_of_row: text = "eia608_control_delete_to_end_of_row"; break;
|
||||
|
||||
case eia608_control_roll_up_2: text = "eia608_control_roll_up_2"; break;
|
||||
|
||||
case eia608_control_roll_up_3: text = "eia608_control_roll_up_3"; break;
|
||||
|
||||
case eia608_control_roll_up_4: text = "eia608_control_roll_up_4"; break;
|
||||
|
||||
case eia608_control_resume_direct_captioning: text = "eia608_control_resume_direct_captioning"; break;
|
||||
|
||||
case eia608_control_text_restart: text = "eia608_control_text_restart"; break;
|
||||
|
||||
case eia608_control_text_resume_text_display: text = "eia608_control_text_resume_text_display"; break;
|
||||
|
||||
case eia608_control_erase_display_memory: text = "eia608_control_erase_display_memory"; break;
|
||||
|
||||
case eia608_control_carriage_return: text = "eia608_control_carriage_return"; break;
|
||||
|
||||
case eia608_control_erase_non_displayed_memory:text = "eia608_control_erase_non_displayed_memory"; break;
|
||||
|
||||
case eia608_control_end_of_caption: text = "eia608_control_end_of_caption"; break;
|
||||
}
|
||||
} else {
|
||||
text = "unhandled";
|
||||
}
|
||||
|
||||
fprintf (stderr,"cc %04X (%04X) '%s' '%s' (%s)\n", cc_data, eia608_parity_strip (cc_data), char1, char2, text);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// below this line is re2c
|
||||
uint16_t _eia608_from_utf8 (const utf8_char_t* s)
|
||||
{
|
||||
const unsigned char* YYMARKER; // needed by default rule
|
||||
const unsigned char* YYCURSOR = (const unsigned char*) s;
|
||||
|
||||
if (0==s) { return 0x0000;}
|
||||
|
||||
|
||||
{
|
||||
unsigned char yych;
|
||||
yych = *YYCURSOR;
|
||||
if (yych <= '`') {
|
||||
if (yych <= '*') {
|
||||
if (yych <= '&') {
|
||||
if (yych <= 0x00) goto yy2;
|
||||
if (yych <= 0x1F) goto yy32;
|
||||
goto yy26;
|
||||
} else {
|
||||
if (yych <= '\'') goto yy4;
|
||||
if (yych <= ')') goto yy26;
|
||||
goto yy6;
|
||||
}
|
||||
} else {
|
||||
if (yych <= ']') {
|
||||
if (yych == '\\') goto yy8;
|
||||
goto yy26;
|
||||
} else {
|
||||
if (yych <= '^') goto yy10;
|
||||
if (yych <= '_') goto yy12;
|
||||
goto yy14;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (yych <= 0x7F) {
|
||||
if (yych <= '|') {
|
||||
if (yych <= 'z') goto yy26;
|
||||
if (yych <= '{') goto yy16;
|
||||
goto yy18;
|
||||
} else {
|
||||
if (yych <= '}') goto yy20;
|
||||
if (yych <= '~') goto yy22;
|
||||
goto yy24;
|
||||
}
|
||||
} else {
|
||||
if (yych <= 0xC3) {
|
||||
if (yych <= 0xC1) goto yy32;
|
||||
if (yych <= 0xC2) goto yy31;
|
||||
goto yy28;
|
||||
} else {
|
||||
if (yych == 0xE2) goto yy30;
|
||||
goto yy32;
|
||||
}
|
||||
}
|
||||
}
|
||||
yy2:
|
||||
++YYCURSOR;
|
||||
{ /*NULL*/ return 0x0000; }
|
||||
yy4:
|
||||
++YYCURSOR;
|
||||
{ /*APOSTROPHE -> RIGHT_SINGLE_QUOTATION_MARK*/ return 0x1229; }
|
||||
yy6:
|
||||
++YYCURSOR;
|
||||
{ /*ASTERISK*/ return 0x1228; }
|
||||
yy8:
|
||||
++YYCURSOR;
|
||||
{ /*REVERSE_SOLIDUS*/ return 0x132B; }
|
||||
yy10:
|
||||
++YYCURSOR;
|
||||
{ /*CIRCUMFLEX_ACCENT*/ return 0x132C; }
|
||||
yy12:
|
||||
++YYCURSOR;
|
||||
{ /*LOW_LINE*/ return 0x132D; }
|
||||
yy14:
|
||||
++YYCURSOR;
|
||||
{ /*GRAVE_ACCENT, No equivalent return 0x0000; return 1;*/ /*LEFT_SINGLE_QUOTATION_MARK*/ return 0x1226; }
|
||||
yy16:
|
||||
++YYCURSOR;
|
||||
{ /*LEFT_CURLY_BRACKET*/ return 0x1329; }
|
||||
yy18:
|
||||
++YYCURSOR;
|
||||
{ /*VERTICAL_LINE*/ return 0x132E; }
|
||||
yy20:
|
||||
++YYCURSOR;
|
||||
{ /*RIGHT_CURLY_BRACKET*/ return 0x132A; }
|
||||
yy22:
|
||||
++YYCURSOR;
|
||||
{ /*TILDE*/ return 0x132F; }
|
||||
yy24:
|
||||
++YYCURSOR;
|
||||
{ /*DEL/BACKSPACE. Need to set bits 9 and 12! return 0x1421;*/ return 0x0000; }
|
||||
yy26:
|
||||
++YYCURSOR;
|
||||
{ /*ASCII range*/ return (s[0]<<8) &0xFF00; }
|
||||
yy28:
|
||||
++YYCURSOR;
|
||||
switch ((yych = *YYCURSOR)) {
|
||||
case 0x80: goto yy157;
|
||||
case 0x81: goto yy169;
|
||||
case 0x82: goto yy155;
|
||||
case 0x83: goto yy129;
|
||||
case 0x84: goto yy111;
|
||||
case 0x85: goto yy101;
|
||||
case 0x87: goto yy153;
|
||||
case 0x88: goto yy151;
|
||||
case 0x89: goto yy167;
|
||||
case 0x8A: goto yy149;
|
||||
case 0x8B: goto yy147;
|
||||
case 0x8C: goto yy123;
|
||||
case 0x8D: goto yy125;
|
||||
case 0x8E: goto yy143;
|
||||
case 0x8F: goto yy141;
|
||||
case 0x91: goto yy187;
|
||||
case 0x92: goto yy119;
|
||||
case 0x93: goto yy165;
|
||||
case 0x94: goto yy137;
|
||||
case 0x95: goto yy115;
|
||||
case 0x96: goto yy107;
|
||||
case 0x98: goto yy97;
|
||||
case 0x99: goto yy135;
|
||||
case 0x9A: goto yy163;
|
||||
case 0x9B: goto yy131;
|
||||
case 0x9C: goto yy161;
|
||||
case 0x9F: goto yy103;
|
||||
case 0xA0: goto yy183;
|
||||
case 0xA1: goto yy201;
|
||||
case 0xA2: goto yy179;
|
||||
case 0xA3: goto yy127;
|
||||
case 0xA4: goto yy109;
|
||||
case 0xA5: goto yy99;
|
||||
case 0xA7: goto yy191;
|
||||
case 0xA8: goto yy181;
|
||||
case 0xA9: goto yy199;
|
||||
case 0xAA: goto yy177;
|
||||
case 0xAB: goto yy145;
|
||||
case 0xAC: goto yy121;
|
||||
case 0xAD: goto yy197;
|
||||
case 0xAE: goto yy175;
|
||||
case 0xAF: goto yy139;
|
||||
case 0xB1: goto yy185;
|
||||
case 0xB2: goto yy117;
|
||||
case 0xB3: goto yy195;
|
||||
case 0xB4: goto yy173;
|
||||
case 0xB5: goto yy113;
|
||||
case 0xB6: goto yy105;
|
||||
case 0xB7: goto yy189;
|
||||
case 0xB8: goto yy95;
|
||||
case 0xB9: goto yy133;
|
||||
case 0xBA: goto yy193;
|
||||
case 0xBB: goto yy171;
|
||||
case 0xBC: goto yy159;
|
||||
default: goto yy29;
|
||||
}
|
||||
yy29:
|
||||
{ /*DEFAULT_RULE*/ return 0x0000; }
|
||||
yy30:
|
||||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
switch (yych) {
|
||||
case 0x80: goto yy63;
|
||||
case 0x84: goto yy64;
|
||||
case 0x94: goto yy61;
|
||||
case 0x96: goto yy66;
|
||||
case 0x99: goto yy65;
|
||||
default: goto yy29;
|
||||
}
|
||||
yy31:
|
||||
yych = *++YYCURSOR;
|
||||
switch (yych) {
|
||||
case 0xA0: goto yy47;
|
||||
case 0xA1: goto yy45;
|
||||
case 0xA2: goto yy51;
|
||||
case 0xA3: goto yy49;
|
||||
case 0xA4: goto yy35;
|
||||
case 0xA5: goto yy37;
|
||||
case 0xA6: goto yy33;
|
||||
case 0xA9: goto yy43;
|
||||
case 0xAB: goto yy41;
|
||||
case 0xAE: goto yy59;
|
||||
case 0xB0: goto yy57;
|
||||
case 0xBB: goto yy39;
|
||||
case 0xBD: goto yy55;
|
||||
case 0xBF: goto yy53;
|
||||
default: goto yy29;
|
||||
}
|
||||
yy32:
|
||||
yych = *++YYCURSOR;
|
||||
goto yy29;
|
||||
yy33:
|
||||
++YYCURSOR;
|
||||
{ /*BROKEN_BAR*/ return 0x1337; }
|
||||
yy35:
|
||||
++YYCURSOR;
|
||||
{ /*CURRENCY_SIGN*/ return 0x1336; }
|
||||
yy37:
|
||||
++YYCURSOR;
|
||||
{ /*YEN_SIGN*/ return 0x1335; }
|
||||
yy39:
|
||||
++YYCURSOR;
|
||||
{ /*RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK*/ return 0x123F; }
|
||||
yy41:
|
||||
++YYCURSOR;
|
||||
{ /*LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK*/ return 0x123E; }
|
||||
yy43:
|
||||
++YYCURSOR;
|
||||
{ /*COPYRIGHT_SIGN*/ return 0x122B; }
|
||||
yy45:
|
||||
++YYCURSOR;
|
||||
{ /*INVERTED_EXCLAMATION_MARK*/ return 0x1227; }
|
||||
yy47:
|
||||
++YYCURSOR;
|
||||
{ /*NO_BREAK_SPACE*/ return 0x1139; }
|
||||
yy49:
|
||||
++YYCURSOR;
|
||||
{ /*POUND_SIGN*/ return 0x1136; }
|
||||
yy51:
|
||||
++YYCURSOR;
|
||||
{ /*CENT_SIGN*/ return 0x1135; }
|
||||
yy53:
|
||||
++YYCURSOR;
|
||||
{ /*INVERTED_QUESTION_MARK*/ return 0x1133; }
|
||||
yy55:
|
||||
++YYCURSOR;
|
||||
{ /*VULGAR_FRACTION_ONE_HALF*/ return 0x1132; }
|
||||
yy57:
|
||||
++YYCURSOR;
|
||||
{ /*DEGREE_SIGN*/ return 0x1131; }
|
||||
yy59:
|
||||
++YYCURSOR;
|
||||
{ /*REGISTERED_SIGN*/ return 0x1130; }
|
||||
yy61:
|
||||
yych = *++YYCURSOR;
|
||||
switch (yych) {
|
||||
case 0x8C: goto yy87;
|
||||
case 0x90: goto yy89;
|
||||
case 0x94: goto yy91;
|
||||
case 0x98: goto yy93;
|
||||
default: goto yy62;
|
||||
}
|
||||
yy62:
|
||||
YYCURSOR = YYMARKER;
|
||||
goto yy29;
|
||||
yy63:
|
||||
yych = *++YYCURSOR;
|
||||
switch (yych) {
|
||||
case 0x94: goto yy79;
|
||||
case 0x98: goto yy75;
|
||||
case 0x99: goto yy77;
|
||||
case 0x9C: goto yy83;
|
||||
case 0x9D: goto yy85;
|
||||
case 0xA2: goto yy81;
|
||||
default: goto yy62;
|
||||
}
|
||||
yy64:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 0xA0) goto yy73;
|
||||
if (yych == 0xA2) goto yy71;
|
||||
goto yy62;
|
||||
yy65:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych == 0xAA) goto yy69;
|
||||
goto yy62;
|
||||
yy66:
|
||||
yych = *++YYCURSOR;
|
||||
if (yych != 0x88) goto yy62;
|
||||
++YYCURSOR;
|
||||
{ /*FULL_BLOCK*/ return 0x7F00; }
|
||||
yy69:
|
||||
++YYCURSOR;
|
||||
{ /*EIGHTH_NOTE*/ return 0x1137; }
|
||||
yy71:
|
||||
++YYCURSOR;
|
||||
{ /*TRADE_MARK_SIGN*/ return 0x1134; }
|
||||
yy73:
|
||||
++YYCURSOR;
|
||||
{ /*SERVICE_MARK*/ return 0x122C; }
|
||||
yy75:
|
||||
++YYCURSOR;
|
||||
{ /*LEFT_SINGLE_QUOTATION_MARK*/ return 0x1226; }
|
||||
yy77:
|
||||
++YYCURSOR;
|
||||
{ /*RIGHT_SINGLE_QUOTATION_MARK -> APOSTROPHE*/ return 0x2700; }
|
||||
yy79:
|
||||
++YYCURSOR;
|
||||
{ /*EM_DASH*/ return 0x122A; }
|
||||
yy81:
|
||||
++YYCURSOR;
|
||||
{ /*BULLET*/ return 0x122D; }
|
||||
yy83:
|
||||
++YYCURSOR;
|
||||
{ /*LEFT_DOUBLE_QUOTATION_MARK*/ return 0x122E; }
|
||||
yy85:
|
||||
++YYCURSOR;
|
||||
{ /*RIGHT_DOUBLE_QUOTATION_MARK*/ return 0x122F; }
|
||||
yy87:
|
||||
++YYCURSOR;
|
||||
{ /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT*/ return 0x133C; }
|
||||
yy89:
|
||||
++YYCURSOR;
|
||||
{ /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT*/ return 0x133D; }
|
||||
yy91:
|
||||
++YYCURSOR;
|
||||
{ /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT*/ return 0x133E; }
|
||||
yy93:
|
||||
++YYCURSOR;
|
||||
{ /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT*/ return 0x133F; }
|
||||
yy95:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_STROKE*/ return 0x133B; }
|
||||
yy97:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_STROKE*/ return 0x133A; }
|
||||
yy99:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_RING_ABOVE*/ return 0x1339; }
|
||||
yy101:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE*/ return 0x1338; }
|
||||
yy103:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_SHARP_S*/ return 0x1334; }
|
||||
yy105:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_DIAERESIS*/ return 0x1333; }
|
||||
yy107:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS*/ return 0x1332; }
|
||||
yy109:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_DIAERESIS*/ return 0x1331; }
|
||||
yy111:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS*/ return 0x1330; }
|
||||
yy113:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_TILDE*/ return 0x1328; }
|
||||
yy115:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_TILDE*/ return 0x1327; }
|
||||
yy117:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_GRAVE*/ return 0x1326; }
|
||||
yy119:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_GRAVE*/ return 0x1325; }
|
||||
yy121:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_I_WITH_GRAVE*/ return 0x1324; }
|
||||
yy123:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_I_WITH_GRAVE*/ return 0x1323; }
|
||||
yy125:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_I_WITH_ACUTE*/ return 0x1322; }
|
||||
yy127:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_TILDE*/ return 0x1321; }
|
||||
yy129:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_TILDE*/ return 0x1320; }
|
||||
yy131:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX*/ return 0x123D; }
|
||||
yy133:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_U_WITH_GRAVE*/ return 0x123C; }
|
||||
yy135:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_U_WITH_GRAVE*/ return 0x123B; }
|
||||
yy137:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX*/ return 0x123A; }
|
||||
yy139:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_I_WITH_DIAERESIS*/ return 0x1239; }
|
||||
yy141:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS*/ return 0x1238; }
|
||||
yy143:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX*/ return 0x1237; }
|
||||
yy145:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_E_WITH_DIAERESIS*/ return 0x1236; }
|
||||
yy147:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS*/ return 0x1235; }
|
||||
yy149:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX*/ return 0x1234; }
|
||||
yy151:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_E_WITH_GRAVE*/ return 0x1233; }
|
||||
yy153:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_C_WITH_CEDILLA*/ return 0x1232; }
|
||||
yy155:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX*/ return 0x1231; }
|
||||
yy157:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_GRAVE*/ return 0x1230; }
|
||||
yy159:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_U_WITH_DIAERESIS*/ return 0x1225; }
|
||||
yy161:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS*/ return 0x1224; }
|
||||
yy163:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_U_WITH_ACUTE*/ return 0x1223; }
|
||||
yy165:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_O_WITH_ACUTE*/ return 0x1222; }
|
||||
yy167:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_E_WITH_ACUTE*/ return 0x1221; }
|
||||
yy169:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_A_WITH_ACUTE*/ return 0x1220; }
|
||||
yy171:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX*/ return 0x113F; }
|
||||
yy173:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX*/ return 0x113E; }
|
||||
yy175:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX*/ return 0x113D; }
|
||||
yy177:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX*/ return 0x113C; }
|
||||
yy179:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX*/ return 0x113B; }
|
||||
yy181:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_E_WITH_GRAVE*/ return 0x113A; }
|
||||
yy183:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_GRAVE*/ return 0x1138; }
|
||||
yy185:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_N_WITH_TILDE*/ return 0x7E00; }
|
||||
yy187:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_CAPITAL_LETTER_N_WITH_TILDE*/ return 0x7D00; }
|
||||
yy189:
|
||||
++YYCURSOR;
|
||||
{ /*DIVISION_SIGN*/ return 0x7C00; }
|
||||
yy191:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_C_WITH_CEDILLA*/ return 0x7B00; }
|
||||
yy193:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_U_WITH_ACUTE*/ return 0x6000; }
|
||||
yy195:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_O_WITH_ACUTE*/ return 0x5F00; }
|
||||
yy197:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_I_WITH_ACUTE*/ return 0x5E00; }
|
||||
yy199:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_E_WITH_ACUTE*/ return 0x5C00; }
|
||||
yy201:
|
||||
++YYCURSOR;
|
||||
{ /*LATIN_SMALL_LETTER_A_WITH_ACUTE*/ return 0x2A00; }
|
||||
}
|
||||
|
||||
}
|
||||
421
deps/libcaption/src/eia608.c.re2c
vendored
Normal file
421
deps/libcaption/src/eia608.c.re2c
vendored
Normal file
|
|
@ -0,0 +1,421 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "eia608.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int eia608_row_map[] = {10, -1, 0, 1, 2, 3, 11, 12, 13, 14, 4, 5, 6, 7, 8, 9};
|
||||
int eia608_reverse_row_map[] = {2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 0, 6, 7, 8, 9, 1};
|
||||
|
||||
const char* eia608_mode_map[] = {
|
||||
"clear",
|
||||
"loading",
|
||||
"popOn",
|
||||
"paintOn",
|
||||
"rollUp",
|
||||
};
|
||||
|
||||
const char* eia608_style_map[] = {
|
||||
"white",
|
||||
"green",
|
||||
"blue",
|
||||
"cyan",
|
||||
"red",
|
||||
"yellow",
|
||||
"magenta",
|
||||
"italics",
|
||||
};
|
||||
|
||||
static inline uint16_t eia608_row_pramble (int row, int chan, int x, int underline)
|
||||
{
|
||||
row = eia608_reverse_row_map[row&0x0F];
|
||||
return eia608_parity (0x1040 | (chan?0x0800:0x0000) | ( (row<<7) &0x0700) | ( (row<<5) &0x0020)) | ( (x<<1) &0x001E) | (underline?0x0001:0x0000);
|
||||
}
|
||||
|
||||
uint16_t eia608_row_column_pramble (int row, int col, int chan, int underline) { return eia608_row_pramble (row,chan,0x10| (col/4),underline); }
|
||||
uint16_t eia608_row_style_pramble (int row, eia608_style_t style, int chan, int underline) { return eia608_row_pramble (row,chan,style,underline); }
|
||||
|
||||
int eia608_parse_preamble (uint16_t cc_data, int* row, int* col, eia608_style_t* style, int* chan, int* underline)
|
||||
{
|
||||
(*row) = eia608_row_map[ ( (0x0700 & cc_data) >> 7) | ( (0x0020 & cc_data) >> 5)];
|
||||
(*chan) = !! (0x0800 & cc_data);
|
||||
(*underline) = 0x0001 & cc_data;
|
||||
|
||||
if (0x0010 & cc_data) {
|
||||
(*style) = eia608_style_white;
|
||||
(*col) = 4* ( (0x000E & cc_data) >> 1);
|
||||
} else {
|
||||
(*style) = (0x000E & cc_data) >> 1;
|
||||
(*col) = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int eia608_parse_midrowchange (uint16_t cc_data, int* chan, eia608_style_t* style, int* underline)
|
||||
{
|
||||
(*chan) = !! (0x0800 & cc_data);
|
||||
|
||||
if (0x1120 == (0x7770 & cc_data)) {
|
||||
(*style) = (0x000E & cc_data) >> 1;
|
||||
(*underline) = 0x0001 & cc_data;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// control command
|
||||
eia608_control_t eia608_parse_control (uint16_t cc_data, int* cc)
|
||||
{
|
||||
if (0x0200&cc_data) {
|
||||
(*cc) = (cc_data&0x0800?0x01:0x00);
|
||||
return (eia608_control_t) (0x177F & cc_data);
|
||||
} else {
|
||||
(*cc) = (cc_data&0x0800?0x01:0x00) | (cc_data&0x0100?0x02:0x00);
|
||||
return (eia608_control_t) (0x167F & cc_data);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t eia608_control_command (eia608_control_t cmd, int cc)
|
||||
{
|
||||
uint16_t c = (cc&0x01) ?0x0800:0x0000;
|
||||
uint16_t f = (cc&0x02) ?0x0100:0x0000;
|
||||
|
||||
if (eia608_tab_offset_0 == (eia608_control_t) (cmd&0xFFC0)) {
|
||||
return (eia608_control_t) eia608_parity (cmd|c);
|
||||
} else {
|
||||
return (eia608_control_t) eia608_parity (cmd|c|f);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// text
|
||||
static const char* utf8_from_index (int idx) { return (0<=idx && EIA608_CHAR_COUNT>idx) ? eia608_char_map[idx] : ""; }
|
||||
static int eia608_to_index (uint16_t cc_data, int* chan, int* c1, int* c2)
|
||||
{
|
||||
(*c1) = (*c2) = -1; (*chan) = 0;
|
||||
cc_data &= 0x7F7F; // strip off parity bits
|
||||
|
||||
// Handle Basic NA BEFORE we strip the channel bit
|
||||
if (eia608_is_basicna (cc_data)) {
|
||||
// we got first char, yes. But what about second char?
|
||||
(*c1) = (cc_data>>8) - 0x20;
|
||||
cc_data &= 0x00FF;
|
||||
|
||||
if (0x0020<=cc_data && 0x0080>cc_data) {
|
||||
(*c2) = cc_data - 0x20;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Check then strip second channel toggle
|
||||
(*chan) = cc_data & 0x0800;
|
||||
cc_data = cc_data & 0xF7FF;
|
||||
|
||||
if (eia608_is_specialna (cc_data)) {
|
||||
// Special North American character
|
||||
(*c1) = cc_data - 0x1130 + 0x60;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0x1220<=cc_data && 0x1240>cc_data) {
|
||||
// Extended Western European character set, Spanish/Miscellaneous/French
|
||||
(*c1) = cc_data - 0x1220 + 0x70;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0x1320<=cc_data && 0x1340>cc_data) {
|
||||
// Extended Western European character set, Portuguese/German/Danish
|
||||
(*c1) = cc_data - 0x1320 + 0x90;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int eia608_to_utf8 (uint16_t c, int* chan, char* str1, char* str2)
|
||||
{
|
||||
int c1, c2;
|
||||
int size = (int) eia608_to_index (c,chan,&c1,&c2);
|
||||
strncpy (str1, utf8_from_index (c1),5);
|
||||
strncpy (str2, utf8_from_index (c2),5);
|
||||
return size;
|
||||
}
|
||||
|
||||
uint16_t eia608_from_basicna (uint16_t bna1, uint16_t bna2)
|
||||
{
|
||||
if (! eia608_is_basicna (bna1) || ! eia608_is_basicna (bna2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return eia608_parity ( ( (0xFF00&bna1) >>0) | ( (0xFF00&bna2) >>8));
|
||||
}
|
||||
|
||||
// prototype for re2c generated function
|
||||
uint16_t _eia608_from_utf8 (const utf8_char_t* s);
|
||||
uint16_t eia608_from_utf8_1 (const utf8_char_t* c, int chan)
|
||||
{
|
||||
uint16_t cc_data = _eia608_from_utf8 (c);
|
||||
|
||||
if (0 == cc_data) {
|
||||
return cc_data;
|
||||
}
|
||||
|
||||
if (chan && ! eia608_is_basicna (cc_data)) {
|
||||
cc_data |= 0x0800;
|
||||
}
|
||||
|
||||
return eia608_parity (cc_data);
|
||||
}
|
||||
|
||||
uint16_t eia608_from_utf8_2 (const utf8_char_t* c1, const utf8_char_t* c2)
|
||||
{
|
||||
uint16_t cc1 = _eia608_from_utf8 (c1);
|
||||
uint16_t cc2 = _eia608_from_utf8 (c2);
|
||||
return eia608_from_basicna (cc1,cc2);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void eia608_dump (uint16_t cc_data)
|
||||
{
|
||||
eia608_style_t style;
|
||||
const char* text = 0;
|
||||
char char1[5], char2[5];
|
||||
char1[0] = char2[0] = 0;
|
||||
int row, col, chan, underline;
|
||||
|
||||
if (!eia608_parity_varify (cc_data)) {
|
||||
text = "parity failed";
|
||||
} else if (0 == eia608_parity_strip (cc_data)) {
|
||||
text = "pad";
|
||||
} else if (eia608_is_basicna (cc_data)) {
|
||||
text = "basicna";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_specialna (cc_data)) {
|
||||
text = "specialna";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_westeu (cc_data)) {
|
||||
text = "westeu";
|
||||
eia608_to_utf8 (cc_data,&chan,&char1[0],&char2[0]);
|
||||
} else if (eia608_is_xds (cc_data)) {
|
||||
text = "xds";
|
||||
} else if (eia608_is_midrowchange (cc_data)) {
|
||||
text = "midrowchange";
|
||||
} else if (eia608_is_norpak (cc_data)) {
|
||||
text = "norpak";
|
||||
} else if (eia608_is_preamble (cc_data)) {
|
||||
text = "preamble";
|
||||
eia608_parse_preamble (cc_data, &row, &col, &style, &chan, &underline);
|
||||
fprintf (stderr,"preamble %d %d %d %d %d\n", row, col, style, chan, underline);
|
||||
|
||||
} else if (eia608_is_control (cc_data)) {
|
||||
switch (eia608_parse_control (cc_data,&chan)) {
|
||||
|
||||
default: text = "unknown_control"; break;
|
||||
|
||||
case eia608_tab_offset_0: text = "eia608_tab_offset_0"; break;
|
||||
|
||||
case eia608_tab_offset_1: text = "eia608_tab_offset_1"; break;
|
||||
|
||||
case eia608_tab_offset_2:text = "eia608_tab_offset_2"; break;
|
||||
|
||||
case eia608_tab_offset_3: text = "eia608_tab_offset_3"; break;
|
||||
|
||||
case eia608_control_resume_caption_loading: text = "eia608_control_resume_caption_loading"; break;
|
||||
|
||||
case eia608_control_backspace: text = "eia608_control_backspace"; break;
|
||||
|
||||
case eia608_control_alarm_off: text = "eia608_control_alarm_off"; break;
|
||||
|
||||
case eia608_control_alarm_on: text = "eia608_control_alarm_on"; break;
|
||||
|
||||
case eia608_control_delete_to_end_of_row: text = "eia608_control_delete_to_end_of_row"; break;
|
||||
|
||||
case eia608_control_roll_up_2: text = "eia608_control_roll_up_2"; break;
|
||||
|
||||
case eia608_control_roll_up_3: text = "eia608_control_roll_up_3"; break;
|
||||
|
||||
case eia608_control_roll_up_4: text = "eia608_control_roll_up_4"; break;
|
||||
|
||||
case eia608_control_resume_direct_captioning: text = "eia608_control_resume_direct_captioning"; break;
|
||||
|
||||
case eia608_control_text_restart: text = "eia608_control_text_restart"; break;
|
||||
|
||||
case eia608_control_text_resume_text_display: text = "eia608_control_text_resume_text_display"; break;
|
||||
|
||||
case eia608_control_erase_display_memory: text = "eia608_control_erase_display_memory"; break;
|
||||
|
||||
case eia608_control_carriage_return: text = "eia608_control_carriage_return"; break;
|
||||
|
||||
case eia608_control_erase_non_displayed_memory:text = "eia608_control_erase_non_displayed_memory"; break;
|
||||
|
||||
case eia608_control_end_of_caption: text = "eia608_control_end_of_caption"; break;
|
||||
}
|
||||
} else {
|
||||
text = "unhandled";
|
||||
}
|
||||
|
||||
fprintf (stderr,"cc %04X (%04X) '%s' '%s' (%s)\n", cc_data, eia608_parity_strip (cc_data), char1, char2, text);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// below this line is re2c
|
||||
uint16_t _eia608_from_utf8 (const utf8_char_t* s)
|
||||
{
|
||||
const unsigned char* YYMARKER; // needed by default rule
|
||||
const unsigned char* YYCURSOR = (const unsigned char*) s;
|
||||
|
||||
if (0==s) { return 0x0000;}
|
||||
|
||||
/*!re2c
|
||||
re2c:yyfill:enable = 0;
|
||||
re2c:indent:string = " ";
|
||||
re2c:define:YYCTYPE = "unsigned char";
|
||||
|
||||
/*Ascii Exceptions*/
|
||||
"\x00" { /*NULL*/ return 0x0000; }
|
||||
"\x27" { /*APOSTROPHE -> RIGHT_SINGLE_QUOTATION_MARK*/ return 0x1229; }
|
||||
"\x2A" { /*ASTERISK*/ return 0x1228; }
|
||||
"\x5C" { /*REVERSE_SOLIDUS*/ return 0x132B; }
|
||||
"\x5E" { /*CIRCUMFLEX_ACCENT*/ return 0x132C; }
|
||||
"\x5F" { /*LOW_LINE*/ return 0x132D; }
|
||||
/*Lets Map this to a LEFT_SINGLE_QUOTATION_MARK, just so we have a cc_data for every printable ASCII value*/
|
||||
"\x60" { /*GRAVE_ACCENT, No equivalent return 0x0000; return 1;*/ /*LEFT_SINGLE_QUOTATION_MARK*/ return 0x1226; }
|
||||
"\x7B" { /*LEFT_CURLY_BRACKET*/ return 0x1329; }
|
||||
"\x7C" { /*VERTICAL_LINE*/ return 0x132E; }
|
||||
"\x7D" { /*RIGHT_CURLY_BRACKET*/ return 0x132A; }
|
||||
"\x7E" { /*TILDE*/ return 0x132F; }
|
||||
/*There is a controll equivilant. Havnt decided if we want to habcle that here, or not*/
|
||||
"\x7F" { /*DEL/BACKSPACE. Need to set bits 9 and 12! return 0x1421;*/ return 0x0000; }
|
||||
|
||||
/* Rules are processed top to bottom. So All single byte chars MUST be above this line!*/
|
||||
[\x20-\x7F] { /*ASCII range*/ return (s[0]<<8) &0xFF00; } /* Should we use yych instead of s[0]?*/
|
||||
|
||||
/*This is the second half of the ascii exceptions*/
|
||||
"\xC3\xA1" { /*LATIN_SMALL_LETTER_A_WITH_ACUTE*/ return 0x2A00; }
|
||||
"\xC3\xA9" { /*LATIN_SMALL_LETTER_E_WITH_ACUTE*/ return 0x5C00; }
|
||||
"\xC3\xAD" { /*LATIN_SMALL_LETTER_I_WITH_ACUTE*/ return 0x5E00; }
|
||||
"\xC3\xB3" { /*LATIN_SMALL_LETTER_O_WITH_ACUTE*/ return 0x5F00; }
|
||||
"\xC3\xBA" { /*LATIN_SMALL_LETTER_U_WITH_ACUTE*/ return 0x6000; }
|
||||
"\xC3\xA7" { /*LATIN_SMALL_LETTER_C_WITH_CEDILLA*/ return 0x7B00; }
|
||||
"\xC3\xB7" { /*DIVISION_SIGN*/ return 0x7C00; }
|
||||
"\xC3\x91" { /*LATIN_CAPITAL_LETTER_N_WITH_TILDE*/ return 0x7D00; }
|
||||
"\xC3\xB1" { /*LATIN_SMALL_LETTER_N_WITH_TILDE*/ return 0x7E00; }
|
||||
"\xE2\x96\x88" { /*FULL_BLOCK*/ return 0x7F00; }
|
||||
|
||||
/*Special North American character set*/
|
||||
"\xC2\xAE" { /*REGISTERED_SIGN*/ return 0x1130; }
|
||||
"\xC2\xB0" { /*DEGREE_SIGN*/ return 0x1131; }
|
||||
"\xC2\xBD" { /*VULGAR_FRACTION_ONE_HALF*/ return 0x1132; }
|
||||
"\xC2\xBF" { /*INVERTED_QUESTION_MARK*/ return 0x1133; }
|
||||
"\xE2\x84\xA2" { /*TRADE_MARK_SIGN*/ return 0x1134; }
|
||||
"\xC2\xA2" { /*CENT_SIGN*/ return 0x1135; }
|
||||
"\xC2\xA3" { /*POUND_SIGN*/ return 0x1136; }
|
||||
"\xE2\x99\xAA" { /*EIGHTH_NOTE*/ return 0x1137; }
|
||||
"\xC3\xA0" { /*LATIN_SMALL_LETTER_A_WITH_GRAVE*/ return 0x1138; }
|
||||
"\xC2\xA0" { /*NO_BREAK_SPACE*/ return 0x1139; }
|
||||
"\xC3\xA8" { /*LATIN_SMALL_LETTER_E_WITH_GRAVE*/ return 0x113A; }
|
||||
"\xC3\xA2" { /*LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX*/ return 0x113B; }
|
||||
"\xC3\xAA" { /*LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX*/ return 0x113C; }
|
||||
"\xC3\xAE" { /*LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX*/ return 0x113D; }
|
||||
"\xC3\xB4" { /*LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX*/ return 0x113E; }
|
||||
"\xC3\xBB" { /*LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX*/ return 0x113F; }
|
||||
|
||||
/*Extended Spanish/Miscellaneous*/
|
||||
"\xC3\x81" { /*LATIN_CAPITAL_LETTER_A_WITH_ACUTE*/ return 0x1220; }
|
||||
"\xC3\x89" { /*LATIN_CAPITAL_LETTER_E_WITH_ACUTE*/ return 0x1221; }
|
||||
"\xC3\x93" { /*LATIN_CAPITAL_LETTER_O_WITH_ACUTE*/ return 0x1222; }
|
||||
"\xC3\x9A" { /*LATIN_CAPITAL_LETTER_U_WITH_ACUTE*/ return 0x1223; }
|
||||
"\xC3\x9C" { /*LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS*/ return 0x1224; }
|
||||
"\xC3\xBC" { /*LATIN_SMALL_LETTER_U_WITH_DIAERESIS*/ return 0x1225; }
|
||||
"\xE2\x80\x98" { /*LEFT_SINGLE_QUOTATION_MARK*/ return 0x1226; }
|
||||
"\xC2\xA1" { /*INVERTED_EXCLAMATION_MARK*/ return 0x1227; }
|
||||
/*ASTERISK handled in ASCII mapping*/
|
||||
"\xE2\x80\x99" { /*RIGHT_SINGLE_QUOTATION_MARK -> APOSTROPHE*/ return 0x2700; }
|
||||
"\xE2\x80\x94" { /*EM_DASH*/ return 0x122A; }
|
||||
"\xC2\xA9" { /*COPYRIGHT_SIGN*/ return 0x122B; }
|
||||
"\xE2\x84\xA0" { /*SERVICE_MARK*/ return 0x122C; }
|
||||
"\xE2\x80\xA2" { /*BULLET*/ return 0x122D; }
|
||||
"\xE2\x80\x9C" { /*LEFT_DOUBLE_QUOTATION_MARK*/ return 0x122E; }
|
||||
"\xE2\x80\x9D" { /*RIGHT_DOUBLE_QUOTATION_MARK*/ return 0x122F; }
|
||||
|
||||
/*Extended French*/
|
||||
"\xC3\x80" { /*LATIN_CAPITAL_LETTER_A_WITH_GRAVE*/ return 0x1230; }
|
||||
"\xC3\x82" { /*LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX*/ return 0x1231; }
|
||||
"\xC3\x87" { /*LATIN_CAPITAL_LETTER_C_WITH_CEDILLA*/ return 0x1232; }
|
||||
"\xC3\x88" { /*LATIN_CAPITAL_LETTER_E_WITH_GRAVE*/ return 0x1233; }
|
||||
"\xC3\x8A" { /*LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX*/ return 0x1234; }
|
||||
"\xC3\x8B" { /*LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS*/ return 0x1235; }
|
||||
"\xC3\xAB" { /*LATIN_SMALL_LETTER_E_WITH_DIAERESIS*/ return 0x1236; }
|
||||
"\xC3\x8E" { /*LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX*/ return 0x1237; }
|
||||
"\xC3\x8F" { /*LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS*/ return 0x1238; }
|
||||
"\xC3\xAF" { /*LATIN_SMALL_LETTER_I_WITH_DIAERESIS*/ return 0x1239; }
|
||||
"\xC3\x94" { /*LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX*/ return 0x123A; }
|
||||
"\xC3\x99" { /*LATIN_CAPITAL_LETTER_U_WITH_GRAVE*/ return 0x123B; }
|
||||
"\xC3\xB9" { /*LATIN_SMALL_LETTER_U_WITH_GRAVE*/ return 0x123C; }
|
||||
"\xC3\x9B" { /*LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX*/ return 0x123D; }
|
||||
"\xC2\xAB" { /*LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK*/ return 0x123E; }
|
||||
"\xC2\xBB" { /*RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK*/ return 0x123F; }
|
||||
|
||||
/*Portuguese*/
|
||||
"\xC3\x83" { /*LATIN_CAPITAL_LETTER_A_WITH_TILDE*/ return 0x1320; }
|
||||
"\xC3\xA3" { /*LATIN_SMALL_LETTER_A_WITH_TILDE*/ return 0x1321; }
|
||||
"\xC3\x8D" { /*LATIN_CAPITAL_LETTER_I_WITH_ACUTE*/ return 0x1322; }
|
||||
"\xC3\x8C" { /*LATIN_CAPITAL_LETTER_I_WITH_GRAVE*/ return 0x1323; }
|
||||
"\xC3\xAC" { /*LATIN_SMALL_LETTER_I_WITH_GRAVE*/ return 0x1324; }
|
||||
"\xC3\x92" { /*LATIN_CAPITAL_LETTER_O_WITH_GRAVE*/ return 0x1325; }
|
||||
"\xC3\xB2" { /*LATIN_SMALL_LETTER_O_WITH_GRAVE*/ return 0x1326; }
|
||||
"\xC3\x95" { /*LATIN_CAPITAL_LETTER_O_WITH_TILDE*/ return 0x1327; }
|
||||
"\xC3\xB5" { /*LATIN_SMALL_LETTER_O_WITH_TILDE*/ return 0x1328; }
|
||||
/*LEFT_CURLY_BRACKET handled in ASCII mapping*/
|
||||
/*RIGHT_CURLY_BRACKET handled in ASCII mapping*/
|
||||
/*REVERSE_SOLIDUS handled in ASCII mapping*/
|
||||
/*CIRCUMFLEX_ACCENT handled in ASCII mapping*/
|
||||
/*LOW_LINE handled in ASCII mapping*/
|
||||
/*VERTICAL_LINE handled in ASCII mapping*/
|
||||
/*TILDE handled in ASCII mapping*/
|
||||
|
||||
/*German/Danish*/
|
||||
"\xC3\x84" { /*LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS*/ return 0x1330; }
|
||||
"\xC3\xA4" { /*LATIN_SMALL_LETTER_A_WITH_DIAERESIS*/ return 0x1331; }
|
||||
"\xC3\x96" { /*LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS*/ return 0x1332; }
|
||||
"\xC3\xB6" { /*LATIN_SMALL_LETTER_O_WITH_DIAERESIS*/ return 0x1333; }
|
||||
"\xC3\x9F" { /*LATIN_SMALL_LETTER_SHARP_S*/ return 0x1334; }
|
||||
"\xC2\xA5" { /*YEN_SIGN*/ return 0x1335; }
|
||||
"\xC2\xA4" { /*CURRENCY_SIGN*/ return 0x1336; }
|
||||
"\xC2\xA6" { /*BROKEN_BAR*/ return 0x1337; }
|
||||
"\xC3\x85" { /*LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE*/ return 0x1338; }
|
||||
"\xC3\xA5" { /*LATIN_SMALL_LETTER_A_WITH_RING_ABOVE*/ return 0x1339; }
|
||||
"\xC3\x98" { /*LATIN_CAPITAL_LETTER_O_WITH_STROKE*/ return 0x133A; }
|
||||
"\xC3\xB8" { /*LATIN_SMALL_LETTER_O_WITH_STROKE*/ return 0x133B; }
|
||||
"\xE2\x94\x8C" { /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT*/ return 0x133C; }
|
||||
"\xE2\x94\x90" { /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT*/ return 0x133D; }
|
||||
"\xE2\x94\x94" { /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT*/ return 0x133E; }
|
||||
"\xE2\x94\x98" { /*EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT*/ return 0x133F; }
|
||||
|
||||
/*Default rule*/
|
||||
[^] { /*DEFAULT_RULE*/ return 0x0000; }
|
||||
*/
|
||||
}
|
||||
54
deps/libcaption/src/eia608_charmap.c
vendored
Normal file
54
deps/libcaption/src/eia608_charmap.c
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "eia608_charmap.h"
|
||||
// 0 - 95: Basic North American character set
|
||||
// 96 - 111: Special North American character
|
||||
// 112 - 127: Extended Western European character set : Extended Spanish/Miscellaneous
|
||||
// 128 - 143: Extended Western European character set : Extended French
|
||||
// 144 - 159: Extended Western European character set : Portuguese
|
||||
// 160 - 175: Extended Western European character set : German/Danish
|
||||
const char* eia608_char_map[] = {
|
||||
EIA608_CHAR_SPACE, EIA608_CHAR_EXCLAMATION_MARK, EIA608_CHAR_QUOTATION_MARK, EIA608_CHAR_NUMBER_SIGN, EIA608_CHAR_DOLLAR_SIGN, EIA608_CHAR_PERCENT_SIGN, EIA608_CHAR_AMPERSAND, EIA608_CHAR_RIGHT_SINGLE_QUOTATION_MARK,
|
||||
EIA608_CHAR_LEFT_PARENTHESIS, EIA608_CHAR_RIGHT_PARENTHESIS, EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_ACUTE, EIA608_CHAR_PLUS_SIGN, EIA608_CHAR_COMMA, EIA608_CHAR_HYPHEN_MINUS, EIA608_CHAR_FULL_STOP, EIA608_CHAR_SOLIDUS,
|
||||
EIA608_CHAR_DIGIT_ZERO, EIA608_CHAR_DIGIT_ONE, EIA608_CHAR_DIGIT_TWO, EIA608_CHAR_DIGIT_THREE, EIA608_CHAR_DIGIT_FOUR, EIA608_CHAR_DIGIT_FIVE, EIA608_CHAR_DIGIT_SIX, EIA608_CHAR_DIGIT_SEVEN, EIA608_CHAR_DIGIT_EIGHT,
|
||||
EIA608_CHAR_DIGIT_NINE, EIA608_CHAR_COLON, EIA608_CHAR_SEMICOLON, EIA608_CHAR_LESS_THAN_SIGN, EIA608_CHAR_EQUALS_SIGN, EIA608_CHAR_GREATER_THAN_SIGN, EIA608_CHAR_QUESTION_MARK, EIA608_CHAR_COMMERCIAL_AT,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A, EIA608_CHAR_LATIN_CAPITAL_LETTER_B, EIA608_CHAR_LATIN_CAPITAL_LETTER_C, EIA608_CHAR_LATIN_CAPITAL_LETTER_D, EIA608_CHAR_LATIN_CAPITAL_LETTER_E, EIA608_CHAR_LATIN_CAPITAL_LETTER_F, EIA608_CHAR_LATIN_CAPITAL_LETTER_G, EIA608_CHAR_LATIN_CAPITAL_LETTER_H,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_I, EIA608_CHAR_LATIN_CAPITAL_LETTER_J, EIA608_CHAR_LATIN_CAPITAL_LETTER_K, EIA608_CHAR_LATIN_CAPITAL_LETTER_L, EIA608_CHAR_LATIN_CAPITAL_LETTER_M, EIA608_CHAR_LATIN_CAPITAL_LETTER_N, EIA608_CHAR_LATIN_CAPITAL_LETTER_O, EIA608_CHAR_LATIN_CAPITAL_LETTER_P,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_Q, EIA608_CHAR_LATIN_CAPITAL_LETTER_R, EIA608_CHAR_LATIN_CAPITAL_LETTER_S, EIA608_CHAR_LATIN_CAPITAL_LETTER_T, EIA608_CHAR_LATIN_CAPITAL_LETTER_U, EIA608_CHAR_LATIN_CAPITAL_LETTER_V, EIA608_CHAR_LATIN_CAPITAL_LETTER_W, EIA608_CHAR_LATIN_CAPITAL_LETTER_X,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_Y, EIA608_CHAR_LATIN_CAPITAL_LETTER_Z, EIA608_CHAR_LEFT_SQUARE_BRACKET, EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_ACUTE, EIA608_CHAR_RIGHT_SQUARE_BRACKET, EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_ACUTE, EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_ACUTE,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_ACUTE, EIA608_CHAR_LATIN_SMALL_LETTER_A, EIA608_CHAR_LATIN_SMALL_LETTER_B, EIA608_CHAR_LATIN_SMALL_LETTER_C, EIA608_CHAR_LATIN_SMALL_LETTER_D, EIA608_CHAR_LATIN_SMALL_LETTER_E, EIA608_CHAR_LATIN_SMALL_LETTER_F, EIA608_CHAR_LATIN_SMALL_LETTER_G, EIA608_CHAR_LATIN_SMALL_LETTER_H,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_I, EIA608_CHAR_LATIN_SMALL_LETTER_J, EIA608_CHAR_LATIN_SMALL_LETTER_K, EIA608_CHAR_LATIN_SMALL_LETTER_L, EIA608_CHAR_LATIN_SMALL_LETTER_M, EIA608_CHAR_LATIN_SMALL_LETTER_N, EIA608_CHAR_LATIN_SMALL_LETTER_O, EIA608_CHAR_LATIN_SMALL_LETTER_P,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_Q, EIA608_CHAR_LATIN_SMALL_LETTER_R, EIA608_CHAR_LATIN_SMALL_LETTER_S, EIA608_CHAR_LATIN_SMALL_LETTER_T, EIA608_CHAR_LATIN_SMALL_LETTER_U, EIA608_CHAR_LATIN_SMALL_LETTER_V, EIA608_CHAR_LATIN_SMALL_LETTER_W, EIA608_CHAR_LATIN_SMALL_LETTER_X,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_Y, EIA608_CHAR_LATIN_SMALL_LETTER_Z, EIA608_CHAR_LATIN_SMALL_LETTER_C_WITH_CEDILLA, EIA608_CHAR_DIVISION_SIGN, EIA608_CHAR_LATIN_CAPITAL_LETTER_N_WITH_TILDE, EIA608_CHAR_LATIN_SMALL_LETTER_N_WITH_TILDE, EIA608_CHAR_FULL_BLOCK,
|
||||
EIA608_CHAR_REGISTERED_SIGN, EIA608_CHAR_DEGREE_SIGN, EIA608_CHAR_VULGAR_FRACTION_ONE_HALF, EIA608_CHAR_INVERTED_QUESTION_MARK, EIA608_CHAR_TRADE_MARK_SIGN, EIA608_CHAR_CENT_SIGN, EIA608_CHAR_POUND_SIGN, EIA608_CHAR_EIGHTH_NOTE,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_GRAVE, EIA608_CHAR_NO_BREAK_SPACE, EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_GRAVE, EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_CIRCUMFLEX,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_ACUTE, EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_ACUTE, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_ACUTE, EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_ACUTE, EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_DIAERESIS, EIA608_CHAR_LEFT_SINGLE_QUOTATION_MARK, EIA608_CHAR_INVERTED_EXCLAMATION_MARK,
|
||||
EIA608_CHAR_ASTERISK, EIA608_CHAR_APOSTROPHE, EIA608_CHAR_EM_DASH, EIA608_CHAR_COPYRIGHT_SIGN, EIA608_CHAR_SERVICE_MARK, EIA608_CHAR_BULLET, EIA608_CHAR_LEFT_DOUBLE_QUOTATION_MARK, EIA608_CHAR_RIGHT_DOUBLE_QUOTATION_MARK,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_GRAVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_CAPITAL_LETTER_C_WITH_CEDILLA, EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_GRAVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_CAPITAL_LETTER_E_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_E_WITH_DIAERESIS, EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_CIRCUMFLEX,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_DIAERESIS, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_CIRCUMFLEX, EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_GRAVE, EIA608_CHAR_LATIN_SMALL_LETTER_U_WITH_GRAVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_U_WITH_CIRCUMFLEX, EIA608_CHAR_LEFT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK, EIA608_CHAR_RIGHT_POINTING_DOUBLE_ANGLE_QUOTATION_MARK,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_TILDE, EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_TILDE, EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_ACUTE, EIA608_CHAR_LATIN_CAPITAL_LETTER_I_WITH_GRAVE, EIA608_CHAR_LATIN_SMALL_LETTER_I_WITH_GRAVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_GRAVE, EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_GRAVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_TILDE,
|
||||
EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_TILDE, EIA608_CHAR_LEFT_CURLY_BRACKET, EIA608_CHAR_RIGHT_CURLY_BRACKET, EIA608_CHAR_REVERSE_SOLIDUS, EIA608_CHAR_CIRCUMFLEX_ACCENT, EIA608_CHAR_LOW_LINE, EIA608_CHAR_VERTICAL_LINE, EIA608_CHAR_TILDE,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_DIAERESIS, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_DIAERESIS, EIA608_CHAR_LATIN_SMALL_LETTER_SHARP_S, EIA608_CHAR_YEN_SIGN, EIA608_CHAR_CURRENCY_SIGN, EIA608_CHAR_BROKEN_BAR,
|
||||
EIA608_CHAR_LATIN_CAPITAL_LETTER_A_WITH_RING_ABOVE, EIA608_CHAR_LATIN_SMALL_LETTER_A_WITH_RING_ABOVE, EIA608_CHAR_LATIN_CAPITAL_LETTER_O_WITH_STROKE, EIA608_CHAR_LATIN_SMALL_LETTER_O_WITH_STROKE, EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT, EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT, EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT, EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT,
|
||||
};
|
||||
54
deps/libcaption/src/scc.c
vendored
Normal file
54
deps/libcaption/src/scc.c
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "scc.h"
|
||||
#include "utf8.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FRAME_RATE (1000.0/30)
|
||||
#define SCCTIME2MS(HH,MM,SS,FF) (((HH*3600.0 + MM*60.0 + SS) * 1000.0) + ( FF * FRAME_RATE ))
|
||||
|
||||
// 00:00:25:16 9420 9440 aeae ae79 ef75 2068 6176 e520 79ef 75f2 20f2 ef62 eff4 e9e3 732c 2061 6e64 2049 94fe 9723 ea75 73f4 20f7 616e f420 f4ef 2062 e520 61f7 e573 ef6d e520 e96e 2073 7061 e3e5 ae80 942c 8080 8080 942f
|
||||
|
||||
int scc_to_608 (const char* line, double* pts, uint16_t* cc, int cc_max)
|
||||
{
|
||||
int cc_count = 0, cc_data = 0, hh = 0, mm = 0, ss = 0, ff = 0;
|
||||
|
||||
// TODO if ';' use 29.79 fps, if ':' use 30 fls
|
||||
if (4 == sscanf (line, "%2d:%2d:%2d%*1[:;]%2d", &hh, &mm, &ss, &ff)) {
|
||||
(*pts) = SCCTIME2MS (hh,mm,ss,ff); // scc files start at one hour for some reason
|
||||
line += 12;
|
||||
|
||||
while (1 == sscanf (line, "%04x ", &cc_data)) {
|
||||
line += 5; cc[cc_count] = cc_data; ++cc_count;
|
||||
|
||||
if (cc_count >= cc_max) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cc_count;
|
||||
}
|
||||
194
deps/libcaption/src/srt.c
vendored
Normal file
194
deps/libcaption/src/srt.c
vendored
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
#include "srt.h"
|
||||
#include "utf8.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
srt_t* srt_new (const utf8_char_t* data, size_t size, double timestamp, srt_t* prev, srt_t** head)
|
||||
{
|
||||
srt_t* srt = malloc (sizeof (srt_t)+size+1);
|
||||
srt->next = 0;
|
||||
srt->duration = 0;
|
||||
srt->aloc = size;
|
||||
srt->timestamp = timestamp;
|
||||
utf8_char_t* dest = (utf8_char_t*) srt_data (srt);
|
||||
|
||||
if (prev) {
|
||||
prev->next = srt;
|
||||
prev->duration = timestamp - prev->timestamp;
|
||||
}
|
||||
|
||||
if (head && 0 == (*head)) {
|
||||
(*head) = srt;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
memcpy (dest, data, size);
|
||||
} else {
|
||||
memset (dest, 0, size);
|
||||
}
|
||||
|
||||
dest[size] = '\0';
|
||||
return srt;
|
||||
}
|
||||
|
||||
srt_t* srt_free_head (srt_t* head)
|
||||
{
|
||||
srt_t* next = head->next;
|
||||
free (head);
|
||||
return next;
|
||||
}
|
||||
|
||||
void srt_free (srt_t* srt)
|
||||
{
|
||||
while (srt) {
|
||||
srt = srt_free_head (srt);
|
||||
}
|
||||
}
|
||||
|
||||
#define SRTTIME2SECONDS(HH,MM,SS,MS) ((HH*3600.0) + (MM*60.0) + SS + (MS/1000.0))
|
||||
srt_t* srt_parse (const utf8_char_t* data, size_t size)
|
||||
{
|
||||
int counter;
|
||||
srt_t* head = 0, *prev = 0;
|
||||
double str_pts = 0, end_pts = 0;
|
||||
size_t line_length = 0, trimmed_length = 0;
|
||||
int hh1, hh2, mm1, mm2, ss1, ss2, ms1, ms2;
|
||||
|
||||
for (;;) {
|
||||
line_length = 0;
|
||||
|
||||
do {
|
||||
data += line_length;
|
||||
size -= line_length;
|
||||
line_length = utf8_line_length (data);
|
||||
trimmed_length = utf8_trimmed_length (data,line_length);
|
||||
// Skip empty lines
|
||||
} while (0 < line_length && 0 == trimmed_length);
|
||||
|
||||
// linelength cant be zero before EOF
|
||||
if (0 == line_length) {
|
||||
break;
|
||||
}
|
||||
|
||||
counter = atoi (data);
|
||||
// printf ("counter (%d): '%.*s'\n", line_length, (int) line_length, data);
|
||||
data += line_length;
|
||||
size -= line_length;
|
||||
|
||||
line_length = utf8_line_length (data);
|
||||
// printf ("time (%d): '%.*s'\n", line_length, (int) line_length, data);
|
||||
|
||||
{
|
||||
if (8 == sscanf (data, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d", &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2)) {
|
||||
str_pts = SRTTIME2SECONDS (hh1, mm1, ss1, ms1);
|
||||
end_pts = SRTTIME2SECONDS (hh2, mm2, ss2, ms2);
|
||||
}
|
||||
|
||||
data += line_length;
|
||||
size -= line_length;
|
||||
}
|
||||
|
||||
// Caption text starts here
|
||||
const utf8_char_t* text = data;
|
||||
size_t text_size = 0;
|
||||
// printf ("time: '(%f --> %f)\n",srt.srt_time, srt.end_time);
|
||||
|
||||
do {
|
||||
line_length = utf8_line_length (data);
|
||||
trimmed_length = utf8_trimmed_length (data,line_length);
|
||||
// printf ("cap (%d): '%.*s'\n", line_length, (int) trimmed_length, data);
|
||||
data += line_length;
|
||||
size -= line_length;
|
||||
text_size += line_length;
|
||||
} while (trimmed_length);
|
||||
|
||||
// should we trim here?
|
||||
srt_t* srt = srt_new (text,text_size,str_pts,prev,&head);
|
||||
srt->duration = end_pts - str_pts;
|
||||
prev = srt;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
int srt_to_caption_frame (srt_t* srt, caption_frame_t* frame)
|
||||
{
|
||||
const char* data = srt_data (srt);
|
||||
return caption_frame_from_text (frame,data);
|
||||
}
|
||||
|
||||
srt_t* srt_from_caption_frame (caption_frame_t* frame, srt_t* prev, srt_t** head)
|
||||
{
|
||||
// CRLF per row, plus an extra at the end
|
||||
srt_t* srt = srt_new (0, 2+CAPTION_FRAME_TEXT_BYTES, frame->timestamp, prev, head);
|
||||
utf8_char_t* data = srt_data (srt);
|
||||
|
||||
caption_frame_to_text (frame,data);
|
||||
// srt requires an extra new line
|
||||
strcat ( (char*) data,"\r\n");
|
||||
|
||||
return srt;
|
||||
}
|
||||
|
||||
static inline void _crack_time (double tt, int* hh, int* mm, int* ss, int* ms)
|
||||
{
|
||||
(*ms) = (int) ((int64_t) (tt * 1000.0) % 1000);
|
||||
(*ss) = (int) ((int64_t) (tt) % 60);
|
||||
(*mm) = (int) ((int64_t) (tt / (60.0)) % 60);
|
||||
(*hh) = (int) ((int64_t) (tt / (60.0*60.0)));
|
||||
}
|
||||
|
||||
static void _dump (srt_t* head, char type)
|
||||
{
|
||||
int i;
|
||||
srt_t* srt;
|
||||
|
||||
if ('v' == type) {
|
||||
printf ("WEBVTT\r\n");
|
||||
}
|
||||
|
||||
for (srt = head, i = 1; srt; srt=srt_next (srt), ++i) {
|
||||
int hh1, hh2, mm1, mm2, ss1, ss2, ms1, ms2;
|
||||
_crack_time (srt->timestamp, &hh1, &mm1, &ss1, &ms1);
|
||||
_crack_time (srt->timestamp + srt->duration, &hh2, &mm2, &ss2, &ms2);
|
||||
|
||||
if ('s' == type) {
|
||||
printf ("%02d\r\n%d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n%s\r\n", i,
|
||||
hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, srt_data (srt));
|
||||
}
|
||||
|
||||
else if ('v' == type) {
|
||||
printf ("%d:%02d:%02d.%03d --> %02d:%02d:%02d.%03d\r\n%s\r\n",
|
||||
hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, srt_data (srt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void srt_dump (srt_t* head) { _dump (head,'s'); }
|
||||
void vtt_dump (srt_t* head) { _dump (head,'v'); }
|
||||
170
deps/libcaption/src/utf8.c
vendored
Normal file
170
deps/libcaption/src/utf8.c
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include "utf8.h"
|
||||
#include <string.h>
|
||||
|
||||
const utf8_char_t* utf8_char_next (const char* s)
|
||||
{
|
||||
if (0x80 == (s[0]&0xC0)) { ++s; }
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// returnes the length of the char in bytes
|
||||
size_t utf8_char_length (const utf8_char_t* c)
|
||||
{
|
||||
// count null term as zero size
|
||||
if (0x00 == c[0]) { return 0; }
|
||||
|
||||
if (0x00 == (c[0]&0x80)) { return 1; }
|
||||
|
||||
if (0xC0 == (c[0]&0xE0) && 0x80 == (c[1]&0xC0)) { return 2; }
|
||||
|
||||
if (0xE0 == (c[0]&0xF0) && 0x80 == (c[1]&0xC0) && 0x80 == (c[2]&0xC0)) { return 3; }
|
||||
|
||||
if (0xF0 == (c[0]&0xF8) && 0x80 == (c[1]&0xC0) && 0x80 == (c[2]&0xC0) && 0x80 == (c[3]&0xC0)) { return 4; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns length of the string in bytes
|
||||
// size is number of charcter to count (0 to count until NULL term)
|
||||
size_t utf8_string_length (const utf8_char_t* data, utf8_size_t size)
|
||||
{
|
||||
size_t char_length, byts = 0;
|
||||
|
||||
if (0 == size) {
|
||||
size = utf8_char_count (data,0);
|
||||
}
|
||||
|
||||
for (; 0 < size ; --size) {
|
||||
if (0 == (char_length = utf8_char_length (data))) {
|
||||
break;
|
||||
}
|
||||
|
||||
data += char_length;
|
||||
byts += char_length;
|
||||
}
|
||||
|
||||
return byts;
|
||||
}
|
||||
|
||||
size_t utf8_char_copy (utf8_char_t* dst, const utf8_char_t* src)
|
||||
{
|
||||
size_t bytes = utf8_char_length (src);
|
||||
|
||||
if (bytes&&dst) {
|
||||
memcpy (dst,src,bytes);
|
||||
dst[bytes] = '\0';
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// returnes the number of utf8 charcters in a string given the number of bytes
|
||||
// to count until the a null terminator, pass 0 for size
|
||||
utf8_size_t utf8_char_count (const char* data, size_t size)
|
||||
{
|
||||
size_t i, bytes = 0;
|
||||
utf8_size_t count = 0;
|
||||
|
||||
if (0 == size) {
|
||||
size = strlen (data);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < size ; ++count, i += bytes) {
|
||||
if (0 == (bytes = utf8_char_length (&data[i]))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
// returnes the length of the line in bytes triming not printable charcters at the end
|
||||
size_t utf8_trimmed_length (const char* data, size_t size)
|
||||
{
|
||||
for (; 0 < size && ' ' >= (uint8_t) data[size-1] ; --size) { }
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// returns the length in bytes of the line including the new line charcter(s)
|
||||
// auto detects between windows(CRLF), unix(LF), mac(CR) and riscos (LFCR) line endings
|
||||
size_t utf8_line_length (const char* data)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
for (len = 0; 0 != data[len]; ++len) {
|
||||
if ('\r' == data[len]) {
|
||||
if ('\n' == data[len+1]) {
|
||||
return len + 2; // windows
|
||||
} else {
|
||||
return len + 1; // unix
|
||||
}
|
||||
} else if ('\n' == data[len]) {
|
||||
if ('\r' == data[len+1]) {
|
||||
return len + 2; // riscos
|
||||
} else {
|
||||
return len + 1; // macos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
// returns number of chars to include before split
|
||||
utf8_size_t utf8_wrap_length (const utf8_char_t* data, utf8_size_t size)
|
||||
{
|
||||
// Set split_at to size, so if a split point cna not be found, retuns the size passed in
|
||||
size_t char_length, char_count, split_at = size;
|
||||
|
||||
for (char_count = 0 ; char_count <= size ; ++char_count) {
|
||||
if (' ' >= (*data)) {
|
||||
split_at = char_count;
|
||||
}
|
||||
|
||||
char_length = utf8_char_length (data);
|
||||
data += char_length;
|
||||
}
|
||||
|
||||
return split_at;
|
||||
}
|
||||
|
||||
int utf8_line_count (const utf8_char_t* data)
|
||||
{
|
||||
size_t len = 0;
|
||||
int count = 0;
|
||||
|
||||
do {
|
||||
len = utf8_line_length (data);
|
||||
data += len; ++count;
|
||||
} while (0<len);
|
||||
|
||||
return count-1;
|
||||
}
|
||||
51
deps/libcaption/src/xds.c
vendored
Normal file
51
deps/libcaption/src/xds.c
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**********************************************************************************************/
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file */
|
||||
/* except in compliance with the License. A copy of the License is located at */
|
||||
/* */
|
||||
/* http://aws.amazon.com/apache2.0/ */
|
||||
/* */
|
||||
/* or in the "license" file accompanying this file. This file is distributed on an "AS IS" */
|
||||
/* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the */
|
||||
/* License for the specific language governing permissions and limitations under the License. */
|
||||
/**********************************************************************************************/
|
||||
// http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/CC_XDS.HTML#PR
|
||||
#include "xds.h"
|
||||
#include "caption.h"
|
||||
#include <string.h>
|
||||
|
||||
void xds_init (xds_t* xds)
|
||||
{
|
||||
memset (xds,0,sizeof (xds_t));
|
||||
}
|
||||
|
||||
int xds_decode (xds_t* xds, uint16_t cc)
|
||||
{
|
||||
switch (xds->state) {
|
||||
default:
|
||||
case 0:
|
||||
xds_init (xds);
|
||||
xds->class = (cc&0x0F00) >>8;
|
||||
xds->type = (cc&0x000F);
|
||||
xds->state = 1;
|
||||
return LIBCAPTION_OK;
|
||||
|
||||
case 1:
|
||||
if (0x8F00 == (cc&0xFF00)) {
|
||||
xds->checksum = (cc&0x007F);
|
||||
xds->state = 0;
|
||||
return LIBCAPTION_READY;
|
||||
}
|
||||
|
||||
if (xds->size < 32) {
|
||||
xds->content[xds->size+0] = (cc&0x7F00) >>8;
|
||||
xds->content[xds->size+1] = (cc&0x007F);
|
||||
xds->size += 2;
|
||||
return LIBCAPTION_OK;
|
||||
}
|
||||
}
|
||||
|
||||
xds->state = 0;
|
||||
return LIBCAPTION_ERROR;
|
||||
}
|
||||
280
deps/libcaption/unit_tests/eia608_test.c
vendored
Normal file
280
deps/libcaption/unit_tests/eia608_test.c
vendored
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include "eia608.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
// all possible utf8 valies, including invalid ones
|
||||
void encode_utf8ish (int32_t in, char out[7])
|
||||
{
|
||||
if (0 > in) {
|
||||
out[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0xxxxxxx, 7 bits
|
||||
if (0x80 > in) {
|
||||
out[0] = in;
|
||||
out[1] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 110xxxxx 10xxxxxx, 11 bits
|
||||
if (0x800 > in) {
|
||||
out[0] = 0xC0 | ( (in >> (6*1)) & 0x1F);
|
||||
out[1] = 0x80 | ( (in >> (6*0)) & 0x3F);
|
||||
out[2] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 1110xxxx 10xxxxxx 10xxxxxx, 16 bits
|
||||
if (0x10000 > in) {
|
||||
out[0] = 0xE0 | ( (in >> (6*2)) & 0x0F);
|
||||
out[1] = 0x80 | ( (in >> (6*1)) & 0x3F);
|
||||
out[2] = 0x80 | ( (in >> (6*0)) & 0x3F);
|
||||
out[3] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx, 21 bits
|
||||
if (0x200000 > in) {
|
||||
out[0] = 0xF0 | ( (in >> (6*3)) & 0x07);
|
||||
out[1] = 0x80 | ( (in >> (6*2)) & 0x3F);
|
||||
out[2] = 0x80 | ( (in >> (6*1)) & 0x3F);
|
||||
out[3] = 0x80 | ( (in >> (6*0)) & 0x3F);
|
||||
out[4] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx, 26 bits
|
||||
if (0x4000000 > in) {
|
||||
out[0] = 0xF8 | ( (in >> (6*4)) & 0x03);
|
||||
out[1] = 0x80 | ( (in >> (6*3)) & 0x3F);
|
||||
out[2] = 0x80 | ( (in >> (6*2)) & 0x3F);
|
||||
out[3] = 0x80 | ( (in >> (6*1)) & 0x3F);
|
||||
out[4] = 0x80 | ( (in >> (6*0)) & 0x3F);
|
||||
out[5] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx, 31 bits
|
||||
if (0x80000000 > in) {
|
||||
out[0] = 0xFC | ( (in >> (6*5)) & 0x01);
|
||||
out[1] = 0x80 | ( (in >> (6*4)) & 0x3F);
|
||||
out[2] = 0x80 | ( (in >> (6*3)) & 0x3F);
|
||||
out[3] = 0x80 | ( (in >> (6*2)) & 0x3F);
|
||||
out[4] = 0x80 | ( (in >> (6*1)) & 0x3F);
|
||||
out[5] = 0x80 | ( (in >> (6*0)) & 0x3F);
|
||||
out[6] = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void test_all_utf8()
|
||||
{
|
||||
char s[7]; size_t size, count = 0; uint16_t code1, code2;
|
||||
|
||||
for (int i = 0 ; i < 0x80000000 ; ++i) {
|
||||
encode_utf8ish (i, &s[0]);
|
||||
code1 = eia608_from_utf8 ( (const char*) &s[0], 0, &size);
|
||||
|
||||
// code2 = eia608_from_utf8 ( (const char*) &s[0], 1, &size);
|
||||
if (code1) {
|
||||
++count;
|
||||
printf ("%d: string: '%s' code: %04X\n",count, &s[0],code1);
|
||||
}
|
||||
}
|
||||
|
||||
// Count must be 177
|
||||
// 176 charcters, pile we have two mapping for left quote mark
|
||||
}
|
||||
|
||||
#define BIN "%d%d%d%d%d%d%d%d %d%d%d%d%d%d%d%d"
|
||||
#define BIND(D) ((D)>>15)&0x01, ((D)>>14)&0x01,((D)>>13)&0x01,((D)>>12)&0x01,((D)>>11)&0x01,((D)>>10)&0x01,((D)>>9)&0x01,((D)>>8)&0x01,((D)>>7)&0x01,((D)>>6)&0x01,((D)>>5)&0x01,((D)>>4)&0x01,((D)>>3)&0x01,((D)>>2)&0x01,((D)>>1)&0x01,((D)>>0)&0x01
|
||||
|
||||
|
||||
void print_bin (int n)
|
||||
{
|
||||
int mask = 0x80;
|
||||
|
||||
for (int mask = 0x80 ; mask ; mask >>= 1) {
|
||||
printf ("%s", n & mask ? "1" : "0");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void void_test_all_possible_code_words()
|
||||
{
|
||||
for (int i = 0 ; i <= 0x3FFF ; ++i) {
|
||||
int16_t code = eia608_parity ( ( (i<<1) &0x7F00) | (i&0x7F));
|
||||
|
||||
int count =eia608_cc_data_is_extended_data_service (code)+
|
||||
eia608_cc_data_is_basic_north_american_character (code) +
|
||||
eia608_cc_data_is_special_north_american_character (code) +
|
||||
eia608_cc_data_is_extended_western_european_character (code) +
|
||||
eia608_cc_data_is_nonwestern_norpak_character (code) +
|
||||
eia608_cc_data_is_row_preamble (code) +
|
||||
eia608_cc_data_is_control_command (code);
|
||||
|
||||
if (1 < count) {
|
||||
printf ("code 0x%04X matched >1\n",code&0x7F7F);
|
||||
}
|
||||
|
||||
// if (0 == count) {
|
||||
// printf ("code 0x%04X not matched %d\n",eia608_strip_parity_bits (code), i);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void print_charmap()
|
||||
{
|
||||
for (int i = 0 ; i < EIA608_CHAR_COUNT ; ++i) {
|
||||
printf ("%s", eia608_char_map[i]);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void dance()
|
||||
{
|
||||
for (int i = 0 ; i < 100 ; ++i) {
|
||||
const char* l = 0 == rand() % 2 ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT;
|
||||
const char* r = 0 == rand() % 2 ? EIA608_CHAR_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT : EIA608_CHAR_BOX_DRAWINGS_LIGHT_UP_AND_LEFT;
|
||||
printf ("%s %s%s%s%s%s%s%s %s ", EIA608_CHAR_EIGHTH_NOTE, l, EIA608_CHAR_LEFT_PARENTHESIS, EIA608_CHAR_EM_DASH, EIA608_CHAR_LOW_LINE, EIA608_CHAR_EM_DASH,
|
||||
EIA608_CHAR_RIGHT_PARENTHESIS, r, EIA608_CHAR_EIGHTH_NOTE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char** arg)
|
||||
{
|
||||
// print_charmap();
|
||||
// // return 0;
|
||||
// srand (time (0));
|
||||
// // test_all_utf8();
|
||||
// // void_test_all_possible_code_words();
|
||||
// // return 0;
|
||||
// // print_charmap();
|
||||
// dance();
|
||||
// return 0;
|
||||
for (int i = 0 ; i <= 0x3FFF ; ++i) {
|
||||
uint16_t code1 = eia608_parity ( ( (i<<1) &0x7F00) | (i&0x7F));
|
||||
|
||||
switch (eia608_cc_data_type (code1)) {
|
||||
default:
|
||||
case EIA608_CC_DATA_UNKNOWN:
|
||||
// printf ("Unknown code %04X\n",code);
|
||||
break;
|
||||
|
||||
case EIA608_CC_DATA_CONTROL_COMMAND: {
|
||||
int cc;
|
||||
eia608_control_t cmd = eia608_parse_control (code1, &cc);
|
||||
uint16_t code2 = eia608_control_command (cmd,cc);
|
||||
|
||||
if (code1 != code2) {
|
||||
printf (BIN " != " BIN " (0x%04x != 0x%04x) cc: %d\n", BIND (code1), BIND (code2),code1,code2,cc);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
case EIA608_CC_DATA_BASIC_NORTH_AMERICAN_CHARACTER: {
|
||||
char char1[5], char2[5]; int chan; size_t size;
|
||||
|
||||
if (eia608_to_utf8 (code1, &chan, &char1[0], &char2[0])) {
|
||||
uint16_t code2 = eia608_from_utf8_2 (&char1[0], &char2[0]);
|
||||
|
||||
// if the second char is invalid, mask it off, we will accept the first
|
||||
if (0x80 < (code1 &0x007F) || 0x20 > (code1 &0x007F)) {
|
||||
code1 = (code1&0xFF00) |0x0080;
|
||||
}
|
||||
|
||||
if (code1 == code2) {
|
||||
// printf ("%s " BIN " == " BIN " (0x%04x == 0x%04x)\n", &char1[0], BIND (code1), BIND (code2),code1,code2);
|
||||
} else {
|
||||
printf ("%s %s " BIN " != " BIN " (0x%04x != 0x%04x)\n", &char1[0], &char2[0], BIND (code1), BIND (code2),code1,code2);
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case EIA608_CC_DATA_SPECIAL_NORTH_AMERICAN_CHARACTER:
|
||||
case EIA608_CC_DATA_EXTENDED_WESTERN_EUROPEAN_CHARACTER: {
|
||||
char char1[5], char2[5]; int chan; size_t size;
|
||||
|
||||
if (eia608_to_utf8 (code1, &chan, &char1[0], &char2[0])) {
|
||||
uint16_t code2 = eia608_from_utf8 (&char1[0], chan, &size);
|
||||
|
||||
if (code1 == code2) {
|
||||
// printf ("%s " BIN " == " BIN " (0x%04x == 0x%04x)\n", &char1[0], BIND (code1), BIND (code2),code1,code2);
|
||||
} else {
|
||||
printf ("%s " BIN " != " BIN " (0x%04x != 0x%04x)\n", &char1[0], BIND (code1), BIND (code2),code1,code2);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
// #define EIA608_CODE_ROW_PREAMBLE 4
|
||||
// #define EIA608_CODE_EXTENDED_DATA_SERVICE 5
|
||||
// #define EIA608_CODE_CONTROL_COMMAND 6
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// for (uint16_t i = 0 ; i < 0x4000; ++i) {
|
||||
// int chan;
|
||||
// char str[7];
|
||||
// uint16_t code = ( (i<<1) &0x7F00) | (i & 0x007F);
|
||||
//
|
||||
// if (eia608_to_utf8 (code,&chan,str)) {
|
||||
// printf ("code: 0x%04X str: '%s'\n", code,str);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // for(int i = 0 ; i < cie608_char_count ; ++i)
|
||||
// // {
|
||||
// // cie608_char_map[i]
|
||||
// //
|
||||
// // }
|
||||
//
|
||||
//
|
||||
// for (int i = 0 ; i < 128 ; ++i) {
|
||||
// // print_bin( B7( i ) );
|
||||
// // print_bin( eia608_parity_table[i] );
|
||||
// printf ("%d %d %d\n", i, 0x7F & eia608_parity_table[i], eia608_parity_table[i]);
|
||||
// // if ( i != eia608_parity_table[i] )
|
||||
// // {
|
||||
// // printf( "ERROR\n" );
|
||||
// //
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
148
deps/libcaption/unit_tests/test_sei.c
vendored
Normal file
148
deps/libcaption/unit_tests/test_sei.c
vendored
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
/**********************************************************************************************/
|
||||
/* The MIT License */
|
||||
/* */
|
||||
/* Copyright 2016-2016 Twitch Interactive, Inc. or its affiliates. All Rights Reserved. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include "avcsei.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint8_t sei1[] = { 0x06, 0x04, 0x68, 0xB5, 0x00, 0x31, 0x47, 0x41, 0x39, 0x34, 0x03, 0xDF, 0xFF, 0xFC, 0xEC, 0xE5,
|
||||
0xFC, 0xAE, 0x80, 0xFC, 0x94, 0x52, 0xFC, 0x97, 0xA1, 0xFC, 0x2A, 0x20, 0xFC, 0xDC, 0x20, 0xFC,
|
||||
0x5E, 0x20, 0xFC, 0xDF, 0x20, 0xFC, 0xE0, 0x20, 0xFC, 0x91, 0x38, 0xFC, 0x20, 0x80, 0xFC, 0x91,
|
||||
0xBA, 0xFC, 0x20, 0xE9, 0xFC, 0x13, 0xA4, 0xFC, 0x20, 0xEF, 0xFC, 0x13, 0x26, 0xFC, 0x20, 0x75,
|
||||
0xFC, 0x92, 0xBC, 0xFC, 0x94, 0xF2, 0xFC, 0x97, 0xA1, 0xFC, 0x61, 0x80, 0xFC, 0x13, 0x31, 0xFC,
|
||||
0x20, 0xE5, 0xFC, 0x92, 0xB6, 0xFC, 0x20, 0xE9, 0xFC, 0x92, 0xB9, 0xFC, 0x20, 0xEF, 0xFC, 0x13,
|
||||
0xB3, 0xFC, 0x20, 0x75, 0xFC, 0x92, 0x25, 0xFC, 0x20, 0x80, 0xFF, 0x80,
|
||||
};
|
||||
|
||||
uint8_t sei2[] = { 0x06, 0x04, 0x35, 0xB5, 0x00, 0x31, 0x47, 0x41, 0x39, 0x34, 0x03, 0xCE, 0xFF, 0xFC, 0x94, 0x26,
|
||||
0xFC, 0x94, 0xAD, 0xFC, 0x94, 0xF2, 0xFC, 0x43, 0xC1, 0xFC, 0xD0, 0x54, 0xFC, 0x49, 0x4F, 0xFC,
|
||||
0xCE, 0x20, 0xFC, 0x4C, 0x49, 0xFC, 0xCE, 0x45, 0xFC, 0xD3, 0x20, 0xFC, 0x52, 0x4F, 0xFC, 0x4C,
|
||||
0x4C, 0xFC, 0x20, 0xD5, 0xFC, 0xD0, 0x80, 0xFF, 0x80,
|
||||
};
|
||||
|
||||
|
||||
uint8_t sei3[] = { 0x06,
|
||||
0x04, 0x68, 0xB5, 0x00, 0x31, 0x47, 0x41, 0x39, 0x34, 0x03, 0xDF, 0xFF, 0xFC, 0xEC, 0xE5, 0xFC,
|
||||
0xAE, 0x80, 0xFC, 0x94, 0x52, 0xFC, 0x97, 0xA1, 0x00, 0x00, 0x03, 0x00, 0xFC, 0xDC, 0x20, 0xFC,
|
||||
0x5E, 0x20, 0xFC, 0xDF, 0x20, 0xFC, 0xE0, 0x20, 0xFC, 0x91, 0x38, 0xFC, 0x20, 0x80, 0xFC, 0x91,
|
||||
0xBA, 0xFC, 0x20, 0xE9, 0xFC, 0x13, 0xA4, 0xFC, 0x20, 0xEF, 0xFC, 0x13, 0x26, 0xFC, 0x20, 0x75,
|
||||
0xFC, 0x92, 0xBC, 0xFC, 0x94, 0xF2, 0xFC, 0x97, 0xA1, 0xFC, 0x61, 0x80, 0xFC, 0x13, 0x31, 0xFC,
|
||||
0x20, 0xE5, 0xFC, 0x92, 0xB6, 0xFC, 0x20, 0xE9, 0xFC, 0x92, 0xB9, 0xFC, 0x20, 0xEF, 0xFC, 0x13,
|
||||
0xB3, 0xFC, 0x20, 0x75, 0xFC, 0x92, 0x25, 0xFC, 0x20, 0x80, 0xFF,
|
||||
|
||||
0x04, 0x68, 0xB5, 0x00, 0x31, 0x47, 0x41, 0x39, 0x34, 0x03, 0xDF, 0xFF, 0xFC, 0xEC, 0xE5,
|
||||
0xFC, 0xAE, 0x80, 0xFC, 0x94, 0x52, 0xFC, 0x97, 0xA1, 0x00, 0x00, 0x03, 0x00, 0xFC, 0xDC, 0x20,
|
||||
0xFC, 0x5E, 0x20, 0xFC, 0xDF, 0x20, 0xFC, 0xE0, 0x20, 0xFC, 0x91, 0x38, 0xFC, 0x20, 0x80, 0xFC,
|
||||
0x91, 0xBA, 0xFC, 0x20, 0xE9, 0xFC, 0x13, 0xA4, 0xFC, 0x20, 0xEF, 0xFC, 0x13, 0x26, 0xFC, 0x20,
|
||||
0x75, 0xFC, 0x92, 0xBC, 0xFC, 0x94, 0xF2, 0xFC, 0x97, 0xA1, 0xFC, 0x61, 0x80, 0xFC, 0x13, 0x31,
|
||||
0xFC, 0x20, 0xE5, 0xFC, 0x92, 0xB6, 0xFC, 0x20, 0xE9, 0xFC, 0x92, 0xB9, 0xFC, 0x20, 0xEF, 0xFC,
|
||||
0x13, 0xB3, 0xFC, 0x20, 0x75, 0xFC, 0x92, 0x25, 0xFC, 0x20, 0x80, 0xFF,
|
||||
0x80,
|
||||
};
|
||||
|
||||
|
||||
// TODO make SEI with multiple messages
|
||||
// TODO make SEI with emupation prevention
|
||||
|
||||
|
||||
uint8_t* read_file (const char* file, size_t* size)
|
||||
{
|
||||
FILE* f = fopen (file, "rb");
|
||||
|
||||
if (! f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek (f,0,SEEK_END);
|
||||
(*size) = ftell (f);
|
||||
fseek (f,0,SEEK_SET);
|
||||
uint8_t* data = (uint8_t*) malloc (*size);
|
||||
|
||||
for (int i = 0 ; i < (*size) ;) {
|
||||
i += fread (&data[i], 1, *size, f);
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
return data;
|
||||
}
|
||||
|
||||
int test_emulation_byte()
|
||||
{
|
||||
avcsei_t sei;
|
||||
avcsei_init (&sei);
|
||||
avcsei_parse (&sei,sei3,sizeof (sei3));
|
||||
avcsei_dump (&sei);
|
||||
avcsei_free (&sei);
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char** argv)
|
||||
{
|
||||
// test_emulation_byte();
|
||||
// return 0;
|
||||
|
||||
size_t size;
|
||||
avcsei_t sei;
|
||||
cea708_t cea708;
|
||||
eia608_screen_t screen;
|
||||
char screen_buf[EIA608_SCREEN_DUMP_BUF_SIZE];
|
||||
char json_buf[EIA608_SCREEN_JSON_BUF_SIZE];
|
||||
|
||||
// uint8_t* data =
|
||||
for (int i = 1 ; i < argc ; ++i) {
|
||||
avcsei_init (&sei);
|
||||
eia608_screen_init (&screen);
|
||||
uint8_t* data = read_file (argv[i],&size);
|
||||
avcsei_parse (&sei,data,size);
|
||||
free (data);
|
||||
|
||||
// avcsei_parse (&sei,sei1,sizeof (sei1));
|
||||
|
||||
for (avcsei_message_t* msg = avcsei_message_head (&sei) ; msg ; msg = avcsei_message_next (msg)) {
|
||||
if (sei_type_user_data_registered_itu_t_t35 == avcsei_message_type (msg)) {
|
||||
// avcsei_dump (&sei);
|
||||
avcsei_decode_cea708 (msg,&cea708);
|
||||
int count = cea708_cc_count (&cea708.user_data);
|
||||
|
||||
for (int i = 0 ; i < count ; ++i) {
|
||||
cea708_cc_type_t type; int valid;
|
||||
uint16_t cc_data = cea708_cc_data (&cea708.user_data, i, &valid, &type);
|
||||
|
||||
if (valid && (cc_type_ntsc_cc_field_1 == type || cc_type_ntsc_cc_field_2 == type)) {
|
||||
eia608_screen_decode (&screen,cc_data);
|
||||
}
|
||||
}
|
||||
|
||||
// eia608_screen_dump (&screen, &screen_buf[0]);
|
||||
// printf ("screen:\n%s\n",&screen_buf[0]);
|
||||
|
||||
eia608_screen_json (&screen, &json_buf[0]);
|
||||
printf ("json:\n%s\n",&json_buf[0]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
avcsei_free (&sei);
|
||||
}
|
||||
}
|
||||
154
deps/libcaption/unit_tests/tos.scc
vendored
Normal file
154
deps/libcaption/unit_tests/tos.scc
vendored
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
Scenarist_SCC V1.0
|
||||
|
||||
00:00:22:10 9420 94f2 97a2 d9ef 75a7 f2e5 2061 20ea e5f2 6b2c 2054 68ef 6dae 942c 8080 8080 942f
|
||||
|
||||
00:00:23:28 9420 947c 97a2 4cef ef6b 2043 e5ec e961 2c20 f7e5 2068 6176 e520 f4ef 20e6 efec ecef f720 ef75 f220 7061 7373 e9ef 6e73 3b80 942c 8080 8080 942f
|
||||
|
||||
00:00:25:16 9420 9440 aeae ae79 ef75 2068 6176 e520 79ef 75f2 20f2 ef62 eff4 e9e3 732c 2061 6e64 2049 94fe 9723 ea75 73f4 20f7 616e f420 f4ef 2062 e520 61f7 e573 ef6d e520 e96e 2073 7061 e3e5 ae80 942c 8080 8080 942f
|
||||
|
||||
00:00:29:09 9420 9440 97a1 5768 7920 64ef 6ea7 f420 79ef 7520 ea75 73f4 2061 646d e9f4 20f4 6861 f480 94fe 97a2 79ef 75a7 f2e5 20e6 f2e5 616b e564 20ef 75f4 2062 7920 6d79 20f2 ef62 eff4 2068 616e 64bf 942c 8080 8080 942f
|
||||
|
||||
00:00:33:19 9420 94e0 49a7 6d20 6eef f420 e6f2 e561 6be5 6420 ef75 f420 6279 ad20 e9f4 a773 aeae ae80 942c 8080 8080 942f
|
||||
|
||||
00:00:36:10 9420 94f2 9723 aeae ae61 ecf2 e967 68f4 a120 46e9 6ee5 a180 942c 8080 8080 942f
|
||||
|
||||
00:00:36:29 9420 945e 9723 49a7 6d20 e6f2 e561 6be5 6420 ef75 f4a1 2049 2068 6176 e520 6ee9 6768 f46d 61f2 e573 94f2 f468 61f4 2049 a76d 2062 e5e9 6e67 20e3 6861 73e5 64ae aeae 942c 8080 8080 942f
|
||||
|
||||
00:00:39:27 9420 947c 97a2 aeae ae62 7920 f468 e573 e520 67e9 616e f420 f2ef 62ef f4e9 e320 e3ec 61f7 7320 efe6 2064 e561 f468 aeae ae80 942c 8080 8080 942f
|
||||
|
||||
00:00:40:29 9420 9452 97a2 a246 ef75 f2f4 7920 79e5 61f2 7320 ec61 f4e5 f2a2 94e0 97a2 5768 61f4 e576 e5f2 2c20 5468 ef6d ae20 57e5 a7f2 e520 64ef 6ee5 ae80 942c 8080 8080 942f
|
||||
|
||||
00:00:49:02 9420 94fe 9723 52ef 62ef f4a7 7320 6de5 6def f279 2073 796e e3e5 6420 616e 6420 ecef e36b e564 a180 942c 8080 8080 942f
|
||||
|
||||
00:01:00:08 9420 94f2 97a1 5468 e973 20e9 7320 70f2 e5f4 f479 20e6 f2e5 616b 79ae 942c 8080 8080 942f
|
||||
|
||||
00:01:56:03 9420 94e0 97a2 d368 ef75 ec64 6ea7 f420 79ef 7520 62e5 2064 eff7 6e20 f468 e5f2 e5bf 942c 8080 8080 942f
|
||||
|
||||
00:02:09:29 9420 94fe 97a2 4920 68e5 61f2 6420 79ef 7520 6775 7973 20f4 61ec 6be9 6e67 20ec 6173 f420 6ee9 6768 f4ae 942c 8080 8080 942f
|
||||
|
||||
00:02:15:02 9420 94e0 97a2 49f4 a773 206e eff4 206d 7920 e661 75ec f42c 2079 ef75 206b 6eef f7ae 942c 8080 8080 942f
|
||||
|
||||
00:03:10:08 9420 94f4 97a1 c1f2 e520 79ef 7520 f2e5 6164 79bf 942c 8080 8080 942f
|
||||
|
||||
00:03:11:24 9420 947c 9723 4fe6 20e3 ef75 f273 e520 79ef 75a7 f2e5 20f2 e561 6479 2c20 79ef 75a7 f2e5 2061 20f2 efe3 6b73 f461 f2ae 942c 8080 8080 942f
|
||||
|
||||
00:03:16:02 9420 94e0 9723 c8ef f7a7 7320 e9f4 20ec efef 6be9 6e67 2c20 c261 f2ec e579 bf80 942c 8080 8080 942f
|
||||
|
||||
00:03:17:27 9420 94fe 97a2 57e5 2073 68ef 75ec 6420 6861 76e5 2061 62ef 75f4 20f4 e56e 206d e96e 75f4 e573 aeae ae80 942c 8080 8080 942f
|
||||
|
||||
00:03:20:19 9420 94f2 97a2 57e5 ecec 20f4 6861 f4a7 7320 70e5 f2e6 e5e3 f4ae 942c 8080 8080 942f
|
||||
|
||||
00:03:22:05 9420 9440 57e5 a7f2 e520 ef6e 20e9 6e20 ef6e e5a1 20c1 ecec 2073 7973 f4e5 6d73 2067 efa1 94f4 97a1 d9e5 6168 2079 ef75 2c20 67ef a180 942c 8080 8080 942f
|
||||
|
||||
00:03:26:29 9420 94e0 97a1 c7ef a120 cdef 76e5 2079 ef75 f220 6173 73e5 73a1 20c7 ef20 67ef 2067 efa1 942c 8080 8080 942f
|
||||
|
||||
00:03:32:03 9420 94f2 4920 ecef 76e5 20e9 f4a1 2043 ef6d e520 ef6e 2c20 67ef a180 942c 8080 8080 942f
|
||||
|
||||
00:03:42:08 9420 94f4 97a2 5468 61f4 a773 206e e9e3 e5ae 942c 8080 8080 942f
|
||||
|
||||
00:03:43:18 9420 94f2 ceef f468 e96e 6720 f4ef 20f7 eff2 f279 2061 62ef 75f4 ae80 942c 8080 8080 942f
|
||||
|
||||
00:03:45:11 9420 9476 97a1 5468 ef6d ae80 942c 8080 8080 942f
|
||||
|
||||
00:03:50:07 9420 94f4 97a1 5468 e5f2 e520 7368 e520 e973 ae80 942c 8080 8080 942f
|
||||
|
||||
00:03:52:27 9420 9476 97a2 ceef f7ae 942c 8080 8080 942f
|
||||
|
||||
00:03:54:06 9420 94f4 97a1 d9ef 7520 ecef 76e5 2068 e5f2 ae80 942c 8080 8080 942f
|
||||
|
||||
00:03:56:03 9420 94f2 97a2 d368 e520 e973 2079 ef75 f220 7061 7373 e9ef 6ea1 942c 8080 8080 942f
|
||||
|
||||
00:03:59:04 9420 94f2 9723 c2e5 20f4 e56e 64e5 f220 f4ef 2068 e5f2 ae80 942c 8080 8080 942f
|
||||
|
||||
00:04:00:15 9420 94e0 9723 c2e5 2068 ef6e e573 f4a1 2045 68ad 2062 e520 f4e5 6e64 e5f2 ae80 942c 8080 8080 942f
|
||||
|
||||
00:04:04:02 9420 94f2 52e5 6de9 6e64 2068 e5f2 20f7 6861 f420 ecef 76e5 20e9 73ae 942c 8080 8080 942f
|
||||
|
||||
00:04:51:05 9420 94f4 aeae ae61 6e64 2c20 61e3 f4e9 ef6e a180 942c 8080 8080 942f
|
||||
|
||||
00:04:55:12 9420 94e0 97a1 cde5 6def f279 20ef 76e5 f2f7 f2e9 f4e5 20e9 6e20 70f2 ef67 f2e5 7373 a180 942c 8080 8080 942f
|
||||
|
||||
00:04:58:02 9420 94f2 97a2 d9ef 75a7 f2e5 2061 20ea e5f2 6b2c 2054 68ef 6da1 942c 8080 8080 942f
|
||||
|
||||
00:05:01:17 9420 94f2 9723 4f68 70ad 20d3 eff2 f279 a120 d3ef f2f2 79ae 942c 8080 8080 942f
|
||||
|
||||
00:05:15:05 9420 94f4 97a2 4cef ef6b 2043 e5ec e961 ae80 942c 8080 8080 942f
|
||||
|
||||
00:05:16:26 9420 94e0 57e5 2068 6176 e520 f4ef 20e6 efec ecef f720 ef75 f220 7061 7373 e9ef 6e73 ae80 942c 8080 8080 942f
|
||||
|
||||
00:05:19:28 9420 94e0 9723 d9ef 7520 6861 76e5 2079 ef75 f220 f2ef 62ef f4e9 e373 aeae ae80 942c 8080 8080 942f
|
||||
|
||||
00:05:23:20 9420 947c 9723 aeae ae61 6e64 2049 20ea 7573 f420 f761 6ef4 20f4 ef20 62e5 2061 f7e5 73ef 6de5 20e9 6e20 7370 61e3 e5ae 942c 8080 8080 942f
|
||||
|
||||
00:05:37:21 9420 94fe 4f6b 6179 2c20 f468 e579 a7f2 e520 e3ef 6de9 6e67 ae20 54f7 ef20 6de9 6e75 f4e5 7320 ece5 e6f4 a180 942c 8080 8080 942f
|
||||
|
||||
00:05:42:01 9420 94f2 9723 d370 e5e5 6420 e9f4 2075 702c 2054 68ef 6da1 942c 8080 8080 942f
|
||||
|
||||
00:05:44:04 9420 94f4 97a2 d6e9 7661 e3e9 7373 e96d efa1 942c 8080 8080 942f
|
||||
|
||||
00:05:45:05 9420 945e 97a2 5768 7920 64ef 6ea7 f420 79ef 7520 ea75 73f4 2061 646d e9f4 20f4 6861 f420 79ef 75a7 f2e5 94e0 97a1 e6f2 e561 6be5 6420 ef75 f420 6279 206d 7920 f2ef 62ef f420 6861 6e64 bf80 942c 8080 8080 942f
|
||||
|
||||
00:05:54:26 9420 94e0 97a2 4ce9 73f4 e56e 2043 e5ec e961 2c20 4920 f761 7320 79ef 756e 67ae aeae 942c 8080 8080 942f
|
||||
|
||||
00:05:58:18 9420 94f4 97a1 aeae ae61 6e64 2061 2064 e9e3 6bae 942c 8080 8080 942f
|
||||
|
||||
00:05:59:18 9420 9452 c275 f420 f468 61f4 a773 206e ef20 f2e5 6173 ef6e 20f4 ef80 94f2 9723 64e5 73f4 f2ef 7920 f468 e520 f7ef f2ec 64ae 942c 8080 8080 942f
|
||||
|
||||
00:06:04:00 9420 94f2 97a2 5768 7920 64ef e573 2068 e520 64ef 20f4 68e9 73bf 942c 8080 8080 942f
|
||||
|
||||
00:06:05:12 9420 94e0 9723 57e5 2061 ecf2 e561 6479 20f4 f2e9 e564 20f4 6861 f420 ef6e e5a1 942c 8080 8080 942f
|
||||
|
||||
00:06:10:21 9420 9476 97a1 c162 eff2 f4a1 942c 8080 8080 942f
|
||||
|
||||
00:06:12:07 9420 9476 97a2 4375 f4a1 942c 8080 8080 942f
|
||||
|
||||
00:06:13:06 9420 9476 5768 ef61 6161 a180 942c 8080 8080 942f
|
||||
|
||||
00:06:18:06 9420 9476 5768 ef61 6161 a180 942c 8080 8080 942f
|
||||
|
||||
00:06:20:06 9420 9476 ceef efef efef a180 942c 8080 8080 942f
|
||||
|
||||
00:06:21:29 9420 94f2 97a2 d9ef 7520 62f2 ef6b e520 6d79 2068 e561 f2f4 ae80 942c 8080 8080 942f
|
||||
|
||||
00:06:25:06 9420 9476 4920 6b6e eff7 ae80 942c 8080 8080 942f
|
||||
|
||||
00:06:25:28 9420 94f2 d9ef 7520 e6ef f267 eff4 206d e520 ef6e 20e5 61f2 f468 ae80 942c 8080 8080 942f
|
||||
|
||||
00:06:28:06 9420 9476 4920 6b6e eff7 ae80 942c 8080 8080 942f
|
||||
|
||||
00:06:29:13 9420 94f2 4920 7368 ef75 ec64 20ea 7573 f420 e3f2 7573 6820 79ef 75ae 942c 8080 8080 942f
|
||||
|
||||
00:06:35:07 9420 9476 97a2 49a7 6dad 942c 8080 8080 942f
|
||||
|
||||
00:06:46:03 9420 94f4 9723 49a7 6d20 73ef f2f2 79ae 942c 8080 8080 942f
|
||||
|
||||
00:06:49:02 9420 94f4 97a2 c7ef ef64 2061 64ad ece9 62ae 942c 8080 8080 942f
|
||||
|
||||
00:06:58:01 9420 94f4 97a1 ceef f420 6d79 20e6 6175 ecf4 a180 942c 8080 8080 942f
|
||||
|
||||
00:07:01:03 9420 94f4 9723 5468 e973 20f4 e96d e5ae 942c 8080 8080 942f
|
||||
|
||||
00:07:07:01 9420 94f4 97a1 5175 e9e5 f420 ef6e 2073 e5f4 a180 942c 8080 8080 942f
|
||||
|
||||
00:07:08:29 9420 94f2 9723 57e5 a7f2 e520 ef75 f420 efe6 20f4 e96d e5a1 942c 8080 8080 942f
|
||||
|
||||
00:08:12:03 9420 9476 43ef 6de5 20ef 6ea1 942c 8080 8080 942f
|
||||
|
||||
00:08:20:29 9420 94f4 97a2 52c1 c1c1 c1c1 c1c1 c1c8 a180 942c 8080 8080 942f
|
||||
|
||||
00:08:22:24 9420 94f2 97a1 cde5 6def f279 20ef 76e5 f2f7 f2e9 f4e5 2c20 b9b0 25ae 942c 8080 8080 942f
|
||||
|
||||
00:08:24:22 9420 94e0 9723 4361 70f4 61e9 6ea1 2057 e520 6861 76e5 20f4 ef20 6162 eff2 f4a1 942c 8080 8080 942f
|
||||
|
||||
00:08:36:20 9420 94e0 97a1 5468 e520 f7ef f2ec 64a7 7320 e368 616e 67e5 642c 2043 e5ec e961 aeae ae80 942c 8080 8080 942f
|
||||
|
||||
00:08:52:24 9420 94f2 97a2 aeae ae6d 6179 62e5 20f7 e520 e361 6e20 f4ef efae 942c 8080 8080 942f
|
||||
|
||||
00:08:56:21 9420 94e0 9723 cde5 6def f279 20ef 76e5 f2f7 f2e9 f4e5 20e3 ef6d 70ec e5f4 e5a1 942c 8080 8080 942f
|
||||
|
||||
00:09:17:29 9420 94f4 9723 d9ef 7520 6b6e eff7 ae80 942c 8080 8080 942f
|
||||
|
||||
00:09:20:13 9420 947c 9723 5468 e5f2 e5a7 7320 6120 ece5 7373 ef6e 20f4 ef20 62e5 20ec e561 f26e e564 20e6 f2ef 6d20 f468 e973 ae80 942c 8080 8080 942f
|
||||
|
||||
00:09:24:24 9420 94f2 97a2 43ef 75ec 64a7 6120 67ef 6ee5 20f7 eff2 73e5 ae80 942c 8080 8080 942f
|
||||
|
||||
2
deps/libff/libff/ff-decoder.c
vendored
2
deps/libff/libff/ff-decoder.c
vendored
|
|
@ -178,7 +178,7 @@ void ff_decoder_refresh(void *opaque)
|
|||
|
||||
struct ff_frame *frame;
|
||||
|
||||
if (decoder && decoder->stream) {
|
||||
if (decoder->stream) {
|
||||
if (decoder->frame_queue.size == 0) {
|
||||
if (!decoder->eof || !decoder->finished) {
|
||||
// We expected a frame, but there were none
|
||||
|
|
|
|||
10
deps/libff/libff/ff-demuxer.c
vendored
10
deps/libff/libff/ff-demuxer.c
vendored
|
|
@ -297,7 +297,13 @@ static bool find_decoder(struct ff_demuxer *demuxer, AVStream *stream)
|
|||
}
|
||||
|
||||
if (codec == NULL) {
|
||||
codec = avcodec_find_decoder(codec_context->codec_id);
|
||||
if (codec_context->codec_id == AV_CODEC_ID_VP8)
|
||||
codec = avcodec_find_decoder_by_name("libvpx");
|
||||
else if (codec_context->codec_id == AV_CODEC_ID_VP9)
|
||||
codec = avcodec_find_decoder_by_name("libvpx-vp9");
|
||||
|
||||
if (!codec)
|
||||
codec = avcodec_find_decoder(codec_context->codec_id);
|
||||
if (codec == NULL) {
|
||||
av_log(NULL, AV_LOG_WARNING, "no decoder found for"
|
||||
" codec with id %d",
|
||||
|
|
@ -377,7 +383,7 @@ static bool open_input(struct ff_demuxer *demuxer,
|
|||
}
|
||||
|
||||
if (avformat_open_input(format_context, demuxer->input,
|
||||
input_format, NULL) != 0)
|
||||
input_format, &demuxer->options.custom_options) != 0)
|
||||
return false;
|
||||
|
||||
return avformat_find_stream_info(*format_context, NULL) >= 0;
|
||||
|
|
|
|||
1
deps/libff/libff/ff-demuxer.h
vendored
1
deps/libff/libff/ff-demuxer.h
vendored
|
|
@ -40,6 +40,7 @@ struct ff_demuxer_options
|
|||
bool is_hw_decoding;
|
||||
bool is_looping;
|
||||
enum AVDiscard frame_drop;
|
||||
AVDictionary *custom_options;
|
||||
};
|
||||
|
||||
typedef struct ff_demuxer_options ff_demuxer_options_t;
|
||||
|
|
|
|||
25
deps/libff/libff/ff-util.c
vendored
25
deps/libff/libff/ff-util.c
vendored
|
|
@ -99,7 +99,8 @@ static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev)
|
|||
|
||||
static void add_codec_to_list(const struct ff_format_desc *format_desc,
|
||||
struct ff_codec_desc **first, struct ff_codec_desc **current,
|
||||
enum AVCodecID id, const AVCodec *codec)
|
||||
enum AVCodecID id, const AVCodec *codec,
|
||||
bool ignore_compatability)
|
||||
{
|
||||
if (codec == NULL)
|
||||
codec = avcodec_find_encoder(id);
|
||||
|
|
@ -112,11 +113,13 @@ static void add_codec_to_list(const struct ff_format_desc *format_desc,
|
|||
if (!av_codec_is_encoder(codec))
|
||||
return;
|
||||
|
||||
// Format doesn't support this codec
|
||||
unsigned int tag = av_codec_get_tag(format_desc->codec_tags,
|
||||
codec->id);
|
||||
if (tag == 0)
|
||||
return;
|
||||
if (!ignore_compatability) {
|
||||
// Format doesn't support this codec
|
||||
unsigned int tag = av_codec_get_tag(format_desc->codec_tags,
|
||||
codec->id);
|
||||
if (tag == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
struct ff_codec_desc *d = av_mallocz(sizeof(struct ff_codec_desc));
|
||||
|
||||
|
|
@ -150,16 +153,17 @@ static void add_codec_to_list(const struct ff_format_desc *format_desc,
|
|||
|
||||
static void get_codecs_for_id(const struct ff_format_desc *format_desc,
|
||||
struct ff_codec_desc **first, struct ff_codec_desc **current,
|
||||
enum AVCodecID id)
|
||||
enum AVCodecID id, bool ignore_compatability)
|
||||
{
|
||||
const AVCodec *codec = NULL;
|
||||
while ((codec = next_codec_for_id(id, codec)))
|
||||
add_codec_to_list(format_desc, first, current, codec->id,
|
||||
codec);
|
||||
codec, ignore_compatability);
|
||||
}
|
||||
|
||||
const struct ff_codec_desc *ff_codec_supported(
|
||||
const struct ff_format_desc *format_desc)
|
||||
const struct ff_format_desc *format_desc,
|
||||
bool ignore_compatability)
|
||||
{
|
||||
const AVCodecDescriptor **codecs;
|
||||
unsigned int size;
|
||||
|
|
@ -172,7 +176,8 @@ const struct ff_codec_desc *ff_codec_supported(
|
|||
|
||||
for(i = 0; i < size; i++) {
|
||||
const AVCodecDescriptor *codec = codecs[i];
|
||||
get_codecs_for_id(format_desc, &first, ¤t, codec->id);
|
||||
get_codecs_for_id(format_desc, &first, ¤t, codec->id,
|
||||
ignore_compatability);
|
||||
}
|
||||
|
||||
av_free((void *)codecs);
|
||||
|
|
|
|||
3
deps/libff/libff/ff-util.h
vendored
3
deps/libff/libff/ff-util.h
vendored
|
|
@ -37,7 +37,8 @@ const char *ff_codec_name_from_id(int codec_id);
|
|||
|
||||
// Codec Description
|
||||
const struct ff_codec_desc *ff_codec_supported(
|
||||
const struct ff_format_desc *format_desc);
|
||||
const struct ff_format_desc *format_desc,
|
||||
bool ignore_compatability);
|
||||
void ff_codec_desc_free(const struct ff_codec_desc *codec_desc);
|
||||
const char *ff_codec_desc_name(const struct ff_codec_desc *codec_desc);
|
||||
const char *ff_codec_desc_long_name(const struct ff_codec_desc *codec_desc);
|
||||
|
|
|
|||
145
deps/lzma/CMakeLists.txt
vendored
Normal file
145
deps/lzma/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(lzma)
|
||||
|
||||
set(LIBLZMA_INCLUDE_DIRS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/liblzma/api"
|
||||
CACHE PATH "lzma include path")
|
||||
|
||||
set(LIBLZMA_CONFIG
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/config.h"
|
||||
CACHE PATH "lzma config.h path")
|
||||
|
||||
include_directories(
|
||||
${LIBLZMA_INCLUDE_DIRS}
|
||||
common
|
||||
liblzma/api
|
||||
liblzma/check
|
||||
liblzma/common
|
||||
liblzma/delta
|
||||
liblzma/lz
|
||||
liblzma/lzma
|
||||
liblzma/rangecoder
|
||||
liblzma/simple
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DHAVE_CONFIG_H
|
||||
-DTUKLIB_SYMBOL_PREFIX=lzma_)
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
add_compile_options("$<$<CONFIG:RelWithDebInfo>:/MT>")
|
||||
endif()
|
||||
add_definitions(
|
||||
-Dinline=_inline
|
||||
-Drestrict=__restrict)
|
||||
endif()
|
||||
|
||||
set(liblzma_check_SOURCES
|
||||
liblzma/check/check.c)
|
||||
|
||||
list(APPEND liblzma_check_SOURCES
|
||||
liblzma/check/crc32_table.c
|
||||
liblzma/check/crc32_fast.c
|
||||
liblzma/check/crc64_table.c
|
||||
liblzma/check/crc64_fast.c
|
||||
liblzma/check/sha256.c)
|
||||
|
||||
set(liblzma_common_SOURCES
|
||||
liblzma/common/common.c
|
||||
liblzma/common/block_util.c
|
||||
liblzma/common/easy_preset.c
|
||||
liblzma/common/filter_common.c
|
||||
liblzma/common/hardware_physmem.c
|
||||
liblzma/common/index.c
|
||||
liblzma/common/stream_flags_common.c
|
||||
liblzma/common/vli_size.c
|
||||
liblzma/common/alone_encoder.c
|
||||
liblzma/common/block_buffer_encoder.c
|
||||
liblzma/common/block_encoder.c
|
||||
liblzma/common/block_header_encoder.c
|
||||
liblzma/common/easy_buffer_encoder.c
|
||||
liblzma/common/easy_encoder.c
|
||||
liblzma/common/easy_encoder_memusage.c
|
||||
liblzma/common/filter_buffer_encoder.c
|
||||
liblzma/common/filter_encoder.c
|
||||
liblzma/common/filter_flags_encoder.c
|
||||
liblzma/common/index_encoder.c
|
||||
liblzma/common/stream_buffer_encoder.c
|
||||
liblzma/common/stream_encoder.c
|
||||
liblzma/common/stream_flags_encoder.c
|
||||
liblzma/common/vli_encoder.c
|
||||
liblzma/common/alone_decoder.c
|
||||
liblzma/common/auto_decoder.c
|
||||
liblzma/common/block_buffer_decoder.c
|
||||
liblzma/common/block_decoder.c
|
||||
liblzma/common/block_header_decoder.c
|
||||
liblzma/common/easy_decoder_memusage.c
|
||||
liblzma/common/filter_buffer_decoder.c
|
||||
liblzma/common/filter_decoder.c
|
||||
liblzma/common/filter_flags_decoder.c
|
||||
liblzma/common/index_decoder.c
|
||||
liblzma/common/index_hash.c
|
||||
liblzma/common/stream_buffer_decoder.c
|
||||
liblzma/common/stream_decoder.c
|
||||
liblzma/common/stream_flags_decoder.c
|
||||
liblzma/common/vli_decoder.c)
|
||||
|
||||
set(liblzma_delta_SOURCES
|
||||
liblzma/delta/delta_common.c
|
||||
liblzma/delta/delta_encoder.c
|
||||
liblzma/delta/delta_decoder.c)
|
||||
|
||||
set(liblzma_lzma_SOURCES
|
||||
liblzma/lzma/lzma_encoder.c
|
||||
liblzma/lzma/lzma_encoder_presets.c
|
||||
liblzma/lzma/lzma_encoder_optimum_fast.c
|
||||
liblzma/lzma/lzma_encoder_optimum_normal.c
|
||||
liblzma/lzma/fastpos_table.c
|
||||
liblzma/lzma/lzma_decoder.c
|
||||
|
||||
liblzma/lzma/lzma2_encoder.c
|
||||
liblzma/lzma/lzma2_decoder.c)
|
||||
|
||||
set(liblzma_lz_SOURCES
|
||||
liblzma/lz/lz_encoder.c
|
||||
liblzma/lz/lz_encoder_mf.c
|
||||
liblzma/lz/lz_decoder.c)
|
||||
|
||||
set(liblzma_rangecoder_SOURCES
|
||||
liblzma/rangecoder/price_table.c)
|
||||
|
||||
set(liblzma_simple_SOURCES
|
||||
liblzma/simple/simple_coder.c
|
||||
liblzma/simple/simple_encoder.c
|
||||
liblzma/simple/simple_decoder.c
|
||||
|
||||
liblzma/simple/arm.c
|
||||
liblzma/simple/armthumb.c
|
||||
liblzma/simple/ia64.c
|
||||
liblzma/simple/powerpc.c
|
||||
liblzma/simple/sparc.c
|
||||
liblzma/simple/x86.c)
|
||||
|
||||
if (WIN32)
|
||||
SET_SOURCE_FILES_PROPERTIES(
|
||||
${liblzma_check_SOURCES}
|
||||
${liblzma_common_SOURCES}
|
||||
${liblzma_delta_SOURCES}
|
||||
${liblzma_lz_SOURCES}
|
||||
${liblzma_lzma_SOURCES}
|
||||
${liblzma_rangecoder_SOURCES}
|
||||
${liblzma_simple_SOURCES}
|
||||
PROPERTIES LANGUAGE C)
|
||||
endif()
|
||||
|
||||
add_library(lzma STATIC
|
||||
${liblzma_check_SOURCES}
|
||||
${liblzma_common_SOURCES}
|
||||
${liblzma_delta_SOURCES}
|
||||
${liblzma_lz_SOURCES}
|
||||
${liblzma_lzma_SOURCES}
|
||||
${liblzma_rangecoder_SOURCES}
|
||||
${liblzma_simple_SOURCES})
|
||||
50
deps/lzma/common/common_w32res.rc
vendored
Normal file
50
deps/lzma/common/common_w32res.rc
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#include <winresrc.h>
|
||||
#include "config.h"
|
||||
#define LZMA_H_INTERNAL
|
||||
#define LZMA_H_INTERNAL_RC
|
||||
#include "lzma/version.h"
|
||||
|
||||
#ifndef MY_BUILD
|
||||
# define MY_BUILD 0
|
||||
#endif
|
||||
#define MY_VERSION LZMA_VERSION_MAJOR,LZMA_VERSION_MINOR,LZMA_VERSION_PATCH,MY_BUILD
|
||||
|
||||
#define MY_FILENAME MY_NAME MY_SUFFIX
|
||||
#define MY_COMPANY "The Tukaani Project <http://tukaani.org/>"
|
||||
#define MY_PRODUCT PACKAGE_NAME " <" PACKAGE_URL ">"
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION MY_VERSION
|
||||
PRODUCTVERSION MY_VERSION
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE MY_TYPE
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", MY_COMPANY
|
||||
VALUE "FileDescription", MY_DESC
|
||||
VALUE "FileVersion", LZMA_VERSION_STRING
|
||||
VALUE "InternalName", MY_NAME
|
||||
VALUE "OriginalFilename", MY_FILENAME
|
||||
VALUE "ProductName", MY_PRODUCT
|
||||
VALUE "ProductVersion", LZMA_VERSION_STRING
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
42
deps/lzma/common/mythread.h
vendored
Normal file
42
deps/lzma/common/mythread.h
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file mythread.h
|
||||
/// \brief Wrappers for threads
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "sysdefs.h"
|
||||
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
# include <pthread.h>
|
||||
|
||||
# define mythread_once(func) \
|
||||
do { \
|
||||
static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
|
||||
pthread_once(&once_, &func); \
|
||||
} while (0)
|
||||
|
||||
# define mythread_sigmask(how, set, oset) \
|
||||
pthread_sigmask(how, set, oset)
|
||||
|
||||
#else
|
||||
|
||||
# define mythread_once(func) \
|
||||
do { \
|
||||
static bool once_ = false; \
|
||||
if (!once_) { \
|
||||
func(); \
|
||||
once_ = true; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
# define mythread_sigmask(how, set, oset) \
|
||||
sigprocmask(how, set, oset)
|
||||
|
||||
#endif
|
||||
199
deps/lzma/common/sysdefs.h
vendored
Normal file
199
deps/lzma/common/sysdefs.h
vendored
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file sysdefs.h
|
||||
/// \brief Common includes, definitions, system-specific things etc.
|
||||
///
|
||||
/// This file is used also by the lzma command line tool, that's why this
|
||||
/// file is separate from common.h.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LZMA_SYSDEFS_H
|
||||
#define LZMA_SYSDEFS_H
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define VC_EXTRALEAN
|
||||
# include <Windows.h>
|
||||
# include <intrin.h>
|
||||
# undef VC_EXTRALEAN
|
||||
#endif
|
||||
|
||||
// Get standard-compliant stdio functions under MinGW and MinGW-w64.
|
||||
#ifdef __MINGW32__
|
||||
# define __USE_MINGW_ANSI_STDIO 1
|
||||
#endif
|
||||
|
||||
// size_t and NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
// C99 says that inttypes.h always includes stdint.h, but some systems
|
||||
// don't do that, and require including stdint.h separately.
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
// Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The
|
||||
// limits are also used to figure out some macros missing from pre-C99 systems.
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
// Be more compatible with systems that have non-conforming inttypes.h.
|
||||
// We assume that int is 32-bit and that long is either 32-bit or 64-bit.
|
||||
// Full Autoconf test could be more correct, but this should work well enough.
|
||||
// Note that this duplicates some code from lzma.h, but this is better since
|
||||
// we can work without inttypes.h thanks to Autoconf tests.
|
||||
#ifndef UINT32_C
|
||||
# if UINT_MAX != 4294967295U
|
||||
# error UINT32_C is not defined and unsigned int is not 32-bit.
|
||||
# endif
|
||||
# define UINT32_C(n) n ## U
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
# define UINT32_MAX UINT32_C(4294967295)
|
||||
#endif
|
||||
#ifndef PRIu32
|
||||
# define PRIu32 "u"
|
||||
#endif
|
||||
#ifndef PRIx32
|
||||
# define PRIx32 "x"
|
||||
#endif
|
||||
#ifndef PRIX32
|
||||
# define PRIX32 "X"
|
||||
#endif
|
||||
|
||||
#if ULONG_MAX == 4294967295UL
|
||||
# ifndef UINT64_C
|
||||
# define UINT64_C(n) n ## ULL
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "llu"
|
||||
# endif
|
||||
# ifndef PRIx64
|
||||
# define PRIx64 "llx"
|
||||
# endif
|
||||
# ifndef PRIX64
|
||||
# define PRIX64 "llX"
|
||||
# endif
|
||||
#else
|
||||
# ifndef UINT64_C
|
||||
# define UINT64_C(n) n ## UL
|
||||
# endif
|
||||
# ifndef PRIu64
|
||||
# define PRIu64 "lu"
|
||||
# endif
|
||||
# ifndef PRIx64
|
||||
# define PRIx64 "lx"
|
||||
# endif
|
||||
# ifndef PRIX64
|
||||
# define PRIX64 "lX"
|
||||
# endif
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
# define UINT64_MAX UINT64_C(18446744073709551615)
|
||||
#endif
|
||||
|
||||
// Incorrect(?) SIZE_MAX:
|
||||
// - Interix headers typedef size_t to unsigned long,
|
||||
// but a few lines later define SIZE_MAX to INT32_MAX.
|
||||
// - SCO OpenServer (x86) headers typedef size_t to unsigned int
|
||||
// but define SIZE_MAX to INT32_MAX.
|
||||
#if defined(__INTERIX) || defined(_SCO_DS)
|
||||
# undef SIZE_MAX
|
||||
#endif
|
||||
|
||||
// The code currently assumes that size_t is either 32-bit or 64-bit.
|
||||
#ifndef SIZE_MAX
|
||||
# if SIZEOF_SIZE_T == 4
|
||||
# define SIZE_MAX UINT32_MAX
|
||||
# elif SIZEOF_SIZE_T == 8
|
||||
# define SIZE_MAX UINT64_MAX
|
||||
# else
|
||||
# error size_t is not 32-bit or 64-bit
|
||||
# endif
|
||||
#endif
|
||||
#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX
|
||||
# error size_t is not 32-bit or 64-bit
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written
|
||||
// so that it works with fake bool type, for example:
|
||||
//
|
||||
// bool foo = (flags & 0x100) != 0;
|
||||
// bool bar = !!(flags & 0x100);
|
||||
//
|
||||
// This works with the real C99 bool but breaks with fake bool:
|
||||
//
|
||||
// bool baz = (flags & 0x100);
|
||||
//
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# if ! HAVE__BOOL
|
||||
typedef unsigned char _Bool;
|
||||
# endif
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
// string.h should be enough but let's include strings.h and memory.h too if
|
||||
// they exists, since that shouldn't do any harm, but may improve portability.
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
#endif
|
||||
|
||||
|
||||
////////////
|
||||
// Macros //
|
||||
////////////
|
||||
|
||||
#undef memzero
|
||||
#define memzero(s, n) memset(s, 0, n)
|
||||
|
||||
// NOTE: Avoid using MIN() and MAX(), because even conditionally defining
|
||||
// those macros can cause some portability trouble, since on some systems
|
||||
// the system headers insist defining their own versions.
|
||||
#define my_min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define my_max(x, y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
|
||||
# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x)))
|
||||
#else
|
||||
# define lzma_attr_alloc_size(x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
71
deps/lzma/common/tuklib_common.h
vendored
Normal file
71
deps/lzma/common/tuklib_common.h
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_common.h
|
||||
/// \brief Common definitions for tuklib modules
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_COMMON_H
|
||||
#define TUKLIB_COMMON_H
|
||||
|
||||
// The config file may be replaced by a package-specific file.
|
||||
// It should include at least stddef.h, inttypes.h, and limits.h.
|
||||
#include "tuklib_config.h"
|
||||
|
||||
// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by
|
||||
// the tuklib modules. If you use a tuklib module in a library,
|
||||
// you should use TUKLIB_SYMBOL_PREFIX to make sure that there
|
||||
// are no symbol conflicts in case someone links your library
|
||||
// into application that also uses the same tuklib module.
|
||||
#ifndef TUKLIB_SYMBOL_PREFIX
|
||||
# define TUKLIB_SYMBOL_PREFIX
|
||||
#endif
|
||||
|
||||
#define TUKLIB_CAT_X(a, b) a ## b
|
||||
#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b)
|
||||
|
||||
#ifndef TUKLIB_SYMBOL
|
||||
# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym)
|
||||
#endif
|
||||
|
||||
#ifndef TUKLIB_DECLS_BEGIN
|
||||
# ifdef __cplusplus
|
||||
# define TUKLIB_DECLS_BEGIN extern "C" {
|
||||
# else
|
||||
# define TUKLIB_DECLS_BEGIN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef TUKLIB_DECLS_END
|
||||
# ifdef __cplusplus
|
||||
# define TUKLIB_DECLS_END }
|
||||
# else
|
||||
# define TUKLIB_DECLS_END
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
# define TUKLIB_GNUC_REQ(major, minor) \
|
||||
((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \
|
||||
|| __GNUC__ > (major))
|
||||
#else
|
||||
# define TUKLIB_GNUC_REQ(major, minor) 0
|
||||
#endif
|
||||
|
||||
#if TUKLIB_GNUC_REQ(2, 5)
|
||||
# define tuklib_attr_noreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
# define tuklib_attr_noreturn
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32) && !defined(__CYGWIN__)) \
|
||||
|| defined(__OS2__) || defined(__MSDOS__)
|
||||
# define TUKLIB_DOSLIKE 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
7
deps/lzma/common/tuklib_config.h
vendored
Normal file
7
deps/lzma/common/tuklib_config.h
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "sysdefs.h"
|
||||
#else
|
||||
# include <stddef.h>
|
||||
# include <inttypes.h>
|
||||
# include <limits.h>
|
||||
#endif
|
||||
62
deps/lzma/common/tuklib_cpucores.c
vendored
Normal file
62
deps/lzma/common/tuklib_cpucores.c
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_cpucores.c
|
||||
/// \brief Get the number of CPU cores online
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_cpucores.h"
|
||||
|
||||
#if defined(TUKLIB_CPUCORES_SYSCTL)
|
||||
# ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# include <sys/sysctl.h>
|
||||
|
||||
#elif defined(TUKLIB_CPUCORES_SYSCONF)
|
||||
# include <unistd.h>
|
||||
|
||||
// HP-UX
|
||||
#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
|
||||
# include <sys/param.h>
|
||||
# include <sys/pstat.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern uint32_t
|
||||
tuklib_cpucores(void)
|
||||
{
|
||||
uint32_t ret = 0;
|
||||
|
||||
#if defined(TUKLIB_CPUCORES_SYSCTL)
|
||||
int name[2] = { CTL_HW, HW_NCPU };
|
||||
int cpus;
|
||||
size_t cpus_size = sizeof(cpus);
|
||||
if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1
|
||||
&& cpus_size == sizeof(cpus) && cpus > 0)
|
||||
ret = cpus;
|
||||
|
||||
#elif defined(TUKLIB_CPUCORES_SYSCONF)
|
||||
# ifdef _SC_NPROCESSORS_ONLN
|
||||
// Most systems
|
||||
const long cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
# else
|
||||
// IRIX
|
||||
const long cpus = sysconf(_SC_NPROC_ONLN);
|
||||
# endif
|
||||
if (cpus > 0)
|
||||
ret = cpus;
|
||||
|
||||
#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)
|
||||
struct pst_dynamic pst;
|
||||
if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1)
|
||||
ret = pst.psd_proc_cnt;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
23
deps/lzma/common/tuklib_cpucores.h
vendored
Normal file
23
deps/lzma/common/tuklib_cpucores.h
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_cpucores.h
|
||||
/// \brief Get the number of CPU cores online
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_CPUCORES_H
|
||||
#define TUKLIB_CPUCORES_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#define tuklib_cpucores TUKLIB_SYMBOL(tuklib_cpucores)
|
||||
extern uint32_t tuklib_cpucores(void);
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
57
deps/lzma/common/tuklib_exit.c
vendored
Normal file
57
deps/lzma/common/tuklib_exit.c
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_exit.c
|
||||
/// \brief Close stdout and stderr, and exit
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_common.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tuklib_gettext.h"
|
||||
#include "tuklib_progname.h"
|
||||
#include "tuklib_exit.h"
|
||||
|
||||
|
||||
extern void
|
||||
tuklib_exit(int status, int err_status, int show_error)
|
||||
{
|
||||
if (status != err_status) {
|
||||
// Close stdout. If something goes wrong,
|
||||
// print an error message to stderr.
|
||||
const int ferror_err = ferror(stdout);
|
||||
const int fclose_err = fclose(stdout);
|
||||
if (ferror_err || fclose_err) {
|
||||
status = err_status;
|
||||
|
||||
// If it was fclose() that failed, we have the reason
|
||||
// in errno. If only ferror() indicated an error,
|
||||
// we have no idea what the reason was.
|
||||
if (show_error)
|
||||
fprintf(stderr, "%s: %s: %s\n", progname,
|
||||
_("Writing to standard "
|
||||
"output failed"),
|
||||
fclose_err ? strerror(errno)
|
||||
: _("Unknown error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (status != err_status) {
|
||||
// Close stderr. If something goes wrong, there's
|
||||
// nothing where we could print an error message.
|
||||
// Just set the exit status.
|
||||
const int ferror_err = ferror(stderr);
|
||||
const int fclose_err = fclose(stderr);
|
||||
if (fclose_err || ferror_err)
|
||||
status = err_status;
|
||||
}
|
||||
|
||||
exit(status);
|
||||
}
|
||||
25
deps/lzma/common/tuklib_exit.h
vendored
Normal file
25
deps/lzma/common/tuklib_exit.h
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_exit.h
|
||||
/// \brief Close stdout and stderr, and exit
|
||||
/// \note Requires tuklib_progname and tuklib_gettext modules
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_EXIT_H
|
||||
#define TUKLIB_EXIT_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#define tuklib_exit TUKLIB_SYMBOL(tuklib_exit)
|
||||
extern void tuklib_exit(int status, int err_status, int show_error)
|
||||
tuklib_attr_noreturn;
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
44
deps/lzma/common/tuklib_gettext.h
vendored
Normal file
44
deps/lzma/common/tuklib_gettext.h
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_gettext.h
|
||||
/// \brief Wrapper for gettext and friends
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_GETTEXT_H
|
||||
#define TUKLIB_GETTEXT_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
#include <locale.h>
|
||||
|
||||
#ifndef TUKLIB_GETTEXT
|
||||
# ifdef ENABLE_NLS
|
||||
# define TUKLIB_GETTEXT 1
|
||||
# else
|
||||
# define TUKLIB_GETTEXT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if TUKLIB_GETTEXT
|
||||
# include <libintl.h>
|
||||
# define tuklib_gettext_init(package, localedir) \
|
||||
do { \
|
||||
setlocale(LC_ALL, ""); \
|
||||
bindtextdomain(package, localedir); \
|
||||
textdomain(package); \
|
||||
} while (0)
|
||||
# define _(msgid) gettext(msgid)
|
||||
#else
|
||||
# define tuklib_gettext_init(package, localedir) \
|
||||
setlocale(LC_ALL, "")
|
||||
# define _(msgid) (msgid)
|
||||
# define ngettext(msgid1, msgid2, n) ((n) == 1 ? (msgid1) : (msgid2))
|
||||
#endif
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#endif
|
||||
523
deps/lzma/common/tuklib_integer.h
vendored
Normal file
523
deps/lzma/common/tuklib_integer.h
vendored
Normal file
|
|
@ -0,0 +1,523 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_integer.h
|
||||
/// \brief Various integer and bit operations
|
||||
///
|
||||
/// This file provides macros or functions to do some basic integer and bit
|
||||
/// operations.
|
||||
///
|
||||
/// Endianness related integer operations (XX = 16, 32, or 64; Y = b or l):
|
||||
/// - Byte swapping: bswapXX(num)
|
||||
/// - Byte order conversions to/from native: convXXYe(num)
|
||||
/// - Aligned reads: readXXYe(ptr)
|
||||
/// - Aligned writes: writeXXYe(ptr, num)
|
||||
/// - Unaligned reads (16/32-bit only): unaligned_readXXYe(ptr)
|
||||
/// - Unaligned writes (16/32-bit only): unaligned_writeXXYe(ptr, num)
|
||||
///
|
||||
/// Since they can macros, the arguments should have no side effects since
|
||||
/// they may be evaluated more than once.
|
||||
///
|
||||
/// \todo PowerPC and possibly some other architectures support
|
||||
/// byte swapping load and store instructions. This file
|
||||
/// doesn't take advantage of those instructions.
|
||||
///
|
||||
/// Bit scan operations for non-zero 32-bit integers:
|
||||
/// - Bit scan reverse (find highest non-zero bit): bsr32(num)
|
||||
/// - Count leading zeros: clz32(num)
|
||||
/// - Count trailing zeros: ctz32(num)
|
||||
/// - Bit scan forward (simply an alias for ctz32()): bsf32(num)
|
||||
///
|
||||
/// The above bit scan operations return 0-31. If num is zero,
|
||||
/// the result is undefined.
|
||||
//
|
||||
// Authors: Lasse Collin
|
||||
// Joachim Henke
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_INTEGER_H
|
||||
#define TUKLIB_INTEGER_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
// Operating system specific features //
|
||||
////////////////////////////////////////
|
||||
|
||||
#if defined(HAVE_BYTESWAP_H)
|
||||
// glibc, uClibc, dietlibc
|
||||
# include <byteswap.h>
|
||||
# ifdef HAVE_BSWAP_16
|
||||
# define bswap16(num) bswap_16(num)
|
||||
# endif
|
||||
# ifdef HAVE_BSWAP_32
|
||||
# define bswap32(num) bswap_32(num)
|
||||
# endif
|
||||
# ifdef HAVE_BSWAP_64
|
||||
# define bswap64(num) bswap_64(num)
|
||||
# endif
|
||||
|
||||
#elif defined(HAVE_SYS_ENDIAN_H)
|
||||
// *BSDs and Darwin
|
||||
# include <sys/endian.h>
|
||||
|
||||
#elif defined(HAVE_SYS_BYTEORDER_H)
|
||||
// Solaris
|
||||
# include <sys/byteorder.h>
|
||||
# ifdef BSWAP_16
|
||||
# define bswap16(num) BSWAP_16(num)
|
||||
# endif
|
||||
# ifdef BSWAP_32
|
||||
# define bswap32(num) BSWAP_32(num)
|
||||
# endif
|
||||
# ifdef BSWAP_64
|
||||
# define bswap64(num) BSWAP_64(num)
|
||||
# endif
|
||||
# ifdef BE_16
|
||||
# define conv16be(num) BE_16(num)
|
||||
# endif
|
||||
# ifdef BE_32
|
||||
# define conv32be(num) BE_32(num)
|
||||
# endif
|
||||
# ifdef BE_64
|
||||
# define conv64be(num) BE_64(num)
|
||||
# endif
|
||||
# ifdef LE_16
|
||||
# define conv16le(num) LE_16(num)
|
||||
# endif
|
||||
# ifdef LE_32
|
||||
# define conv32le(num) LE_32(num)
|
||||
# endif
|
||||
# ifdef LE_64
|
||||
# define conv64le(num) LE_64(num)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////
|
||||
// Byte swapping //
|
||||
///////////////////
|
||||
|
||||
#ifndef bswap16
|
||||
# define bswap16(num) \
|
||||
(((uint16_t)(num) << 8) | ((uint16_t)(num) >> 8))
|
||||
#endif
|
||||
|
||||
#ifndef bswap32
|
||||
# define bswap32(num) \
|
||||
( (((uint32_t)(num) << 24) ) \
|
||||
| (((uint32_t)(num) << 8) & UINT32_C(0x00FF0000)) \
|
||||
| (((uint32_t)(num) >> 8) & UINT32_C(0x0000FF00)) \
|
||||
| (((uint32_t)(num) >> 24) ) )
|
||||
#endif
|
||||
|
||||
#ifndef bswap64
|
||||
# define bswap64(num) \
|
||||
( (((uint64_t)(num) << 56) ) \
|
||||
| (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \
|
||||
| (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \
|
||||
| (((uint64_t)(num) << 8) & UINT64_C(0x000000FF00000000)) \
|
||||
| (((uint64_t)(num) >> 8) & UINT64_C(0x00000000FF000000)) \
|
||||
| (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \
|
||||
| (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \
|
||||
| (((uint64_t)(num) >> 56) ) )
|
||||
#endif
|
||||
|
||||
// Define conversion macros using the basic byte swapping macros.
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# ifndef conv16be
|
||||
# define conv16be(num) ((uint16_t)(num))
|
||||
# endif
|
||||
# ifndef conv32be
|
||||
# define conv32be(num) ((uint32_t)(num))
|
||||
# endif
|
||||
# ifndef conv64be
|
||||
# define conv64be(num) ((uint64_t)(num))
|
||||
# endif
|
||||
# ifndef conv16le
|
||||
# define conv16le(num) bswap16(num)
|
||||
# endif
|
||||
# ifndef conv32le
|
||||
# define conv32le(num) bswap32(num)
|
||||
# endif
|
||||
# ifndef conv64le
|
||||
# define conv64le(num) bswap64(num)
|
||||
# endif
|
||||
#else
|
||||
# ifndef conv16be
|
||||
# define conv16be(num) bswap16(num)
|
||||
# endif
|
||||
# ifndef conv32be
|
||||
# define conv32be(num) bswap32(num)
|
||||
# endif
|
||||
# ifndef conv64be
|
||||
# define conv64be(num) bswap64(num)
|
||||
# endif
|
||||
# ifndef conv16le
|
||||
# define conv16le(num) ((uint16_t)(num))
|
||||
# endif
|
||||
# ifndef conv32le
|
||||
# define conv32le(num) ((uint32_t)(num))
|
||||
# endif
|
||||
# ifndef conv64le
|
||||
# define conv64le(num) ((uint64_t)(num))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// Aligned reads and writes //
|
||||
//////////////////////////////
|
||||
|
||||
static inline uint16_t
|
||||
read16be(const uint8_t *buf)
|
||||
{
|
||||
uint16_t num = *(const uint16_t *)buf;
|
||||
return conv16be(num);
|
||||
}
|
||||
|
||||
|
||||
static inline uint16_t
|
||||
read16le(const uint8_t *buf)
|
||||
{
|
||||
uint16_t num = *(const uint16_t *)buf;
|
||||
return conv16le(num);
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
read32be(const uint8_t *buf)
|
||||
{
|
||||
uint32_t num = *(const uint32_t *)buf;
|
||||
return conv32be(num);
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
read32le(const uint8_t *buf)
|
||||
{
|
||||
uint32_t num = *(const uint32_t *)buf;
|
||||
return conv32le(num);
|
||||
}
|
||||
|
||||
|
||||
static inline uint64_t
|
||||
read64be(const uint8_t *buf)
|
||||
{
|
||||
uint64_t num = *(const uint64_t *)buf;
|
||||
return conv64be(num);
|
||||
}
|
||||
|
||||
|
||||
static inline uint64_t
|
||||
read64le(const uint8_t *buf)
|
||||
{
|
||||
uint64_t num = *(const uint64_t *)buf;
|
||||
return conv64le(num);
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Possible byte swapping must be done in a macro to allow GCC
|
||||
// to optimize byte swapping of constants when using glibc's or *BSD's
|
||||
// byte swapping macros. The actual write is done in an inline function
|
||||
// to make type checking of the buf pointer possible similarly to readXXYe()
|
||||
// functions.
|
||||
|
||||
#define write16be(buf, num) write16ne((buf), conv16be(num))
|
||||
#define write16le(buf, num) write16ne((buf), conv16le(num))
|
||||
#define write32be(buf, num) write32ne((buf), conv32be(num))
|
||||
#define write32le(buf, num) write32ne((buf), conv32le(num))
|
||||
#define write64be(buf, num) write64ne((buf), conv64be(num))
|
||||
#define write64le(buf, num) write64ne((buf), conv64le(num))
|
||||
|
||||
|
||||
static inline void
|
||||
write16ne(uint8_t *buf, uint16_t num)
|
||||
{
|
||||
*(uint16_t *)buf = num;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
write32ne(uint8_t *buf, uint32_t num)
|
||||
{
|
||||
*(uint32_t *)buf = num;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
write64ne(uint8_t *buf, uint64_t num)
|
||||
{
|
||||
*(uint64_t *)buf = num;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// Unaligned reads and writes //
|
||||
////////////////////////////////
|
||||
|
||||
// NOTE: TUKLIB_FAST_UNALIGNED_ACCESS indicates only support for 16-bit and
|
||||
// 32-bit unaligned integer loads and stores. It's possible that 64-bit
|
||||
// unaligned access doesn't work or is slower than byte-by-byte access.
|
||||
// Since unaligned 64-bit is probably not needed as often as 16-bit or
|
||||
// 32-bit, we simply don't support 64-bit unaligned access for now.
|
||||
#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
|
||||
# define unaligned_read16be read16be
|
||||
# define unaligned_read16le read16le
|
||||
# define unaligned_read32be read32be
|
||||
# define unaligned_read32le read32le
|
||||
# define unaligned_write16be write16be
|
||||
# define unaligned_write16le write16le
|
||||
# define unaligned_write32be write32be
|
||||
# define unaligned_write32le write32le
|
||||
|
||||
#else
|
||||
|
||||
static inline uint16_t
|
||||
unaligned_read16be(const uint8_t *buf)
|
||||
{
|
||||
uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
static inline uint16_t
|
||||
unaligned_read16le(const uint8_t *buf)
|
||||
{
|
||||
uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8);
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
unaligned_read32be(const uint8_t *buf)
|
||||
{
|
||||
uint32_t num = (uint32_t)buf[0] << 24;
|
||||
num |= (uint32_t)buf[1] << 16;
|
||||
num |= (uint32_t)buf[2] << 8;
|
||||
num |= (uint32_t)buf[3];
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
unaligned_read32le(const uint8_t *buf)
|
||||
{
|
||||
uint32_t num = (uint32_t)buf[0];
|
||||
num |= (uint32_t)buf[1] << 8;
|
||||
num |= (uint32_t)buf[2] << 16;
|
||||
num |= (uint32_t)buf[3] << 24;
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
unaligned_write16be(uint8_t *buf, uint16_t num)
|
||||
{
|
||||
buf[0] = num >> 8;
|
||||
buf[1] = num;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
unaligned_write16le(uint8_t *buf, uint16_t num)
|
||||
{
|
||||
buf[0] = num;
|
||||
buf[1] = num >> 8;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
unaligned_write32be(uint8_t *buf, uint32_t num)
|
||||
{
|
||||
buf[0] = num >> 24;
|
||||
buf[1] = num >> 16;
|
||||
buf[2] = num >> 8;
|
||||
buf[3] = num;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
unaligned_write32le(uint8_t *buf, uint32_t num)
|
||||
{
|
||||
buf[0] = num;
|
||||
buf[1] = num >> 8;
|
||||
buf[2] = num >> 16;
|
||||
buf[3] = num >> 24;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
bsr32(uint32_t n)
|
||||
{
|
||||
// Check for ICC first, since it tends to define __GNUC__ too.
|
||||
#if defined(__INTEL_COMPILER)
|
||||
return _bit_scan_reverse(n);
|
||||
|
||||
#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
|
||||
// GCC >= 3.4 has __builtin_clz(), which gives good results on
|
||||
// multiple architectures. On x86, __builtin_clz() ^ 31U becomes
|
||||
// either plain BSR (so the XOR gets optimized away) or LZCNT and
|
||||
// XOR (if -march indicates that SSE4a instructions are supported).
|
||||
return __builtin_clz(n) ^ 31U;
|
||||
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
uint32_t i;
|
||||
__asm__("bsrl %1, %0" : "=r" (i) : "rm" (n));
|
||||
return i;
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
// MSVC isn't supported by tuklib, but since this code exists,
|
||||
// it doesn't hurt to have it here anyway.
|
||||
uint32_t i;
|
||||
_BitScanReverse((DWORD *)&i, n);
|
||||
return i;
|
||||
|
||||
#else
|
||||
uint32_t i = 31;
|
||||
|
||||
if ((n & UINT32_C(0xFFFF0000)) == 0) {
|
||||
n <<= 16;
|
||||
i = 15;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xFF000000)) == 0) {
|
||||
n <<= 8;
|
||||
i -= 8;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xF0000000)) == 0) {
|
||||
n <<= 4;
|
||||
i -= 4;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xC0000000)) == 0) {
|
||||
n <<= 2;
|
||||
i -= 2;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x80000000)) == 0)
|
||||
--i;
|
||||
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
clz32(uint32_t n)
|
||||
{
|
||||
#if defined(__INTEL_COMPILER)
|
||||
return _bit_scan_reverse(n) ^ 31U;
|
||||
|
||||
#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
|
||||
return __builtin_clz(n);
|
||||
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
uint32_t i;
|
||||
__asm__("bsrl %1, %0\n\t"
|
||||
"xorl $31, %0"
|
||||
: "=r" (i) : "rm" (n));
|
||||
return i;
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
uint32_t i;
|
||||
_BitScanReverse((DWORD *)&i, n);
|
||||
return i ^ 31U;
|
||||
|
||||
#else
|
||||
uint32_t i = 0;
|
||||
|
||||
if ((n & UINT32_C(0xFFFF0000)) == 0) {
|
||||
n <<= 16;
|
||||
i = 16;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xFF000000)) == 0) {
|
||||
n <<= 8;
|
||||
i += 8;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xF0000000)) == 0) {
|
||||
n <<= 4;
|
||||
i += 4;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0xC0000000)) == 0) {
|
||||
n <<= 2;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x80000000)) == 0)
|
||||
++i;
|
||||
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
ctz32(uint32_t n)
|
||||
{
|
||||
#if defined(__INTEL_COMPILER)
|
||||
return _bit_scan_forward(n);
|
||||
|
||||
#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX
|
||||
return __builtin_ctz(n);
|
||||
|
||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||
uint32_t i;
|
||||
__asm__("bsfl %1, %0" : "=r" (i) : "rm" (n));
|
||||
return i;
|
||||
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
uint32_t i;
|
||||
_BitScanForward((DWORD *)&i, n);
|
||||
return i;
|
||||
|
||||
#else
|
||||
uint32_t i = 0;
|
||||
|
||||
if ((n & UINT32_C(0x0000FFFF)) == 0) {
|
||||
n >>= 16;
|
||||
i = 16;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x000000FF)) == 0) {
|
||||
n >>= 8;
|
||||
i += 8;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x0000000F)) == 0) {
|
||||
n >>= 4;
|
||||
i += 4;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x00000003)) == 0) {
|
||||
n >>= 2;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
if ((n & UINT32_C(0x00000001)) == 0)
|
||||
++i;
|
||||
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define bsf32 ctz32
|
||||
|
||||
#endif
|
||||
66
deps/lzma/common/tuklib_mbstr.h
vendored
Normal file
66
deps/lzma/common/tuklib_mbstr.h
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_mstr.h
|
||||
/// \brief Utility functions for handling multibyte strings
|
||||
///
|
||||
/// If not enough multibyte string support is available in the C library,
|
||||
/// these functions keep working with the assumption that all strings
|
||||
/// are in a single-byte character set without combining characters, e.g.
|
||||
/// US-ASCII or ISO-8859-*.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_MBSTR_H
|
||||
#define TUKLIB_MBSTR_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#define tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width)
|
||||
extern size_t tuklib_mbstr_width(const char *str, size_t *bytes);
|
||||
///<
|
||||
/// \brief Get the number of columns needed for the multibyte string
|
||||
///
|
||||
/// This is somewhat similar to wcswidth() but works on multibyte strings.
|
||||
///
|
||||
/// \param str String whose width is to be calculated. If the
|
||||
/// current locale uses a multibyte character set
|
||||
/// that has shift states, the string must begin
|
||||
/// and end in the initial shift state.
|
||||
/// \param bytes If this is not NULL, *bytes is set to the
|
||||
/// value returned by strlen(str) (even if an
|
||||
/// error occurs when calculating the width).
|
||||
///
|
||||
/// \return On success, the number of columns needed to display the
|
||||
/// string e.g. in a terminal emulator is returned. On error,
|
||||
/// (size_t)-1 is returned. Possible errors include invalid,
|
||||
/// partial, or non-printable multibyte character in str, or
|
||||
/// that str doesn't end in the initial shift state.
|
||||
|
||||
#define tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw)
|
||||
extern int tuklib_mbstr_fw(const char *str, int columns_min);
|
||||
///<
|
||||
/// \brief Get the field width for printf() e.g. to align table columns
|
||||
///
|
||||
/// Printing simple tables to a terminal can be done using the field field
|
||||
/// feature in the printf() format string, but it works only with single-byte
|
||||
/// character sets. To do the same with multibyte strings, tuklib_mbstr_fw()
|
||||
/// can be used to calculate appropriate field width.
|
||||
///
|
||||
/// The behavior of this function is undefined, if
|
||||
/// - str is NULL or not terminated with '\0';
|
||||
/// - columns_min <= 0; or
|
||||
/// - the calculated field width exceeds INT_MAX.
|
||||
///
|
||||
/// \return If tuklib_mbstr_width(str, NULL) fails, -1 is returned.
|
||||
/// If str needs more columns than columns_min, zero is returned.
|
||||
/// Otherwise a positive integer is returned, which can be
|
||||
/// used as the field width, e.g. printf("%*s", fw, str).
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
31
deps/lzma/common/tuklib_mbstr_fw.c
vendored
Normal file
31
deps/lzma/common/tuklib_mbstr_fw.c
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_mstr_fw.c
|
||||
/// \brief Get the field width for printf() e.g. to align table columns
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_mbstr.h"
|
||||
|
||||
|
||||
extern int
|
||||
tuklib_mbstr_fw(const char *str, int columns_min)
|
||||
{
|
||||
size_t len;
|
||||
const size_t width = tuklib_mbstr_width(str, &len);
|
||||
if (width == (size_t)-1)
|
||||
return -1;
|
||||
|
||||
if (width > (size_t)columns_min)
|
||||
return 0;
|
||||
|
||||
if (width < (size_t)columns_min)
|
||||
len += (size_t)columns_min - width;
|
||||
|
||||
return len;
|
||||
}
|
||||
64
deps/lzma/common/tuklib_mbstr_width.c
vendored
Normal file
64
deps/lzma/common/tuklib_mbstr_width.c
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_mstr_width.c
|
||||
/// \brief Calculate width of a multibyte string
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_mbstr.h"
|
||||
|
||||
#if defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern size_t
|
||||
tuklib_mbstr_width(const char *str, size_t *bytes)
|
||||
{
|
||||
const size_t len = strlen(str);
|
||||
if (bytes != NULL)
|
||||
*bytes = len;
|
||||
|
||||
#if !(defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH))
|
||||
// In single-byte mode, the width of the string is the same
|
||||
// as its length.
|
||||
return len;
|
||||
|
||||
#else
|
||||
mbstate_t state;
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
size_t width = 0;
|
||||
size_t i = 0;
|
||||
|
||||
// Convert one multibyte character at a time to wchar_t
|
||||
// and get its width using wcwidth().
|
||||
while (i < len) {
|
||||
wchar_t wc;
|
||||
const size_t ret = mbrtowc(&wc, str + i, len - i, &state);
|
||||
if (ret < 1 || ret > len)
|
||||
return (size_t)-1;
|
||||
|
||||
i += ret;
|
||||
|
||||
const int wc_width = wcwidth(wc);
|
||||
if (wc_width < 0)
|
||||
return (size_t)-1;
|
||||
|
||||
width += wc_width;
|
||||
}
|
||||
|
||||
// Require that the string ends in the initial shift state.
|
||||
// This way the caller can be combine the string with other
|
||||
// strings without needing to worry about the shift states.
|
||||
if (!mbsinit(&state))
|
||||
return (size_t)-1;
|
||||
|
||||
return width;
|
||||
#endif
|
||||
}
|
||||
57
deps/lzma/common/tuklib_open_stdxxx.c
vendored
Normal file
57
deps/lzma/common/tuklib_open_stdxxx.c
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_open_stdxxx.c
|
||||
/// \brief Make sure that file descriptors 0, 1, and 2 are open
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_open_stdxxx.h"
|
||||
|
||||
#ifndef TUKLIB_DOSLIKE
|
||||
# include <stdlib.h>
|
||||
# include <errno.h>
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern void
|
||||
tuklib_open_stdxxx(int err_status)
|
||||
{
|
||||
#ifdef TUKLIB_DOSLIKE
|
||||
// Do nothing, just silence warnings.
|
||||
(void)err_status;
|
||||
|
||||
#else
|
||||
for (int i = 0; i <= 2; ++i) {
|
||||
// We use fcntl() to check if the file descriptor is open.
|
||||
if (fcntl(i, F_GETFD) == -1 && errno == EBADF) {
|
||||
// With stdin, we could use /dev/full so that
|
||||
// writing to stdin would fail. However, /dev/full
|
||||
// is Linux specific, and if the program tries to
|
||||
// write to stdin, there's already a problem anyway.
|
||||
const int fd = open("/dev/null", O_NOCTTY
|
||||
| (i == 0 ? O_WRONLY : O_RDONLY));
|
||||
|
||||
if (fd != i) {
|
||||
if (fd != -1)
|
||||
(void)close(fd);
|
||||
|
||||
// Something went wrong. Exit with the
|
||||
// exit status we were given. Don't try
|
||||
// to print an error message, since stderr
|
||||
// may very well be non-existent. This
|
||||
// error should be extremely rare.
|
||||
exit(err_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
23
deps/lzma/common/tuklib_open_stdxxx.h
vendored
Normal file
23
deps/lzma/common/tuklib_open_stdxxx.h
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_open_stdxxx.h
|
||||
/// \brief Make sure that file descriptors 0, 1, and 2 are open
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_OPEN_STDXXX_H
|
||||
#define TUKLIB_OPEN_STDXXX_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#define tuklib_open_stdxx TUKLIB_SYMBOL(tuklib_open_stdxxx)
|
||||
extern void tuklib_open_stdxxx(int err_status);
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
196
deps/lzma/common/tuklib_physmem.c
vendored
Normal file
196
deps/lzma/common/tuklib_physmem.c
vendored
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_physmem.c
|
||||
/// \brief Get the amount of physical memory
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_physmem.h"
|
||||
|
||||
// We want to use Windows-specific code on Cygwin, which also has memory
|
||||
// information available via sysconf(), but on Cygwin 1.5 and older it
|
||||
// gives wrong results (from our point of view).
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
# ifndef _WIN32_WINNT
|
||||
# define _WIN32_WINNT 0x0500
|
||||
# endif
|
||||
# include <windows.h>
|
||||
|
||||
#elif defined(__OS2__)
|
||||
# define INCL_DOSMISC
|
||||
# include <os2.h>
|
||||
|
||||
#elif defined(__DJGPP__)
|
||||
# include <dpmi.h>
|
||||
|
||||
#elif defined(__VMS)
|
||||
# include <lib$routines.h>
|
||||
# include <syidef.h>
|
||||
# include <ssdef.h>
|
||||
|
||||
// AIX
|
||||
#elif defined(TUKLIB_PHYSMEM_AIX)
|
||||
# include <sys/systemcfg.h>
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCONF)
|
||||
# include <unistd.h>
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCTL)
|
||||
# ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# include <sys/sysctl.h>
|
||||
|
||||
// Tru64
|
||||
#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)
|
||||
# include <sys/sysinfo.h>
|
||||
# include <machine/hal_sysinfo.h>
|
||||
|
||||
// HP-UX
|
||||
#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
|
||||
# include <sys/param.h>
|
||||
# include <sys/pstat.h>
|
||||
|
||||
// IRIX
|
||||
#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
|
||||
# include <invent.h>
|
||||
|
||||
// This sysinfo() is Linux-specific.
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSINFO)
|
||||
# include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
|
||||
extern uint64_t
|
||||
tuklib_physmem(void)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
if ((GetVersion() & 0xFF) >= 5) {
|
||||
// Windows 2000 and later have GlobalMemoryStatusEx() which
|
||||
// supports reporting values greater than 4 GiB. To keep the
|
||||
// code working also on older Windows versions, use
|
||||
// GlobalMemoryStatusEx() conditionally.
|
||||
HMODULE kernel32 = GetModuleHandle("kernel32.dll");
|
||||
if (kernel32 != NULL) {
|
||||
BOOL (WINAPI *gmse)(LPMEMORYSTATUSEX) = GetProcAddress(
|
||||
kernel32, "GlobalMemoryStatusEx");
|
||||
if (gmse != NULL) {
|
||||
MEMORYSTATUSEX meminfo;
|
||||
meminfo.dwLength = sizeof(meminfo);
|
||||
if (gmse(&meminfo))
|
||||
ret = meminfo.ullTotalPhys;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
// GlobalMemoryStatus() is supported by Windows 95 and later,
|
||||
// so it is fine to link against it unconditionally. Note that
|
||||
// GlobalMemoryStatus() has no return value.
|
||||
MEMORYSTATUS meminfo;
|
||||
meminfo.dwLength = sizeof(meminfo);
|
||||
GlobalMemoryStatus(&meminfo);
|
||||
ret = meminfo.dwTotalPhys;
|
||||
}
|
||||
|
||||
#elif defined(__OS2__)
|
||||
unsigned long mem;
|
||||
if (DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,
|
||||
&mem, sizeof(mem)) == 0)
|
||||
ret = mem;
|
||||
|
||||
#elif defined(__DJGPP__)
|
||||
__dpmi_free_mem_info meminfo;
|
||||
if (__dpmi_get_free_memory_information(&meminfo) == 0
|
||||
&& meminfo.total_number_of_physical_pages
|
||||
!= (unsigned long)-1)
|
||||
ret = (uint64_t)meminfo.total_number_of_physical_pages * 4096;
|
||||
|
||||
#elif defined(__VMS)
|
||||
int vms_mem;
|
||||
int val = SYI$_MEMSIZE;
|
||||
if (LIB$GETSYI(&val, &vms_mem, 0, 0, 0, 0) == SS$_NORMAL)
|
||||
ret = (uint64_t)vms_mem * 8192;
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_AIX)
|
||||
ret = _system_configuration.physmem;
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCONF)
|
||||
const long pagesize = sysconf(_SC_PAGESIZE);
|
||||
const long pages = sysconf(_SC_PHYS_PAGES);
|
||||
if (pagesize != -1 && pages != -1)
|
||||
// According to docs, pagesize * pages can overflow.
|
||||
// Simple case is 32-bit box with 4 GiB or more RAM,
|
||||
// which may report exactly 4 GiB of RAM, and "long"
|
||||
// being 32-bit will overflow. Casting to uint64_t
|
||||
// hopefully avoids overflows in the near future.
|
||||
ret = (uint64_t)pagesize * (uint64_t)pages;
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSCTL)
|
||||
int name[2] = {
|
||||
CTL_HW,
|
||||
#ifdef HW_PHYSMEM64
|
||||
HW_PHYSMEM64
|
||||
#else
|
||||
HW_PHYSMEM
|
||||
#endif
|
||||
};
|
||||
union {
|
||||
uint32_t u32;
|
||||
uint64_t u64;
|
||||
} mem;
|
||||
size_t mem_ptr_size = sizeof(mem.u64);
|
||||
if (sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0) != -1) {
|
||||
// IIRC, 64-bit "return value" is possible on some 64-bit
|
||||
// BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
|
||||
// so support both.
|
||||
if (mem_ptr_size == sizeof(mem.u64))
|
||||
ret = mem.u64;
|
||||
else if (mem_ptr_size == sizeof(mem.u32))
|
||||
ret = mem.u32;
|
||||
}
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)
|
||||
// Docs are unclear if "start" is needed, but it doesn't hurt
|
||||
// much to have it.
|
||||
int memkb;
|
||||
int start = 0;
|
||||
if (getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start)
|
||||
!= -1)
|
||||
ret = (uint64_t)memkb * 1024;
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)
|
||||
struct pst_static pst;
|
||||
if (pstat_getstatic(&pst, sizeof(pst), 1, 0) != -1)
|
||||
ret = (uint64_t)pst.physical_memory * (uint64_t)pst.page_size;
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)
|
||||
inv_state_t *st = NULL;
|
||||
if (setinvent_r(&st) != -1) {
|
||||
inventory_t *i;
|
||||
while ((i = getinvent_r(st)) != NULL) {
|
||||
if (i->inv_class == INV_MEMORY
|
||||
&& i->inv_type == INV_MAIN_MB) {
|
||||
ret = (uint64_t)i->inv_state << 20;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
endinvent_r(st);
|
||||
}
|
||||
|
||||
#elif defined(TUKLIB_PHYSMEM_SYSINFO)
|
||||
struct sysinfo si;
|
||||
if (sysinfo(&si) == 0)
|
||||
ret = (uint64_t)si.totalram * si.mem_unit;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
28
deps/lzma/common/tuklib_physmem.h
vendored
Normal file
28
deps/lzma/common/tuklib_physmem.h
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_physmem.h
|
||||
/// \brief Get the amount of physical memory
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_PHYSMEM_H
|
||||
#define TUKLIB_PHYSMEM_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#define tuklib_physmem TUKLIB_SYMBOL(tuklib_physmem)
|
||||
extern uint64_t tuklib_physmem(void);
|
||||
///<
|
||||
/// \brief Get the amount of physical memory in bytes
|
||||
///
|
||||
/// \return Amount of physical memory in bytes. On error, zero is
|
||||
/// returned.
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
50
deps/lzma/common/tuklib_progname.c
vendored
Normal file
50
deps/lzma/common/tuklib_progname.c
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_progname.c
|
||||
/// \brief Program name to be displayed in messages
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "tuklib_progname.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#if !HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||
char *progname = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
extern void
|
||||
tuklib_progname_init(char **argv)
|
||||
{
|
||||
#ifdef TUKLIB_DOSLIKE
|
||||
// On these systems, argv[0] always has the full path and .exe
|
||||
// suffix even if the user just types the plain program name.
|
||||
// We modify argv[0] to make it nicer to read.
|
||||
|
||||
// Strip the leading path.
|
||||
char *p = argv[0] + strlen(argv[0]);
|
||||
while (argv[0] < p && p[-1] != '/' && p[-1] != '\\')
|
||||
--p;
|
||||
|
||||
argv[0] = p;
|
||||
|
||||
// Strip the .exe suffix.
|
||||
p = strrchr(p, '.');
|
||||
if (p != NULL)
|
||||
*p = '\0';
|
||||
|
||||
// Make it lowercase.
|
||||
for (p = argv[0]; *p != '\0'; ++p)
|
||||
if (*p >= 'A' && *p <= 'Z')
|
||||
*p = *p - 'A' + 'a';
|
||||
#endif
|
||||
|
||||
progname = argv[0];
|
||||
return;
|
||||
}
|
||||
32
deps/lzma/common/tuklib_progname.h
vendored
Normal file
32
deps/lzma/common/tuklib_progname.h
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file tuklib_progname.h
|
||||
/// \brief Program name to be displayed in messages
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TUKLIB_PROGNAME_H
|
||||
#define TUKLIB_PROGNAME_H
|
||||
|
||||
#include "tuklib_common.h"
|
||||
#include <errno.h>
|
||||
|
||||
TUKLIB_DECLS_BEGIN
|
||||
|
||||
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||
# define progname program_invocation_name
|
||||
#else
|
||||
# define progname TUKLIB_SYMBOL(tuklib_progname)
|
||||
extern char *progname;
|
||||
#endif
|
||||
|
||||
#define tuklib_progname_init TUKLIB_SYMBOL(tuklib_progname_init)
|
||||
extern void tuklib_progname_init(char **argv);
|
||||
|
||||
TUKLIB_DECLS_END
|
||||
#endif
|
||||
415
deps/lzma/config.h
vendored
Normal file
415
deps/lzma/config.h
vendored
Normal file
|
|
@ -0,0 +1,415 @@
|
|||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* How many MiB of RAM to assume if the real amount cannot be determined. */
|
||||
#define ASSUME_RAM 128
|
||||
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
/* #undef ENABLE_NLS */
|
||||
|
||||
/* Define to 1 if bswap_16 is available. */
|
||||
/* #undef HAVE_BSWAP_16 */
|
||||
|
||||
/* Define to 1 if bswap_32 is available. */
|
||||
/* #undef HAVE_BSWAP_32 */
|
||||
|
||||
/* Define to 1 if bswap_64 is available. */
|
||||
/* #undef HAVE_BSWAP_64 */
|
||||
|
||||
/* Define to 1 if you have the <byteswap.h> header file. */
|
||||
/* #undef HAVE_BYTESWAP_H */
|
||||
|
||||
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
|
||||
CoreFoundation framework. */
|
||||
/* #undef HAVE_CFLOCALECOPYCURRENT */
|
||||
|
||||
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
|
||||
the CoreFoundation framework. */
|
||||
/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
|
||||
|
||||
/* Define to 1 if crc32 integrity check is enabled. */
|
||||
#define HAVE_CHECK_CRC32 1
|
||||
|
||||
/* Define to 1 if crc64 integrity check is enabled. */
|
||||
#define HAVE_CHECK_CRC64 1
|
||||
|
||||
/* Define to 1 if sha256 integrity check is enabled. */
|
||||
#define HAVE_CHECK_SHA256 1
|
||||
|
||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||
*/
|
||||
/* #undef HAVE_DCGETTEXT */
|
||||
|
||||
/* Define to 1 if you have the declaration of `program_invocation_name', and
|
||||
to 0 if you don't. */
|
||||
#define HAVE_DECL_PROGRAM_INVOCATION_NAME 0
|
||||
|
||||
/* Define to 1 if arm decoder is enabled. */
|
||||
#define HAVE_DECODER_ARM 1
|
||||
|
||||
/* Define to 1 if armthumb decoder is enabled. */
|
||||
#define HAVE_DECODER_ARMTHUMB 1
|
||||
|
||||
/* Define to 1 if delta decoder is enabled. */
|
||||
#define HAVE_DECODER_DELTA 1
|
||||
|
||||
/* Define to 1 if ia64 decoder is enabled. */
|
||||
#define HAVE_DECODER_IA64 1
|
||||
|
||||
/* Define to 1 if lzma1 decoder is enabled. */
|
||||
#define HAVE_DECODER_LZMA1 1
|
||||
|
||||
/* Define to 1 if lzma2 decoder is enabled. */
|
||||
#define HAVE_DECODER_LZMA2 1
|
||||
|
||||
/* Define to 1 if powerpc decoder is enabled. */
|
||||
#define HAVE_DECODER_POWERPC 1
|
||||
|
||||
/* Define to 1 if sparc decoder is enabled. */
|
||||
#define HAVE_DECODER_SPARC 1
|
||||
|
||||
/* Define to 1 if x86 decoder is enabled. */
|
||||
#define HAVE_DECODER_X86 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Define to 1 if arm encoder is enabled. */
|
||||
#define HAVE_ENCODER_ARM 1
|
||||
|
||||
/* Define to 1 if armthumb encoder is enabled. */
|
||||
#define HAVE_ENCODER_ARMTHUMB 1
|
||||
|
||||
/* Define to 1 if delta encoder is enabled. */
|
||||
#define HAVE_ENCODER_DELTA 1
|
||||
|
||||
/* Define to 1 if ia64 encoder is enabled. */
|
||||
#define HAVE_ENCODER_IA64 1
|
||||
|
||||
/* Define to 1 if lzma1 encoder is enabled. */
|
||||
#define HAVE_ENCODER_LZMA1 1
|
||||
|
||||
/* Define to 1 if lzma2 encoder is enabled. */
|
||||
#define HAVE_ENCODER_LZMA2 1
|
||||
|
||||
/* Define to 1 if powerpc encoder is enabled. */
|
||||
#define HAVE_ENCODER_POWERPC 1
|
||||
|
||||
/* Define to 1 if sparc encoder is enabled. */
|
||||
#define HAVE_ENCODER_SPARC 1
|
||||
|
||||
/* Define to 1 if x86 encoder is enabled. */
|
||||
#define HAVE_ENCODER_X86 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `futimens' function. */
|
||||
/* #undef HAVE_FUTIMENS */
|
||||
|
||||
/* Define to 1 if you have the `futimes' function. */
|
||||
/* #undef HAVE_FUTIMES */
|
||||
|
||||
/* Define to 1 if you have the `futimesat' function. */
|
||||
/* #undef HAVE_FUTIMESAT */
|
||||
|
||||
/* Define to 1 if you have the <getopt.h> header file. */
|
||||
/* #undef HAVE_GETOPT_H */
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
/* #undef HAVE_GETOPT_LONG */
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
/* #undef HAVE_GETTEXT */
|
||||
|
||||
/* Define if you have the iconv() function and it works. */
|
||||
#define HAVE_ICONV 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
|
||||
#define HAVE_MBRTOWC 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 to enable bt2 match finder. */
|
||||
#define HAVE_MF_BT2 1
|
||||
|
||||
/* Define to 1 to enable bt3 match finder. */
|
||||
#define HAVE_MF_BT3 1
|
||||
|
||||
/* Define to 1 to enable bt4 match finder. */
|
||||
#define HAVE_MF_BT4 1
|
||||
|
||||
/* Define to 1 to enable hc3 match finder. */
|
||||
#define HAVE_MF_HC3 1
|
||||
|
||||
/* Define to 1 to enable hc4 match finder. */
|
||||
#define HAVE_MF_HC4 1
|
||||
|
||||
/* Define to 1 if getopt.h declares extern int optreset. */
|
||||
/* #undef HAVE_OPTRESET */
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
/* #undef HAVE_PTHREAD */
|
||||
|
||||
/* Have PTHREAD_PRIO_INHERIT. */
|
||||
/* #undef HAVE_PTHREAD_PRIO_INHERIT */
|
||||
|
||||
/* Define to 1 if optimizing for size. */
|
||||
/* #undef HAVE_SMALL */
|
||||
|
||||
/* Define to 1 if stdbool.h conforms to C99. */
|
||||
#define HAVE_STDBOOL_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
|
||||
/* #undef HAVE_STRUCT_STAT_ST_ATIMENSEC */
|
||||
|
||||
/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */
|
||||
/* #undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC */
|
||||
|
||||
/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */
|
||||
/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */
|
||||
|
||||
/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
|
||||
/* #undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC */
|
||||
|
||||
/* Define to 1 if `st_uatime' is a member of `struct stat'. */
|
||||
/* #undef HAVE_STRUCT_STAT_ST_UATIME */
|
||||
|
||||
/* Define to 1 if you have the <sys/byteorder.h> header file. */
|
||||
/* #undef HAVE_SYS_BYTEORDER_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||
#define HAVE_UINTPTR_T 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `utime' function. */
|
||||
#define HAVE_UTIME 1
|
||||
|
||||
/* Define to 1 if you have the `utimes' function. */
|
||||
/* #undef HAVE_UTIMES */
|
||||
|
||||
/* Define to 1 or 0, depending whether the compiler supports simple visibility
|
||||
declarations. */
|
||||
#define HAVE_VISIBILITY 1
|
||||
|
||||
/* Define to 1 if you have the `wcwidth' function. */
|
||||
/* #undef HAVE_WCWIDTH */
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#define HAVE__BOOL 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "xz"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "XZ Utils"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "xz"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://tukaani.org/xz/"
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#define SIZEOF_SIZE_T 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if the number of available CPU cores can be detected with
|
||||
pstat_getdynamic(). */
|
||||
/* #undef TUKLIB_CPUCORES_PSTAT_GETDYNAMIC */
|
||||
|
||||
/* Define to 1 if the number of available CPU cores can be detected with
|
||||
sysconf(_SC_NPROCESSORS_ONLN) or sysconf(_SC_NPROC_ONLN). */
|
||||
/* #undef TUKLIB_CPUCORES_SYSCONF */
|
||||
|
||||
/* Define to 1 if the number of available CPU cores can be detected with
|
||||
sysctl(). */
|
||||
/* #undef TUKLIB_CPUCORES_SYSCTL */
|
||||
|
||||
/* Define to 1 if the system supports fast unaligned access to 16-bit and
|
||||
32-bit integers. */
|
||||
#define TUKLIB_FAST_UNALIGNED_ACCESS 1
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with
|
||||
_system_configuration.physmem. */
|
||||
/* #undef TUKLIB_PHYSMEM_AIX */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with
|
||||
getinvent_r(). */
|
||||
/* #undef TUKLIB_PHYSMEM_GETINVENT_R */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with
|
||||
getsysinfo(). */
|
||||
/* #undef TUKLIB_PHYSMEM_GETSYSINFO */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with
|
||||
pstat_getstatic(). */
|
||||
/* #undef TUKLIB_PHYSMEM_PSTAT_GETSTATIC */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with
|
||||
sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES). */
|
||||
/* #undef TUKLIB_PHYSMEM_SYSCONF */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with sysctl().
|
||||
*/
|
||||
/* #undef TUKLIB_PHYSMEM_SYSCTL */
|
||||
|
||||
/* Define to 1 if the amount of physical memory can be detected with Linux
|
||||
sysinfo(). */
|
||||
/* #undef TUKLIB_PHYSMEM_SYSINFO */
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# define _TANDEM_SOURCE 1
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# define __EXTENSIONS__ 1
|
||||
#endif
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Enable large inode numbers on Mac OS X 10.5. */
|
||||
#ifndef _DARWIN_USE_64_BIT_INODE
|
||||
# define _DARWIN_USE_64_BIT_INODE 1
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
/* #undef _MINIX */
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
/* #undef _POSIX_1_SOURCE */
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
/* #undef _POSIX_SOURCE */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT32_T */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT64_T */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT8_T */
|
||||
|
||||
/* Define to rpl_ if the getopt replacement functions and variables should be
|
||||
used. */
|
||||
/* #undef __GETOPT_PREFIX */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int32_t */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int64_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint16_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint32_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint64_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint8_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type wide enough to hold a
|
||||
pointer, if such a type exists, and if the system does not define it. */
|
||||
/* #undef uintptr_t */
|
||||
314
deps/lzma/liblzma/api/lzma.h
vendored
Normal file
314
deps/lzma/liblzma/api/lzma.h
vendored
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
/**
|
||||
* \file api/lzma.h
|
||||
* \brief The public API of liblzma data compression library
|
||||
*
|
||||
* liblzma is a public domain general-purpose data compression library with
|
||||
* a zlib-like API. The native file format is .xz, but also the old .lzma
|
||||
* format and raw (no headers) streams are supported. Multiple compression
|
||||
* algorithms (filters) are supported. Currently LZMA2 is the primary filter.
|
||||
*
|
||||
* liblzma is part of XZ Utils <http://tukaani.org/xz/>. XZ Utils includes
|
||||
* a gzip-like command line tool named xz and some other tools. XZ Utils
|
||||
* is developed and maintained by Lasse Collin.
|
||||
*
|
||||
* Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK
|
||||
* <http://7-zip.org/sdk.html>.
|
||||
*
|
||||
* The SHA-256 implementation is based on the public domain code found from
|
||||
* 7-Zip <http://7-zip.org/>, which has a modified version of the public
|
||||
* domain SHA-256 code found from Crypto++ <http://www.cryptopp.com/>.
|
||||
* The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H
|
||||
#define LZMA_H
|
||||
|
||||
/*****************************
|
||||
* Required standard headers *
|
||||
*****************************/
|
||||
|
||||
/*
|
||||
* liblzma API headers need some standard types and macros. To allow
|
||||
* including lzma.h without requiring the application to include other
|
||||
* headers first, lzma.h includes the required standard headers unless
|
||||
* they already seem to be included already or if LZMA_MANUAL_HEADERS
|
||||
* has been defined.
|
||||
*
|
||||
* Here's what types and macros are needed and from which headers:
|
||||
* - stddef.h: size_t, NULL
|
||||
* - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
|
||||
* UINT32_MAX, UINT64_MAX
|
||||
*
|
||||
* However, inttypes.h is a little more portable than stdint.h, although
|
||||
* inttypes.h declares some unneeded things compared to plain stdint.h.
|
||||
*
|
||||
* The hacks below aren't perfect, specifically they assume that inttypes.h
|
||||
* exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
|
||||
* and that, in case of incomplete inttypes.h, unsigned int is 32-bit.
|
||||
* If the application already takes care of setting up all the types and
|
||||
* macros properly (for example by using gnulib's stdint.h or inttypes.h),
|
||||
* we try to detect that the macros are already defined and don't include
|
||||
* inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to
|
||||
* force this file to never include any system headers.
|
||||
*
|
||||
* Some could argue that liblzma API should provide all the required types,
|
||||
* for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
|
||||
* seen as an unnecessary mess, since most systems already provide all the
|
||||
* necessary types and macros in the standard headers.
|
||||
*
|
||||
* Note that liblzma API still has lzma_bool, because using stdbool.h would
|
||||
* break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't
|
||||
* necessarily the same as sizeof(bool) in C++.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_MANUAL_HEADERS
|
||||
/*
|
||||
* I suppose this works portably also in C++. Note that in C++,
|
||||
* we need to get size_t into the global namespace.
|
||||
*/
|
||||
# include <stddef.h>
|
||||
|
||||
/*
|
||||
* Skip inttypes.h if we already have all the required macros. If we
|
||||
* have the macros, we assume that we have the matching typedefs too.
|
||||
*/
|
||||
# if !defined(UINT32_C) || !defined(UINT64_C) \
|
||||
|| !defined(UINT32_MAX) || !defined(UINT64_MAX)
|
||||
/*
|
||||
* MSVC has no C99 support, and thus it cannot be used to
|
||||
* compile liblzma. The liblzma API has to still be usable
|
||||
* from MSVC, so we need to define the required standard
|
||||
* integer types here.
|
||||
*/
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# else
|
||||
/* Use the standard inttypes.h. */
|
||||
# ifdef __cplusplus
|
||||
/*
|
||||
* C99 sections 7.18.2 and 7.18.4 specify
|
||||
* that C++ implementations define the limit
|
||||
* and constant macros only if specifically
|
||||
* requested. Note that if you want the
|
||||
* format macros (PRIu64 etc.) too, you need
|
||||
* to define __STDC_FORMAT_MACROS before
|
||||
* including lzma.h, since re-including
|
||||
* inttypes.h with __STDC_FORMAT_MACROS
|
||||
* defined doesn't necessarily work.
|
||||
*/
|
||||
# ifndef __STDC_LIMIT_MACROS
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
# endif
|
||||
# ifndef __STDC_CONSTANT_MACROS
|
||||
# define __STDC_CONSTANT_MACROS 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Some old systems have only the typedefs in inttypes.h, and
|
||||
* lack all the macros. For those systems, we need a few more
|
||||
* hacks. We assume that unsigned int is 32-bit and unsigned
|
||||
* long is either 32-bit or 64-bit. If these hacks aren't
|
||||
* enough, the application has to setup the types manually
|
||||
* before including lzma.h.
|
||||
*/
|
||||
# ifndef UINT32_C
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
# define UINT32_C(n) n ## UI32
|
||||
# else
|
||||
# define UINT32_C(n) n ## U
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_C
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
# define UINT64_C(n) n ## UI64
|
||||
# else
|
||||
/* Get ULONG_MAX. */
|
||||
# include <limits.h>
|
||||
# if ULONG_MAX == 4294967295UL
|
||||
# define UINT64_C(n) n ## ULL
|
||||
# else
|
||||
# define UINT64_C(n) n ## UL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef UINT32_MAX
|
||||
# define UINT32_MAX (UINT32_C(4294967295))
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_MAX
|
||||
# define UINT64_MAX (UINT64_C(18446744073709551615))
|
||||
# endif
|
||||
# endif
|
||||
#endif /* ifdef LZMA_MANUAL_HEADERS */
|
||||
|
||||
|
||||
/******************
|
||||
* LZMA_API macro *
|
||||
******************/
|
||||
|
||||
/*
|
||||
* Some systems require that the functions and function pointers are
|
||||
* declared specially in the headers. LZMA_API_IMPORT is for importing
|
||||
* symbols and LZMA_API_CALL is to specify the calling convention.
|
||||
*
|
||||
* By default it is assumed that the application will link dynamically
|
||||
* against liblzma. #define LZMA_API_STATIC in your application if you
|
||||
* want to link against static liblzma. If you don't care about portability
|
||||
* to operating systems like Windows, or at least don't care about linking
|
||||
* against static liblzma on them, don't worry about LZMA_API_STATIC. That
|
||||
* is, most developers will never need to use LZMA_API_STATIC.
|
||||
*
|
||||
* The GCC variants are a special case on Windows (Cygwin and MinGW).
|
||||
* We rely on GCC doing the right thing with its auto-import feature,
|
||||
* and thus don't use __declspec(dllimport). This way developers don't
|
||||
* need to worry about LZMA_API_STATIC. Also the calling convention is
|
||||
* omitted on Cygwin but not on MinGW.
|
||||
*/
|
||||
#ifndef LZMA_API_IMPORT
|
||||
# define LZMA_API_STATIC
|
||||
# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)
|
||||
# define LZMA_API_IMPORT __declspec(dllimport)
|
||||
# else
|
||||
# define LZMA_API_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LZMA_API_CALL
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# define LZMA_API_CALL __cdecl
|
||||
# else
|
||||
# define LZMA_API_CALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LZMA_API
|
||||
# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL
|
||||
#endif
|
||||
|
||||
|
||||
/***********
|
||||
* nothrow *
|
||||
***********/
|
||||
|
||||
/*
|
||||
* None of the functions in liblzma may throw an exception. Even
|
||||
* the functions that use callback functions won't throw exceptions,
|
||||
* because liblzma would break if a callback function threw an exception.
|
||||
*/
|
||||
#ifndef lzma_nothrow
|
||||
# if defined(__cplusplus)
|
||||
# define lzma_nothrow throw()
|
||||
# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
|
||||
# define lzma_nothrow __attribute__((__nothrow__))
|
||||
# else
|
||||
# define lzma_nothrow
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/********************
|
||||
* GNU C extensions *
|
||||
********************/
|
||||
|
||||
/*
|
||||
* GNU C extensions are used conditionally in the public API. It doesn't
|
||||
* break anything if these are sometimes enabled and sometimes not, only
|
||||
* affects warnings and optimizations.
|
||||
*/
|
||||
#if __GNUC__ >= 3
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr) __attribute__(attr)
|
||||
# endif
|
||||
|
||||
/* warn_unused_result was added in GCC 3.4. */
|
||||
# ifndef lzma_attr_warn_unused_result
|
||||
# if __GNUC__ == 3 && __GNUC_MINOR__ < 4
|
||||
# define lzma_attr_warn_unused_result
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef lzma_attr_pure
|
||||
# define lzma_attr_pure lzma_attribute((__pure__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_const
|
||||
# define lzma_attr_const lzma_attribute((__const__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_warn_unused_result
|
||||
# define lzma_attr_warn_unused_result \
|
||||
lzma_attribute((__warn_unused_result__))
|
||||
#endif
|
||||
|
||||
|
||||
/**************
|
||||
* Subheaders *
|
||||
**************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Subheaders check that this is defined. It is to prevent including
|
||||
* them directly from applications.
|
||||
*/
|
||||
#define LZMA_H_INTERNAL 1
|
||||
|
||||
/* Basic features */
|
||||
#include "lzma/version.h"
|
||||
#include "lzma/base.h"
|
||||
#include "lzma/vli.h"
|
||||
#include "lzma/check.h"
|
||||
|
||||
/* Filters */
|
||||
#include "lzma/filter.h"
|
||||
#include "lzma/bcj.h"
|
||||
#include "lzma/delta.h"
|
||||
#include "lzma/lzma.h"
|
||||
|
||||
/* Container formats */
|
||||
#include "lzma/container.h"
|
||||
|
||||
/* Advanced features */
|
||||
#include "lzma/stream_flags.h"
|
||||
#include "lzma/block.h"
|
||||
#include "lzma/index.h"
|
||||
#include "lzma/index_hash.h"
|
||||
|
||||
/* Hardware information */
|
||||
#include "lzma/hardware.h"
|
||||
|
||||
/*
|
||||
* All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
|
||||
* re-including the subheaders.
|
||||
*/
|
||||
#undef LZMA_H_INTERNAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef LZMA_H */
|
||||
601
deps/lzma/liblzma/api/lzma/base.h
vendored
Normal file
601
deps/lzma/liblzma/api/lzma/base.h
vendored
Normal file
|
|
@ -0,0 +1,601 @@
|
|||
/**
|
||||
* \file lzma/base.h
|
||||
* \brief Data types and functions used in many places in liblzma API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Boolean
|
||||
*
|
||||
* This is here because C89 doesn't have stdbool.h. To set a value for
|
||||
* variables having type lzma_bool, you can use
|
||||
* - C99's `true' and `false' from stdbool.h;
|
||||
* - C++'s internal `true' and `false'; or
|
||||
* - integers one (true) and zero (false).
|
||||
*/
|
||||
typedef unsigned char lzma_bool;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of reserved enumeration variable in structures
|
||||
*
|
||||
* To avoid breaking library ABI when new features are added, several
|
||||
* structures contain extra variables that may be used in future. Since
|
||||
* sizeof(enum) can be different than sizeof(int), and sizeof(enum) may
|
||||
* even vary depending on the range of enumeration constants, we specify
|
||||
* a separate type to be used for reserved enumeration variables. All
|
||||
* enumeration constants in liblzma API will be non-negative and less
|
||||
* than 128, which should guarantee that the ABI won't break even when
|
||||
* new constants are added to existing enumerations.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_RESERVED_ENUM = 0
|
||||
} lzma_reserved_enum;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return values used by several functions in liblzma
|
||||
*
|
||||
* Check the descriptions of specific functions to find out which return
|
||||
* values they can return. With some functions the return values may have
|
||||
* more specific meanings than described here; those differences are
|
||||
* described per-function basis.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_OK = 0,
|
||||
/**<
|
||||
* \brief Operation completed successfully
|
||||
*/
|
||||
|
||||
LZMA_STREAM_END = 1,
|
||||
/**<
|
||||
* \brief End of stream was reached
|
||||
*
|
||||
* In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
|
||||
* LZMA_FINISH was finished. In decoder, this indicates
|
||||
* that all the data was successfully decoded.
|
||||
*
|
||||
* In all cases, when LZMA_STREAM_END is returned, the last
|
||||
* output bytes should be picked from strm->next_out.
|
||||
*/
|
||||
|
||||
LZMA_NO_CHECK = 2,
|
||||
/**<
|
||||
* \brief Input stream has no integrity check
|
||||
*
|
||||
* This return value can be returned only if the
|
||||
* LZMA_TELL_NO_CHECK flag was used when initializing
|
||||
* the decoder. LZMA_NO_CHECK is just a warning, and
|
||||
* the decoding can be continued normally.
|
||||
*
|
||||
* It is possible to call lzma_get_check() immediately after
|
||||
* lzma_code has returned LZMA_NO_CHECK. The result will
|
||||
* naturally be LZMA_CHECK_NONE, but the possibility to call
|
||||
* lzma_get_check() may be convenient in some applications.
|
||||
*/
|
||||
|
||||
LZMA_UNSUPPORTED_CHECK = 3,
|
||||
/**<
|
||||
* \brief Cannot calculate the integrity check
|
||||
*
|
||||
* The usage of this return value is different in encoders
|
||||
* and decoders.
|
||||
*
|
||||
* Encoders can return this value only from the initialization
|
||||
* function. If initialization fails with this value, the
|
||||
* encoding cannot be done, because there's no way to produce
|
||||
* output with the correct integrity check.
|
||||
*
|
||||
* Decoders can return this value only from lzma_code() and
|
||||
* only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when
|
||||
* initializing the decoder. The decoding can still be
|
||||
* continued normally even if the check type is unsupported,
|
||||
* but naturally the check will not be validated, and possible
|
||||
* errors may go undetected.
|
||||
*
|
||||
* With decoder, it is possible to call lzma_get_check()
|
||||
* immediately after lzma_code() has returned
|
||||
* LZMA_UNSUPPORTED_CHECK. This way it is possible to find
|
||||
* out what the unsupported Check ID was.
|
||||
*/
|
||||
|
||||
LZMA_GET_CHECK = 4,
|
||||
/**<
|
||||
* \brief Integrity check type is now available
|
||||
*
|
||||
* This value can be returned only by the lzma_code() function
|
||||
* and only if the decoder was initialized with the
|
||||
* LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the
|
||||
* application that it may now call lzma_get_check() to find
|
||||
* out the Check ID. This can be used, for example, to
|
||||
* implement a decoder that accepts only files that have
|
||||
* strong enough integrity check.
|
||||
*/
|
||||
|
||||
LZMA_MEM_ERROR = 5,
|
||||
/**<
|
||||
* \brief Cannot allocate memory
|
||||
*
|
||||
* Memory allocation failed, or the size of the allocation
|
||||
* would be greater than SIZE_MAX.
|
||||
*
|
||||
* Due to internal implementation reasons, the coding cannot
|
||||
* be continued even if more memory were made available after
|
||||
* LZMA_MEM_ERROR.
|
||||
*/
|
||||
|
||||
LZMA_MEMLIMIT_ERROR = 6,
|
||||
/**
|
||||
* \brief Memory usage limit was reached
|
||||
*
|
||||
* Decoder would need more memory than allowed by the
|
||||
* specified memory usage limit. To continue decoding,
|
||||
* the memory usage limit has to be increased with
|
||||
* lzma_memlimit_set().
|
||||
*/
|
||||
|
||||
LZMA_FORMAT_ERROR = 7,
|
||||
/**<
|
||||
* \brief File format not recognized
|
||||
*
|
||||
* The decoder did not recognize the input as supported file
|
||||
* format. This error can occur, for example, when trying to
|
||||
* decode .lzma format file with lzma_stream_decoder,
|
||||
* because lzma_stream_decoder accepts only the .xz format.
|
||||
*/
|
||||
|
||||
LZMA_OPTIONS_ERROR = 8,
|
||||
/**<
|
||||
* \brief Invalid or unsupported options
|
||||
*
|
||||
* Invalid or unsupported options, for example
|
||||
* - unsupported filter(s) or filter options; or
|
||||
* - reserved bits set in headers (decoder only).
|
||||
*
|
||||
* Rebuilding liblzma with more features enabled, or
|
||||
* upgrading to a newer version of liblzma may help.
|
||||
*/
|
||||
|
||||
LZMA_DATA_ERROR = 9,
|
||||
/**<
|
||||
* \brief Data is corrupt
|
||||
*
|
||||
* The usage of this return value is different in encoders
|
||||
* and decoders. In both encoder and decoder, the coding
|
||||
* cannot continue after this error.
|
||||
*
|
||||
* Encoders return this if size limits of the target file
|
||||
* format would be exceeded. These limits are huge, thus
|
||||
* getting this error from an encoder is mostly theoretical.
|
||||
* For example, the maximum compressed and uncompressed
|
||||
* size of a .xz Stream is roughly 8 EiB (2^63 bytes).
|
||||
*
|
||||
* Decoders return this error if the input data is corrupt.
|
||||
* This can mean, for example, invalid CRC32 in headers
|
||||
* or invalid check of uncompressed data.
|
||||
*/
|
||||
|
||||
LZMA_BUF_ERROR = 10,
|
||||
/**<
|
||||
* \brief No progress is possible
|
||||
*
|
||||
* This error code is returned when the coder cannot consume
|
||||
* any new input and produce any new output. The most common
|
||||
* reason for this error is that the input stream being
|
||||
* decoded is truncated or corrupt.
|
||||
*
|
||||
* This error is not fatal. Coding can be continued normally
|
||||
* by providing more input and/or more output space, if
|
||||
* possible.
|
||||
*
|
||||
* Typically the first call to lzma_code() that can do no
|
||||
* progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only
|
||||
* the second consecutive call doing no progress will return
|
||||
* LZMA_BUF_ERROR. This is intentional.
|
||||
*
|
||||
* With zlib, Z_BUF_ERROR may be returned even if the
|
||||
* application is doing nothing wrong, so apps will need
|
||||
* to handle Z_BUF_ERROR specially. The above hack
|
||||
* guarantees that liblzma never returns LZMA_BUF_ERROR
|
||||
* to properly written applications unless the input file
|
||||
* is truncated or corrupt. This should simplify the
|
||||
* applications a little.
|
||||
*/
|
||||
|
||||
LZMA_PROG_ERROR = 11,
|
||||
/**<
|
||||
* \brief Programming error
|
||||
*
|
||||
* This indicates that the arguments given to the function are
|
||||
* invalid or the internal state of the decoder is corrupt.
|
||||
* - Function arguments are invalid or the structures
|
||||
* pointed by the argument pointers are invalid
|
||||
* e.g. if strm->next_out has been set to NULL and
|
||||
* strm->avail_out > 0 when calling lzma_code().
|
||||
* - lzma_* functions have been called in wrong order
|
||||
* e.g. lzma_code() was called right after lzma_end().
|
||||
* - If errors occur randomly, the reason might be flaky
|
||||
* hardware.
|
||||
*
|
||||
* If you think that your code is correct, this error code
|
||||
* can be a sign of a bug in liblzma. See the documentation
|
||||
* how to report bugs.
|
||||
*/
|
||||
} lzma_ret;
|
||||
|
||||
|
||||
/**
|
||||
* \brief The `action' argument for lzma_code()
|
||||
*
|
||||
* After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH,
|
||||
* the same `action' must is used until lzma_code() returns LZMA_STREAM_END.
|
||||
* Also, the amount of input (that is, strm->avail_in) must not be modified
|
||||
* by the application until lzma_code() returns LZMA_STREAM_END. Changing the
|
||||
* `action' or modifying the amount of input will make lzma_code() return
|
||||
* LZMA_PROG_ERROR.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_RUN = 0,
|
||||
/**<
|
||||
* \brief Continue coding
|
||||
*
|
||||
* Encoder: Encode as much input as possible. Some internal
|
||||
* buffering will probably be done (depends on the filter
|
||||
* chain in use), which causes latency: the input used won't
|
||||
* usually be decodeable from the output of the same
|
||||
* lzma_code() call.
|
||||
*
|
||||
* Decoder: Decode as much input as possible and produce as
|
||||
* much output as possible.
|
||||
*/
|
||||
|
||||
LZMA_SYNC_FLUSH = 1,
|
||||
/**<
|
||||
* \brief Make all the input available at output
|
||||
*
|
||||
* Normally the encoder introduces some latency.
|
||||
* LZMA_SYNC_FLUSH forces all the buffered data to be
|
||||
* available at output without resetting the internal
|
||||
* state of the encoder. This way it is possible to use
|
||||
* compressed stream for example for communication over
|
||||
* network.
|
||||
*
|
||||
* Only some filters support LZMA_SYNC_FLUSH. Trying to use
|
||||
* LZMA_SYNC_FLUSH with filters that don't support it will
|
||||
* make lzma_code() return LZMA_OPTIONS_ERROR. For example,
|
||||
* LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.
|
||||
*
|
||||
* Using LZMA_SYNC_FLUSH very often can dramatically reduce
|
||||
* the compression ratio. With some filters (for example,
|
||||
* LZMA2), fine-tuning the compression options may help
|
||||
* mitigate this problem significantly (for example,
|
||||
* match finder with LZMA2).
|
||||
*
|
||||
* Decoders don't support LZMA_SYNC_FLUSH.
|
||||
*/
|
||||
|
||||
LZMA_FULL_FLUSH = 2,
|
||||
/**<
|
||||
* \brief Finish encoding of the current Block
|
||||
*
|
||||
* All the input data going to the current Block must have
|
||||
* been given to the encoder (the last bytes can still be
|
||||
* pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH
|
||||
* until it returns LZMA_STREAM_END. Then continue normally
|
||||
* with LZMA_RUN or finish the Stream with LZMA_FINISH.
|
||||
*
|
||||
* This action is currently supported only by Stream encoder
|
||||
* and easy encoder (which uses Stream encoder). If there is
|
||||
* no unfinished Block, no empty Block is created.
|
||||
*/
|
||||
|
||||
LZMA_FINISH = 3
|
||||
/**<
|
||||
* \brief Finish the coding operation
|
||||
*
|
||||
* All the input data must have been given to the encoder
|
||||
* (the last bytes can still be pending in next_in).
|
||||
* Call lzma_code() with LZMA_FINISH until it returns
|
||||
* LZMA_STREAM_END. Once LZMA_FINISH has been used,
|
||||
* the amount of input must no longer be changed by
|
||||
* the application.
|
||||
*
|
||||
* When decoding, using LZMA_FINISH is optional unless the
|
||||
* LZMA_CONCATENATED flag was used when the decoder was
|
||||
* initialized. When LZMA_CONCATENATED was not used, the only
|
||||
* effect of LZMA_FINISH is that the amount of input must not
|
||||
* be changed just like in the encoder.
|
||||
*/
|
||||
} lzma_action;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Custom functions for memory handling
|
||||
*
|
||||
* A pointer to lzma_allocator may be passed via lzma_stream structure
|
||||
* to liblzma, and some advanced functions take a pointer to lzma_allocator
|
||||
* as a separate function argument. The library will use the functions
|
||||
* specified in lzma_allocator for memory handling instead of the default
|
||||
* malloc() and free(). C++ users should note that the custom memory
|
||||
* handling functions must not throw exceptions.
|
||||
*
|
||||
* liblzma doesn't make an internal copy of lzma_allocator. Thus, it is
|
||||
* OK to change these function pointers in the middle of the coding
|
||||
* process, but obviously it must be done carefully to make sure that the
|
||||
* replacement `free' can deallocate memory allocated by the earlier
|
||||
* `alloc' function(s).
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Pointer to a custom memory allocation function
|
||||
*
|
||||
* If you don't want a custom allocator, but still want
|
||||
* custom free(), set this to NULL and liblzma will use
|
||||
* the standard malloc().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param nmemb Number of elements like in calloc(). liblzma
|
||||
* will always set nmemb to 1, so it is safe to
|
||||
* ignore nmemb in a custom allocator if you like.
|
||||
* The nmemb argument exists only for
|
||||
* compatibility with zlib and libbzip2.
|
||||
* \param size Size of an element in bytes.
|
||||
* liblzma never sets this to zero.
|
||||
*
|
||||
* \return Pointer to the beginning of a memory block of
|
||||
* `size' bytes, or NULL if allocation fails
|
||||
* for some reason. When allocation fails, functions
|
||||
* of liblzma return LZMA_MEM_ERROR.
|
||||
*
|
||||
* The allocator should not waste time zeroing the allocated buffers.
|
||||
* This is not only about speed, but also memory usage, since the
|
||||
* operating system kernel doesn't necessarily allocate the requested
|
||||
* memory in physical memory until it is actually used. With small
|
||||
* input files, liblzma may actually need only a fraction of the
|
||||
* memory that it requested for allocation.
|
||||
*
|
||||
* \note LZMA_MEM_ERROR is also used when the size of the
|
||||
* allocation would be greater than SIZE_MAX. Thus,
|
||||
* don't assume that the custom allocator must have
|
||||
* returned NULL if some function from liblzma
|
||||
* returns LZMA_MEM_ERROR.
|
||||
*/
|
||||
void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Pointer to a custom memory freeing function
|
||||
*
|
||||
* If you don't want a custom freeing function, but still
|
||||
* want a custom allocator, set this to NULL and liblzma
|
||||
* will use the standard free().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param ptr Pointer returned by lzma_allocator.alloc(),
|
||||
* or when it is set to NULL, a pointer returned
|
||||
* by the standard malloc().
|
||||
*/
|
||||
void (LZMA_API_CALL *free)(void *opaque, void *ptr);
|
||||
|
||||
/**
|
||||
* \brief Pointer passed to .alloc() and .free()
|
||||
*
|
||||
* opaque is passed as the first argument to lzma_allocator.alloc()
|
||||
* and lzma_allocator.free(). This intended to ease implementing
|
||||
* custom memory allocation functions for use with liblzma.
|
||||
*
|
||||
* If you don't need this, you should set this to NULL.
|
||||
*/
|
||||
void *opaque;
|
||||
|
||||
} lzma_allocator;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Internal data structure
|
||||
*
|
||||
* The contents of this structure is not visible outside the library.
|
||||
*/
|
||||
typedef struct lzma_internal_s lzma_internal;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Passing data to and from liblzma
|
||||
*
|
||||
* The lzma_stream structure is used for
|
||||
* - passing pointers to input and output buffers to liblzma;
|
||||
* - defining custom memory hander functions; and
|
||||
* - holding a pointer to coder-specific internal data structures.
|
||||
*
|
||||
* Typical usage:
|
||||
*
|
||||
* - After allocating lzma_stream (on stack or with malloc()), it must be
|
||||
* initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
|
||||
*
|
||||
* - Initialize a coder to the lzma_stream, for example by using
|
||||
* lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
|
||||
* - In contrast to zlib, strm->next_in and strm->next_out are
|
||||
* ignored by all initialization functions, thus it is safe
|
||||
* to not initialize them yet.
|
||||
* - The initialization functions always set strm->total_in and
|
||||
* strm->total_out to zero.
|
||||
* - If the initialization function fails, no memory is left allocated
|
||||
* that would require freeing with lzma_end() even if some memory was
|
||||
* associated with the lzma_stream structure when the initialization
|
||||
* function was called.
|
||||
*
|
||||
* - Use lzma_code() to do the actual work.
|
||||
*
|
||||
* - Once the coding has been finished, the existing lzma_stream can be
|
||||
* reused. It is OK to reuse lzma_stream with different initialization
|
||||
* function without calling lzma_end() first. Old allocations are
|
||||
* automatically freed.
|
||||
*
|
||||
* - Finally, use lzma_end() to free the allocated memory. lzma_end() never
|
||||
* frees the lzma_stream structure itself.
|
||||
*
|
||||
* Application may modify the values of total_in and total_out as it wants.
|
||||
* They are updated by liblzma to match the amount of data read and
|
||||
* written, but aren't used for anything else.
|
||||
*/
|
||||
typedef struct {
|
||||
const uint8_t *next_in; /**< Pointer to the next input byte. */
|
||||
size_t avail_in; /**< Number of available input bytes in next_in. */
|
||||
uint64_t total_in; /**< Total number of bytes read by liblzma. */
|
||||
|
||||
uint8_t *next_out; /**< Pointer to the next output position. */
|
||||
size_t avail_out; /**< Amount of free space in next_out. */
|
||||
uint64_t total_out; /**< Total number of bytes written by liblzma. */
|
||||
|
||||
/**
|
||||
* \brief Custom memory allocation functions
|
||||
*
|
||||
* In most cases this is NULL which makes liblzma use
|
||||
* the standard malloc() and free().
|
||||
*/
|
||||
lzma_allocator *allocator;
|
||||
|
||||
/** Internal state is not visible to applications. */
|
||||
lzma_internal *internal;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. Excluding the initialization of this structure,
|
||||
* you should not touch these, because the names of these variables
|
||||
* may change.
|
||||
*/
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
void *reserved_ptr4;
|
||||
uint64_t reserved_int1;
|
||||
uint64_t reserved_int2;
|
||||
size_t reserved_int3;
|
||||
size_t reserved_int4;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
|
||||
} lzma_stream;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialization for lzma_stream
|
||||
*
|
||||
* When you declare an instance of lzma_stream, you can immediately
|
||||
* initialize it so that initialization functions know that no memory
|
||||
* has been allocated yet:
|
||||
*
|
||||
* lzma_stream strm = LZMA_STREAM_INIT;
|
||||
*
|
||||
* If you need to initialize a dynamically allocated lzma_stream, you can use
|
||||
* memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this
|
||||
* violates the C standard since NULL may have different internal
|
||||
* representation than zero, but it should be portable enough in practice.
|
||||
* Anyway, for maximum portability, you can use something like this:
|
||||
*
|
||||
* lzma_stream tmp = LZMA_STREAM_INIT;
|
||||
* *strm = tmp;
|
||||
*/
|
||||
#define LZMA_STREAM_INIT \
|
||||
{ NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
|
||||
NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
|
||||
LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode or decode data
|
||||
*
|
||||
* Once the lzma_stream has been successfully initialized (e.g. with
|
||||
* lzma_stream_encoder()), the actual encoding or decoding is done
|
||||
* using this function. The application has to update strm->next_in,
|
||||
* strm->avail_in, strm->next_out, and strm->avail_out to pass input
|
||||
* to and get output from liblzma.
|
||||
*
|
||||
* See the description of the coder-specific initialization function to find
|
||||
* out what `action' values are supported by the coder.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Free memory allocated for the coder data structures
|
||||
*
|
||||
* \param strm Pointer to lzma_stream that is at least initialized
|
||||
* with LZMA_STREAM_INIT.
|
||||
*
|
||||
* After lzma_end(strm), strm->internal is guaranteed to be NULL. No other
|
||||
* members of the lzma_stream structure are touched.
|
||||
*
|
||||
* \note zlib indicates an error if application end()s unfinished
|
||||
* stream structure. liblzma doesn't do this, and assumes that
|
||||
* application knows what it is doing.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the memory usage of decoder filter chain
|
||||
*
|
||||
* This function is currently supported only when *strm has been initialized
|
||||
* with a function that takes a memlimit argument. With other functions, you
|
||||
* should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()
|
||||
* to estimate the memory requirements.
|
||||
*
|
||||
* This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big
|
||||
* the memory usage limit should have been to decode the input. Note that
|
||||
* this may give misleading information if decoding .xz Streams that have
|
||||
* multiple Blocks, because each Block can have different memory requirements.
|
||||
*
|
||||
* \return How much memory is currently allocated for the filter
|
||||
* decoders. If no filter chain is currently allocated,
|
||||
* some non-zero value is still returned, which is less than
|
||||
* or equal to what any filter chain would indicate as its
|
||||
* memory requirement.
|
||||
*
|
||||
* If this function isn't supported by *strm or some other error
|
||||
* occurs, zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the current memory usage limit
|
||||
*
|
||||
* This function is supported only when *strm has been initialized with
|
||||
* a function that takes a memlimit argument.
|
||||
*
|
||||
* \return On success, the current memory usage limit is returned
|
||||
* (always non-zero). On error, zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the memory usage limit
|
||||
*
|
||||
* This function is supported only when *strm has been initialized with
|
||||
* a function that takes a memlimit argument.
|
||||
*
|
||||
* \return - LZMA_OK: New memory usage limit successfully set.
|
||||
* - LZMA_MEMLIMIT_ERROR: The new limit is too small.
|
||||
* The limit was not changed.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
|
||||
* support memory usage limit or memlimit was zero.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_memlimit_set(
|
||||
lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
|
||||
90
deps/lzma/liblzma/api/lzma/bcj.h
vendored
Normal file
90
deps/lzma/liblzma/api/lzma/bcj.h
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* \file lzma/bcj.h
|
||||
* \brief Branch/Call/Jump conversion filters
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/* Filter IDs for lzma_filter.id */
|
||||
|
||||
#define LZMA_FILTER_X86 LZMA_VLI_C(0x04)
|
||||
/**<
|
||||
* Filter for x86 binaries
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05)
|
||||
/**<
|
||||
* Filter for Big endian PowerPC binaries
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06)
|
||||
/**<
|
||||
* Filter for IA-64 (Itanium) binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_ARM LZMA_VLI_C(0x07)
|
||||
/**<
|
||||
* Filter for ARM binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08)
|
||||
/**<
|
||||
* Filter for ARM-Thumb binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09)
|
||||
/**<
|
||||
* Filter for SPARC binaries.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for BCJ filters
|
||||
*
|
||||
* The BCJ filters never change the size of the data. Specifying options
|
||||
* for them is optional: if pointer to options is NULL, default value is
|
||||
* used. You probably never need to specify options to BCJ filters, so just
|
||||
* set the options pointer to NULL and be happy.
|
||||
*
|
||||
* If options with non-default values have been specified when encoding,
|
||||
* the same options must also be specified when decoding.
|
||||
*
|
||||
* \note At the moment, none of the BCJ filters support
|
||||
* LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
|
||||
* LZMA_OPTIONS_ERROR will be returned. If there is need,
|
||||
* partial support for LZMA_SYNC_FLUSH can be added in future.
|
||||
* Partial means that flushing would be possible only at
|
||||
* offsets that are multiple of 2, 4, or 16 depending on
|
||||
* the filter, except x86 which cannot be made to support
|
||||
* LZMA_SYNC_FLUSH predictably.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Start offset for conversions
|
||||
*
|
||||
* This setting is useful only when the same filter is used
|
||||
* _separately_ for multiple sections of the same executable file,
|
||||
* and the sections contain cross-section branch/call/jump
|
||||
* instructions. In that case it is beneficial to set the start
|
||||
* offset of the non-first sections so that the relative addresses
|
||||
* of the cross-section branch/call/jump instructions will use the
|
||||
* same absolute addresses as in the first section.
|
||||
*
|
||||
* When the pointer to options is NULL, the default value (zero)
|
||||
* is used.
|
||||
*/
|
||||
uint32_t start_offset;
|
||||
|
||||
} lzma_options_bcj;
|
||||
533
deps/lzma/liblzma/api/lzma/block.h
vendored
Normal file
533
deps/lzma/liblzma/api/lzma/block.h
vendored
Normal file
|
|
@ -0,0 +1,533 @@
|
|||
/**
|
||||
* \file lzma/block.h
|
||||
* \brief .xz Block handling
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Block and Block Header encoders and decoders
|
||||
*
|
||||
* Different Block handling functions use different parts of this structure.
|
||||
* Some read some members, other functions write, and some do both. Only the
|
||||
* members listed for reading need to be initialized when the specified
|
||||
* functions are called. The members marked for writing will be assigned
|
||||
* new values at some point either by calling the given function or by
|
||||
* later calls to lzma_code().
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Block format version
|
||||
*
|
||||
* To prevent API and ABI breakages if new features are needed in
|
||||
* the Block field, a version number is used to indicate which
|
||||
* fields in this structure are in use. For now, version must always
|
||||
* be zero. With non-zero version, most Block related functions will
|
||||
* return LZMA_OPTIONS_ERROR.
|
||||
*
|
||||
* Read by:
|
||||
* - All functions that take pointer to lzma_block as argument,
|
||||
* including lzma_block_header_decode().
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
*/
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* \brief Size of the Block Header field
|
||||
*
|
||||
* This is always a multiple of four.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_buffer_encode()
|
||||
*/
|
||||
uint32_t header_size;
|
||||
# define LZMA_BLOCK_HEADER_SIZE_MIN 8
|
||||
# define LZMA_BLOCK_HEADER_SIZE_MAX 1024
|
||||
|
||||
/**
|
||||
* \brief Type of integrity Check
|
||||
*
|
||||
* The Check ID is not stored into the Block Header, thus its value
|
||||
* must be provided also when decoding.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_check check;
|
||||
|
||||
/**
|
||||
* \brief Size of the Compressed Data in bytes
|
||||
*
|
||||
* Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
|
||||
* will store this value to the Block Header. Block encoder doesn't
|
||||
* care about this value, but will set it once the encoding has been
|
||||
* finished.
|
||||
*
|
||||
* Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
|
||||
* verify that the size of the Compressed Data field matches
|
||||
* compressed_size.
|
||||
*
|
||||
* Usually you don't know this value when encoding in streamed mode,
|
||||
* and thus cannot write this field into the Block Header.
|
||||
*
|
||||
* In non-streamed mode you can reserve space for this field before
|
||||
* encoding the actual Block. After encoding the data, finish the
|
||||
* Block by encoding the Block Header. Steps in detail:
|
||||
*
|
||||
* - Set compressed_size to some big enough value. If you don't know
|
||||
* better, use LZMA_VLI_MAX, but remember that bigger values take
|
||||
* more space in Block Header.
|
||||
*
|
||||
* - Call lzma_block_header_size() to see how much space you need to
|
||||
* reserve for the Block Header.
|
||||
*
|
||||
* - Encode the Block using lzma_block_encoder() and lzma_code().
|
||||
* It sets compressed_size to the correct value.
|
||||
*
|
||||
* - Use lzma_block_header_encode() to encode the Block Header.
|
||||
* Because space was reserved in the first step, you don't need
|
||||
* to call lzma_block_header_size() anymore, because due to
|
||||
* reserving, header_size has to be big enough. If it is "too big",
|
||||
* lzma_block_header_encode() will add enough Header Padding to
|
||||
* make Block Header to match the size specified by header_size.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_vli compressed_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed Size in bytes
|
||||
*
|
||||
* This is handled very similarly to compressed_size above.
|
||||
*
|
||||
* uncompressed_size is needed by fewer functions than
|
||||
* compressed_size. This is because uncompressed_size isn't
|
||||
* needed to validate that Block stays within proper limits.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Array of filters
|
||||
*
|
||||
* There can be 1-4 filters. The end of the array is marked with
|
||||
* .id = LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode(): Note that this does NOT free()
|
||||
* the old filter options structures. All unused filters[] will
|
||||
* have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
|
||||
* decoding fails, all filters[] are guaranteed to be
|
||||
* LZMA_VLI_UNKNOWN and NULL.
|
||||
*
|
||||
* \note Because of the array is terminated with
|
||||
* .id = LZMA_VLI_UNKNOWN, the actual array must
|
||||
* have LZMA_FILTERS_MAX + 1 members or the Block
|
||||
* Header decoder will overflow the buffer.
|
||||
*/
|
||||
lzma_filter *filters;
|
||||
|
||||
/**
|
||||
* \brief Raw value stored in the Check field
|
||||
*
|
||||
* After successful coding, the first lzma_check_size(check) bytes
|
||||
* of this array contain the raw value stored in the Check field.
|
||||
*
|
||||
* Note that CRC32 and CRC64 are stored in little endian byte order.
|
||||
* Take it into account if you display the Check values to the user.
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* with the currently supported options, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
lzma_vli reserved_int3;
|
||||
lzma_vli reserved_int4;
|
||||
lzma_vli reserved_int5;
|
||||
lzma_vli reserved_int6;
|
||||
lzma_vli reserved_int7;
|
||||
lzma_vli reserved_int8;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
lzma_bool reserved_bool1;
|
||||
lzma_bool reserved_bool2;
|
||||
lzma_bool reserved_bool3;
|
||||
lzma_bool reserved_bool4;
|
||||
lzma_bool reserved_bool5;
|
||||
lzma_bool reserved_bool6;
|
||||
lzma_bool reserved_bool7;
|
||||
lzma_bool reserved_bool8;
|
||||
|
||||
} lzma_block;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode the Block Header Size field
|
||||
*
|
||||
* To decode Block Header using lzma_block_header_decode(), the size of the
|
||||
* Block Header has to be known and stored into lzma_block.header_size.
|
||||
* The size can be calculated from the first byte of a Block using this macro.
|
||||
* Note that if the first byte is 0x00, it indicates beginning of Index; use
|
||||
* this macro only when the byte is not 0x00.
|
||||
*
|
||||
* There is no encoding macro, because Block Header encoder is enough for that.
|
||||
*/
|
||||
#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate Block Header Size
|
||||
*
|
||||
* Calculate the minimum size needed for the Block Header field using the
|
||||
* settings specified in the lzma_block structure. Note that it is OK to
|
||||
* increase the calculated header_size value as long as it is a multiple of
|
||||
* four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
|
||||
* just means that lzma_block_header_encode() will add Header Padding.
|
||||
*
|
||||
* \return - LZMA_OK: Size calculated successfully and stored to
|
||||
* block->header_size.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported version, filters or
|
||||
* filter options.
|
||||
* - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
|
||||
*
|
||||
* \note This doesn't check that all the options are valid i.e. this
|
||||
* may return LZMA_OK even if lzma_block_header_encode() or
|
||||
* lzma_block_encoder() would fail. If you want to validate the
|
||||
* filter chain, consider using lzma_memlimit_encoder() which as
|
||||
* a side-effect validates the filter chain.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Block Header
|
||||
*
|
||||
* The caller must have calculated the size of the Block Header already with
|
||||
* lzma_block_header_size(). If a value larger than the one calculated by
|
||||
* lzma_block_header_size() is used, the Block Header will be padded to the
|
||||
* specified size.
|
||||
*
|
||||
* \param out Beginning of the output buffer. This must be
|
||||
* at least block->header_size bytes.
|
||||
* \param block Block options to be encoded.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful. block->header_size
|
||||
* bytes were written to output buffer.
|
||||
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
||||
* block->header_size is invalid or block->filters is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_encode(
|
||||
const lzma_block *block, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Block Header
|
||||
*
|
||||
* block->version should be set to the highest value supported by the
|
||||
* application; currently the only possible version is zero. This function
|
||||
* will set version to the lowest value that still supports all the features
|
||||
* required by the Block Header.
|
||||
*
|
||||
* The size of the Block Header must have already been decoded with
|
||||
* lzma_block_header_size_decode() macro and stored to block->header_size.
|
||||
*
|
||||
* The integrity check type from Stream Header must have been stored
|
||||
* to block->check.
|
||||
*
|
||||
* block->filters must have been allocated, but they don't need to be
|
||||
* initialized (possible existing filter options are not freed).
|
||||
*
|
||||
* \param block Destination for Block options.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() (and also free()
|
||||
* if an error occurs).
|
||||
* \param in Beginning of the input buffer. This must be
|
||||
* at least block->header_size bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful. block->header_size
|
||||
* bytes were read from the input buffer.
|
||||
* - LZMA_OPTIONS_ERROR: The Block Header specifies some
|
||||
* unsupported options such as unsupported filters. This can
|
||||
* happen also if block->version was set to a too low value
|
||||
* compared to what would be required to properly represent
|
||||
* the information stored in the Block Header.
|
||||
* - LZMA_DATA_ERROR: Block Header is corrupt, for example,
|
||||
* the CRC32 doesn't match.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
||||
* block->header_size is invalid or block->filters is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
|
||||
lzma_allocator *allocator, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Validate and set Compressed Size according to Unpadded Size
|
||||
*
|
||||
* Block Header stores Compressed Size, but Index has Unpadded Size. If the
|
||||
* application has already parsed the Index and is now decoding Blocks,
|
||||
* it can calculate Compressed Size from Unpadded Size. This function does
|
||||
* exactly that with error checking:
|
||||
*
|
||||
* - Compressed Size calculated from Unpadded Size must be positive integer,
|
||||
* that is, Unpadded Size must be big enough that after Block Header and
|
||||
* Check fields there's still at least one byte for Compressed Size.
|
||||
*
|
||||
* - If Compressed Size was present in Block Header, the new value
|
||||
* calculated from Unpadded Size is compared against the value
|
||||
* from Block Header.
|
||||
*
|
||||
* \note This function must be called _after_ decoding the Block Header
|
||||
* field so that it can properly validate Compressed Size if it
|
||||
* was present in Block Header.
|
||||
*
|
||||
* \return - LZMA_OK: block->compressed_size was set successfully.
|
||||
* - LZMA_DATA_ERROR: unpadded_size is too small compared to
|
||||
* block->header_size and lzma_check_size(block->check).
|
||||
* - LZMA_PROG_ERROR: Some values are invalid. For example,
|
||||
* block->header_size must be a multiple of four and
|
||||
* between 8 and 1024 inclusive.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_compressed_size(
|
||||
lzma_block *block, lzma_vli unpadded_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate Unpadded Size
|
||||
*
|
||||
* The Index field stores Unpadded Size and Uncompressed Size. The latter
|
||||
* can be taken directly from the lzma_block structure after coding a Block,
|
||||
* but Unpadded Size needs to be calculated from Block Header Size,
|
||||
* Compressed Size, and size of the Check field. This is where this function
|
||||
* is needed.
|
||||
*
|
||||
* \return Unpadded Size on success, or zero on error.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate the total encoded size of a Block
|
||||
*
|
||||
* This is equivalent to lzma_block_unpadded_size() except that the returned
|
||||
* value includes the size of the Block Padding field.
|
||||
*
|
||||
* \return On success, total encoded size of the Block. On error,
|
||||
* zero is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Block encoder
|
||||
*
|
||||
* Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
|
||||
* filter chain supports it), and LZMA_FINISH.
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
|
||||
* that is not supported by this buid of liblzma. Initializing
|
||||
* the encoder failed.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_encoder(
|
||||
lzma_stream *strm, lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Block decoder
|
||||
*
|
||||
* Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
|
||||
* LZMA_FINISH is not required. It is supported only for convenience.
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
|
||||
* the given Check ID is not supported, thus Check will be
|
||||
* ignored.
|
||||
* - LZMA_PROG_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_decoder(
|
||||
lzma_stream *strm, lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate maximum output size for single-call Block encoding
|
||||
*
|
||||
* This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
|
||||
* See the documentation of lzma_stream_buffer_bound().
|
||||
*/
|
||||
extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Block encoder
|
||||
*
|
||||
* In contrast to the multi-call encoder initialized with
|
||||
* lzma_block_encoder(), this function encodes also the Block Header. This
|
||||
* is required to make it possible to write appropriate Block Header also
|
||||
* in case the data isn't compressible, and different filter chain has to be
|
||||
* used to encode the data in uncompressed form using uncompressed chunks
|
||||
* of the LZMA2 filter.
|
||||
*
|
||||
* When the data isn't compressible, header_size, compressed_size, and
|
||||
* uncompressed_size are set just like when the data was compressible, but
|
||||
* it is possible that header_size is too small to hold the filter chain
|
||||
* specified in block->filters, because that isn't necessarily the filter
|
||||
* chain that was actually used to encode the data. lzma_block_unpadded_size()
|
||||
* still works normally, because it doesn't read the filters array.
|
||||
*
|
||||
* \param block Block options: block->version, block->check,
|
||||
* and block->filters must have been initialized.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
|
||||
lzma_block *block, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Block decoder
|
||||
*
|
||||
* This is single-call equivalent of lzma_block_decoder(), and requires that
|
||||
* the caller has already decoded Block Header and checked its memory usage.
|
||||
*
|
||||
* \param block Block options just like with lzma_block_decoder().
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_BUF_ERROR: Output buffer was too small.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
|
||||
lzma_block *block, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow;
|
||||
150
deps/lzma/liblzma/api/lzma/check.h
vendored
Normal file
150
deps/lzma/liblzma/api/lzma/check.h
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* \file lzma/check.h
|
||||
* \brief Integrity checks
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of the integrity check (Check ID)
|
||||
*
|
||||
* The .xz format supports multiple types of checks that are calculated
|
||||
* from the uncompressed data. They vary in both speed and ability to
|
||||
* detect errors.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_CHECK_NONE = 0,
|
||||
/**<
|
||||
* No Check is calculated.
|
||||
*
|
||||
* Size of the Check field: 0 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC32 = 1,
|
||||
/**<
|
||||
* CRC32 using the polynomial from the IEEE 802.3 standard
|
||||
*
|
||||
* Size of the Check field: 4 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC64 = 4,
|
||||
/**<
|
||||
* CRC64 using the polynomial from the ECMA-182 standard
|
||||
*
|
||||
* Size of the Check field: 8 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_SHA256 = 10
|
||||
/**<
|
||||
* SHA-256
|
||||
*
|
||||
* Size of the Check field: 32 bytes
|
||||
*/
|
||||
} lzma_check;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum valid Check ID
|
||||
*
|
||||
* The .xz file format specification specifies 16 Check IDs (0-15). Some
|
||||
* of them are only reserved, that is, no actual Check algorithm has been
|
||||
* assigned. When decoding, liblzma still accepts unknown Check IDs for
|
||||
* future compatibility. If a valid but unsupported Check ID is detected,
|
||||
* liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
|
||||
* LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
|
||||
*/
|
||||
#define LZMA_CHECK_ID_MAX 15
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Check ID is supported
|
||||
*
|
||||
* Return true if the given Check ID is supported by this liblzma build.
|
||||
* Otherwise false is returned. It is safe to call this with a value that
|
||||
* is not in the range [0, 15]; in that case the return value is always false.
|
||||
*
|
||||
* You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always
|
||||
* supported (even if liblzma is built with limited features).
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Check field with the given Check ID
|
||||
*
|
||||
* Although not all Check IDs have a check algorithm associated, the size of
|
||||
* every Check is already frozen. This function returns the size (in bytes) of
|
||||
* the Check field with the specified Check ID. The values are:
|
||||
* { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
|
||||
*
|
||||
* If the argument is not in the range [0, 15], UINT32_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum size of a Check field
|
||||
*/
|
||||
#define LZMA_CHECK_SIZE_MAX 64
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC32
|
||||
*
|
||||
* Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
|
||||
*
|
||||
* \param buf Pointer to the input buffer
|
||||
* \param size Size of the input buffer
|
||||
* \param crc Previously returned CRC value. This is used to
|
||||
* calculate the CRC of a big buffer in smaller chunks.
|
||||
* Set to zero when starting a new calculation.
|
||||
*
|
||||
* \return Updated CRC value, which can be passed to this function
|
||||
* again to continue CRC calculation.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_crc32(
|
||||
const uint8_t *buf, size_t size, uint32_t crc)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC64
|
||||
*
|
||||
* Calculate CRC64 using the polynomial from the ECMA-182 standard.
|
||||
*
|
||||
* This function is used similarly to lzma_crc32(). See its documentation.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_crc64(
|
||||
const uint8_t *buf, size_t size, uint64_t crc)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/*
|
||||
* SHA-256 functions are currently not exported to public API.
|
||||
* Contact Lasse Collin if you think it should be.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the type of the integrity check
|
||||
*
|
||||
* This function can be called only immediately after lzma_code() has
|
||||
* returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
|
||||
* Calling this function in any other situation has undefined behavior.
|
||||
*/
|
||||
extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
|
||||
lzma_nothrow;
|
||||
424
deps/lzma/liblzma/api/lzma/container.h
vendored
Normal file
424
deps/lzma/liblzma/api/lzma/container.h
vendored
Normal file
|
|
@ -0,0 +1,424 @@
|
|||
/**
|
||||
* \file lzma/container.h
|
||||
* \brief File formats
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/************
|
||||
* Encoding *
|
||||
************/
|
||||
|
||||
/**
|
||||
* \brief Default compression preset
|
||||
*
|
||||
* It's not straightforward to recommend a default preset, because in some
|
||||
* cases keeping the resource usage relatively low is more important that
|
||||
* getting the maximum compression ratio.
|
||||
*/
|
||||
#define LZMA_PRESET_DEFAULT UINT32_C(6)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mask for preset level
|
||||
*
|
||||
* This is useful only if you need to extract the level from the preset
|
||||
* variable. That should be rare.
|
||||
*/
|
||||
#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F)
|
||||
|
||||
|
||||
/*
|
||||
* Preset flags
|
||||
*
|
||||
* Currently only one flag is defined.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Extreme compression preset
|
||||
*
|
||||
* This flag modifies the preset to make the encoding significantly slower
|
||||
* while improving the compression ratio only marginally. This is useful
|
||||
* when you don't mind wasting time to get as small result as possible.
|
||||
*
|
||||
* This flag doesn't affect the memory usage requirements of the decoder (at
|
||||
* least not significantly). The memory usage of the encoder may be increased
|
||||
* a little but only at the lowest preset levels (0-3).
|
||||
*/
|
||||
#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory usage of easy encoder
|
||||
*
|
||||
* This function is a wrapper for lzma_raw_encoder_memusage().
|
||||
*
|
||||
* \param preset Compression preset (level and possible flags)
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* preset when encoding. If an error occurs, for example
|
||||
* due to unsupported preset, UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate decoder memory usage of a preset
|
||||
*
|
||||
* This function is a wrapper for lzma_raw_decoder_memusage().
|
||||
*
|
||||
* \param preset Compression preset (level and possible flags)
|
||||
*
|
||||
* \return Number of bytes of memory required to decompress a file
|
||||
* that was compressed using the given preset. If an error
|
||||
* occurs, for example due to unsupported preset, UINT64_MAX
|
||||
* is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream encoder using a preset number
|
||||
*
|
||||
* This function is intended for those who just want to use the basic features
|
||||
* if liblzma (that is, most developers out there).
|
||||
*
|
||||
* \param strm Pointer to lzma_stream that is at least initialized
|
||||
* with LZMA_STREAM_INIT.
|
||||
* \param preset Compression preset to use. A preset consist of level
|
||||
* number and zero or more flags. Usually flags aren't
|
||||
* used, so preset is simply a number [0, 9] which match
|
||||
* the options -0 ... -9 of the xz command line tool.
|
||||
* Additional flags can be be set using bitwise-or with
|
||||
* the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.
|
||||
* \param check Integrity check type to use. See check.h for available
|
||||
* checks. The xz command line tool defaults to
|
||||
* LZMA_CHECK_CRC64, which is a good choice if you are
|
||||
* unsure. LZMA_CHECK_CRC32 is good too as long as the
|
||||
* uncompressed file is not many gigabytes.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded. Use lzma_code() to
|
||||
* encode your data.
|
||||
* - LZMA_MEM_ERROR: Memory allocation failed.
|
||||
* - LZMA_OPTIONS_ERROR: The given compression preset is not
|
||||
* supported by this build of liblzma.
|
||||
* - LZMA_UNSUPPORTED_CHECK: The given check type is not
|
||||
* supported by this liblzma build.
|
||||
* - LZMA_PROG_ERROR: One or more of the parameters have values
|
||||
* that will never be valid. For example, strm == NULL.
|
||||
*
|
||||
* If initialization fails (return value is not LZMA_OK), all the memory
|
||||
* allocated for *strm by liblzma is always freed. Thus, there is no need
|
||||
* to call lzma_end() after failed initialization.
|
||||
*
|
||||
* If initialization succeeds, use lzma_code() to do the actual encoding.
|
||||
* Valid values for `action' (the second argument of lzma_code()) are
|
||||
* LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
|
||||
* there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_easy_encoder(
|
||||
lzma_stream *strm, uint32_t preset, lzma_check check)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream encoding using a preset number
|
||||
*
|
||||
* The maximum required output buffer size can be calculated with
|
||||
* lzma_stream_buffer_bound().
|
||||
*
|
||||
* \param preset Compression preset to use. See the description
|
||||
* in lzma_easy_encoder().
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
|
||||
uint32_t preset, lzma_check check,
|
||||
lzma_allocator *allocator, const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream encoder using a custom filter chain
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param filters Array of filters. This must be terminated with
|
||||
* filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for
|
||||
* more information.
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
|
||||
const lzma_filter *filters, lzma_check check)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .lzma encoder (legacy file format)
|
||||
*
|
||||
* The .lzma format is sometimes called the LZMA_Alone format, which is the
|
||||
* reason for the name of this function. The .lzma format supports only the
|
||||
* LZMA1 filter. There is no support for integrity checks like CRC32.
|
||||
*
|
||||
* Use this function if and only if you need to create files readable by
|
||||
* legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
|
||||
* is strongly recommended.
|
||||
*
|
||||
* The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* No kind of flushing is supported, because the file format doesn't make
|
||||
* it possible.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_alone_encoder(
|
||||
lzma_stream *strm, const lzma_options_lzma *options)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate output buffer size for single-call Stream encoder
|
||||
*
|
||||
* When trying to compress uncompressible data, the encoded size will be
|
||||
* slightly bigger than the input data. This function calculates how much
|
||||
* output buffer space is required to be sure that lzma_stream_buffer_encode()
|
||||
* doesn't return LZMA_BUF_ERROR.
|
||||
*
|
||||
* The calculated value is not exact, but it is guaranteed to be big enough.
|
||||
* The actual maximum output space required may be slightly smaller (up to
|
||||
* about 100 bytes). This should not be a problem in practice.
|
||||
*
|
||||
* If the calculated maximum size doesn't fit into size_t or would make the
|
||||
* Stream grow past LZMA_VLI_MAX (which should never happen in practice),
|
||||
* zero is returned to indicate the error.
|
||||
*
|
||||
* \note The limit calculated by this function applies only to
|
||||
* single-call encoding. Multi-call encoding may (and probably
|
||||
* will) have larger maximum expansion when encoding
|
||||
* uncompressible data. Currently there is no function to
|
||||
* calculate the maximum expansion of multi-call encoding.
|
||||
*/
|
||||
extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream encoder
|
||||
*
|
||||
* \param filters Array of filters. This must be terminated with
|
||||
* filters[n].id = LZMA_VLI_UNKNOWN. See filter.h
|
||||
* for more information.
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
|
||||
lzma_filter *filters, lzma_check check,
|
||||
lzma_allocator *allocator, const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/************
|
||||
* Decoding *
|
||||
************/
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
|
||||
* being decoded has no integrity check. Note that when used with
|
||||
* lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK
|
||||
* if LZMA_TELL_NO_CHECK is used.
|
||||
*/
|
||||
#define LZMA_TELL_NO_CHECK UINT32_C(0x01)
|
||||
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
|
||||
* stream has an integrity check, but the type of the integrity check is not
|
||||
* supported by this liblzma version or build. Such files can still be
|
||||
* decoded, but the integrity check cannot be verified.
|
||||
*/
|
||||
#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02)
|
||||
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type
|
||||
* of the integrity check is known. The type can then be got with
|
||||
* lzma_get_check().
|
||||
*/
|
||||
#define LZMA_TELL_ANY_CHECK UINT32_C(0x04)
|
||||
|
||||
|
||||
/**
|
||||
* This flag enables decoding of concatenated files with file formats that
|
||||
* allow concatenating compressed files as is. From the formats currently
|
||||
* supported by liblzma, only the .xz format allows concatenated files.
|
||||
* Concatenated files are not allowed with the legacy .lzma format.
|
||||
*
|
||||
* This flag also affects the usage of the `action' argument for lzma_code().
|
||||
* When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END
|
||||
* unless LZMA_FINISH is used as `action'. Thus, the application has to set
|
||||
* LZMA_FINISH in the same way as it does when encoding.
|
||||
*
|
||||
* If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH
|
||||
* as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required.
|
||||
*/
|
||||
#define LZMA_CONCATENATED UINT32_C(0x08)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream decoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
||||
* to effectively disable the limiter.
|
||||
* \param flags Bitwise-or of zero or more of the decoder flags:
|
||||
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
||||
* LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode .xz Streams and .lzma files with autodetection
|
||||
*
|
||||
* This decoder autodetects between the .xz and .lzma file formats, and
|
||||
* calls lzma_stream_decoder() or lzma_alone_decoder() once the type
|
||||
* of the input file has been detected.
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
||||
* to effectively disable the limiter.
|
||||
* \param flags Bitwise-or of flags, or zero for no flags.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_auto_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .lzma decoder (legacy file format)
|
||||
*
|
||||
* Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* There is no need to use LZMA_FINISH, but allowing it may simplify
|
||||
* certain types of applications.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_alone_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream decoder
|
||||
*
|
||||
* \param memlimit Pointer to how much memory the decoder is allowed
|
||||
* to allocate. The value pointed by this pointer is
|
||||
* modified if and only if LZMA_MEMLIMIT_ERROR is
|
||||
* returned.
|
||||
* \param flags Bitwise-or of zero or more of the decoder flags:
|
||||
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
||||
* LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK
|
||||
* is not allowed and will return LZMA_PROG_ERROR.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if decoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_NO_CHECK: This can be returned only if using
|
||||
* the LZMA_TELL_NO_CHECK flag.
|
||||
* - LZMA_UNSUPPORTED_CHECK: This can be returned only if using
|
||||
* the LZMA_TELL_UNSUPPORTED_CHECK flag.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
||||
* The minimum required memlimit value was stored to *memlimit.
|
||||
* - LZMA_BUF_ERROR: Output buffer was too small.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
|
||||
uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
77
deps/lzma/liblzma/api/lzma/delta.h
vendored
Normal file
77
deps/lzma/liblzma/api/lzma/delta.h
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* \file lzma/delta.h
|
||||
* \brief Delta filter
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Filter ID of the Delta filter. This is used as lzma_filter.id.
|
||||
*/
|
||||
#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of the delta calculation
|
||||
*
|
||||
* Currently only byte-wise delta is supported. Other possible types could
|
||||
* be, for example, delta of 16/32/64-bit little/big endian integers, but
|
||||
* these are not currently planned since byte-wise delta is almost as good.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_DELTA_TYPE_BYTE
|
||||
} lzma_delta_type;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Delta filter
|
||||
*
|
||||
* These options are needed by both encoder and decoder.
|
||||
*/
|
||||
typedef struct {
|
||||
/** For now, this must always be LZMA_DELTA_TYPE_BYTE. */
|
||||
lzma_delta_type type;
|
||||
|
||||
/**
|
||||
* \brief Delta distance
|
||||
*
|
||||
* With the only currently supported type, LZMA_DELTA_TYPE_BYTE,
|
||||
* the distance is as bytes.
|
||||
*
|
||||
* Examples:
|
||||
* - 16-bit stereo audio: distance = 4 bytes
|
||||
* - 24-bit RGB image data: distance = 3 bytes
|
||||
*/
|
||||
uint32_t dist;
|
||||
# define LZMA_DELTA_DIST_MIN 1
|
||||
# define LZMA_DELTA_DIST_MAX 256
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
uint32_t reserved_int3;
|
||||
uint32_t reserved_int4;
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
|
||||
} lzma_options_delta;
|
||||
424
deps/lzma/liblzma/api/lzma/filter.h
vendored
Normal file
424
deps/lzma/liblzma/api/lzma/filter.h
vendored
Normal file
|
|
@ -0,0 +1,424 @@
|
|||
/**
|
||||
* \file lzma/filter.h
|
||||
* \brief Common filter related types and functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum number of filters in a chain
|
||||
*
|
||||
* A filter chain can have 1-4 filters, of which three are allowed to change
|
||||
* the size of the data. Usually only one or two filters are needed.
|
||||
*/
|
||||
#define LZMA_FILTERS_MAX 4
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter options
|
||||
*
|
||||
* This structure is used to pass Filter ID and a pointer filter's
|
||||
* options to liblzma. A few functions work with a single lzma_filter
|
||||
* structure, while most functions expect a filter chain.
|
||||
*
|
||||
* A filter chain is indicated with an array of lzma_filter structures.
|
||||
* The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter
|
||||
* array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to
|
||||
* be able to hold any arbitrary filter chain. This is important when
|
||||
* using lzma_block_header_decode() from block.h, because too small
|
||||
* array would make liblzma write past the end of the filters array.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Use constants whose name begin with `LZMA_FILTER_' to specify
|
||||
* different filters. In an array of lzma_filter structures, use
|
||||
* LZMA_VLI_UNKNOWN to indicate end of filters.
|
||||
*
|
||||
* \note This is not an enum, because on some systems enums
|
||||
* cannot be 64-bit.
|
||||
*/
|
||||
lzma_vli id;
|
||||
|
||||
/**
|
||||
* \brief Pointer to filter-specific options structure
|
||||
*
|
||||
* If the filter doesn't need options, set this to NULL. If id is
|
||||
* set to LZMA_VLI_UNKNOWN, options is ignored, and thus
|
||||
* doesn't need be initialized.
|
||||
*/
|
||||
void *options;
|
||||
|
||||
} lzma_filter;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Filter ID is supported for encoding
|
||||
*
|
||||
* Return true if the give Filter ID is supported for encoding by this
|
||||
* liblzma build. Otherwise false is returned.
|
||||
*
|
||||
* There is no way to list which filters are available in this particular
|
||||
* liblzma version and build. It would be useless, because the application
|
||||
* couldn't know what kind of options the filter would need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Filter ID is supported for decoding
|
||||
*
|
||||
* Return true if the give Filter ID is supported for decoding by this
|
||||
* liblzma build. Otherwise false is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Copy the filters array
|
||||
*
|
||||
* Copy the Filter IDs and filter-specific options from src to dest.
|
||||
* Up to LZMA_FILTERS_MAX filters are copied, plus the terminating
|
||||
* .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least
|
||||
* LZMA_FILTERS_MAX + 1 elements space unless the caller knows that
|
||||
* src is smaller than that.
|
||||
*
|
||||
* Unless the filter-specific options is NULL, the Filter ID has to be
|
||||
* supported by liblzma, because liblzma needs to know the size of every
|
||||
* filter-specific options structure. The filter-specific options are not
|
||||
* validated. If options is NULL, any unsupported Filter IDs are copied
|
||||
* without returning an error.
|
||||
*
|
||||
* Old filter-specific options in dest are not freed, so dest doesn't
|
||||
* need to be initialized by the caller in any way.
|
||||
*
|
||||
* If an error occurs, memory possibly already allocated by this function
|
||||
* is always freed.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options
|
||||
* is not NULL.
|
||||
* - LZMA_PROG_ERROR: src or dest is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src,
|
||||
lzma_filter *dest, lzma_allocator *allocator) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory requirements for raw encoder
|
||||
*
|
||||
* This function can be used to calculate the memory requirements for
|
||||
* Block and Stream encoders too because Block and Stream encoders don't
|
||||
* need significantly more memory than raw encoder.
|
||||
*
|
||||
* \param filters Array of filters terminated with
|
||||
* .id == LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* filter chain when encoding. If an error occurs,
|
||||
* for example due to unsupported filter chain,
|
||||
* UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory requirements for raw decoder
|
||||
*
|
||||
* This function can be used to calculate the memory requirements for
|
||||
* Block and Stream decoders too because Block and Stream decoders don't
|
||||
* need significantly more memory than raw decoder.
|
||||
*
|
||||
* \param filters Array of filters terminated with
|
||||
* .id == LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* filter chain when decoding. If an error occurs,
|
||||
* for example due to unsupported filter chain,
|
||||
* UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize raw encoder
|
||||
*
|
||||
* This function may be useful when implementing custom file formats.
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the
|
||||
* filter chain supports it), or LZMA_FINISH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_encoder(
|
||||
lzma_stream *strm, const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize raw decoder
|
||||
*
|
||||
* The initialization of raw decoder goes similarly to raw encoder.
|
||||
*
|
||||
* The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using
|
||||
* LZMA_FINISH is not required, it is supported just for convenience.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_decoder(
|
||||
lzma_stream *strm, const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Update the filter chain in the encoder
|
||||
*
|
||||
* This function is for advanced users only. This function has two slightly
|
||||
* different purposes:
|
||||
*
|
||||
* - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter
|
||||
* chain, which will be used starting from the next Block.
|
||||
*
|
||||
* - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change
|
||||
* the filter-specific options in the middle of encoding. The actual
|
||||
* filters in the chain (Filter IDs) cannot be changed. In the future,
|
||||
* it might become possible to change the filter options without
|
||||
* using LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* While rarely useful, this function may be called also when no data has
|
||||
* been compressed yet. In that case, this function will behave as if
|
||||
* LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block
|
||||
* encoder) had been used right before calling this function.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filters_update(
|
||||
lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call raw encoder
|
||||
*
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note There is no function to calculate how big output buffer
|
||||
* would surely be big enough. (lzma_stream_buffer_bound()
|
||||
* works only for lzma_stream_buffer_encode(); raw encoder
|
||||
* won't necessarily meet that bound.)
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
|
||||
const lzma_filter *filters, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size, uint8_t *out,
|
||||
size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call raw decoder
|
||||
*
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
|
||||
const lzma_filter *filters, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Filter Properties field
|
||||
*
|
||||
* This function may be useful when implementing custom file formats
|
||||
* using the raw encoder and decoder.
|
||||
*
|
||||
* \param size Pointer to uint32_t to hold the size of the properties
|
||||
* \param filter Filter ID and options (the size of the properties may
|
||||
* vary depending on the options)
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note This function validates the Filter ID, but does not
|
||||
* necessarily validate the options. Thus, it is possible
|
||||
* that this returns LZMA_OK while the following call to
|
||||
* lzma_properties_encode() returns LZMA_OPTIONS_ERROR.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_size(
|
||||
uint32_t *size, const lzma_filter *filter) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode the Filter Properties field
|
||||
*
|
||||
* \param filter Filter ID and options
|
||||
* \param props Buffer to hold the encoded options. The size of
|
||||
* buffer must have been already determined with
|
||||
* lzma_properties_size().
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note Even this function won't validate more options than actually
|
||||
* necessary. Thus, it is possible that encoding the properties
|
||||
* succeeds but using the same options to initialize the encoder
|
||||
* will fail.
|
||||
*
|
||||
* \note If lzma_properties_size() indicated that the size
|
||||
* of the Filter Properties field is zero, calling
|
||||
* lzma_properties_encode() is not required, but it
|
||||
* won't do any harm either.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_encode(
|
||||
const lzma_filter *filter, uint8_t *props) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode the Filter Properties field
|
||||
*
|
||||
* \param filter filter->id must have been set to the correct
|
||||
* Filter ID. filter->options doesn't need to be
|
||||
* initialized (it's not freed by this function). The
|
||||
* decoded options will be stored to filter->options.
|
||||
* filter->options is set to NULL if there are no
|
||||
* properties or if an error occurs.
|
||||
* \param allocator Custom memory allocator used to allocate the
|
||||
* options. Set to NULL to use the default malloc(),
|
||||
* and in case of an error, also free().
|
||||
* \param props Input buffer containing the properties.
|
||||
* \param props_size Size of the properties. This must be the exact
|
||||
* size; giving too much or too little input will
|
||||
* return LZMA_OPTIONS_ERROR.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_decode(
|
||||
lzma_filter *filter, lzma_allocator *allocator,
|
||||
const uint8_t *props, size_t props_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate encoded size of a Filter Flags field
|
||||
*
|
||||
* Knowing the size of Filter Flags is useful to know when allocating
|
||||
* memory to hold the encoded Filter Flags.
|
||||
*
|
||||
* \param size Pointer to integer to hold the calculated size
|
||||
* \param filter Filter ID and associated options whose encoded
|
||||
* size is to be calculated
|
||||
*
|
||||
* \return - LZMA_OK: *size set successfully. Note that this doesn't
|
||||
* guarantee that filter->options is valid, thus
|
||||
* lzma_filter_flags_encode() may still fail.
|
||||
* - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options
|
||||
*
|
||||
* \note If you need to calculate size of List of Filter Flags,
|
||||
* you need to loop over every lzma_filter entry.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_size(
|
||||
uint32_t *size, const lzma_filter *filter)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Filter Flags into given buffer
|
||||
*
|
||||
* In contrast to some functions, this doesn't allocate the needed buffer.
|
||||
* This is due to how this function is used internally by liblzma.
|
||||
*
|
||||
* \param filter Filter ID and options to be encoded
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos out[*out_pos] is the next write position. This
|
||||
* is updated by the encoder.
|
||||
* \param out_size out[out_size] is the first byte to not write.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options or not enough output
|
||||
* buffer space (you should have checked it with
|
||||
* lzma_filter_flags_size()).
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Filter Flags from given buffer
|
||||
*
|
||||
* The decoded result is stored into *filter. The old value of
|
||||
* filter->options is not free()d.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
|
||||
lzma_filter *filter, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
50
deps/lzma/liblzma/api/lzma/hardware.h
vendored
Normal file
50
deps/lzma/liblzma/api/lzma/hardware.h
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* \file lzma/hardware.h
|
||||
* \brief Hardware information
|
||||
*
|
||||
* Since liblzma can consume a lot of system resources, it also provides
|
||||
* ways to limit the resource usage. Applications linking against liblzma
|
||||
* need to do the actual decisions how much resources to let liblzma to use.
|
||||
* To ease making these decisions, liblzma provides functions to find out
|
||||
* the relevant capabilities of the underlaying hardware. Currently there
|
||||
* is only a function to find out the amount of RAM, but in the future there
|
||||
* will be also a function to detect how many concurrent threads the system
|
||||
* can run.
|
||||
*
|
||||
* \note On some operating systems, these function may temporarily
|
||||
* load a shared library or open file descriptor(s) to find out
|
||||
* the requested hardware information. Unless the application
|
||||
* assumes that specific file descriptors are not touched by
|
||||
* other threads, this should have no effect on thread safety.
|
||||
* Possible operations involving file descriptors will restart
|
||||
* the syscalls if they return EINTR.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total amount of physical memory (RAM) in bytes
|
||||
*
|
||||
* This function may be useful when determining a reasonable memory
|
||||
* usage limit for decompressing or how much memory it is OK to use
|
||||
* for compressing.
|
||||
*
|
||||
* \return On success, the total amount of physical memory in bytes
|
||||
* is returned. If the amount of RAM cannot be determined,
|
||||
* zero is returned. This can happen if an error occurs
|
||||
* or if there is no code in liblzma to detect the amount
|
||||
* of RAM on the specific operating system.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
|
||||
682
deps/lzma/liblzma/api/lzma/index.h
vendored
Normal file
682
deps/lzma/liblzma/api/lzma/index.h
vendored
Normal file
|
|
@ -0,0 +1,682 @@
|
|||
/**
|
||||
* \file lzma/index.h
|
||||
* \brief Handling of .xz Index and related information
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Opaque data type to hold the Index(es) and other information
|
||||
*
|
||||
* lzma_index often holds just one .xz Index and possibly the Stream Flags
|
||||
* of the same Stream and size of the Stream Padding field. However,
|
||||
* multiple lzma_indexes can be concatenated with lzma_index_cat() and then
|
||||
* there may be information about multiple Streams in the same lzma_index.
|
||||
*
|
||||
* Notes about thread safety: Only one thread may modify lzma_index at
|
||||
* a time. All functions that take non-const pointer to lzma_index
|
||||
* modify it. As long as no thread is modifying the lzma_index, getting
|
||||
* information from the same lzma_index can be done from multiple threads
|
||||
* at the same time with functions that take a const pointer to
|
||||
* lzma_index or use lzma_index_iter. The same iterator must be used
|
||||
* only by one thread at a time, of course, but there can be as many
|
||||
* iterators for the same lzma_index as needed.
|
||||
*/
|
||||
typedef struct lzma_index_s lzma_index;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Iterator to get information about Blocks and Streams
|
||||
*/
|
||||
typedef struct {
|
||||
struct {
|
||||
/**
|
||||
* \brief Pointer to Stream Flags
|
||||
*
|
||||
* This is NULL if Stream Flags have not been set for
|
||||
* this Stream with lzma_index_stream_flags().
|
||||
*/
|
||||
const lzma_stream_flags *flags;
|
||||
|
||||
const void *reserved_ptr1;
|
||||
const void *reserved_ptr2;
|
||||
const void *reserved_ptr3;
|
||||
|
||||
/**
|
||||
* \brief Stream number in the lzma_index
|
||||
*
|
||||
* The first Stream is 1.
|
||||
*/
|
||||
lzma_vli number;
|
||||
|
||||
/**
|
||||
* \brief Number of Blocks in the Stream
|
||||
*
|
||||
* If this is zero, the block structure below has
|
||||
* undefined values.
|
||||
*/
|
||||
lzma_vli block_count;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Stream
|
||||
*
|
||||
* The offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*/
|
||||
lzma_vli compressed_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Stream
|
||||
*
|
||||
* The offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*/
|
||||
lzma_vli uncompressed_offset;
|
||||
|
||||
/**
|
||||
* \brief Compressed size of this Stream
|
||||
*
|
||||
* This includes all headers except the possible
|
||||
* Stream Padding after this Stream.
|
||||
*/
|
||||
lzma_vli compressed_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed size of this Stream
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Size of Stream Padding after this Stream
|
||||
*
|
||||
* If it hasn't been set with lzma_index_stream_padding(),
|
||||
* this defaults to zero. Stream Padding is always
|
||||
* a multiple of four bytes.
|
||||
*/
|
||||
lzma_vli padding;
|
||||
|
||||
lzma_vli reserved_vli1;
|
||||
lzma_vli reserved_vli2;
|
||||
lzma_vli reserved_vli3;
|
||||
lzma_vli reserved_vli4;
|
||||
} stream;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* \brief Block number in the file
|
||||
*
|
||||
* The first Block is 1.
|
||||
*/
|
||||
lzma_vli number_in_file;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the
|
||||
* lzma_index (i.e. usually the beginning of the .xz file).
|
||||
* Normally this is where you should seek in the .xz file
|
||||
* to start decompressing this Block.
|
||||
*/
|
||||
lzma_vli compressed_file_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*
|
||||
* When doing random-access reading, it is possible that
|
||||
* the target offset is not exactly at Block boundary. One
|
||||
* will need to compare the target offset against
|
||||
* uncompressed_file_offset or uncompressed_stream_offset,
|
||||
* and possibly decode and throw away some amount of data
|
||||
* before reaching the target offset.
|
||||
*/
|
||||
lzma_vli uncompressed_file_offset;
|
||||
|
||||
/**
|
||||
* \brief Block number in this Stream
|
||||
*
|
||||
* The first Block is 1.
|
||||
*/
|
||||
lzma_vli number_in_stream;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the Stream
|
||||
* containing this Block.
|
||||
*/
|
||||
lzma_vli compressed_stream_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the Stream
|
||||
* containing this Block.
|
||||
*/
|
||||
lzma_vli uncompressed_stream_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed size of this Block
|
||||
*
|
||||
* You should pass this to the Block decoder if you will
|
||||
* decode this Block. It will allow the Block decoder to
|
||||
* validate the uncompressed size.
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Unpadded size of this Block
|
||||
*
|
||||
* You should pass this to the Block decoder if you will
|
||||
* decode this Block. It will allow the Block decoder to
|
||||
* validate the unpadded size.
|
||||
*/
|
||||
lzma_vli unpadded_size;
|
||||
|
||||
/**
|
||||
* \brief Total compressed size
|
||||
*
|
||||
* This includes all headers and padding in this Block.
|
||||
* This is useful if you need to know how many bytes
|
||||
* the Block decoder will actually read.
|
||||
*/
|
||||
lzma_vli total_size;
|
||||
|
||||
lzma_vli reserved_vli1;
|
||||
lzma_vli reserved_vli2;
|
||||
lzma_vli reserved_vli3;
|
||||
lzma_vli reserved_vli4;
|
||||
|
||||
const void *reserved_ptr1;
|
||||
const void *reserved_ptr2;
|
||||
const void *reserved_ptr3;
|
||||
const void *reserved_ptr4;
|
||||
} block;
|
||||
|
||||
/*
|
||||
* Internal data which is used to store the state of the iterator.
|
||||
* The exact format may vary between liblzma versions, so don't
|
||||
* touch these in any way.
|
||||
*/
|
||||
union {
|
||||
const void *p;
|
||||
size_t s;
|
||||
lzma_vli v;
|
||||
} internal[6];
|
||||
} lzma_index_iter;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Operation mode for lzma_index_iter_next()
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_INDEX_ITER_ANY = 0,
|
||||
/**<
|
||||
* \brief Get the next Block or Stream
|
||||
*
|
||||
* Go to the next Block if the current Stream has at least
|
||||
* one Block left. Otherwise go to the next Stream even if
|
||||
* it has no Blocks. If the Stream has no Blocks
|
||||
* (lzma_index_iter.stream.block_count == 0),
|
||||
* lzma_index_iter.block will have undefined values.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_STREAM = 1,
|
||||
/**<
|
||||
* \brief Get the next Stream
|
||||
*
|
||||
* Go to the next Stream even if the current Stream has
|
||||
* unread Blocks left. If the next Stream has at least one
|
||||
* Block, the iterator will point to the first Block.
|
||||
* If there are no Blocks, lzma_index_iter.block will have
|
||||
* undefined values.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_BLOCK = 2,
|
||||
/**<
|
||||
* \brief Get the next Block
|
||||
*
|
||||
* Go to the next Block if the current Stream has at least
|
||||
* one Block left. If the current Stream has no Blocks left,
|
||||
* the next Stream with at least one Block is located and
|
||||
* the iterator will be made to point to the first Block of
|
||||
* that Stream.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3
|
||||
/**<
|
||||
* \brief Get the next non-empty Block
|
||||
*
|
||||
* This is like LZMA_INDEX_ITER_BLOCK except that it will
|
||||
* skip Blocks whose Uncompressed Size is zero.
|
||||
*/
|
||||
|
||||
} lzma_index_iter_mode;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate memory usage of lzma_index
|
||||
*
|
||||
* On disk, the size of the Index field depends on both the number of Records
|
||||
* stored and how big values the Records store (due to variable-length integer
|
||||
* encoding). When the Index is kept in lzma_index structure, the memory usage
|
||||
* depends only on the number of Records/Blocks stored in the Index(es), and
|
||||
* in case of concatenated lzma_indexes, the number of Streams. The size in
|
||||
* RAM is almost always significantly bigger than in the encoded form on disk.
|
||||
*
|
||||
* This function calculates an approximate amount of memory needed hold
|
||||
* the given number of Streams and Blocks in lzma_index structure. This
|
||||
* value may vary between CPU architectures and also between liblzma versions
|
||||
* if the internal implementation is modified.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_index_memusage(
|
||||
lzma_vli streams, lzma_vli blocks) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate the memory usage of an existing lzma_index
|
||||
*
|
||||
* This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),
|
||||
* lzma_index_block_count(i)).
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Allocate and initialize a new lzma_index structure
|
||||
*
|
||||
* \return On success, a pointer to an empty initialized lzma_index is
|
||||
* returned. If allocation fails, NULL is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Deallocate lzma_index
|
||||
*
|
||||
* If i is NULL, this does nothing.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Add a new Block to lzma_index
|
||||
*
|
||||
* \param i Pointer to a lzma_index structure
|
||||
* \param allocator Pointer to lzma_allocator, or NULL to
|
||||
* use malloc()
|
||||
* \param unpadded_size Unpadded Size of a Block. This can be
|
||||
* calculated with lzma_block_unpadded_size()
|
||||
* after encoding or decoding the Block.
|
||||
* \param uncompressed_size Uncompressed Size of a Block. This can be
|
||||
* taken directly from lzma_block structure
|
||||
* after encoding or decoding the Block.
|
||||
*
|
||||
* Appending a new Block does not invalidate iterators. For example,
|
||||
* if an iterator was pointing to the end of the lzma_index, after
|
||||
* lzma_index_append() it is possible to read the next Block with
|
||||
* an existing iterator.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
||||
* Stream or size of the Index field would grow too big.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_append(
|
||||
lzma_index *i, lzma_allocator *allocator,
|
||||
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the Stream Flags
|
||||
*
|
||||
* Set the Stream Flags of the last (and typically the only) Stream
|
||||
* in lzma_index. This can be useful when reading information from the
|
||||
* lzma_index, because to decode Blocks, knowing the integrity check type
|
||||
* is needed.
|
||||
*
|
||||
* The given Stream Flags are copied into internal preallocated structure
|
||||
* in the lzma_index, thus the caller doesn't need to keep the *stream_flags
|
||||
* available after calling this function.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_stream_flags(
|
||||
lzma_index *i, const lzma_stream_flags *stream_flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the types of integrity Checks
|
||||
*
|
||||
* If lzma_index_stream_flags() is used to set the Stream Flags for
|
||||
* every Stream, lzma_index_checks() can be used to get a bitmask to
|
||||
* indicate which Check types have been used. It can be useful e.g. if
|
||||
* showing the Check types to the user.
|
||||
*
|
||||
* The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the amount of Stream Padding
|
||||
*
|
||||
* Set the amount of Stream Padding of the last (and typically the only)
|
||||
* Stream in the lzma_index. This is needed when planning to do random-access
|
||||
* reading within multiple concatenated Streams.
|
||||
*
|
||||
* By default, the amount of Stream Padding is assumed to be zero bytes.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_DATA_ERROR: The file size would grow too big.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_stream_padding(
|
||||
lzma_index *i, lzma_vli stream_padding)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of Streams
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of Blocks
|
||||
*
|
||||
* This returns the total number of Blocks in lzma_index. To get number
|
||||
* of Blocks in individual Streams, use lzma_index_iter.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Index field as bytes
|
||||
*
|
||||
* This is needed to verify the Backward Size field in the Stream Footer.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the Stream
|
||||
*
|
||||
* If multiple lzma_indexes have been combined, this works as if the Blocks
|
||||
* were in a single Stream. This is useful if you are going to combine
|
||||
* Blocks from multiple Streams into a single new Stream.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the Blocks
|
||||
*
|
||||
* This doesn't include the Stream Header, Stream Footer, Stream Padding,
|
||||
* or Index fields.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the file
|
||||
*
|
||||
* When no lzma_indexes have been combined with lzma_index_cat() and there is
|
||||
* no Stream Padding, this function is identical to lzma_index_stream_size().
|
||||
* If multiple lzma_indexes have been combined, this includes also the headers
|
||||
* of each separate Stream and the possible Stream Padding fields.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the uncompressed size of the file
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize an iterator
|
||||
*
|
||||
* \param iter Pointer to a lzma_index_iter structure
|
||||
* \param i lzma_index to which the iterator will be associated
|
||||
*
|
||||
* This function associates the iterator with the given lzma_index, and calls
|
||||
* lzma_index_iter_rewind() on the iterator.
|
||||
*
|
||||
* This function doesn't allocate any memory, thus there is no
|
||||
* lzma_index_iter_end(). The iterator is valid as long as the
|
||||
* associated lzma_index is valid, that is, until lzma_index_end() or
|
||||
* using it as source in lzma_index_cat(). Specifically, lzma_index doesn't
|
||||
* become invalid if new Blocks are added to it with lzma_index_append() or
|
||||
* if it is used as the destination in lzma_index_cat().
|
||||
*
|
||||
* It is safe to make copies of an initialized lzma_index_iter, for example,
|
||||
* to easily restart reading at some particular position.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_iter_init(
|
||||
lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Rewind the iterator
|
||||
*
|
||||
* Rewind the iterator so that next call to lzma_index_iter_next() will
|
||||
* return the first Block or Stream.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the next Block or Stream
|
||||
*
|
||||
* \param iter Iterator initialized with lzma_index_iter_init()
|
||||
* \param mode Specify what kind of information the caller wants
|
||||
* to get. See lzma_index_iter_mode for details.
|
||||
*
|
||||
* \return If next Block or Stream matching the mode was found, *iter
|
||||
* is updated and this function returns false. If no Block or
|
||||
* Stream matching the mode is found, *iter is not modified
|
||||
* and this function returns true. If mode is set to an unknown
|
||||
* value, *iter is not modified and this function returns true.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_index_iter_next(
|
||||
lzma_index_iter *iter, lzma_index_iter_mode mode)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Locate a Block
|
||||
*
|
||||
* If it is possible to seek in the .xz file, it is possible to parse
|
||||
* the Index field(s) and use lzma_index_iter_locate() to do random-access
|
||||
* reading with granularity of Block size.
|
||||
*
|
||||
* \param iter Iterator that was earlier initialized with
|
||||
* lzma_index_iter_init().
|
||||
* \param target Uncompressed target offset which the caller would
|
||||
* like to locate from the Stream
|
||||
*
|
||||
* If the target is smaller than the uncompressed size of the Stream (can be
|
||||
* checked with lzma_index_uncompressed_size()):
|
||||
* - Information about the Stream and Block containing the requested
|
||||
* uncompressed offset is stored into *iter.
|
||||
* - Internal state of the iterator is adjusted so that
|
||||
* lzma_index_iter_next() can be used to read subsequent Blocks or Streams.
|
||||
* - This function returns false.
|
||||
*
|
||||
* If target is greater than the uncompressed size of the Stream, *iter
|
||||
* is not modified, and this function returns true.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_index_iter_locate(
|
||||
lzma_index_iter *iter, lzma_vli target) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Concatenate lzma_indexes
|
||||
*
|
||||
* Concatenating lzma_indexes is useful when doing random-access reading in
|
||||
* multi-Stream .xz file, or when combining multiple Streams into single
|
||||
* Stream.
|
||||
*
|
||||
* \param dest lzma_index after which src is appended
|
||||
* \param src lzma_index to be appended after dest. If this
|
||||
* function succeeds, the memory allocated for src
|
||||
* is freed or moved to be part of dest, and all
|
||||
* iterators pointing to src will become invalid.
|
||||
* \param allocator Custom memory allocator; can be NULL to use
|
||||
* malloc() and free().
|
||||
*
|
||||
* \return - LZMA_OK: lzma_indexes were concatenated successfully.
|
||||
* src is now a dangling pointer.
|
||||
* - LZMA_DATA_ERROR: *dest would grow too big.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_cat(
|
||||
lzma_index *dest, lzma_index *src, lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Duplicate lzma_index
|
||||
*
|
||||
* \return A copy of the lzma_index, or NULL if memory allocation failed.
|
||||
*/
|
||||
extern LZMA_API(lzma_index *) lzma_index_dup(
|
||||
const lzma_index *i, lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Index encoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param i Pointer to lzma_index which should be encoded.
|
||||
*
|
||||
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* It is enough to use only one of them (you can choose freely; use LZMA_RUN
|
||||
* to support liblzma versions older than 5.0.0).
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_encoder(
|
||||
lzma_stream *strm, const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Index decoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param i The decoded Index will be made available via
|
||||
* this pointer. Initially this function will
|
||||
* set *i to NULL (the old value is ignored). If
|
||||
* decoding succeeds (lzma_code() returns
|
||||
* LZMA_STREAM_END), *i will be set to point
|
||||
* to a new lzma_index, which the application
|
||||
* has to later free with lzma_index_end().
|
||||
* \param memlimit How much memory the resulting lzma_index is
|
||||
* allowed to require.
|
||||
*
|
||||
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* It is enough to use only one of them (you can choose freely; use LZMA_RUN
|
||||
* to support liblzma versions older than 5.0.0).
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_decoder(
|
||||
lzma_stream *strm, lzma_index **i, uint64_t memlimit)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Index encoder
|
||||
*
|
||||
* \param i lzma_index to be encoded
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Output buffer is too small. Use
|
||||
* lzma_index_size() to find out how much output
|
||||
* space is needed.
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note This function doesn't take allocator argument since all
|
||||
* the internal data is allocated on stack.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Index decoder
|
||||
*
|
||||
* \param i If decoding succeeds, *i will point to a new
|
||||
* lzma_index, which the application has to
|
||||
* later free with lzma_index_end(). If an error
|
||||
* occurs, *i will be NULL. The old value of *i
|
||||
* is always ignored and thus doesn't need to be
|
||||
* initialized by the caller.
|
||||
* \param memlimit Pointer to how much memory the resulting
|
||||
* lzma_index is allowed to require. The value
|
||||
* pointed by this pointer is modified if and only
|
||||
* if LZMA_MEMLIMIT_ERROR is returned.
|
||||
* \param allocator Pointer to lzma_allocator, or NULL to use malloc()
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
||||
* The minimum required memlimit value was stored to *memlimit.
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
|
||||
uint64_t *memlimit, lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow;
|
||||
107
deps/lzma/liblzma/api/lzma/index_hash.h
vendored
Normal file
107
deps/lzma/liblzma/api/lzma/index_hash.h
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* \file lzma/index_hash.h
|
||||
* \brief Validate Index by using a hash function
|
||||
*
|
||||
* Hashing makes it possible to use constant amount of memory to validate
|
||||
* Index of arbitrary size.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Opaque data type to hold the Index hash
|
||||
*/
|
||||
typedef struct lzma_index_hash_s lzma_index_hash;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Allocate and initialize a new lzma_index_hash structure
|
||||
*
|
||||
* If index_hash is NULL, a new lzma_index_hash structure is allocated,
|
||||
* initialized, and a pointer to it returned. If allocation fails, NULL
|
||||
* is returned.
|
||||
*
|
||||
* If index_hash is non-NULL, it is reinitialized and the same pointer
|
||||
* returned. In this case, return value cannot be NULL or a different
|
||||
* pointer than the index_hash that was given as an argument.
|
||||
*/
|
||||
extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
|
||||
lzma_index_hash *index_hash, lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Deallocate lzma_index_hash structure
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_hash_end(
|
||||
lzma_index_hash *index_hash, lzma_allocator *allocator)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Add a new Record to an Index hash
|
||||
*
|
||||
* \param index Pointer to a lzma_index_hash structure
|
||||
* \param unpadded_size Unpadded Size of a Block
|
||||
* \param uncompressed_size Uncompressed Size of a Block
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
||||
* Stream or size of the Index field would grow too big.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments or this function is being
|
||||
* used when lzma_index_hash_decode() has already been used.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
|
||||
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode and validate the Index field
|
||||
*
|
||||
* After telling the sizes of all Blocks with lzma_index_hash_append(),
|
||||
* the actual Index field is decoded with this function. Specifically,
|
||||
* once decoding of the Index field has been started, no more Records
|
||||
* can be added using lzma_index_hash_append().
|
||||
*
|
||||
* This function doesn't use lzma_stream structure to pass the input data.
|
||||
* Instead, the input buffer is specified using three arguments. This is
|
||||
* because it matches better the internal APIs of liblzma.
|
||||
*
|
||||
* \param index_hash Pointer to a lzma_index_hash structure
|
||||
* \param in Pointer to the beginning of the input buffer
|
||||
* \param in_pos in[*in_pos] is the next byte to process
|
||||
* \param in_size in[in_size] is the first byte not to process
|
||||
*
|
||||
* \return - LZMA_OK: So far good, but more input is needed.
|
||||
* - LZMA_STREAM_END: Index decoded successfully and it matches
|
||||
* the Records given with lzma_index_hash_append().
|
||||
* - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
|
||||
* information given with lzma_index_hash_append().
|
||||
* - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Index field as bytes
|
||||
*
|
||||
* This is needed to verify the Backward Size field in the Stream Footer.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_hash_size(
|
||||
const lzma_index_hash *index_hash)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
420
deps/lzma/liblzma/api/lzma/lzma.h
vendored
Normal file
420
deps/lzma/liblzma/api/lzma/lzma.h
vendored
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
/**
|
||||
* \file lzma/lzma.h
|
||||
* \brief LZMA1 and LZMA2 filters
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief LZMA1 Filter ID
|
||||
*
|
||||
* LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
|
||||
* 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
|
||||
* accidentally using LZMA when they actually want LZMA2.
|
||||
*
|
||||
* LZMA1 shouldn't be used for new applications unless you _really_ know
|
||||
* what you are doing. LZMA2 is almost always a better choice.
|
||||
*/
|
||||
#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
|
||||
|
||||
/**
|
||||
* \brief LZMA2 Filter ID
|
||||
*
|
||||
* Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
|
||||
* support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
|
||||
* when trying to compress uncompressible data), possibility to change
|
||||
* lc/lp/pb in the middle of encoding, and some other internal improvements.
|
||||
*/
|
||||
#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Match finders
|
||||
*
|
||||
* Match finder has major effect on both speed and compression ratio.
|
||||
* Usually hash chains are faster than binary trees.
|
||||
*
|
||||
* If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
|
||||
* choice, because binary trees get much higher compression ratio penalty
|
||||
* with LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* The memory usage formulas are only rough estimates, which are closest to
|
||||
* reality when dict_size is a power of two. The formulas are more complex
|
||||
* in reality, and can also change a little between liblzma versions. Use
|
||||
* lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MF_HC3 = 0x03,
|
||||
/**<
|
||||
* \brief Hash Chain with 2- and 3-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 3
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 16 MiB: dict_size * 7.5
|
||||
* - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_HC4 = 0x04,
|
||||
/**<
|
||||
* \brief Hash Chain with 2-, 3-, and 4-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 4
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 32 MiB: dict_size * 7.5
|
||||
* - dict_size > 32 MiB: dict_size * 6.5
|
||||
*/
|
||||
|
||||
LZMA_MF_BT2 = 0x12,
|
||||
/**<
|
||||
* \brief Binary Tree with 2-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 2
|
||||
*
|
||||
* Memory usage: dict_size * 9.5
|
||||
*/
|
||||
|
||||
LZMA_MF_BT3 = 0x13,
|
||||
/**<
|
||||
* \brief Binary Tree with 2- and 3-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 3
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 16 MiB: dict_size * 11.5
|
||||
* - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_BT4 = 0x14
|
||||
/**<
|
||||
* \brief Binary Tree with 2-, 3-, and 4-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 4
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 32 MiB: dict_size * 11.5
|
||||
* - dict_size > 32 MiB: dict_size * 10.5
|
||||
*/
|
||||
} lzma_match_finder;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if given match finder is supported
|
||||
*
|
||||
* Return true if the given match finder is supported by this liblzma build.
|
||||
* Otherwise false is returned. It is safe to call this with a value that
|
||||
* isn't listed in lzma_match_finder enumeration; the return value will be
|
||||
* false.
|
||||
*
|
||||
* There is no way to list which match finders are available in this
|
||||
* particular liblzma version and build. It would be useless, because
|
||||
* a new match finder, which the application developer wasn't aware,
|
||||
* could require giving additional options to the encoder that the older
|
||||
* match finders don't need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compression modes
|
||||
*
|
||||
* This selects the function used to analyze the data produced by the match
|
||||
* finder.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MODE_FAST = 1,
|
||||
/**<
|
||||
* \brief Fast compression
|
||||
*
|
||||
* Fast mode is usually at its best when combined with
|
||||
* a hash chain match finder.
|
||||
*/
|
||||
|
||||
LZMA_MODE_NORMAL = 2
|
||||
/**<
|
||||
* \brief Normal compression
|
||||
*
|
||||
* This is usually notably slower than fast mode. Use this
|
||||
* together with binary tree match finders to expose the
|
||||
* full potential of the LZMA1 or LZMA2 encoder.
|
||||
*/
|
||||
} lzma_mode;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if given compression mode is supported
|
||||
*
|
||||
* Return true if the given compression mode is supported by this liblzma
|
||||
* build. Otherwise false is returned. It is safe to call this with a value
|
||||
* that isn't listed in lzma_mode enumeration; the return value will be false.
|
||||
*
|
||||
* There is no way to list which modes are available in this particular
|
||||
* liblzma version and build. It would be useless, because a new compression
|
||||
* mode, which the application developer wasn't aware, could require giving
|
||||
* additional options to the encoder that the older modes don't need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options specific to the LZMA1 and LZMA2 filters
|
||||
*
|
||||
* Since LZMA1 and LZMA2 share most of the code, it's simplest to share
|
||||
* the options structure too. For encoding, all but the reserved variables
|
||||
* need to be initialized unless specifically mentioned otherwise.
|
||||
* lzma_lzma_preset() can be used to get a good starting point.
|
||||
*
|
||||
* For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
|
||||
* preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Dictionary size in bytes
|
||||
*
|
||||
* Dictionary size indicates how many bytes of the recently processed
|
||||
* uncompressed data is kept in memory. One method to reduce size of
|
||||
* the uncompressed data is to store distance-length pairs, which
|
||||
* indicate what data to repeat from the dictionary buffer. Thus,
|
||||
* the bigger the dictionary, the better the compression ratio
|
||||
* usually is.
|
||||
*
|
||||
* Maximum size of the dictionary depends on multiple things:
|
||||
* - Memory usage limit
|
||||
* - Available address space (not a problem on 64-bit systems)
|
||||
* - Selected match finder (encoder only)
|
||||
*
|
||||
* Currently the maximum dictionary size for encoding is 1.5 GiB
|
||||
* (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
|
||||
* systems for certain match finder implementation reasons. In the
|
||||
* future, there may be match finders that support bigger
|
||||
* dictionaries.
|
||||
*
|
||||
* Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
|
||||
* UINT32_MAX), so increasing the maximum dictionary size of the
|
||||
* encoder won't cause problems for old decoders.
|
||||
*
|
||||
* Because extremely small dictionaries sizes would have unneeded
|
||||
* overhead in the decoder, the minimum dictionary size is 4096 bytes.
|
||||
*
|
||||
* \note When decoding, too big dictionary does no other harm
|
||||
* than wasting memory.
|
||||
*/
|
||||
uint32_t dict_size;
|
||||
# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
|
||||
# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
|
||||
|
||||
/**
|
||||
* \brief Pointer to an initial dictionary
|
||||
*
|
||||
* It is possible to initialize the LZ77 history window using
|
||||
* a preset dictionary. It is useful when compressing many
|
||||
* similar, relatively small chunks of data independently from
|
||||
* each other. The preset dictionary should contain typical
|
||||
* strings that occur in the files being compressed. The most
|
||||
* probable strings should be near the end of the preset dictionary.
|
||||
*
|
||||
* This feature should be used only in special situations. For
|
||||
* now, it works correctly only with raw encoding and decoding.
|
||||
* Currently none of the container formats supported by
|
||||
* liblzma allow preset dictionary when decoding, thus if
|
||||
* you create a .xz or .lzma file with preset dictionary, it
|
||||
* cannot be decoded with the regular decoder functions. In the
|
||||
* future, the .xz format will likely get support for preset
|
||||
* dictionary though.
|
||||
*/
|
||||
const uint8_t *preset_dict;
|
||||
|
||||
/**
|
||||
* \brief Size of the preset dictionary
|
||||
*
|
||||
* Specifies the size of the preset dictionary. If the size is
|
||||
* bigger than dict_size, only the last dict_size bytes are
|
||||
* processed.
|
||||
*
|
||||
* This variable is read only when preset_dict is not NULL.
|
||||
* If preset_dict is not NULL but preset_dict_size is zero,
|
||||
* no preset dictionary is used (identical to only setting
|
||||
* preset_dict to NULL).
|
||||
*/
|
||||
uint32_t preset_dict_size;
|
||||
|
||||
/**
|
||||
* \brief Number of literal context bits
|
||||
*
|
||||
* How many of the highest bits of the previous uncompressed
|
||||
* eight-bit byte (also known as `literal') are taken into
|
||||
* account when predicting the bits of the next literal.
|
||||
*
|
||||
* E.g. in typical English text, an upper-case letter is
|
||||
* often followed by a lower-case letter, and a lower-case
|
||||
* letter is usually followed by another lower-case letter.
|
||||
* In the US-ASCII character set, the highest three bits are 010
|
||||
* for upper-case letters and 011 for lower-case letters.
|
||||
* When lc is at least 3, the literal coding can take advantage of
|
||||
* this property in the uncompressed data.
|
||||
*
|
||||
* There is a limit that applies to literal context bits and literal
|
||||
* position bits together: lc + lp <= 4. Without this limit the
|
||||
* decoding could become very slow, which could have security related
|
||||
* results in some cases like email servers doing virus scanning.
|
||||
* This limit also simplifies the internal implementation in liblzma.
|
||||
*
|
||||
* There may be LZMA1 streams that have lc + lp > 4 (maximum possible
|
||||
* lc would be 8). It is not possible to decode such streams with
|
||||
* liblzma.
|
||||
*/
|
||||
uint32_t lc;
|
||||
# define LZMA_LCLP_MIN 0
|
||||
# define LZMA_LCLP_MAX 4
|
||||
# define LZMA_LC_DEFAULT 3
|
||||
|
||||
/**
|
||||
* \brief Number of literal position bits
|
||||
*
|
||||
* lp affects what kind of alignment in the uncompressed data is
|
||||
* assumed when encoding literals. A literal is a single 8-bit byte.
|
||||
* See pb below for more information about alignment.
|
||||
*/
|
||||
uint32_t lp;
|
||||
# define LZMA_LP_DEFAULT 0
|
||||
|
||||
/**
|
||||
* \brief Number of position bits
|
||||
*
|
||||
* pb affects what kind of alignment in the uncompressed data is
|
||||
* assumed in general. The default means four-byte alignment
|
||||
* (2^ pb =2^2=4), which is often a good choice when there's
|
||||
* no better guess.
|
||||
*
|
||||
* When the aligment is known, setting pb accordingly may reduce
|
||||
* the file size a little. E.g. with text files having one-byte
|
||||
* alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
|
||||
* improve compression slightly. For UTF-16 text, pb=1 is a good
|
||||
* choice. If the alignment is an odd number like 3 bytes, pb=0
|
||||
* might be the best choice.
|
||||
*
|
||||
* Even though the assumed alignment can be adjusted with pb and
|
||||
* lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
|
||||
* It might be worth taking into account when designing file formats
|
||||
* that are likely to be often compressed with LZMA1 or LZMA2.
|
||||
*/
|
||||
uint32_t pb;
|
||||
# define LZMA_PB_MIN 0
|
||||
# define LZMA_PB_MAX 4
|
||||
# define LZMA_PB_DEFAULT 2
|
||||
|
||||
/** Compression mode */
|
||||
lzma_mode mode;
|
||||
|
||||
/**
|
||||
* \brief Nice length of a match
|
||||
*
|
||||
* This determines how many bytes the encoder compares from the match
|
||||
* candidates when looking for the best match. Once a match of at
|
||||
* least nice_len bytes long is found, the encoder stops looking for
|
||||
* better candidates and encodes the match. (Naturally, if the found
|
||||
* match is actually longer than nice_len, the actual length is
|
||||
* encoded; it's not truncated to nice_len.)
|
||||
*
|
||||
* Bigger values usually increase the compression ratio and
|
||||
* compression time. For most files, 32 to 128 is a good value,
|
||||
* which gives very good compression ratio at good speed.
|
||||
*
|
||||
* The exact minimum value depends on the match finder. The maximum
|
||||
* is 273, which is the maximum length of a match that LZMA1 and
|
||||
* LZMA2 can encode.
|
||||
*/
|
||||
uint32_t nice_len;
|
||||
|
||||
/** Match finder ID */
|
||||
lzma_match_finder mf;
|
||||
|
||||
/**
|
||||
* \brief Maximum search depth in the match finder
|
||||
*
|
||||
* For every input byte, match finder searches through the hash chain
|
||||
* or binary tree in a loop, each iteration going one step deeper in
|
||||
* the chain or tree. The searching stops if
|
||||
* - a match of at least nice_len bytes long is found;
|
||||
* - all match candidates from the hash chain or binary tree have
|
||||
* been checked; or
|
||||
* - maximum search depth is reached.
|
||||
*
|
||||
* Maximum search depth is needed to prevent the match finder from
|
||||
* wasting too much time in case there are lots of short match
|
||||
* candidates. On the other hand, stopping the search before all
|
||||
* candidates have been checked can reduce compression ratio.
|
||||
*
|
||||
* Setting depth to zero tells liblzma to use an automatic default
|
||||
* value, that depends on the selected match finder and nice_len.
|
||||
* The default is in the range [4, 200] or so (it may vary between
|
||||
* liblzma versions).
|
||||
*
|
||||
* Using a bigger depth value than the default can increase
|
||||
* compression ratio in some cases. There is no strict maximum value,
|
||||
* but high values (thousands or millions) should be used with care:
|
||||
* the encoder could remain fast enough with typical input, but
|
||||
* malicious input could cause the match finder to slow down
|
||||
* dramatically, possibly creating a denial of service attack.
|
||||
*/
|
||||
uint32_t depth;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* with the currently supported options, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
uint32_t reserved_int3;
|
||||
uint32_t reserved_int4;
|
||||
uint32_t reserved_int5;
|
||||
uint32_t reserved_int6;
|
||||
uint32_t reserved_int7;
|
||||
uint32_t reserved_int8;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
|
||||
} lzma_options_lzma;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set a compression preset to lzma_options_lzma structure
|
||||
*
|
||||
* 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
|
||||
* of the xz command line tool. In addition, it is possible to bitwise-or
|
||||
* flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
|
||||
* The flags are defined in container.h, because the flags are used also
|
||||
* with lzma_easy_encoder().
|
||||
*
|
||||
* The preset values are subject to changes between liblzma versions.
|
||||
*
|
||||
* This function is available only if LZMA1 or LZMA2 encoder has been enabled
|
||||
* when building liblzma.
|
||||
*
|
||||
* \return On success, false is returned. If the preset is not
|
||||
* supported, true is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_lzma_preset(
|
||||
lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
|
||||
223
deps/lzma/liblzma/api/lzma/stream_flags.h
vendored
Normal file
223
deps/lzma/liblzma/api/lzma/stream_flags.h
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/**
|
||||
* \file lzma/stream_flags.h
|
||||
* \brief .xz Stream Header and Stream Footer encoder and decoder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Size of Stream Header and Stream Footer
|
||||
*
|
||||
* Stream Header and Stream Footer have the same size and they are not
|
||||
* going to change even if a newer version of the .xz file format is
|
||||
* developed in future.
|
||||
*/
|
||||
#define LZMA_STREAM_HEADER_SIZE 12
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for encoding/decoding Stream Header and Stream Footer
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Stream Flags format version
|
||||
*
|
||||
* To prevent API and ABI breakages if new features are needed in
|
||||
* Stream Header or Stream Footer, a version number is used to
|
||||
* indicate which fields in this structure are in use. For now,
|
||||
* version must always be zero. With non-zero version, the
|
||||
* lzma_stream_header_encode() and lzma_stream_footer_encode()
|
||||
* will return LZMA_OPTIONS_ERROR.
|
||||
*
|
||||
* lzma_stream_header_decode() and lzma_stream_footer_decode()
|
||||
* will always set this to the lowest value that supports all the
|
||||
* features indicated by the Stream Flags field. The application
|
||||
* must check that the version number set by the decoding functions
|
||||
* is supported by the application. Otherwise it is possible that
|
||||
* the application will decode the Stream incorrectly.
|
||||
*/
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* \brief Backward Size
|
||||
*
|
||||
* Backward Size must be a multiple of four bytes. In this Stream
|
||||
* format version, Backward Size is the size of the Index field.
|
||||
*
|
||||
* Backward Size isn't actually part of the Stream Flags field, but
|
||||
* it is convenient to include in this structure anyway. Backward
|
||||
* Size is present only in the Stream Footer. There is no need to
|
||||
* initialize backward_size when encoding Stream Header.
|
||||
*
|
||||
* lzma_stream_header_decode() always sets backward_size to
|
||||
* LZMA_VLI_UNKNOWN so that it is convenient to use
|
||||
* lzma_stream_flags_compare() when both Stream Header and Stream
|
||||
* Footer have been decoded.
|
||||
*/
|
||||
lzma_vli backward_size;
|
||||
# define LZMA_BACKWARD_SIZE_MIN 4
|
||||
# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
|
||||
|
||||
/**
|
||||
* \brief Check ID
|
||||
*
|
||||
* This indicates the type of the integrity check calculated from
|
||||
* uncompressed data.
|
||||
*/
|
||||
lzma_check check;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the
|
||||
* names of these variables may change.
|
||||
*
|
||||
* (We will never be able to use all of these since Stream Flags
|
||||
* is just two bytes plus Backward Size of four bytes. But it's
|
||||
* nice to have the proper types when they are needed.)
|
||||
*/
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
lzma_bool reserved_bool1;
|
||||
lzma_bool reserved_bool2;
|
||||
lzma_bool reserved_bool3;
|
||||
lzma_bool reserved_bool4;
|
||||
lzma_bool reserved_bool5;
|
||||
lzma_bool reserved_bool6;
|
||||
lzma_bool reserved_bool7;
|
||||
lzma_bool reserved_bool8;
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
|
||||
} lzma_stream_flags;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Stream Header
|
||||
*
|
||||
* \param options Stream Header options to be encoded.
|
||||
* options->backward_size is ignored and doesn't
|
||||
* need to be initialized.
|
||||
* \param out Beginning of the output buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
||||
* this liblzma version.
|
||||
* - LZMA_PROG_ERROR: Invalid options.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_header_encode(
|
||||
const lzma_stream_flags *options, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Stream Footer
|
||||
*
|
||||
* \param options Stream Footer options to be encoded.
|
||||
* \param out Beginning of the output buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
||||
* this liblzma version.
|
||||
* - LZMA_PROG_ERROR: Invalid options.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_footer_encode(
|
||||
const lzma_stream_flags *options, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Stream Header
|
||||
*
|
||||
* \param options Target for the decoded Stream Header options.
|
||||
* \param in Beginning of the input buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to
|
||||
* help comparing Stream Flags from Stream Header and Stream Footer with
|
||||
* lzma_stream_flags_compare().
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
||||
* buffer cannot be Stream Header.
|
||||
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
|
||||
* is corrupt.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
||||
* in the header.
|
||||
*
|
||||
* \note When decoding .xz files that contain multiple Streams, it may
|
||||
* make sense to print "file format not recognized" only if
|
||||
* decoding of the Stream Header of the _first_ Stream gives
|
||||
* LZMA_FORMAT_ERROR. If non-first Stream Header gives
|
||||
* LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is
|
||||
* probably more appropriate.
|
||||
*
|
||||
* For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if
|
||||
* LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode()
|
||||
* when decoding non-first Stream.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_header_decode(
|
||||
lzma_stream_flags *options, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Stream Footer
|
||||
*
|
||||
* \param options Target for the decoded Stream Header options.
|
||||
* \param in Beginning of the input buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
||||
* buffer cannot be Stream Footer.
|
||||
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer
|
||||
* is corrupt.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
||||
* in Stream Footer.
|
||||
*
|
||||
* \note If Stream Header was already decoded successfully, but
|
||||
* decoding Stream Footer returns LZMA_FORMAT_ERROR, the
|
||||
* application should probably report some other error message
|
||||
* than "file format not recognized", since the file more likely
|
||||
* is corrupt (possibly truncated). Stream decoder in liblzma
|
||||
* uses LZMA_DATA_ERROR in this situation.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_footer_decode(
|
||||
lzma_stream_flags *options, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compare two lzma_stream_flags structures
|
||||
*
|
||||
* backward_size values are compared only if both are not
|
||||
* LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return - LZMA_OK: Both are equal. If either had backward_size set
|
||||
* to LZMA_VLI_UNKNOWN, backward_size values were not
|
||||
* compared or validated.
|
||||
* - LZMA_DATA_ERROR: The structures differ.
|
||||
* - LZMA_OPTIONS_ERROR: version in either structure is greater
|
||||
* than the maximum supported version (currently zero).
|
||||
* - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or
|
||||
* backward_size.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_flags_compare(
|
||||
const lzma_stream_flags *a, const lzma_stream_flags *b)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
121
deps/lzma/liblzma/api/lzma/version.h
vendored
Normal file
121
deps/lzma/liblzma/api/lzma/version.h
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* \file lzma/version.h
|
||||
* \brief Version number
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Version number split into components
|
||||
*/
|
||||
#define LZMA_VERSION_MAJOR 5
|
||||
#define LZMA_VERSION_MINOR 0
|
||||
#define LZMA_VERSION_PATCH 7
|
||||
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
|
||||
|
||||
#ifndef LZMA_VERSION_COMMIT
|
||||
# define LZMA_VERSION_COMMIT ""
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Map symbolic stability levels to integers.
|
||||
*/
|
||||
#define LZMA_VERSION_STABILITY_ALPHA 0
|
||||
#define LZMA_VERSION_STABILITY_BETA 1
|
||||
#define LZMA_VERSION_STABILITY_STABLE 2
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compile-time version number
|
||||
*
|
||||
* The version number is of format xyyyzzzs where
|
||||
* - x = major
|
||||
* - yyy = minor
|
||||
* - zzz = revision
|
||||
* - s indicates stability: 0 = alpha, 1 = beta, 2 = stable
|
||||
*
|
||||
* The same xyyyzzz triplet is never reused with different stability levels.
|
||||
* For example, if 5.1.0alpha has been released, there will never be 5.1.0beta
|
||||
* or 5.1.0 stable.
|
||||
*
|
||||
* \note The version number of liblzma has nothing to with
|
||||
* the version number of Igor Pavlov's LZMA SDK.
|
||||
*/
|
||||
#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \
|
||||
+ LZMA_VERSION_MINOR * UINT32_C(10000) \
|
||||
+ LZMA_VERSION_PATCH * UINT32_C(10) \
|
||||
+ LZMA_VERSION_STABILITY)
|
||||
|
||||
|
||||
/*
|
||||
* Macros to construct the compile-time version string
|
||||
*/
|
||||
#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA
|
||||
# define LZMA_VERSION_STABILITY_STRING "alpha"
|
||||
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA
|
||||
# define LZMA_VERSION_STABILITY_STRING "beta"
|
||||
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE
|
||||
# define LZMA_VERSION_STABILITY_STRING ""
|
||||
#else
|
||||
# error Incorrect LZMA_VERSION_STABILITY
|
||||
#endif
|
||||
|
||||
#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \
|
||||
#major "." #minor "." #patch stability commit
|
||||
|
||||
#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \
|
||||
LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compile-time version as a string
|
||||
*
|
||||
* This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable
|
||||
* versions don't have any "stable" suffix). In future, a snapshot built
|
||||
* from source code repository may include an additional suffix, for example
|
||||
* "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form
|
||||
* in LZMA_VERSION macro.
|
||||
*/
|
||||
#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \
|
||||
LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \
|
||||
LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \
|
||||
LZMA_VERSION_COMMIT)
|
||||
|
||||
|
||||
/* #ifndef is needed for use with windres (MinGW or Cygwin). */
|
||||
#ifndef LZMA_H_INTERNAL_RC
|
||||
|
||||
/**
|
||||
* \brief Run-time version number as an integer
|
||||
*
|
||||
* Return the value of LZMA_VERSION macro at the compile time of liblzma.
|
||||
* This allows the application to compare if it was built against the same,
|
||||
* older, or newer version of liblzma that is currently running.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_version_number(void)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Run-time version as a string
|
||||
*
|
||||
* This function may be useful if you want to display which version of
|
||||
* liblzma your application is currently using.
|
||||
*/
|
||||
extern LZMA_API(const char *) lzma_version_string(void)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
#endif
|
||||
166
deps/lzma/liblzma/api/lzma/vli.h
vendored
Normal file
166
deps/lzma/liblzma/api/lzma/vli.h
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/**
|
||||
* \file lzma/vli.h
|
||||
* \brief Variable-length integer handling
|
||||
*
|
||||
* In the .xz format, most integers are encoded in a variable-length
|
||||
* representation, which is sometimes called little endian base-128 encoding.
|
||||
* This saves space when smaller values are more likely than bigger values.
|
||||
*
|
||||
* The encoding scheme encodes seven bits to every byte, using minimum
|
||||
* number of bytes required to represent the given value. Encodings that use
|
||||
* non-minimum number of bytes are invalid, thus every integer has exactly
|
||||
* one encoded representation. The maximum number of bits in a VLI is 63,
|
||||
* thus the vli argument must be less than or equal to UINT64_MAX / 2. You
|
||||
* should use LZMA_VLI_MAX for clarity.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum supported value of a variable-length integer
|
||||
*/
|
||||
#define LZMA_VLI_MAX (UINT64_MAX / 2)
|
||||
|
||||
/**
|
||||
* \brief VLI value to denote that the value is unknown
|
||||
*/
|
||||
#define LZMA_VLI_UNKNOWN UINT64_MAX
|
||||
|
||||
/**
|
||||
* \brief Maximum supported encoded length of variable length integers
|
||||
*/
|
||||
#define LZMA_VLI_BYTES_MAX 9
|
||||
|
||||
/**
|
||||
* \brief VLI constant suffix
|
||||
*/
|
||||
#define LZMA_VLI_C(n) UINT64_C(n)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Variable-length integer type
|
||||
*
|
||||
* Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
|
||||
* indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
|
||||
* underlaying integer type.
|
||||
*
|
||||
* lzma_vli will be uint64_t for the foreseeable future. If a bigger size
|
||||
* is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
|
||||
* not overflow lzma_vli. This simplifies integer overflow detection.
|
||||
*/
|
||||
typedef uint64_t lzma_vli;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Validate a variable-length integer
|
||||
*
|
||||
* This is useful to test that application has given acceptable values
|
||||
* for example in the uncompressed_size and compressed_size variables.
|
||||
*
|
||||
* \return True if the integer is representable as VLI or if it
|
||||
* indicates unknown value.
|
||||
*/
|
||||
#define lzma_vli_is_valid(vli) \
|
||||
((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode a variable-length integer
|
||||
*
|
||||
* This function has two modes: single-call and multi-call. Single-call mode
|
||||
* encodes the whole integer at once; it is an error if the output buffer is
|
||||
* too small. Multi-call mode saves the position in *vli_pos, and thus it is
|
||||
* possible to continue encoding if the buffer becomes full before the whole
|
||||
* integer has been encoded.
|
||||
*
|
||||
* \param vli Integer to be encoded
|
||||
* \param vli_pos How many VLI-encoded bytes have already been written
|
||||
* out. When starting to encode a new integer in
|
||||
* multi-call mode, *vli_pos must be set to zero.
|
||||
* To use single-call encoding, set vli_pos to NULL.
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return Slightly different return values are used in multi-call and
|
||||
* single-call modes.
|
||||
*
|
||||
* Single-call (vli_pos == NULL):
|
||||
* - LZMA_OK: Integer successfully encoded.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane. This can be due
|
||||
* to too little output space; single-call mode doesn't use
|
||||
* LZMA_BUF_ERROR, since the application should have checked
|
||||
* the encoded size with lzma_vli_size().
|
||||
*
|
||||
* Multi-call (vli_pos != NULL):
|
||||
* - LZMA_OK: So far all OK, but the integer is not
|
||||
* completely written out yet.
|
||||
* - LZMA_STREAM_END: Integer successfully encoded.
|
||||
* - LZMA_BUF_ERROR: No output space was provided.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode a variable-length integer
|
||||
*
|
||||
* Like lzma_vli_encode(), this function has single-call and multi-call modes.
|
||||
*
|
||||
* \param vli Pointer to decoded integer. The decoder will
|
||||
* initialize it to zero when *vli_pos == 0, so
|
||||
* application isn't required to initialize *vli.
|
||||
* \param vli_pos How many bytes have already been decoded. When
|
||||
* starting to decode a new integer in multi-call
|
||||
* mode, *vli_pos must be initialized to zero. To
|
||||
* use single-call decoding, set vli_pos to NULL.
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
*
|
||||
* \return Slightly different return values are used in multi-call and
|
||||
* single-call modes.
|
||||
*
|
||||
* Single-call (vli_pos == NULL):
|
||||
* - LZMA_OK: Integer successfully decoded.
|
||||
* - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
|
||||
* the end of the input buffer before the whole integer was
|
||||
* decoded; providing no input at all will use LZMA_DATA_ERROR.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*
|
||||
* Multi-call (vli_pos != NULL):
|
||||
* - LZMA_OK: So far all OK, but the integer is not
|
||||
* completely decoded yet.
|
||||
* - LZMA_STREAM_END: Integer successfully decoded.
|
||||
* - LZMA_DATA_ERROR: Integer is corrupt.
|
||||
* - LZMA_BUF_ERROR: No input was provided.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of bytes required to encode a VLI
|
||||
*
|
||||
* \return Number of bytes on success (1-9). If vli isn't valid,
|
||||
* zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
51
deps/lzma/liblzma/check/Makefile.inc
vendored
Normal file
51
deps/lzma/liblzma/check/Makefile.inc
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
##
|
||||
## Author: Lasse Collin
|
||||
##
|
||||
## This file has been put into the public domain.
|
||||
## You can do whatever you want with this file.
|
||||
##
|
||||
|
||||
EXTRA_DIST += \
|
||||
check/crc32_tablegen.c \
|
||||
check/crc64_tablegen.c
|
||||
|
||||
liblzma_la_SOURCES += \
|
||||
check/check.c \
|
||||
check/check.h \
|
||||
check/crc_macros.h
|
||||
|
||||
if COND_CHECK_CRC32
|
||||
if COND_SMALL
|
||||
liblzma_la_SOURCES += check/crc32_small.c
|
||||
else
|
||||
liblzma_la_SOURCES += \
|
||||
check/crc32_table.c \
|
||||
check/crc32_table_le.h \
|
||||
check/crc32_table_be.h
|
||||
if COND_ASM_X86
|
||||
liblzma_la_SOURCES += check/crc32_x86.S
|
||||
else
|
||||
liblzma_la_SOURCES += check/crc32_fast.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if COND_CHECK_CRC64
|
||||
if COND_SMALL
|
||||
liblzma_la_SOURCES += check/crc64_small.c
|
||||
else
|
||||
liblzma_la_SOURCES += \
|
||||
check/crc64_table.c \
|
||||
check/crc64_table_le.h \
|
||||
check/crc64_table_be.h
|
||||
if COND_ASM_X86
|
||||
liblzma_la_SOURCES += check/crc64_x86.S
|
||||
else
|
||||
liblzma_la_SOURCES += check/crc64_fast.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if COND_CHECK_SHA256
|
||||
liblzma_la_SOURCES += check/sha256.c
|
||||
endif
|
||||
174
deps/lzma/liblzma/check/check.c
vendored
Normal file
174
deps/lzma/liblzma/check/check.c
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file check.c
|
||||
/// \brief Single API to access different integrity checks
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "check.h"
|
||||
|
||||
|
||||
extern LZMA_API(lzma_bool)
|
||||
lzma_check_is_supported(lzma_check type)
|
||||
{
|
||||
if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
|
||||
return false;
|
||||
|
||||
static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {
|
||||
true, // LZMA_CHECK_NONE
|
||||
|
||||
#ifdef HAVE_CHECK_CRC32
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
|
||||
#ifdef HAVE_CHECK_CRC64
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
|
||||
#ifdef HAVE_CHECK_SHA256
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
false, // Reserved
|
||||
};
|
||||
|
||||
return available_checks[(unsigned int)(type)];
|
||||
}
|
||||
|
||||
|
||||
extern LZMA_API(uint32_t)
|
||||
lzma_check_size(lzma_check type)
|
||||
{
|
||||
if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
|
||||
return UINT32_MAX;
|
||||
|
||||
// See file-format.txt section 2.1.1.2.
|
||||
static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {
|
||||
0,
|
||||
4, 4, 4,
|
||||
8, 8, 8,
|
||||
16, 16, 16,
|
||||
32, 32, 32,
|
||||
64, 64, 64
|
||||
};
|
||||
|
||||
return check_sizes[(unsigned int)(type)];
|
||||
}
|
||||
|
||||
|
||||
extern void
|
||||
lzma_check_init(lzma_check_state *check, lzma_check type)
|
||||
{
|
||||
switch (type) {
|
||||
case LZMA_CHECK_NONE:
|
||||
break;
|
||||
|
||||
#ifdef HAVE_CHECK_CRC32
|
||||
case LZMA_CHECK_CRC32:
|
||||
check->state.crc32 = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_CRC64
|
||||
case LZMA_CHECK_CRC64:
|
||||
check->state.crc64 = 0;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_SHA256
|
||||
case LZMA_CHECK_SHA256:
|
||||
lzma_sha256_init(check);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
extern void
|
||||
lzma_check_update(lzma_check_state *check, lzma_check type,
|
||||
const uint8_t *buf, size_t size)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef HAVE_CHECK_CRC32
|
||||
case LZMA_CHECK_CRC32:
|
||||
check->state.crc32 = lzma_crc32(buf, size, check->state.crc32);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_CRC64
|
||||
case LZMA_CHECK_CRC64:
|
||||
check->state.crc64 = lzma_crc64(buf, size, check->state.crc64);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_SHA256
|
||||
case LZMA_CHECK_SHA256:
|
||||
lzma_sha256_update(buf, size, check);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
extern void
|
||||
lzma_check_finish(lzma_check_state *check, lzma_check type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef HAVE_CHECK_CRC32
|
||||
case LZMA_CHECK_CRC32:
|
||||
check->buffer.u32[0] = conv32le(check->state.crc32);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_CRC64
|
||||
case LZMA_CHECK_CRC64:
|
||||
check->buffer.u64[0] = conv64le(check->state.crc64);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHECK_SHA256
|
||||
case LZMA_CHECK_SHA256:
|
||||
lzma_sha256_finish(check);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
95
deps/lzma/liblzma/check/check.h
vendored
Normal file
95
deps/lzma/liblzma/check/check.h
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file check.h
|
||||
/// \brief Internal API to different integrity check functions
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LZMA_CHECK_H
|
||||
#define LZMA_CHECK_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
// Index hashing needs the best possible hash function (preferably
|
||||
// a cryptographic hash) for maximum reliability.
|
||||
#if defined(HAVE_CHECK_SHA256)
|
||||
# define LZMA_CHECK_BEST LZMA_CHECK_SHA256
|
||||
#elif defined(HAVE_CHECK_CRC64)
|
||||
# define LZMA_CHECK_BEST LZMA_CHECK_CRC64
|
||||
#else
|
||||
# define LZMA_CHECK_BEST LZMA_CHECK_CRC32
|
||||
#endif
|
||||
|
||||
|
||||
/// \brief Structure to hold internal state of the check being calculated
|
||||
///
|
||||
/// \note This is not in the public API because this structure may
|
||||
/// change in future if new integrity check algorithms are added.
|
||||
typedef struct {
|
||||
/// Buffer to hold the final result and a temporary buffer for SHA256.
|
||||
union {
|
||||
uint8_t u8[64];
|
||||
uint32_t u32[16];
|
||||
uint64_t u64[8];
|
||||
} buffer;
|
||||
|
||||
/// Check-specific data
|
||||
union {
|
||||
uint32_t crc32;
|
||||
uint64_t crc64;
|
||||
|
||||
struct {
|
||||
/// Internal state
|
||||
uint32_t state[8];
|
||||
|
||||
/// Size of the message excluding padding
|
||||
uint64_t size;
|
||||
} sha256;
|
||||
} state;
|
||||
|
||||
} lzma_check_state;
|
||||
|
||||
|
||||
/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep
|
||||
/// the array two-dimensional.
|
||||
#ifdef HAVE_SMALL
|
||||
extern uint32_t lzma_crc32_table[1][256];
|
||||
extern void lzma_crc32_init(void);
|
||||
#else
|
||||
extern const uint32_t lzma_crc32_table[8][256];
|
||||
extern const uint64_t lzma_crc64_table[4][256];
|
||||
#endif
|
||||
|
||||
|
||||
/// \brief Initialize *check depending on type
|
||||
///
|
||||
/// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not
|
||||
/// supported by the current version or build of liblzma.
|
||||
/// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX.
|
||||
extern void lzma_check_init(lzma_check_state *check, lzma_check type);
|
||||
|
||||
/// Update the check state
|
||||
extern void lzma_check_update(lzma_check_state *check, lzma_check type,
|
||||
const uint8_t *buf, size_t size);
|
||||
|
||||
/// Finish the check calculation and store the result to check->buffer.u8.
|
||||
extern void lzma_check_finish(lzma_check_state *check, lzma_check type);
|
||||
|
||||
|
||||
/// Prepare SHA-256 state for new input.
|
||||
extern void lzma_sha256_init(lzma_check_state *check);
|
||||
|
||||
/// Update the SHA-256 hash state
|
||||
extern void lzma_sha256_update(
|
||||
const uint8_t *buf, size_t size, lzma_check_state *check);
|
||||
|
||||
/// Finish the SHA-256 calculation and store the result to check->buffer.u8.
|
||||
extern void lzma_sha256_finish(lzma_check_state *check);
|
||||
|
||||
#endif
|
||||
82
deps/lzma/liblzma/check/crc32_fast.c
vendored
Normal file
82
deps/lzma/liblzma/check/crc32_fast.c
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file crc32.c
|
||||
/// \brief CRC32 calculation
|
||||
///
|
||||
/// Calculate the CRC32 using the slice-by-eight algorithm.
|
||||
/// It is explained in this document:
|
||||
/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf
|
||||
/// The code in this file is not the same as in Intel's paper, but
|
||||
/// the basic principle is identical.
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "check.h"
|
||||
#include "crc_macros.h"
|
||||
|
||||
|
||||
// If you make any changes, do some benchmarking! Seemingly unrelated
|
||||
// changes can very easily ruin the performance (and very probably is
|
||||
// very compiler dependent).
|
||||
extern LZMA_API(uint32_t)
|
||||
lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
{
|
||||
crc = ~crc;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
crc = bswap32(crc);
|
||||
#endif
|
||||
|
||||
if (size > 8) {
|
||||
// Fix the alignment, if needed. The if statement above
|
||||
// ensures that this won't read past the end of buf[].
|
||||
while ((uintptr_t)(buf) & 7) {
|
||||
crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
|
||||
--size;
|
||||
}
|
||||
|
||||
// Calculate the position where to stop.
|
||||
const uint8_t *const limit = buf + (size & ~(size_t)(7));
|
||||
|
||||
// Calculate how many bytes must be calculated separately
|
||||
// before returning the result.
|
||||
size &= (size_t)(7);
|
||||
|
||||
// Calculate the CRC32 using the slice-by-eight algorithm.
|
||||
while (buf < limit) {
|
||||
crc ^= *(const uint32_t *)(buf);
|
||||
buf += 4;
|
||||
|
||||
crc = lzma_crc32_table[7][A(crc)]
|
||||
^ lzma_crc32_table[6][B(crc)]
|
||||
^ lzma_crc32_table[5][C(crc)]
|
||||
^ lzma_crc32_table[4][D(crc)];
|
||||
|
||||
const uint32_t tmp = *(const uint32_t *)(buf);
|
||||
buf += 4;
|
||||
|
||||
// At least with some compilers, it is critical for
|
||||
// performance, that the crc variable is XORed
|
||||
// between the two table-lookup pairs.
|
||||
crc = lzma_crc32_table[3][A(tmp)]
|
||||
^ lzma_crc32_table[2][B(tmp)]
|
||||
^ crc
|
||||
^ lzma_crc32_table[1][C(tmp)]
|
||||
^ lzma_crc32_table[0][D(tmp)];
|
||||
}
|
||||
}
|
||||
|
||||
while (size-- != 0)
|
||||
crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
crc = bswap32(crc);
|
||||
#endif
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
61
deps/lzma/liblzma/check/crc32_small.c
vendored
Normal file
61
deps/lzma/liblzma/check/crc32_small.c
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file crc32_small.c
|
||||
/// \brief CRC32 calculation (size-optimized)
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "check.h"
|
||||
|
||||
|
||||
uint32_t lzma_crc32_table[1][256];
|
||||
|
||||
|
||||
static void
|
||||
crc32_init(void)
|
||||
{
|
||||
static const uint32_t poly32 = UINT32_C(0xEDB88320);
|
||||
|
||||
for (size_t b = 0; b < 256; ++b) {
|
||||
uint32_t r = b;
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
if (r & 1)
|
||||
r = (r >> 1) ^ poly32;
|
||||
else
|
||||
r >>= 1;
|
||||
}
|
||||
|
||||
lzma_crc32_table[0][b] = r;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
extern void
|
||||
lzma_crc32_init(void)
|
||||
{
|
||||
mythread_once(crc32_init);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
extern LZMA_API(uint32_t)
|
||||
lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
{
|
||||
lzma_crc32_init();
|
||||
|
||||
crc = ~crc;
|
||||
|
||||
while (size != 0) {
|
||||
crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
||||
--size;
|
||||
}
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
19
deps/lzma/liblzma/check/crc32_table.c
vendored
Normal file
19
deps/lzma/liblzma/check/crc32_table.c
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file crc32_table.c
|
||||
/// \brief Precalculated CRC32 table with correct endianness
|
||||
//
|
||||
// Author: Lasse Collin
|
||||
//
|
||||
// This file has been put into the public domain.
|
||||
// You can do whatever you want with this file.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# include "crc32_table_be.h"
|
||||
#else
|
||||
# include "crc32_table_le.h"
|
||||
#endif
|
||||
525
deps/lzma/liblzma/check/crc32_table_be.h
vendored
Normal file
525
deps/lzma/liblzma/check/crc32_table_be.h
vendored
Normal file
|
|
@ -0,0 +1,525 @@
|
|||
/* This file has been automatically generated by crc32_tablegen.c. */
|
||||
|
||||
const uint32_t lzma_crc32_table[8][256] = {
|
||||
{
|
||||
0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,
|
||||
0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,
|
||||
0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297,
|
||||
0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90,
|
||||
0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84,
|
||||
0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383,
|
||||
0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A,
|
||||
0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D,
|
||||
0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2,
|
||||
0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5,
|
||||
0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC,
|
||||
0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB,
|
||||
0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF,
|
||||
0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8,
|
||||
0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1,
|
||||
0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6,
|
||||
0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF,
|
||||
0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8,
|
||||
0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1,
|
||||
0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6,
|
||||
0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2,
|
||||
0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5,
|
||||
0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC,
|
||||
0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB,
|
||||
0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4,
|
||||
0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3,
|
||||
0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA,
|
||||
0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD,
|
||||
0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9,
|
||||
0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE,
|
||||
0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7,
|
||||
0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0,
|
||||
0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174,
|
||||
0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73,
|
||||
0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A,
|
||||
0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D,
|
||||
0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669,
|
||||
0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E,
|
||||
0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67,
|
||||
0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060,
|
||||
0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F,
|
||||
0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248,
|
||||
0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441,
|
||||
0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946,
|
||||
0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852,
|
||||
0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555,
|
||||
0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C,
|
||||
0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B,
|
||||
0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02,
|
||||
0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005,
|
||||
0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C,
|
||||
0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B,
|
||||
0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F,
|
||||
0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718,
|
||||
0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111,
|
||||
0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16,
|
||||
0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339,
|
||||
0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E,
|
||||
0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837,
|
||||
0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530,
|
||||
0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424,
|
||||
0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923,
|
||||
0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A,
|
||||
0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D
|
||||
}, {
|
||||
0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B,
|
||||
0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F,
|
||||
0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3,
|
||||
0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887,
|
||||
0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61,
|
||||
0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305,
|
||||
0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9,
|
||||
0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD,
|
||||
0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE,
|
||||
0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA,
|
||||
0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076,
|
||||
0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12,
|
||||
0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4,
|
||||
0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790,
|
||||
0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C,
|
||||
0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58,
|
||||
0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB,
|
||||
0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF,
|
||||
0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13,
|
||||
0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177,
|
||||
0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691,
|
||||
0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5,
|
||||
0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59,
|
||||
0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D,
|
||||
0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E,
|
||||
0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A,
|
||||
0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986,
|
||||
0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2,
|
||||
0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204,
|
||||
0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60,
|
||||
0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC,
|
||||
0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8,
|
||||
0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10,
|
||||
0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274,
|
||||
0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8,
|
||||
0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC,
|
||||
0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A,
|
||||
0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E,
|
||||
0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592,
|
||||
0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6,
|
||||
0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85,
|
||||
0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1,
|
||||
0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D,
|
||||
0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29,
|
||||
0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF,
|
||||
0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB,
|
||||
0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107,
|
||||
0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63,
|
||||
0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0,
|
||||
0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84,
|
||||
0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28,
|
||||
0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C,
|
||||
0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA,
|
||||
0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE,
|
||||
0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62,
|
||||
0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006,
|
||||
0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375,
|
||||
0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11,
|
||||
0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD,
|
||||
0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9,
|
||||
0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F,
|
||||
0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B,
|
||||
0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7,
|
||||
0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493
|
||||
}, {
|
||||
0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602,
|
||||
0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05,
|
||||
0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C,
|
||||
0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B,
|
||||
0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E,
|
||||
0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919,
|
||||
0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310,
|
||||
0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17,
|
||||
0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A,
|
||||
0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D,
|
||||
0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834,
|
||||
0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133,
|
||||
0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26,
|
||||
0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421,
|
||||
0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28,
|
||||
0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F,
|
||||
0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72,
|
||||
0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575,
|
||||
0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C,
|
||||
0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B,
|
||||
0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E,
|
||||
0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369,
|
||||
0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960,
|
||||
0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067,
|
||||
0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A,
|
||||
0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D,
|
||||
0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244,
|
||||
0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43,
|
||||
0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756,
|
||||
0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51,
|
||||
0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458,
|
||||
0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F,
|
||||
0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3,
|
||||
0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4,
|
||||
0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED,
|
||||
0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA,
|
||||
0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF,
|
||||
0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8,
|
||||
0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1,
|
||||
0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6,
|
||||
0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB,
|
||||
0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC,
|
||||
0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5,
|
||||
0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2,
|
||||
0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7,
|
||||
0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0,
|
||||
0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9,
|
||||
0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE,
|
||||
0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993,
|
||||
0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094,
|
||||
0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D,
|
||||
0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A,
|
||||
0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F,
|
||||
0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688,
|
||||
0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81,
|
||||
0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586,
|
||||
0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB,
|
||||
0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC,
|
||||
0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5,
|
||||
0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2,
|
||||
0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7,
|
||||
0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0,
|
||||
0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9,
|
||||
0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE
|
||||
}, {
|
||||
0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512,
|
||||
0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D,
|
||||
0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7,
|
||||
0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358,
|
||||
0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42,
|
||||
0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD,
|
||||
0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887,
|
||||
0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08,
|
||||
0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2,
|
||||
0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D,
|
||||
0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377,
|
||||
0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8,
|
||||
0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2,
|
||||
0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D,
|
||||
0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27,
|
||||
0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8,
|
||||
0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189,
|
||||
0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306,
|
||||
0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C,
|
||||
0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3,
|
||||
0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9,
|
||||
0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56,
|
||||
0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C,
|
||||
0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93,
|
||||
0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329,
|
||||
0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6,
|
||||
0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC,
|
||||
0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563,
|
||||
0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79,
|
||||
0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6,
|
||||
0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC,
|
||||
0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33,
|
||||
0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF,
|
||||
0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70,
|
||||
0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A,
|
||||
0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5,
|
||||
0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF,
|
||||
0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720,
|
||||
0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A,
|
||||
0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5,
|
||||
0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F,
|
||||
0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0,
|
||||
0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A,
|
||||
0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815,
|
||||
0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F,
|
||||
0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580,
|
||||
0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA,
|
||||
0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145,
|
||||
0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864,
|
||||
0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB,
|
||||
0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1,
|
||||
0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E,
|
||||
0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134,
|
||||
0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB,
|
||||
0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1,
|
||||
0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E,
|
||||
0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4,
|
||||
0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B,
|
||||
0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01,
|
||||
0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E,
|
||||
0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394,
|
||||
0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B,
|
||||
0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751,
|
||||
0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE
|
||||
}, {
|
||||
0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047,
|
||||
0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2,
|
||||
0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077,
|
||||
0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082,
|
||||
0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027,
|
||||
0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2,
|
||||
0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017,
|
||||
0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2,
|
||||
0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186,
|
||||
0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173,
|
||||
0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6,
|
||||
0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143,
|
||||
0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6,
|
||||
0x461EA154, 0xF637C169, 0x264D612E, 0x96640113,
|
||||
0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6,
|
||||
0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123,
|
||||
0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F,
|
||||
0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA,
|
||||
0x88138368, 0x383AE355, 0xE8404312, 0x5869232F,
|
||||
0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA,
|
||||
0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F,
|
||||
0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A,
|
||||
0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F,
|
||||
0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA,
|
||||
0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE,
|
||||
0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B,
|
||||
0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE,
|
||||
0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B,
|
||||
0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE,
|
||||
0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B,
|
||||
0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E,
|
||||
0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B,
|
||||
0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6,
|
||||
0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603,
|
||||
0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6,
|
||||
0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633,
|
||||
0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696,
|
||||
0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663,
|
||||
0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6,
|
||||
0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653,
|
||||
0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737,
|
||||
0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2,
|
||||
0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707,
|
||||
0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2,
|
||||
0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757,
|
||||
0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2,
|
||||
0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767,
|
||||
0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792,
|
||||
0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE,
|
||||
0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B,
|
||||
0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E,
|
||||
0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B,
|
||||
0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE,
|
||||
0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B,
|
||||
0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE,
|
||||
0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B,
|
||||
0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F,
|
||||
0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A,
|
||||
0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F,
|
||||
0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA,
|
||||
0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F,
|
||||
0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA,
|
||||
0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F,
|
||||
0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA
|
||||
}, {
|
||||
0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486,
|
||||
0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D,
|
||||
0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A,
|
||||
0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1,
|
||||
0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285,
|
||||
0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E,
|
||||
0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169,
|
||||
0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2,
|
||||
0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881,
|
||||
0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A,
|
||||
0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D,
|
||||
0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6,
|
||||
0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82,
|
||||
0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19,
|
||||
0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E,
|
||||
0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5,
|
||||
0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89,
|
||||
0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12,
|
||||
0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65,
|
||||
0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE,
|
||||
0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A,
|
||||
0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11,
|
||||
0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966,
|
||||
0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD,
|
||||
0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E,
|
||||
0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115,
|
||||
0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362,
|
||||
0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9,
|
||||
0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D,
|
||||
0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716,
|
||||
0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561,
|
||||
0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA,
|
||||
0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498,
|
||||
0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503,
|
||||
0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774,
|
||||
0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF,
|
||||
0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B,
|
||||
0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300,
|
||||
0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177,
|
||||
0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC,
|
||||
0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F,
|
||||
0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904,
|
||||
0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73,
|
||||
0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8,
|
||||
0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C,
|
||||
0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07,
|
||||
0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70,
|
||||
0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB,
|
||||
0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97,
|
||||
0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C,
|
||||
0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B,
|
||||
0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0,
|
||||
0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94,
|
||||
0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F,
|
||||
0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978,
|
||||
0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3,
|
||||
0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090,
|
||||
0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B,
|
||||
0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C,
|
||||
0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7,
|
||||
0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693,
|
||||
0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708,
|
||||
0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F,
|
||||
0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4
|
||||
}, {
|
||||
0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831,
|
||||
0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5,
|
||||
0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702,
|
||||
0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6,
|
||||
0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656,
|
||||
0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2,
|
||||
0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965,
|
||||
0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691,
|
||||
0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE,
|
||||
0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A,
|
||||
0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD,
|
||||
0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539,
|
||||
0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99,
|
||||
0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D,
|
||||
0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA,
|
||||
0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E,
|
||||
0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375,
|
||||
0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81,
|
||||
0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46,
|
||||
0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2,
|
||||
0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12,
|
||||
0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6,
|
||||
0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221,
|
||||
0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5,
|
||||
0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA,
|
||||
0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E,
|
||||
0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189,
|
||||
0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D,
|
||||
0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD,
|
||||
0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29,
|
||||
0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE,
|
||||
0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A,
|
||||
0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9,
|
||||
0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D,
|
||||
0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A,
|
||||
0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E,
|
||||
0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE,
|
||||
0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A,
|
||||
0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED,
|
||||
0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019,
|
||||
0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376,
|
||||
0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82,
|
||||
0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45,
|
||||
0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1,
|
||||
0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11,
|
||||
0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5,
|
||||
0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222,
|
||||
0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6,
|
||||
0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD,
|
||||
0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09,
|
||||
0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE,
|
||||
0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A,
|
||||
0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A,
|
||||
0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E,
|
||||
0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9,
|
||||
0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D,
|
||||
0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832,
|
||||
0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6,
|
||||
0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701,
|
||||
0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5,
|
||||
0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655,
|
||||
0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1,
|
||||
0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966,
|
||||
0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692
|
||||
}, {
|
||||
0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E,
|
||||
0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A,
|
||||
0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D,
|
||||
0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9,
|
||||
0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2,
|
||||
0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76,
|
||||
0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121,
|
||||
0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5,
|
||||
0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977,
|
||||
0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3,
|
||||
0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4,
|
||||
0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620,
|
||||
0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B,
|
||||
0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F,
|
||||
0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8,
|
||||
0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C,
|
||||
0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7,
|
||||
0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823,
|
||||
0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774,
|
||||
0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0,
|
||||
0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB,
|
||||
0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F,
|
||||
0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08,
|
||||
0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C,
|
||||
0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E,
|
||||
0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA,
|
||||
0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D,
|
||||
0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09,
|
||||
0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22,
|
||||
0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6,
|
||||
0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1,
|
||||
0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075,
|
||||
0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD,
|
||||
0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59,
|
||||
0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E,
|
||||
0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A,
|
||||
0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1,
|
||||
0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525,
|
||||
0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72,
|
||||
0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6,
|
||||
0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224,
|
||||
0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0,
|
||||
0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7,
|
||||
0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73,
|
||||
0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958,
|
||||
0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC,
|
||||
0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B,
|
||||
0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F,
|
||||
0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4,
|
||||
0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370,
|
||||
0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27,
|
||||
0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3,
|
||||
0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288,
|
||||
0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C,
|
||||
0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B,
|
||||
0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF,
|
||||
0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D,
|
||||
0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589,
|
||||
0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE,
|
||||
0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A,
|
||||
0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471,
|
||||
0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5,
|
||||
0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2,
|
||||
0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue