kumquat-buildroot/package/bento4/0004-more-SPS-parameters.patch
Bernd Kuhls 6dbb40955f package/bento4: new package
Needed for the upcoming Nexus version of kodi-inputstream-adaptive,
the bundled version of bento4 was removed upstream:
70625e7670

Backported upstream commit to fix cmake install as patch 0001.

Added feature- and bugfix-patches from kodi, they were sent upstream:
https://github.com/axiomatic-systems/Bento4/issues/648

Build-tested using this defconfig:

BR2_PACKAGE_BENTO4=y

                             andes-nds32 [ 1/45]: SKIPPED
                             arm-aarch64 [ 2/45]: OK
                   bootlin-aarch64-glibc [ 3/45]: OK
               bootlin-arcle-hs38-uclibc [ 4/45]: OK
                    bootlin-armv5-uclibc [ 5/45]: OK
                     bootlin-armv7-glibc [ 6/45]: OK
                   bootlin-armv7m-uclibc [ 7/45]: OK
                      bootlin-armv7-musl [ 8/45]: OK
                bootlin-m68k-5208-uclibc [ 9/45]: OK
               bootlin-m68k-68040-uclibc [10/45]: OK
             bootlin-microblazeel-uclibc [11/45]: OK
                bootlin-mipsel32r6-glibc [12/45]: OK
                   bootlin-mipsel-uclibc [13/45]: OK
                     bootlin-nios2-glibc [14/45]: OK
                 bootlin-openrisc-uclibc [15/45]: OK
        bootlin-powerpc64le-power8-glibc [16/45]: OK
           bootlin-powerpc-e500mc-uclibc [17/45]: OK
                   bootlin-riscv32-glibc [18/45]: OK
                   bootlin-riscv64-glibc [19/45]: OK
                    bootlin-riscv64-musl [20/45]: OK
                      bootlin-sh4-uclibc [21/45]: OK
                   bootlin-sparc64-glibc [22/45]: OK
                    bootlin-sparc-uclibc [23/45]: OK
                    bootlin-x86-64-glibc [24/45]: OK
                     bootlin-x86-64-musl [25/45]: OK
                   bootlin-x86-64-uclibc [26/45]: OK
                   bootlin-xtensa-uclibc [27/45]: OK
                            br-arm-basic [28/45]: SKIPPED
                    br-arm-full-nothread [29/45]: OK
                      br-arm-full-static [30/45]: OK
                   br-i386-pentium4-full [31/45]: OK
                br-i386-pentium-mmx-musl [32/45]: OK
                      br-mips64-n64-full [33/45]: OK
                 br-mips64r6-el-hf-glibc [34/45]: OK
               br-powerpc-603e-basic-cpp [35/45]: OK
               br-powerpc64-power7-glibc [36/45]: OK
                       linaro-aarch64-be [37/45]: OK
                          linaro-aarch64 [38/45]: OK
                              linaro-arm [39/45]: OK
                     sourcery-arm-armv4t [40/45]: OK
                            sourcery-arm [41/45]: OK
                     sourcery-arm-thumb2 [42/45]: OK
                         sourcery-mips64 [43/45]: OK
                           sourcery-mips [44/45]: OK
                          sourcery-nios2 [45/45]: OK
45 builds, 2 skipped, 0 build failed, 0 legal-info failed

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2021-12-27 11:32:00 +01:00

220 lines
7.4 KiB
Diff

