Skip to content

Commit 98ce2a5

Browse files
authored
Merge branch 'strukturag:master' into master
2 parents f6d4386 + 62ffc12 commit 98ce2a5

File tree

10 files changed

+139
-28
lines changed

10 files changed

+139
-28
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ endif()
167167
plugin_option(OpenJPEG_ENCODER "OpenJPEG J2K encoder" OFF ON)
168168
plugin_option(OpenJPEG_DECODER "OpenJPEG J2K decoder" OFF ON)
169169
if (WITH_OpenJPEG_ENCODER OR WITH_OpenJPEG_DECODER)
170-
find_package(OpenJPEG)
170+
find_package(OpenJPEG 2)
171171
endif()
172172

173173
# ffmpeg

examples/heif-enc.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Output filename (optional).
4242
Enable logging output (more will increase logging level).
4343
.TP
4444
.BR \-P ", "\-\-params\fR
45-
Show all encoder parameters.
45+
Show all encoder parameters and exit. Input file is not required or used.
4646
.TP
4747
.BR \-b\fR\ \fIDEPTH\fR
4848
Bit-depth of generated HEIF file when using 16-bit PNG input (default: 10 bit).

examples/heif_enc.cc

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void show_help(const char* argv0)
155155
<< " --no-thumb-alpha do not save alpha channel in thumbnail image\n"
156156
<< " -o, --output output filename (optional)\n"
157157
<< " --verbose enable logging output (more will increase logging level)\n"
158-
<< " -P, --params show all encoder parameters\n"
158+
<< " -P, --params show all encoder parameters and exit, input file not required or used.\n"
159159
<< " -b, --bit-depth # bit-depth of generated HEIF/AVIF file when using 16-bit PNG input (default: 10 bit)\n"
160160
<< " -p set encoder parameter (NAME=VALUE)\n"
161161
<< " -A, --avif encode as AVIF (not needed if output filename with .avif suffix is provided)\n"
@@ -626,22 +626,6 @@ int main(int argc, char** argv)
626626
return 0;
627627
}
628628

629-
if (optind > argc - 1) {
630-
show_help(argv[0]);
631-
return 0;
632-
}
633-
634-
635-
// If we were given a list of filenames and no '-o' option, check whether the last filename is the desired output filename.
636-
637-
if (output_filename.empty() && argc>1) {
638-
if (guess_compression_format_from_filename(argv[argc-1]) != heif_compression_undefined) {
639-
output_filename = argv[argc-1];
640-
argc--;
641-
}
642-
}
643-
644-
645629
// --- determine output compression format (from output filename or command line parameter)
646630

647631
heif_compression_format compressionFormat;
@@ -720,6 +704,20 @@ int main(int argc, char** argv)
720704
return 0;
721705
}
722706

707+
if (optind > argc - 1) {
708+
show_help(argv[0]);
709+
return 0;
710+
}
711+
712+
713+
// If we were given a list of filenames and no '-o' option, check whether the last filename is the desired output filename.
714+
715+
if (output_filename.empty() && argc>1) {
716+
if (guess_compression_format_from_filename(argv[argc-1]) != heif_compression_undefined) {
717+
output_filename = argv[argc-1];
718+
argc--;
719+
}
720+
}
723721

724722
struct heif_error error;
725723

libheif/box.cc

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,14 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result)
610610
box = std::make_shared<Box_mskC>();
611611
break;
612612

613-
default:
613+
case fourcc("mdat"):
614+
// avoid generating a 'Box_other'
614615
box = std::make_shared<Box>();
615616
break;
617+
618+
default:
619+
box = std::make_shared<Box_other>(hdr.get_short_type());
620+
break;
616621
}
617622

618623
box->set_short_header(hdr);
@@ -849,6 +854,77 @@ void Box::derive_box_version_recursive()
849854
}
850855

851856

857+
Error Box_other::parse(BitstreamRange& range)
858+
{
859+
if (has_fixed_box_size()) {
860+
size_t len = get_box_size() - get_header_size();
861+
m_data.resize(len);
862+
range.read(m_data.data(), len);
863+
}
864+
else {
865+
// TODO: boxes until end of file (we will probably never need this)
866+
}
867+
868+
return range.get_error();
869+
}
870+
871+
872+
Error Box_other::write(StreamWriter& writer) const
873+
{
874+
size_t box_start = reserve_box_header_space(writer);
875+
876+
writer.write(m_data);
877+
878+
prepend_header(writer, box_start);
879+
880+
return Error::Ok;
881+
}
882+
883+
884+
std::string Box_other::dump(Indent& indent) const
885+
{
886+
std::ostringstream sstr;
887+
888+
sstr << BoxHeader::dump(indent);
889+
890+
// --- show raw box content
891+
892+
sstr << std::hex << std::setfill('0');
893+
894+
size_t len = get_box_size() - get_header_size();
895+
896+
for (size_t i = 0; i < len; i++) {
897+
if (i % 16 == 0) {
898+
// start of line
899+
900+
if (i == 0) {
901+
sstr << indent << "data: ";
902+
}
903+
else {
904+
sstr << indent << " ";
905+
}
906+
sstr << std::setw(4) << i << ": "; // address
907+
}
908+
else if (i % 16 == 8) {
909+
// space in middle
910+
sstr << " ";
911+
}
912+
else {
913+
// space between bytes
914+
sstr << " ";
915+
}
916+
917+
sstr << std::setw(2) << ((int) m_data[i]);
918+
919+
if (i % 16 == 15 || i == len - 1) {
920+
sstr << "\n";
921+
}
922+
}
923+
924+
return sstr.str();
925+
}
926+
927+
852928
Error Box_ftyp::parse(BitstreamRange& range)
853929
{
854930
m_major_brand = range.read32();

libheif/box.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,27 @@ class FullBox : public Box
258258
};
259259

