diff --git a/patches/aribb24/12.patch b/patches/aribb24/12.patch new file mode 100644 index 0000000..c55bf23 --- /dev/null +++ b/patches/aribb24/12.patch @@ -0,0 +1,31 @@ +From a5bcc6d17c20e18bdeec295089cc0cdfac9d35c8 Mon Sep 17 00:00:00 2001 +From: xtne6f +Date: Thu, 7 Feb 2019 20:11:13 +0900 +Subject: [PATCH] Fix default macros + +--- + src/decoder_macro.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/decoder_macro.h b/src/decoder_macro.h +index 86edee4..513b81e 100644 +--- a/src/decoder_macro.h ++++ b/src/decoder_macro.h +@@ -30,7 +30,7 @@ static const unsigned char decoder_default_macro_1[] = { + 0x1B,0x24,0x39,0x1B,0x29,0x31,0x1B,0x2A,0x30,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D + }; + static const unsigned char decoder_default_macro_2[] = { +- 0x1B,0x24,0x39,0x1B,0x29,0x20,0x40,0x1B,0x2A,0x30,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D ++ 0x1B,0x24,0x39,0x1B,0x29,0x20,0x41,0x1B,0x2A,0x30,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D + }; + static const unsigned char decoder_default_macro_3[] = { + 0x1B,0x28,0x32,0x1B,0x29,0x34,0x1B,0x2A,0x35,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D +@@ -39,7 +39,7 @@ static const unsigned char decoder_default_macro_4[] = { + 0x1B,0x28,0x32,0x1B,0x29,0x33,0x1B,0x2A,0x35,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D + }; + static const unsigned char decoder_default_macro_5[] = { +- 0x1B,0x28,0x32,0x1B,0x29,0x20,0x40,0x1B,0x2A,0x35,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D ++ 0x1B,0x28,0x32,0x1B,0x29,0x20,0x41,0x1B,0x2A,0x35,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D + }; + static const unsigned char decoder_default_macro_6[] = { + 0x1B,0x28,0x20,0x41,0x1B,0x29,0x20,0x42,0x1B,0x2A,0x20,0x43,0x1B,0x2B,0x20,0x70,0x0F,0x1B,0x7D diff --git a/patches/aribb24/13.patch b/patches/aribb24/13.patch new file mode 100644 index 0000000..30d17ba --- /dev/null +++ b/patches/aribb24/13.patch @@ -0,0 +1,23 @@ +From facc51923d43f26dec09a9391566de7cba29f8db Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= +Date: Sun, 17 Feb 2019 22:42:31 +0200 +Subject: [PATCH] decoder: reset control_time when finalizing decoder + +This way finalize_decoder() can properly be utilized as a flush +function. +--- + src/decoder.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/decoder.c b/src/decoder.c +index 2b77f38..24c0f06 100644 +--- a/src/decoder.c ++++ b/src/decoder.c +@@ -1506,6 +1506,7 @@ void arib_finalize_decoder( arib_decoder_t* decoder ) + free( p_region ); + } + decoder->p_region = NULL; ++ decoder->i_control_time = 0; + } + + size_t arib_decode_buffer( arib_decoder_t* decoder, diff --git a/patches/aribb24/17.patch b/patches/aribb24/17.patch new file mode 100644 index 0000000..5961b2e --- /dev/null +++ b/patches/aribb24/17.patch @@ -0,0 +1,151 @@ +From 58a34b8fabf4d0e9e1984fb603a97f52fb934a09 Mon Sep 17 00:00:00 2001 +From: scimmia9286 +Date: Thu, 22 Apr 2021 20:26:45 +0900 +Subject: [PATCH] Fixed DRCS parser bug + +--- + src/decoder.c | 3 ++- + src/drcs.c | 12 ++++++++---- + src/drcs.h | 2 +- + src/parser.c | 25 +++++++++++++++++++++---- + 4 files changed, 32 insertions(+), 10 deletions(-) + +diff --git a/src/decoder.c b/src/decoder.c +index 2b77f38..c9d6ac3 100644 +--- a/src/decoder.c ++++ b/src/decoder.c +@@ -1139,9 +1139,10 @@ static int decoder_handle_time( arib_decoder_t *decoder ) + return 1; + break; + default: +- if( i_mode == 1 && c >= 0x40 && c <= 0x7F ) ++ if( i_mode == 1 && c >= 0x40 && c <= 0x7F ) { + decoder->i_control_time += c & 0x3f; + return 1; ++ } + return 0; + } + if( i_mode == 0 ) +diff --git a/src/drcs.c b/src/drcs.c +index 114d846..8ff8d4f 100644 +--- a/src/drcs.c ++++ b/src/drcs.c +@@ -406,15 +406,19 @@ static void save_drcs_pattern_data_image( + void save_drcs_pattern( + arib_instance_t *p_instance, + int i_width, int i_height, +- int i_depth, const int8_t* p_patternData ) ++ int i_depth, const int8_t* p_patternData, ++ int16_t i_CharacterCode ) + { ++// int i_drcsPage = (i_CharacterCode >> 16) & 0xff; ++ int i_code = (i_CharacterCode & 0xff) - 0x20; + char* psz_hash = get_drcs_pattern_data_hash( p_instance, + i_width, i_height, i_depth, p_patternData ); + +- strncpy( p_instance->p->drcs_hash_table[p_instance->p->i_drcs_num], psz_hash, 32 ); +- p_instance->p->drcs_hash_table[p_instance->p->i_drcs_num][32] = '\0'; ++ strncpy( p_instance->p->drcs_hash_table[i_code-1], psz_hash, 32 ); ++ p_instance->p->drcs_hash_table[i_code-1][32] = '\0'; + +- p_instance->p->i_drcs_num++; ++ p_instance->p->i_drcs_num = i_code > p_instance->p->i_drcs_num ? ++ i_code : p_instance->p->i_drcs_num; + + save_drcs_pattern_data_image( p_instance, psz_hash, + i_width, i_height, i_depth, p_patternData ); +diff --git a/src/drcs.h b/src/drcs.h +index 274ff44..9c1533e 100644 +--- a/src/drcs.h ++++ b/src/drcs.h +@@ -77,6 +77,6 @@ typedef struct drcs_data_s + + bool apply_drcs_conversion_table( arib_instance_t * ); + bool load_drcs_conversion_table( arib_instance_t * ); +-void save_drcs_pattern( arib_instance_t *, int, int, int, const int8_t* ); ++void save_drcs_pattern( arib_instance_t *, int, int, int, const int8_t*, int16_t ); + + #endif +diff --git a/src/parser.c b/src/parser.c +index 1403dd6..6db27ae 100644 +--- a/src/parser.c ++++ b/src/parser.c +@@ -79,7 +79,6 @@ static void parse_data_unit_DRCS( arib_parser_t *p_parser, bs_t *p_bs, + uint8_t i_data_unit_parameter, + uint32_t i_data_unit_size ) + { +- p_parser->p_instance->p->i_drcs_num = 0; + #ifdef ARIBSUB_GEN_DRCS_DATA + if( p_parser->p_drcs_data != NULL ) + { +@@ -119,7 +118,7 @@ static void parse_data_unit_DRCS( arib_parser_t *p_parser, bs_t *p_bs, + + for( int i = 0; i < i_NumberOfCode; i++ ) + { +- bs_skip( p_bs, 16 ); /* i_character_code */ ++ int16_t i_CharacterCode = bs_read( p_bs, 16 ); /* i_character_code */ + p_parser->i_data_unit_size += 2; + uint8_t i_NumberOfFont = bs_read( p_bs, 8 ); + p_parser->i_data_unit_size += 1; +@@ -139,7 +138,11 @@ static void parse_data_unit_DRCS( arib_parser_t *p_parser, bs_t *p_bs, + + for( int j = 0; j < i_NumberOfFont; j++ ) + { ++#ifdef ARIBSUB_GEN_DRCS_DATA ++ int8_t i_fontId = bs_read( p_bs, 4 ); /* i_fontID */ ++#else + bs_skip( p_bs, 4 ); /* i_fontID */ ++#endif //ARIBSUB_GEN_DRCS_DATA + uint8_t i_mode = bs_read( p_bs, 4 ); + p_parser->i_data_unit_size += 1; + +@@ -206,18 +209,26 @@ static void parse_data_unit_DRCS( arib_parser_t *p_parser, bs_t *p_bs, + + #ifdef ARIBSUB_GEN_DRCS_DATA + save_drcs_pattern( p_parser->p_instance, i_width, i_height, i_depth + 2, +- p_drcs_pattern_data->p_patternData ); ++ p_drcs_pattern_data->p_patternData, i_CharacterCode ); + #else + save_drcs_pattern( p_parser->p_instance, i_width, i_height, i_depth + 2, +- p_patternData ); ++ p_patternData, i_CharacterCode); + free( p_patternData ); + #endif //ARIBSUB_GEN_DRCS_DATA + } + else + { ++#ifdef ARIBSUB_GEN_DRCS_DATA ++ int8_t i_regionX = bs_read( p_bs, 8 ); /* i_regionX */ ++#else + bs_skip( p_bs, 8 ); /* i_regionX */ ++#endif //ARIBSUB_GEN_DRCS_DATA + p_parser->i_data_unit_size += 1; ++#ifdef ARIBSUB_GEN_DRCS_DATA ++ int8_t i_regionY = bs_read( p_bs, 8 ); /* i_regionY */ ++#else + bs_skip( p_bs, 8 ); /* i_regionY */ ++#endif //ARIBSUB_GEN_DRCS_DATA + p_parser->i_data_unit_size += 1; + uint16_t i_geometricData_length = bs_read( p_bs, 16 ); + p_parser->i_data_unit_size += 2; +@@ -245,7 +256,11 @@ static void parse_data_unit_DRCS( arib_parser_t *p_parser, bs_t *p_bs, + + for( int k = 0; k < i_geometricData_length ; k++ ) + { ++#ifdef ARIBSUB_GEN_DRCS_DATA ++ int8_t i_geometricData = bs_read( p_bs, 8 ); /* i_geometric_data */ ++#else + bs_skip( p_bs, 8 ); /* i_geometric_data */ ++#endif //ARIBSUB_GEN_DRCS_DATA + p_parser->i_data_unit_size += 1; + + #ifdef ARIBSUB_GEN_DRCS_DATA +@@ -344,6 +359,8 @@ static void parse_caption_management_data( arib_parser_t *p_parser, bs_t *p_bs ) + p_parser->i_data_unit_size = 0; + p_parser->i_subtitle_data_size = 0; + p_parser->psz_subtitle_data = NULL; ++ p_parser->p_instance->p->i_drcs_num = 0; ++ memset(p_parser->p_instance->p->drcs_hash_table, 0, sizeof(p_parser->p_instance->p->drcs_hash_table)); + if( i_data_unit_loop_length > 0 ) + { + p_parser->psz_subtitle_data = (unsigned char*) calloc( diff --git a/scripts.d/50-aribb24/25-libpng.sh b/scripts.d/50-aribb24/25-libpng.sh new file mode 100755 index 0000000..72e7b36 --- /dev/null +++ b/scripts.d/50-aribb24/25-libpng.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +LIBPNG_REPO="https://github.com/glennrp/libpng.git" +LIBPNG_COMMIT="a37d4836519517bdce6cb9d956092321eca3e73b" + +ffbuild_enabled() { + return 0 +} + +ffbuild_dockerbuild() { + git-mini-clone "$LIBPNG_REPO" "$LIBPNG_COMMIT" libpng + cd libpng + + autoreconf -i + + local myconf=( + --prefix="$FFBUILD_PREFIX" + --disable-shared + --enable-static + --with-pic + ) + + if [[ $TARGET == win* || $TARGET == linux* ]]; then + myconf+=( + --host="$FFBUILD_TOOLCHAIN" + ) + else + echo "Unknown target" + return -1 + fi + + export CPPFLAGS="$CPPFLAGS -I$FFBUILD_PREFIX/include" + + ./configure "${myconf[@]}" + make -j$(nproc) + make install +} diff --git a/scripts.d/50-aribb24/50-libaribb24.sh b/scripts.d/50-aribb24/50-libaribb24.sh new file mode 100755 index 0000000..9131ac4 --- /dev/null +++ b/scripts.d/50-aribb24/50-libaribb24.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +ARIBB24_REPO="https://github.com/nkoriyama/aribb24.git" +ARIBB24_COMMIT="5e9be272f96e00f15a2f3c5f8ba7e124862aec38" + +ffbuild_enabled() { + return 0 +} + +ffbuild_dockerstage() { + to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/aribb24,dst=/patches run_stage /stage.sh" +} + +ffbuild_dockerbuild() { + git-mini-clone "$ARIBB24_REPO" "$ARIBB24_COMMIT" aribb24 + cd aribb24 + + for patch in /patches/*.patch; do + echo "Applying $patch" + git am < "$patch" + done + + # Library switched to LGPL on master, but didn't bump version since. + # FFmpeg checks for >1.0.3 to allow LGPL builds. + sed -i 's/1.0.3/1.0.4/' configure.ac + + autoreconf -i + + local myconf=( + --prefix="$FFBUILD_PREFIX" + --disable-shared + --enable-static + --with-pic + ) + + if [[ $TARGET == win* || $TARGET == linux* ]]; then + myconf+=( + --host="$FFBUILD_TOOLCHAIN" + ) + else + echo "Unknown target" + return -1 + fi + + ./configure "${myconf[@]}" + make -j$(nproc) + make install +} + +ffbuild_configure() { + echo --enable-libaribb24 +} + +ffbuild_unconfigure() { + echo --disable-libaribb24 +}