From 25df596f009514b213c5eaf5d5eb94072391c1be Mon Sep 17 00:00:00 2001
From: peak3d <pfau@peak3d.de>
Date: Thu, 22 Jul 2021 10:22:39 +0200
Subject: [PATCH] more SPS parameters
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
---
Source/C++/Codecs/Ap4AvcParser.cpp | 100 ++++++++++++++++++++++++++++-
Source/C++/Codecs/Ap4AvcParser.h | 22 +++++++
Source/C++/Core/Ap4Utils.cpp | 8 +++
Source/C++/Core/Ap4Utils.h | 2 +-
4 files changed, 129 insertions(+), 3 deletions(-)
diff --git a/Source/C++/Codecs/Ap4AvcParser.cpp b/Source/C++/Codecs/Ap4AvcParser.cpp
index b95398b..7efb5c9 100644
--- a/Source/C++/Codecs/Ap4AvcParser.cpp
+++ b/Source/C++/Codecs/Ap4AvcParser.cpp
@@ -30,7 +30,6 @@
| includes
+---------------------------------------------------------------------*/
#include "Ap4AvcParser.h"
-#include "Ap4Utils.h"
/*----------------------------------------------------------------------
| debugging
@@ -123,6 +122,25 @@ AP4_AvcNalParser::SliceTypeName(unsigned int slice_type)
}
}
+const int SAR[17][2] = {
+ { 0, 1 },
+ { 1, 1 },
+ { 12, 11 },
+ { 10, 11 },
+ { 16, 11 },
+ { 40, 33 },
+ { 24, 11 },
+ { 20, 11 },
+ { 32, 11 },
+ { 80, 33 },
+ { 18, 11 },
+ { 15, 11 },
+ { 64, 33 },
+ { 160, 99 },
+ { 4, 3 },
+ { 3, 2 },
+ { 2, 1 },
+};
/*----------------------------------------------------------------------
| AP4_AvcNalParser::AP4_AvcNalParser
+---------------------------------------------------------------------*/
@@ -236,7 +254,28 @@ AP4_AvcSequenceParameterSet::AP4_AvcSequenceParameterSet() :
frame_crop_left_offset(0),
frame_crop_right_offset(0),
frame_crop_top_offset(0),
- frame_crop_bottom_offset(0)
+ frame_crop_bottom_offset(0),
+ vui_parameters_present_flag(0),
+ aspect_ratio_info_present_flag(0),
+ aspect_ratio_idc(0),
+ sar_width(0),
+ sar_height(0),
+ overscan_info_present_flag(0),
+ overscan_appropriate_flag(0),
+ video_signal_type_present_flag(0),
+ video_format(0),
+ video_full_range_flag(0),
+ colour_description_present_flag(0),
+ colour_primaries(0),
+ transfer_characteristics(0),
+ matrix_coefficients(0),
+ chroma_loc_info_present_flag(0),
+ chroma_sample_loc_type_top_field(0),
+ chroma_sample_loc_type_bottom_field(0),
+ timing_info_present_flag(0),
+ num_units_in_tick(0),
+ time_scale(0),
+ fixed_frame_rate_flag(0)
{
AP4_SetMemory(scaling_list_4x4, 0, sizeof(scaling_list_4x4));
AP4_SetMemory(use_default_scaling_matrix_4x4, 0, sizeof(use_default_scaling_matrix_4x4));
@@ -372,7 +411,64 @@ AP4_AvcFrameParser::ParseSPS(const unsigned char* data,
sps.frame_crop_top_offset = ReadGolomb(bits);
sps.frame_crop_bottom_offset = ReadGolomb(bits);
}
+ sps.vui_parameters_present_flag = bits.ReadBit();
+ if (sps.vui_parameters_present_flag) {
+ sps.aspect_ratio_info_present_flag = bits.ReadBit();
+ if (sps.aspect_ratio_info_present_flag) {
+ sps.aspect_ratio_idc = bits.ReadBits(8);
+ if (sps.aspect_ratio_idc == 0xFF)
+ {
+ sps.sar_width = bits.ReadBits(16);
+ sps.sar_height = bits.ReadBits(16);
+ }
+ else if (sps.aspect_ratio_idc < 17)
+ {
+ sps.sar_width = SAR[sps.aspect_ratio_idc][0];
+ sps.sar_height = SAR[sps.aspect_ratio_idc][1];
+ }
+ }
+ sps.overscan_info_present_flag = bits.ReadBit();
+ if (sps.overscan_info_present_flag)
+ sps.overscan_appropriate_flag = bits.ReadBit();
+
+ sps.video_signal_type_present_flag = bits.ReadBit();
+ if (sps.video_signal_type_present_flag) {
+ sps.video_format = bits.ReadBits(3);
+ sps.video_full_range_flag = bits.ReadBit();
+ sps.colour_description_present_flag = bits.ReadBit();
+ if (sps.colour_description_present_flag) {
+ sps.colour_primaries = bits.ReadBits(8);
+ sps.transfer_characteristics = bits.ReadBits(8);
+ sps.matrix_coefficients = bits.ReadBits(8);
+ }
+ }
+
+ sps.chroma_loc_info_present_flag = bits.ReadBit();
+ if (sps.chroma_loc_info_present_flag) {
+ sps.chroma_sample_loc_type_top_field = ReadGolomb(bits);
+ sps.chroma_sample_loc_type_bottom_field = ReadGolomb(bits);
+ }
+
+ if (bits.PeekBit() && bits.BitsLeft() < 10)
+ return AP4_SUCCESS;
+
+ sps.timing_info_present_flag = bits.ReadBit();
+ if (sps.timing_info_present_flag) {
+#if AP4_PLATFORM_BYTE_ORDER == AP4_PLATFORM_BYTE_ORDER_BIG_ENDIAN
+ sps.num_units_in_tick = bits.ReadBits(32);
+ sps.time_scale = bits.ReadBits(32);
+#else
+ sps.num_units_in_tick = bits.ReadBits(16) << 16;
+ sps.num_units_in_tick |= bits.ReadBits(16);
+ sps.time_scale = bits.ReadBits(16) << 16;
+ sps.time_scale |= bits.ReadBits(16);
+#endif
+ if (!sps.num_units_in_tick || !sps.time_scale)
+ sps.timing_info_present_flag = 0;
+ sps.fixed_frame_rate_flag = bits.ReadBit();
+ }
+ }
return AP4_SUCCESS;
}
diff --git a/Source/C++/Codecs/Ap4AvcParser.h b/Source/C++/Codecs/Ap4AvcParser.h
index 8f9cd6c..9f97892 100644
--- a/Source/C++/Codecs/Ap4AvcParser.h
+++ b/Source/C++/Codecs/Ap4AvcParser.h
@@ -37,6 +37,7 @@
#include "Ap4DataBuffer.h"
#include "Ap4NalParser.h"
#include "Ap4Array.h"
+#include "Ap4Utils.h"
/*----------------------------------------------------------------------
| constants
@@ -131,6 +132,27 @@ struct AP4_AvcSequenceParameterSet {
unsigned int frame_crop_right_offset;
unsigned int frame_crop_top_offset;
unsigned int frame_crop_bottom_offset;
+ unsigned int vui_parameters_present_flag;
+ unsigned int aspect_ratio_info_present_flag;
+ unsigned int aspect_ratio_idc;
+ unsigned int sar_width;
+ unsigned int sar_height;
+ unsigned int overscan_info_present_flag;
+ unsigned int overscan_appropriate_flag;
+ unsigned int video_signal_type_present_flag;
+ unsigned int video_format;
+ unsigned int video_full_range_flag;
+ unsigned int colour_description_present_flag;
+ unsigned int colour_primaries;
+ unsigned int transfer_characteristics;
+ unsigned int matrix_coefficients;
+ unsigned int chroma_loc_info_present_flag;
+ unsigned int chroma_sample_loc_type_top_field;
+ unsigned int chroma_sample_loc_type_bottom_field;
+ unsigned int timing_info_present_flag;
+ unsigned int num_units_in_tick;
+ unsigned int time_scale;
+ unsigned int fixed_frame_rate_flag;
};
struct AP4_AvcPictureParameterSet {
diff --git a/Source/C++/Core/Ap4Utils.cpp b/Source/C++/Core/Ap4Utils.cpp
index 96def27..6de4dba 100644
--- a/Source/C++/Core/Ap4Utils.cpp
+++ b/Source/C++/Core/Ap4Utils.cpp
@@ -581,4 +581,12 @@ AP4_BitReader::SkipBit()
}
}
+/*----------------------------------------------------------------------
+| AP4_BitReader::BitsLeft
++---------------------------------------------------------------------*/
+AP4_UI32
+AP4_BitReader::BitsLeft()
+{
+ return (m_Buffer.GetDataSize() - m_Position) * 8 + m_BitsCached;
+}
diff --git a/Source/C++/Core/Ap4Utils.h b/Source/C++/Core/Ap4Utils.h
index 475bff3..e66bafa 100644
--- a/Source/C++/Core/Ap4Utils.h
+++ b/Source/C++/Core/Ap4Utils.h
@@ -262,7 +262,7 @@ public:
AP4_Result SkipBytes(AP4_Size byte_count);
void SkipBit();
void SkipBits(unsigned int bit_count);
-
+ AP4_UI32 BitsLeft();
unsigned int GetBitsRead();
private:
--
2.30.2