下载、配置、制作并安装 PNG 1.6

下载、配置、制作并安装 PNG 1.6

注意:我猜我没有在 makefile 中设置某些内容,或者我使用的是他们之前要求安装的工作 SDL-devel 和 SDL_image-devel 包。实际上,我正在从存储库安装“libsdl2-image-2.0-0”和“libsdl2-image-dev”...但是,自述文件说这些仅适用于 BPGviewer: (# Compile bpgview (SDL and SDL_image libraries needed) #USE_BPGVIEW=y)

OBS.1:我刚刚发现这个:https://unix.stackexchange.com/questions/181735/how-to-install-bpg-better-portable-graphics-on-linux-mint-17

libbpg 依赖于 PNG 库的 1.6 版本,您无法在 Linux Mint 17 上使用 apt-get 安装该库。该库与 libpng12 不兼容,需要从源代码安装(我使用的是 1.6.16 版本)

好吧,无论如何,我正在尝试按照自述文件编译 libbpg-0.9.7:

2) Compilation and Installation Notes
-------------------------------------

2.1) Linux
----------

  - Edit the Makefile to change the compile options (the default
  compile options should be OK). Type 'make' to compile and 'make
  install' to install the compiled binaries.

  - Use 'make -j N' where N is the number of CPU cores to compile faster.

  - The following packages must be installed: SDL-devel
  SDL_image-devel yasm. It is recommended to use yasm version >= 1.3.0
  to have a faster compilation.

所以:

sudo apt-get install --force-yes -y libsdl2-image-2.0-0 libsdl2-image-dev yasm
sudo apt-get install -y emscripten

进而:

wget http://bellard.org/bpg/libbpg-0.9.7.tar.gz
tar xzf libbpg-0.9.7.tar.gz
cd libbpg-0.9.7/
make

但是,它不起作用:

$: make -j 6 install
gcc -Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT -I. -DCONFIG_BPG_VERSION=\"0.9.7\" -g -DUSE_X265 -Wno-unused-but-set-variable -c -o bpgenc.o bpgenc.c
make -C x265.out/12bit
make[1]: Entering directory `/home/rgr/src/bpg/libbpg-0.9.7/x265.out/12bit'
make[1]: *** No targets specified and no makefile found.  Stop.
ar rcs libbpg.a libavcodec/hevc_cabac.o libavcodec/hevc_filter.o libavcodec/hevc.o libavcodec/hevcpred.o libavcodec/hevc_refs.o libavcodec/hevcdsp.o libavcodec/hevc_mvs.o libavcodec/hevc_ps.o libavcodec/hevc_sei.o libavcodec/utils.o libavcodec/cabac.o libavcodec/golomb.o libavcodec/videodsp.o libavutil/mem.o libavutil/buffer.o libavutil/log2_tab.o libavutil/frame.o libavutil/pixdesc.o libavutil/md5.o libbpg.o
make[1]: Leaving directory `/home/rgr/src/bpg/libbpg-0.9.7/x265.out/12bit'
make: *** [x265_make] Error 2
make: *** Waiting for unfinished jobs....
bpgenc.c: In function ‘read_png’:
bpgenc.c:987:9: warning: implicit declaration of function ‘png_set_alpha_mode’ [-Wimplicit-function-declaration]
         png_set_alpha_mode(png_ptr, PNG_ALPHA_ASSOCIATED, PNG_GAMMA_LINEAR);
         ^
bpgenc.c:987:37: error: ‘PNG_ALPHA_ASSOCIATED’ undeclared (first use in this function)
         png_set_alpha_mode(png_ptr, PNG_ALPHA_ASSOCIATED, PNG_GAMMA_LINEAR);
                                     ^
bpgenc.c:987:37: note: each undeclared identifier is reported only once for each function it appears in
bpgenc.c:987:59: error: ‘PNG_GAMMA_LINEAR’ undeclared (first use in this function)
         png_set_alpha_mode(png_ptr, PNG_ALPHA_ASSOCIATED, PNG_GAMMA_LINEAR);
                                                           ^
bpgenc.c:1072:26: warning: passing argument 5 of ‘png_get_iCCP’ from incompatible pointer type [enabled by default]
                          &name, &comp_type, &iccp_buf, &iccp_buf_len) == 
                          ^
In file included from /usr/include/png.h:540:0,
                 from bpgenc.c:32:
/usr/include/png.h:2490:8: note: expected ‘png_charpp’ but argument is of type ‘png_byte **’
 extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
        ^
make: *** [bpgenc.o] Error 1

make文件的内容为:

