jdeng / goheif Goto Github PK
View Code? Open in Web Editor NEWgo gettable decoder/converter for HEIF/HEIC based on libde265
go gettable decoder/converter for HEIF/HEIC based on libde265
The source code of libde265 is included in the project. I believe this is not the best practice.
I think doing the following steps a better approach:
cd libde265
rm -rf libde265
git commit -am "libde265 removed"
git submodule add https://github.com/strukturag/libde265.git
I ran into this error, photo taken with Samsung Galaxy
2021/05/01 23:30:17 Warning: no EXIF from test\20210330_002711.heic: error reading "meta" box: got box type "mdat" instead
2021/05/01 23:30:17 Failed to parse test\20210330_002711.heic: error reading "meta" box: got box type "mdat" instead
Thank you.
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -platform windows
go version go1.18.4 darwin/amd64
ld: warning: ignoring file $WORK/b054/_x001.o, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x64 0x86 0x0A 0x00 0x00 0x00 0x00 0x00 0xCE 0x03 0x00 0x00 0x14 0x00 0x00 0x00 )
ld: warning: ignoring file $WORK/b054/_cgo_main.o, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x64 0x86 0x11 0x00 0x00 0x00 0x00 0x00 0xF0 0x0B 0x00 0x00 0x2C 0x00 0x00 0x00 )
ld: warning: ignoring file $WORK/b054/_x002.o, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x64 0x86 0x0E 0x00 0x00 0x00 0x00 0x00 0x22 0x44 0x00 0x00 0x40 0x00 0x00 0x00 )
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _de265_get_version_number_maintenance)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/jdeng/goheif/libde265
In file included from libde265.cc:2:
In file included from ../pkg/mod/github.com/jdeng/[email protected]/libde265/libde265-all.inl:37:
../pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/slice.cc:2447:9: warning: 'MAX_PREFIX' macro redefined [-Wmacro-redefined]
../pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/cabac.cc:419:9: note: previous definition is here
Error: exit status 2
When attempting to build on Windows 10, I'm getting the following compile error:
In file included from libde265.cc:2:0:
libde265-all.inl:2:29: fatal error: extra/win32cond.c: No such file or directory
compilation terminated.
Looks like there are some files missing that are required for windows?
or just decoder ? can I use this project to convert my jpg/PNG pictures to heic format ? thank you .
here's the log i see:
iCloud Photos$ go get github.com/jdeng/goheif/...
# github.com/jdeng/goheif/libde265
In file included from libde265.cc:2:
In file included from src/github.com/jdeng/goheif/libde265/libde265-all.inl:37:
src/github.com/jdeng/goheif/libde265/libde265/slice.cc:2447:9: warning: 'MAX_PREFIX' macro redefined [-Wmacro-redefined]
src/github.com/jdeng/goheif/libde265/libde265/cabac.cc:419:9: note: previous definition is here
# github.com/jdeng/goheif/heic2jpg
src/github.com/jdeng/goheif/heic2jpg/main.go:80:14: undefined: goheif.DecodeImage
iCloud Photos$
Hi, does anyone have permission to use this source code? There is not currently a LICENSE attached.
Easiest way to attempt this would be to use xgo.
Steps to reproduce:
xgo --targets=linux/arm .
Checking docker installation...
Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:21:11 2020
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Checking for required docker image karalabe/xgo-latest... found.
Cross compiling goheif...
Building locally goheif...
Bootstrapping linux/arm-5...
Compiling for linux/arm-5...
# github.com/jdeng/goheif/libde265
arm-linux-gnueabi-g++-5: error: unrecognized command line option '-msse4.1'
2020/06/01 23:02:19 Failed to cross compile package: exit status 2.
Any help would be much appreciated. Thanks!
That's the error message I get when I try to compile a project that uses this package.
# github.com/jdeng/goheif/libde265
In file included from libde265.cc:2:
In file included from ../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265-all.inl:37:
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/slice.cc:2447:9: warning: 'MAX_PREFIX' macro redefined [-Wmacro-redefined]
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/cabac.cc:419:9: note: previous definition is here
In file included from libde265.cc:2:
In file included from ../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265-all.inl:47:
In file included from ../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/x86/sse-dct.cc:29:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/emmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/xmmintrin.h:13:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/math.h:649:12: note: '__builtin_isless' declared here
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/math.h:545:22: note: expanded from macro 'isless'
In file included from libde265.cc:2:
In file included from ../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265-all.inl:47:
In file included from ../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/x86/sse-dct.cc:29:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/emmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/xmmintrin.h:13:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:260:19: error: use of undeclared identifier '__builtin_ia32_punpckhdq'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:287:19: error: use of undeclared identifier '__builtin_ia32_punpcklbw'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:310:19: error: use of undeclared identifier '__builtin_ia32_punpcklwd'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:331:19: error: use of undeclared identifier '__builtin_ia32_punpckldq'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:352:19: error: use of undeclared identifier '__builtin_ia32_paddb'; did you mean '__builtin_arm_addg'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:352:19: error: first argument of MTE builtin function must be a pointer ('__v8qi' (vector of 8 'char' values) invalid)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:373:19: error: use of undeclared identifier '__builtin_ia32_paddw'; did you mean '__builtin_arm_addg'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:373:19: error: first argument of MTE builtin function must be a pointer ('__v4hi' (vector of 4 'short' values) invalid)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:394:19: error: use of undeclared identifier '__builtin_ia32_paddd'; did you mean '__builtin_arm_addg'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include/mmintrin.h:394:19: error: first argument of MTE builtin function must be a pointer ('__v2si' (vector of 2 'int' values) invalid)
fatal error: too many errors emitted, stopping now [-ferror-limit=]
make: *** [all] Error 2
Tried to convert few images in JPG but getting errors in alternative runs
package main
import (
"bytes"
"image/jpeg"
"io"
"io/ioutil"
"log"
"os"
"path"
"strings"
"time"
"github.com/jdeng/goheif"
)
func main() {
files, err := ioutil.ReadDir("input")
if err != nil {
log.Fatal(err)
}
if err := os.RemoveAll("output"); err != nil {
log.Fatal(err)
}
if err := os.Mkdir("output", os.ModePerm); err != nil {
log.Fatal(err)
}
for _, file := range files {
if file.IsDir() {
continue
}
if strings.HasSuffix(file.Name(), ".heic") {
out := strings.TrimSuffix(file.Name(), ".heic")
out = out + ".jpg"
fileHandler(path.Join("input", file.Name()), path.Join("output", out))
}
}
log.Println("Conversion Passed")
}
func fileHandler(fin string, fout string) {
t0 := time.Now()
b, err := ioutil.ReadFile(fin)
if err != nil {
log.Fatal(err)
}
br := bytes.NewReader(b)
exif, err := goheif.ExtractExif(br)
if err != nil {
log.Printf("Warning: no EXIF from %s: %v\n", fin, err)
}
img, err := goheif.Decode(br)
if err != nil {
log.Fatalf("Failed to parse %s: %v\n", fin, err)
}
fileOutput, err := os.OpenFile(fout, os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
log.Fatal(err)
}
defer fileOutput.Close()
// Write both convert file + exif data back
w, _ := newWriterExif(fileOutput, exif)
err = jpeg.Encode(w, img, nil)
if err != nil {
log.Fatal(err)
}
e0 := time.Since(t0)
log.Printf("Complete %s => %s in %s\n", fin, fout, e0)
}
// Skip Writer for exif writing
type writerSkipper struct {
w io.Writer
bytesToSkip int
}
func (w *writerSkipper) Write(data []byte) (int, error) {
if w.bytesToSkip <= 0 {
return w.w.Write(data)
}
if dataLen := len(data); dataLen < w.bytesToSkip {
w.bytesToSkip -= dataLen
return dataLen, nil
}
if n, err := w.w.Write(data[w.bytesToSkip:]); err == nil {
n += w.bytesToSkip
w.bytesToSkip = 0
return n, nil
} else {
return n, err
}
}
func newWriterExif(w io.Writer, exif []byte) (io.Writer, error) {
writer := &writerSkipper{w, 2}
soi := []byte{0xff, 0xd8}
if _, err := w.Write(soi); err != nil {
return nil, err
}
if exif != nil {
app1Marker := 0xe1
markerlen := 2 + len(exif)
marker := []byte{0xff, uint8(app1Marker), uint8(markerlen >> 8), uint8(markerlen & 0xff)}
if _, err := w.Write(marker); err != nil {
return nil, err
}
if _, err := w.Write(exif); err != nil {
return nil, err
}
}
return writer, nil
}
# github.com/jdeng/goheif/libde265
In file included from libde265-all.inl:37,
from libde265.cc:2:
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/slice.cc:2447: warning: "MAX_PREFIX" redefined
2447 | #define MAX_PREFIX 64
|
In file included from libde265-all.inl:13,
from libde265.cc:2:
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/cabac.cc:419: note: this is the location of the previous definition
419 | #define MAX_PREFIX 32
|
cc1plus: note: unrecognized command-line option ‘-Wno-constant-conversion’ may have been intended to silence earlier diagnostics
2022/10/04 16:11:01 Complete input/image1.heic => output/image1.jpg in 874.589691ms
2022/10/04 16:11:01 Complete input/image2.heic => output/image2.jpg in 589.208531ms
2022/10/04 16:11:02 Complete input/image3.heic => output/image3.jpg in 571.793151ms
unexpected fault address 0x7f7ca00a0010
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f7ca00a0010 pc=0x49d7dc]
goroutine 1 [running]:
runtime.throw({0x541d61?, 0xc00037f298?})
/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0xc00037f260 sp=0xc00037f230 pc=0x4472fd
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:842 +0x2c5 fp=0xc00037f2b0 sp=0xc00037f260 pc=0x45b3c5
image/jpeg.yCbCrToYCbCr(0xc00009de00, {0x605840?, 0x1?}, 0xc00037f3b8, 0xc00037f8b8, 0xc00037f4b8)
/usr/local/go/src/image/jpeg/writer.go:461 +0x17c fp=0xc00037f330 sp=0xc00037f2b0 pc=0x49d7dc
image/jpeg.(*encoder).writeSOS(0xc00006c180, {0x567c60?, 0xc00009de00?})
/usr/local/go/src/image/jpeg/writer.go:547 +0x485 fp=0xc00037fce8 sp=0xc00037f330 pc=0x49de45
image/jpeg.Encode({0x567880?, 0xc00009e040?}, {0x567c60, 0xc00009de00}, 0x0)
/usr/local/go/src/image/jpeg/writer.go:634 +0x347 fp=0xc00037fd60 sp=0xc00037fce8 pc=0x49e2c7
main.fileHandler({0xc00001a228, 0x11}, {0xc00001a2a0, 0x11})
/home/ganesh/AutoVisas/poc/main.go:69 +0x29a fp=0xc00037fe78 sp=0xc00037fd60 pc=0x4d1efa
main.main()
/home/ganesh/AutoVisas/poc/main.go:35 +0x36f fp=0xc00037ff80 sp=0xc00037fe78 pc=0x4d1c0f
runtime.main()
/usr/local/go/src/runtime/proc.go:250 +0x212 fp=0xc00037ffe0 sp=0xc00037ff80 pc=0x449b52
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00037ffe8 sp=0xc00037ffe0 pc=0x4731c1
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004efb0 sp=0xc00004ef90 pc=0x449f16
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:302 +0xad fp=0xc00004efe0 sp=0xc00004efb0 pc=0x449dad
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004efe8 sp=0xc00004efe0 pc=0x4731c1
created by runtime.init.6
/usr/local/go/src/runtime/proc.go:290 +0x25
goroutine 3 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004f790 sp=0xc00004f770 pc=0x449f16
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
/usr/local/go/src/runtime/mgcsweep.go:297 +0xd7 fp=0xc00004f7c8 sp=0xc00004f790 pc=0x436f57
runtime.gcenable.func1()
/usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc00004f7e0 sp=0xc00004f7c8 pc=0x42bdc6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004f7e8 sp=0xc00004f7e0 pc=0x4731c1
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:178 +0x6b
goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1771f52c0f38?, 0x22cea815?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004ff70 sp=0xc00004ff50 pc=0x449f16
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x616ee0)
/usr/local/go/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc00004ffa0 sp=0xc00004ff70 pc=0x434fb3
runtime.bgscavenge(0x0?)
/usr/local/go/src/runtime/mgcscavenge.go:622 +0x65 fp=0xc00004ffc8 sp=0xc00004ffa0 pc=0x4355a5
runtime.gcenable.func2()
/usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc00004ffe0 sp=0xc00004ffc8 pc=0x42bd66
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004ffe8 sp=0xc00004ffe0 pc=0x4731c1
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:179 +0xaa
goroutine 5 [finalizer wait]:
runtime.gopark(0x6172e0?, 0xc000007860?, 0x0?, 0x0?, 0xc00004e770?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004e628 sp=0xc00004e608 pc=0x449f16
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:180 +0x10f fp=0xc00004e7e0 sp=0xc00004e628 pc=0x42aecf
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004e7e8 sp=0xc00004e7e0 pc=0x4731c1
created by runtime.createfing
/usr/local/go/src/runtime/mfinal.go:157 +0x45
goroutine 6 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000050750 sp=0xc000050730 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0000507e0 sp=0xc000050750 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000507e8 sp=0xc0000507e0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 7 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000050f50 sp=0xc000050f30 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc000050fe0 sp=0xc000050f50 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000050fe8 sp=0xc000050fe0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 8 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000051750 sp=0xc000051730 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0000517e0 sp=0xc000051750 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000517e8 sp=0xc0000517e0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 9 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc000051f50 sp=0xc000051f30 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc000051fe0 sp=0xc000051f50 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000051fe8 sp=0xc000051fe0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 10 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004a750 sp=0xc00004a730 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00004a7e0 sp=0xc00004a750 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004a7e8 sp=0xc00004a7e0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 11 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004af50 sp=0xc00004af30 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00004afe0 sp=0xc00004af50 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004afe8 sp=0xc00004afe0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 12 [GC worker (idle)]:
runtime.gopark(0x177217fab135?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004b750 sp=0xc00004b730 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00004b7e0 sp=0xc00004b750 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004b7e8 sp=0xc00004b7e0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
goroutine 13 [GC worker (idle)]:
runtime.gopark(0x177217fab119?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004bf50 sp=0xc00004bf30 pc=0x449f16
runtime.gcBgMarkWorker()
/usr/local/go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00004bfe0 sp=0xc00004bf50 pc=0x42dd11
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0x4731c1
created by runtime.gcBgMarkStartWorkers
/usr/local/go/src/runtime/mgc.go:1159 +0x25
exit status 2
I've the following error:
`../testdata/camel.heic: heif: no EXIF found
unexpected fault address 0x7f3c51b1e010
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f3c51b1e010 pc=0x4cdf70]
goroutine 1 [running]:
runtime.throw(0x569c6d, 0x5)
/usr/local/go/src/runtime/panic.go:1116 +0x72 fp=0xc00012b390 sp=0xc00012b360 pc=0x445172
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:702 +0x3cc fp=0xc00012b3c0 sp=0xc00012b390 pc=0x4590dc
image/jpeg.yCbCrToYCbCr(0xc000116100, 0x0, 0x0, 0xc00012b4c0, 0xc00012b9c0, 0xc00012b5c0)
/usr/local/go/src/image/jpeg/writer.go:461 +0x140 fp=0xc00012b438 sp=0xc00012b3c0 pc=0x4cdf70
image/jpeg.(*encoder).writeSOS(0xc00014a000, 0x58d020, 0xc000116100)
/usr/local/go/src/image/jpeg/writer.go:547 +0x383 fp=0xc00012bde8 sp=0xc00012b438 pc=0x4ce503
image/jpeg.Encode(0x58bf60, 0xc00000fa00, 0x58d020, 0xc000116100, 0x0, 0x58bf60, 0xc00000fa00)
/usr/local/go/src/image/jpeg/writer.go:634 +0x299 fp=0xc00012be60 sp=0xc00012bde8 pc=0x4ceac9
main.main()
/home/chillaso/proyectos/goheif/heic2jpg/main.go:93 +0x2fa fp=0xc00012bf88 sp=0xc00012be60 pc=0x4e054a
runtime.main()
/usr/local/go/src/runtime/proc.go:203 +0x1fa fp=0xc00012bfe0 sp=0xc00012bf88 pc=0x4477da
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00012bfe8 sp=0xc00012bfe0 pc=0x472071`
I'm using Ubuntu 20.04. GCC 9.3.0 and go 1.14 in a linux/amd64
There are compiler warnings being generated when this is included in any build. Builds should be able to complete with no warnings. We have an automated build process and it will mark any build as failed if there are warnings. One of those warnings is a constant that is redefined to a different value - that is a big warning flag for potential bugs.
In general it's not good practice to ignore compiler warnings.
# github.com/jdeng/goheif/libde265
In file included from libde265-all.inl:37:0,
from libde265.cc:2:
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/slice.cc:2447:0: warning: "MAX_PREFIX" redefined
#define MAX_PREFIX 64
In file included from libde265-all.inl:13:0,
from libde265.cc:2:
../../go/pkg/mod/github.com/jdeng/[email protected]/libde265/libde265/cabac.cc:419:0: note: this is the location of the previous definition
#define MAX_PREFIX 32
cc1plus: warning: unrecognized command line option ‘-Wno-constant-conversion’
I actually spent some time on this, and the rabbit hole goes deeper than you would expect. Here's what I've gleaned:
libde265
repo uses CMake to generate intermediate files based on the target platform.goheif
repo has made enough of these changes directly to the source to allow the build to pass.Here are the differences between https://github.com/strukturag/libde265/tree/v1.0.8/libde265 and https://github.com/adrium/goheif/tree/master/libde265/libde265:
diff --git a/libde265/cabac.cc b/libde265/cabac.cc
index 102bc57e..6ea5b5ba 100644
--- a/libde265/cabac.cc
+++ b/libde265/cabac.cc
@@ -416,8 +416,6 @@ int decode_CABAC_TR_bypass(CABAC_decoder* decoder, int cRiceParam, int cTRMax)
}
-#define MAX_PREFIX 32
-
int decode_CABAC_EGk_bypass(CABAC_decoder* decoder, int k)
{
int base=0;
@@ -433,7 +431,7 @@ int decode_CABAC_EGk_bypass(CABAC_decoder* decoder, int k)
n++;
}
- if (n == k+MAX_PREFIX) {
+ if (n == k+32) {
return 0; // TODO: error
}
}
diff --git a/libde265/fallback-motion.cc b/libde265/fallback-motion.cc
index 1ac41da4..3a386e23 100644
--- a/libde265/fallback-motion.cc
+++ b/libde265/fallback-motion.cc
@@ -475,8 +475,8 @@ void put_qpel_0_0_fallback_16(int16_t *out, ptrdiff_t out_stride,
-static int extra_before[4] = { 0,3,3,2 };
-static int extra_after [4] = { 0,3,4,4 };
+static int fallback_extra_before[4] = { 0,3,3,2 };
+static int fallback_extra_after [4] = { 0,3,4,4 };
template <class pixel_t>
void put_qpel_fallback(int16_t *out, ptrdiff_t out_stride,
@@ -484,10 +484,10 @@ void put_qpel_fallback(int16_t *out, ptrdiff_t out_stride,
int nPbW, int nPbH, int16_t* mcbuffer,
int xFracL, int yFracL, int bit_depth)
{
- int extra_left = extra_before[xFracL];
- //int extra_right = extra_after [xFracL];
- int extra_top = extra_before[yFracL];
- int extra_bottom = extra_after [yFracL];
+ int extra_left = fallback_extra_before[xFracL];
+ //int extra_right = fallback_extra_after [xFracL];
+ int extra_top = fallback_extra_before[yFracL];
+ int extra_bottom = fallback_extra_after [yFracL];
//int nPbW_extra = extra_left + nPbW + extra_right;
int nPbH_extra = extra_top + nPbH + extra_bottom;
diff --git a/libde265/slice.cc b/libde265/slice.cc
index e85ecc61..5e8a6f8e 100644
--- a/libde265/slice.cc
+++ b/libde265/slice.cc
@@ -2444,8 +2444,6 @@ static int decode_coeff_abs_level_greater2(thread_context* tctx,
}
-#define MAX_PREFIX 64
-
static int decode_coeff_abs_level_remaining(thread_context* tctx,
int cRiceParam)
{
@@ -2457,7 +2455,7 @@ static int decode_coeff_abs_level_remaining(thread_context* tctx,
prefix++;
codeword = decode_CABAC_bypass(&tctx->cabac_decoder);
- if (prefix>MAX_PREFIX) {
+ if (prefix>64) {
return 0; // TODO: error
}
}
Originally posted by @tagatac in #21 (comment)
It is segfaulting in both alpine and stretch...
It is not segfaulting on my dev env on OSX. What's weird is that the segfaults happens when trying to write to jpeg the already decoded heic image.
To reproduce:
Dockerfile
:
FROM golang:alpine3.8
RUN apk --no-cache add build-base git
RUN go get github.com/jdeng/goheif/...
WORKDIR /tmp
COPY test.heic .
CMD ["heic2jpg", "test.heic", "test.jpg"]
-or-
FROM golang:stretch
RUN apt-get update && apt-get install -y build-essential git
RUN go get github.com/jdeng/goheif/...
WORKDIR /tmp
COPY test.heic .
CMD ["heic2jpg", "test.heic", "test.jpg"]
Then...
$ docker build -t test .
$ docker run -it --rm test
outputs:
2019/03/28 09:07:37 Warning: no EXIF from test.heic: heif: no EXIF found
unexpected fault address 0x7f6cc965b020
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f6cc965b020 pc=0x4d11dd]
goroutine 1 [running]:
runtime.throw(0x55d0a0, 0x5)
/usr/local/go/src/runtime/panic.go:608 +0x72 fp=0xc0000c12c8 sp=0xc0000c1298 pc=0x43bf62
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:397 +0x275 fp=0xc0000c1318 sp=0xc0000c12c8 pc=0x44eef5
image/jpeg.yCbCrToYCbCr(0xc0000a8100, 0x0, 0x0, 0xc0000c1418, 0xc0000c1918, 0xc0000c1518)
/usr/local/go/src/image/jpeg/writer.go:461 +0x13d fp=0xc0000c1390 sp=0xc0000c1318 pc=0x4d11dd
image/jpeg.(*encoder).writeSOS(0xc0000b80c0, 0x576860, 0xc0000a8100)
/usr/local/go/src/image/jpeg/writer.go:547 +0x398 fp=0xc0000c1d40 sp=0xc0000c1390 pc=0x4d1708
image/jpeg.Encode(0x576280, 0xc000091940, 0x576860, 0xc0000a8100, 0x0, 0x576280, 0xc000091940)
/usr/local/go/src/image/jpeg/writer.go:634 +0x2b0 fp=0xc0000c1dc0 sp=0xc0000c1d40 pc=0x4d1c10
main.main()
/go/src/github.com/jdeng/goheif/heic2jpg/main.go:92 +0x528 fp=0xc0000c1f98 sp=0xc0000c1dc0 pc=0x4d2be8
runtime.main()
/usr/local/go/src/runtime/proc.go:201 +0x207 fp=0xc0000c1fe0 sp=0xc0000c1f98 pc=0x43d8d7
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000c1fe8 sp=0xc0000c1fe0 pc=0x465bc1
The heic
sample file is this one: http://jpgtoheif.com/camel.heic
Hey there, this is a long shot I was unsure if I should put this one here or not
When deploying to app engine Go Build fails with "no buildable Go source files in /go/src/github.com/jdeng/goheif/libde265"
However I can compile / build / run and test the process locally, it just buggers up when I involve App engine deploy for some reason
------------------------------------ STDOUT ------------------------------------
building with dependencies from GOPATH
------------------------------------ STDERR ------------------------------------
2019/04/26 13:13:32 staging for go1.11
2019/04/26 13:13:32 Staging second-gen Standard app: failed analyzing /Users/dimitri/Desktop/xxx/service: no buildable Go source files in /go/src/github.com/jdeng/goheif/libde265
GOPATH: /go:/Users/dimitri/Documents/go_appengine:/Users/dimitri/Documents/GoLangExt:/Users/dimitri/go
--------------------------------------------------------------------------------
I have definitely checked /go/src/github.com/jdeng/goheif/libde265
- and as I said my local tests work fine (converts image from heic to jpg)
here's the log i see:
images# go get github.com/jdeng/goheif/...
# github.com/jdeng/goheif/libde265
In file included from libde265-all.inl:37:0,
from libde265.cc:2:
src/github.com/jdeng/goheif/libde265/libde265/slice.cc:2447:0: warning: "MAX_PREFIX" redefined
#define MAX_PREFIX 64
In file included from libde265-all.inl:13:0,
from libde265.cc:2:
src/github.com/jdeng/goheif/libde265/libde265/cabac.cc:419:0: note: this is the location of the previous definition
#define MAX_PREFIX 32
cc1plus: warning: unrecognized command line option ‘-Wno-constant-conversion’
# github.com/jdeng/goheif/heic2jpg
src/github.com/jdeng/goheif/heic2jpg/main.go:80:14: undefined: goheif.DecodeImage
images#
g++: error: unrecognized command-line option ‘-msse4.1’
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.