260260

261+
class Box_other : public Box
262+
{
263+
public:
264+
Box_other(uint32_t short_type)
265+
{
266+
set_short_type(short_type);
267+
}
268+
269+
Error write(StreamWriter& writer) const override;
270+
271+
std::string dump(Indent&) const override;
272+
273+
protected:
274+
Error parse(BitstreamRange& range) override;
275+
276+
std::vector<uint8_t> m_data;
277+
};
278+
279+
280+
281+
261282
class Box_ftyp : public Box
262283
{
263284
public:

libheif/plugins/encoder_jpeg.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ struct heif_error jpeg_encode_image(void* encoder_raw, const struct heif_image*
360360
}
361361

362362
uint8_t* outbuffer = nullptr;
363+
#ifdef LIBJPEG_TURBO_VERSION
363364
unsigned long outlength = 0;
365+
#else
366+
size_t outlength = 0;
367+
#endif
364368

365369
jpeg_create_compress(&cinfo);
366370
jpeg_mem_dest(&cinfo, &outbuffer, &outlength);

scripts/build-android-libs.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121

2222

2323
# This script builds binaries for all Android architectures. They are placed in the directory 'out'.
24-
# The libheif source has to be unpacked to a directory named "libheif-1.16.2" (replace version number with the value of HEIF_VERSION below).
24+
# The script should be run in the root directory of the libheif sources.
2525

2626
# The configuration below builds libheif with heic decoding only.
2727

2828
# Set these variables to suit your needs
2929
NDK_PATH= ... # for example .../android-sdk/sdk/ndk/25.1.8937393
3030
TOOLCHAIN=clang
31-
ANDROID_VERSION=19 # the minimum version of Android to support
32-
HEIF_VERSION=1.16.2
31+
ANDROID_VERSION=24 # the minimum version of Android to support
3332

3433
function build {
3534
mkdir -p build/$1
@@ -42,6 +41,7 @@ function build {
4241
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
4342
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
4443
-DENABLE_PLUGIN_LOADING=OFF \
44+
-DBUILD_TESTING=OFF \
4545
-DWITH_AOM_DECODER=OFF \
4646
-DWITH_AOM_DECODER_PLUGIN=OFF \
4747
-DWITH_AOM_ENCODER=OFF \
@@ -57,7 +57,8 @@ function build {
5757
-DCMAKE_INSTALL_PREFIX=../../out/$1 \
5858
-DCMAKE_BUILD_TYPE=Release \
5959
-Dld-version-script=OFF \
60-
../../libheif-${HEIF_VERSION}
60+
../..
61+
6162
make VERBOSE=1
6263
make install
6364
cd ../..

third-party/aom.cmd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
: # If you're running this on Windows, be sure you've already run this (from your VC2019 install dir):
1111
: # "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
1212

13-
git clone -b v3.9.0 --depth 1 https://aomedia.googlesource.com/aom
13+
git clone -b v3.9.1 --depth 1 https://aomedia.googlesource.com/aom
1414

1515
cd aom
1616

1717
cmake -S . -B build.libavif -G Ninja -DCMAKE_INSTALL_PREFIX="$(pwd)/dist" -DCMAKE_BUILD_TYPE=Release -DENABLE_DOCS=0 -DENABLE_EXAMPLES=0 -DENABLE_TESTDATA=0 -DENABLE_TESTS=0 -DENABLE_TOOLS=0
1818
ninja -C build.libavif
1919
ninja -C build.libavif install
2020
cd ..
21+
22+
echo ""
23+
echo "----- NOTE ----"
24+
echo "Please add the path to the pkg-config file to your PKG_CONFIG_PATH, like this:"
25+
echo "export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$(pwd)/aom/dist/lib/pkgconfig"

third-party/dav1d.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ meson build --default-library=static --buildtype release --prefix "$(pwd)/dist"
2121
ninja -C build
2222
ninja -C build install
2323
cd ..
24+
25+
echo ""
26+
echo "----- NOTE ----"
27+
echo "Please add the path to the pkg-config file to your PKG_CONFIG_PATH. For"
28+
echo "example, on Linux x86_64, run:"
29+
echo "export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$(pwd)/dav1d/dist/lib/x86_64-linux-gnu/pkgconfig"

third-party/svt.cmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
: # If you want to enable the SVT-AV1 encoder, please check that the WITH_SvtEnc and WITH_SvtEnc_BUILTIN CMake variables are set correctly.
66
: # You will also have to set the PKG_CONFIG_PATH to "third-party/SVT-AV1/Build/linux/Release" so that the local SVT-AV1 library is found.
77

8-
git clone -b v1.2.1 --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git
8+
git clone -b v2.1.0 --depth 1 https://gitlab.com/AOMediaCodec/SVT-AV1.git
99

1010
cd SVT-AV1
1111
cd Build/linux
1212

13-
./build.sh release static no-dec no-apps prefix=`pwd`/install install
13+
./build.sh release static no-dec no-apps prefix=$(pwd)/install install
1414
cd ../../..
1515

1616
echo ""
1717
echo "----- NOTE ----"
1818
echo "Please add the path to the pkg-config file to your PKG_CONFIG_PATH, like this:"
19-
echo "export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:`pwd`/SVT-AV1/Build/linux/install/lib/pkgconfig"
19+
echo "export PKG_CONFIG_PATH=\$PKG_CONFIG_PATH:$(pwd)/SVT-AV1/Build/linux/install/lib/pkgconfig"

0 commit comments

Comments
 (0)