# libbpg Makefile
# 
# Compile options:
#
# Enable compilation of Javascript decoder with Emscripten
#USE_EMCC=y
# Enable x265 for the encoder
USE_X265=y
# Enable the JCTVC code (best quality but slow) for the encoder
#USE_JCTVC=y
# Compile bpgview (SDL and SDL_image libraries needed)
#USE_BPGVIEW=y
# Enable it to use bit depths > 12 (need more tests to validate encoder)
#USE_JCTVC_HIGH_BIT_DEPTH=y
# Enable the cross compilation for Windows
#CONFIG_WIN32=y
# Enable for compilation on MacOS X
#CONFIG_APPLE=y
# Installation prefix
prefix=/usr/local


#################################

ifdef CONFIG_WIN32
CROSS_PREFIX:=x86_64-w64-mingw32-
#CROSS_PREFIX=i686-w64-mingw32-
EXE:=.exe
else
CROSS_PREFIX:=
EXE:=
endif

CC=$(CROSS_PREFIX)gcc
CXX=$(CROSS_PREFIX)g++
AR=$(CROSS_PREFIX)ar
EMCC=emcc

PWD:=$(shell pwd)

CFLAGS:=-Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT
CFLAGS+=-I.
CFLAGS+=-DCONFIG_BPG_VERSION=\"$(shell cat VERSION)\"
ifdef USE_JCTVC_HIGH_BIT_DEPTH
CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT
endif

# Emscriptem config
EMLDFLAGS:=-s "EXPORTED_FUNCTIONS=['_bpg_decoder_open','_bpg_decoder_decode','_bpg_decoder_get_info','_bpg_decoder_start','_bpg_decoder_get_frame_duration','_bpg_decoder_get_line','_bpg_decoder_close','_malloc','_free']"
EMLDFLAGS+=-s NO_FILESYSTEM=1 -s NO_BROWSER=1
#EMLDFLAGS+=-O1 --pre-js pre.js --post-js post.js
# Note: the closure compiler is disabled because it adds unwanted global symbols
EMLDFLAGS+=-O3 --memory-init-file 0 --closure 0 --pre-js pre.js --post-js post.js
EMCFLAGS:=$(CFLAGS)

LDFLAGS=-g
ifdef CONFIG_APPLE
LDFLAGS+=-Wl,-dead_strip
else
LDFLAGS+=-Wl,--gc-sections
endif
CFLAGS+=-g
CXXFLAGS=$(CFLAGS)

PROGS=bpgdec$(EXE) bpgenc$(EXE)
ifdef USE_BPGVIEW
PROGS+=bpgview$(EXE)
endif
ifdef USE_EMCC
PROGS+=bpgdec.js bpgdec8.js bpgdec8a.js
endif

all: $(PROGS)

LIBBPG_OBJS:=$(addprefix libavcodec/, \
hevc_cabac.o  hevc_filter.o  hevc.o         hevcpred.o  hevc_refs.o\
hevcdsp.o     hevc_mvs.o     hevc_ps.o   hevc_sei.o\
utils.o cabac.o golomb.o videodsp.o )
LIBBPG_OBJS+=$(addprefix libavutil/, mem.o buffer.o log2_tab.o frame.o pixdesc.o md5.o )
LIBBPG_OBJS+=libbpg.o

LIBBPG_JS_OBJS:=$(patsubst %.o, %.js.o, $(LIBBPG_OBJS)) tmalloc.js.o

LIBBPG_JS8_OBJS:=$(patsubst %.o, %.js8.o, $(LIBBPG_OBJS)) tmalloc.js8.o

LIBBPG_JS8A_OBJS:=$(patsubst %.o, %.js8a.o, $(LIBBPG_OBJS)) tmalloc.js8a.o

$(LIBBPG_OBJS): CFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH -DUSE_PRED

$(LIBBPG_JS_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_VAR_BIT_DEPTH

$(LIBBPG_JS8_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1

$(LIBBPG_JS8A_OBJS): EMCFLAGS+=-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DHAVE_AV_CONFIG_H -std=c99 -D_GNU_SOURCE=1 -DUSE_PRED

BPGENC_OBJS:=bpgenc.o
BPGENC_LIBS:=

ifdef USE_X265

X265_LIBS:=./x265.out/8bit/libx265.a ./x265.out/10bit/libx265.a ./x265.out/12bit/libx265.a
BPGENC_OBJS+=x265_glue.o $(X265_LIBS)

bpgenc.o: CFLAGS+=-DUSE_X265
x265_glue.o: CFLAGS+=-I./x265/source -I./x265.out/8bit
x265_glue.o: $(X265_LIBS)

ifdef CONFIG_WIN32
CMAKE_OPTS:=-DCMAKE_TOOLCHAIN_FILE=../../x265/build/msys/toolchain-x86_64-w64-mingw32.cmake
else
CMAKE_OPTS:=
endif

x265.out:
    mkdir -p x265.out/8bit x265.out/10bit x265.out/12bit
    cd x265.out/12bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON
    cd x265.out/10bit && cmake ../../x265/source $(CMAKE_OPTS) -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN10=ON
    cd x265.out/8bit && cmake ../../x265/source $(CMAKE_OPTS) -DLINKED_10BIT=ON -DLINKED_12BIT=ON -DENABLE_SHARED=OFF -DENABLE_CLI=OFF

# use this target to manually rebuild x265
x265_make: | x265.out
    $(MAKE) -C x265.out/12bit
    $(MAKE) -C x265.out/10bit
    $(MAKE) -C x265.out/8bit

x265_clean:
    rm -rf x265.out

$(X265_LIBS): x265_make

else

x265_clean:

endif # USE_X265

ifdef USE_JCTVC
JCTVC_OBJS=$(addprefix jctvc/TLibEncoder/, SyntaxElementWriter.o TEncSbac.o \
TEncBinCoderCABACCounter.o TEncGOP.o\
TEncSampleAdaptiveOffset.o TEncBinCoderCABAC.o TEncAnalyze.o\
TEncEntropy.o TEncTop.o SEIwrite.o TEncPic.o TEncRateCtrl.o\
WeightPredAnalysis.o TEncSlice.o TEncCu.o NALwrite.o TEncCavlc.o\
TEncSearch.o TEncPreanalyzer.o)
JCTVC_OBJS+=jctvc/TLibVideoIO/TVideoIOYuv.o
JCTVC_OBJS+=$(addprefix jctvc/TLibCommon/, TComWeightPrediction.o TComLoopFilter.o\
TComBitStream.o TComMotionInfo.o TComSlice.o ContextModel3DBuffer.o\
TComPic.o TComRdCostWeightPrediction.o TComTU.o TComPicSym.o\
TComPicYuv.o TComYuv.o TComTrQuant.o TComInterpolationFilter.o\
ContextModel.o TComSampleAdaptiveOffset.o SEI.o TComPrediction.o\
TComDataCU.o TComChromaFormat.o Debug.o TComRom.o\
TComPicYuvMD5.o TComRdCost.o TComPattern.o TComCABACTables.o)
JCTVC_OBJS+=jctvc/libmd5/libmd5.o
JCTVC_OBJS+=jctvc/TAppEncCfg.o jctvc/TAppEncTop.o jctvc/program_options_lite.o 

$(JCTVC_OBJS) jctvc_glue.o: CFLAGS+=-I$(PWD)/jctvc -Wno-sign-compare

jctvc/libjctvc.a: $(JCTVC_OBJS)
    $(AR) rcs $@ $^

BPGENC_OBJS+=jctvc_glue.o jctvc/libjctvc.a

bpgenc.o: CFLAGS+=-DUSE_JCTVC
endif # USE_JCTVC


ifdef CONFIG_WIN32

BPGDEC_LIBS:=-lpng -lz
BPGENC_LIBS+=-lpng -ljpeg -lz
BPGVIEW_LIBS:=-lmingw32 -lSDLmain -lSDL_image -lSDL -mwindows

else

ifdef CONFIG_APPLE
LIBS:=
else
LIBS:=-lrt
endif # !CONFIG_APPLE 
LIBS+=-lm -lpthread

BPGDEC_LIBS:=-lpng $(LIBS)
BPGENC_LIBS+=-lpng -ljpeg $(LIBS)
BPGVIEW_LIBS:=-lSDL_image -lSDL $(LIBS)

endif #!CONFIG_WIN32

bpgenc.o: CFLAGS+=-Wno-unused-but-set-variable

libbpg.a: $(LIBBPG_OBJS) 
    $(AR) rcs $@ $^

bpgdec$(EXE): bpgdec.o libbpg.a
    $(CC) $(LDFLAGS) -o $@ $^ $(BPGDEC_LIBS)

bpgenc$(EXE): $(BPGENC_OBJS)
    $(CXX) $(LDFLAGS) -o $@ $^ $(BPGENC_LIBS)

bpgview$(EXE): bpgview.o libbpg.a
    $(CC) $(LDFLAGS) -o $@ $^ $(BPGVIEW_LIBS)

bpgdec.js: $(LIBBPG_JS_OBJS) post.js
    $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS_OBJS)

bpgdec8.js: $(LIBBPG_JS8_OBJS) post.js
    $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8_OBJS)

bpgdec8a.js: $(LIBBPG_JS8A_OBJS) post.js
    $(EMCC) $(EMLDFLAGS) -s TOTAL_MEMORY=33554432 -o $@ $(LIBBPG_JS8A_OBJS)

size:
    strip bpgdec
    size bpgdec libbpg.o libavcodec/*.o libavutil/*.o | sort -n
    gzip < bpgdec | wc

install: bpgenc bpgdec
    install -s -m 755 $^ $(prefix)/bin

CLEAN_DIRS=doc html libavcodec libavutil \
     jctvc jctvc/TLibEncoder jctvc/TLibVideoIO jctvc/TLibCommon jctvc/libmd5

clean: x265_clean
    rm -f $(PROGS) *.o *.a *.d *~ $(addsuffix /*.o, $(CLEAN_DIRS)) \
          $(addsuffix /*.d, $(CLEAN_DIRS)) $(addsuffix /*~, $(CLEAN_DIRS)) \
          $(addsuffix /*.a, $(CLEAN_DIRS))

%.o: %.c
    $(CC) $(CFLAGS) -c -o $@ $<

%.o: %.cpp
    $(CXX) $(CXXFLAGS) -c -o $@ $<

%.js.o: %.c
    $(EMCC) $(EMCFLAGS) -c -o $@ $<

%.js8.o: %.c
    $(EMCC) $(EMCFLAGS) -c -o $@ $<

%.js8a.o: %.c
    $(EMCC) $(EMCFLAGS) -c -o $@ $<

-include $(wildcard *.d)
-include $(wildcard libavcodec/*.d)
-include $(wildcard libavutil/*.d)
-include $(wildcard jctvc/*.d)
-include $(wildcard jctvc/TLibEncoder/*.d)
-include $(wildcard jctvc/TLibVideoIO/*.d)
-include $(wildcard jctvc/TLibCommon/*.d)
-include $(wildcard jctvc/libmd5/*.d)

有什么猜测吗?谢谢。

答案1

当我尝试在 Ubuntu 18.04 LTS 中构建 LibBPG 0.98 时,我在编译时不断遇到错误。错误发生在libnuma。在构建过程结束时,它失败了,我收到消息指出

undefined reference to 'numa_available', 'numa_run_on_node_mask', 'numa_max_node'

我曾多次尝试编译上述所有建议,但最终答案却非常简单。

libnuma-dev彻底删除了库,然后编译了 LibBPG,没有出现错误。然后libnuma-dev再次安装。我知道这很笨拙,但它有效。哦,我用的是libpng1.6.37。

我希望这可以为遇到此烦人错误的人节省大量时间,这花了我几个小时。;)

答案2

这是我为了完成这件事所做的事情:

从 Ubuntu: 查找软件包位置时出现问题:libsdl2-image-2.0-0 https://unix.stackexchange.com/questions/181735/how-to-install-bpg-better-portable-graphics-on-linux-mint-17

LIBPNG libbpg 依赖于 PNG 库的 1.6 版本,您无法使用 apt-get 安装该版本。此库与 libpng12 不兼容,需要从源代码安装(我使用的是 1.6.16 版本)。最好不要更改官方安装的软件包 libpng12-dev,而是在 libbpg 的 Makefile 中指示在哪里可以找到 libpng 1.6。

sudo apt-get install -y libsdl-image1.2-dev libsdl1.2-dev libjpeg8-dev emscripten
sudo apt-get install --force-yes -y yasm

下载、配置、制作并安装 PNG 1.6

wget -O libpng-1.6.28.tar.xz "https://downloads.sourceforge.net/project/libpng/libpng16/1.6.28/libpng-1.6.28.tar.gz?ts=$(date +%s)"
tar xf libpng-1.6.28.tar.xz
./configure --help
./configure
make -j
sudo make install
sudo checkinstall
sudo ldconfig /usr/local/lib

Done. The new package has been installed and saved to
/home/rgr/src/libpng/libpng-1.6.28/libpng_1.6.28-1_amd64.deb
You can remove it from your system anytime using: 

dpkg-r libpng

下载、制作并安装 BPG

mkdir bpg
cd bpg
wget http://bellard.org/bpg/libbpg-0.9.5.tar.gz
tar xzf libbpg-0.9.5.tar.gz
cd libbpg-0.9.5/

编辑 Makefile 并插入以下两个指令:

sudo nano Makefile
"CFLAGS+=-I/usr/local/include"      after the line "CFLAGS+=-I"
"LDFLAGS+=-L /usr/local/lib"        before the line "CFLAGS+=-g"

然后: make -j 6 sudo make install sudo checkinstall sudo ldconfig /usr/local/lib


Done. The new package has been installed and saved to
/home/rgr/src/bpg/libbpg-0.9.5/libbpg_0.9.5-1_amd64.deb
You can remove it from your system anytime using: 

dpkg-r libbpg

相关内容