Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it takes 4 seconds for 4K image HEIC to decodie #552

Open
ByteYIFFF opened this issue Oct 20, 2021 · 10 comments
Open

it takes 4 seconds for 4K image HEIC to decodie #552

ByteYIFFF opened this issue Oct 20, 2021 · 10 comments

Comments

@ByteYIFFF
Copy link

Is there any way to speed up decodin. e.g.:heif_decode_image
2021-10-20 112837.zip
g

@farindk
Copy link
Contributor

farindk commented Oct 23, 2021

For me 0,8s on a 4770k CPU including writing two images to JPEG:

$ time heif-convert 2021-10-20\ 112837.heic out.jpg
File contains 1 images
Written to out.jpg
Auxiliary image written to out-urn:com:apple:photo:2020:aux:hdrgainmap.jpg

real	0m0,843s

@homm
Copy link
Contributor

homm commented Oct 28, 2021

It should be at least two times faster (mobile i5-8279U). See #551 and #555.

In [1]: from HeifImagePlugin import Image, pyheif

In [2]: data = open('./2021-10-20 112837.heic', 'rb').read()

In [3]: %%time
   ...: heif_file = pyheif.read(data, apply_transformations=False)
   ...: image = Image.frombytes(
   ...:     heif_file.mode, heif_file.size, heif_file.data,
   ...:     "raw", heif_file.mode, heif_file.stride)
   ...:
CPU times: user 709 ms, sys: 79.5 ms, total: 788 ms
Wall time: 279 ms

@ByteYIFFF
Copy link
Author

the problem still exists。And heif_decode_image runs slowly. Is it related to my libheif version? Are you using the master branch?

@ByteYIFFF
Copy link
Author

It should be at least two times faster (mobile i5-8279U). See #551 and #555.

In [1]: from HeifImagePlugin import Image, pyheif                                                                               

In [2]: data = open('./2021-10-20 112837.heic', 'rb').read()                                                                    

In [3]: %%time 
   ...: heif_file = pyheif.read(data, apply_transformations=False) 
   ...: image = Image.frombytes( 
   ...:     heif_file.mode, heif_file.size, heif_file.data, 
   ...:     "raw", heif_file.mode, heif_file.stride) 
   ...:                                                                                                                         
CPU times: user 709 ms, sys: 79.5 ms, total: 788 ms
Wall time: 279 ms

my cpu is i7-8700K. my version is v.1.12.0.
@homm

@ByteYIFFF
Copy link
Author

hi.guys~
i know why it takes too much time for decoding.Because I choose to acquire RGB data.if i acquire yuv, the decoding will be qiuck.

@ByteYIFFF ByteYIFFF reopened this Nov 9, 2021
@ByteYIFFF
Copy link
Author

ByteYIFFF commented Nov 9, 2021

对于我在 4770k CPU 上的 0.8 秒,包括将两个图像写入 JPEG:

$ time heif-convert 2021-10-20\ 112837.heic out.jpg
File contains 1 images
Written to out.jpg
Auxiliary image written to out-urn:com:apple:photo:2020:aux:hdrgainmap.jpg

real	0m0,843s

please,try to transform HEIC to a PNG picture. i guess that it will need more time to decode. @farindk

@homm
Copy link
Contributor

homm commented Nov 9, 2021

So it takes 4 seconds for 4K image to encode in PNG, right?

@ByteYIFFF
Copy link
Author

So it takes 4 seconds for 4K image to encode in PNG, right?

"i know why it takes too much time for decoding.Because I choose to acquire RGB data.if i acquire yuv, the decoding will be qiuck."------this is my guess.

in my computer, for a 4K heic, it takes 2second to run this code (heif_decode_image(handle, &img, heif_colorspace_RGB, heif_chroma_interleaved_RGBA, nullptr) @homm

@ByteYIFFF ByteYIFFF changed the title it takes 4 seconds for 4K image HEIC to decodie,too slow~ it takes 4 seconds for 4K image HEIC to decodie Nov 12, 2021
@ByteYIFFF
Copy link
Author

所以 4K 图像在 PNG 中编码需要 4 秒,对吗?

in fact, when i decode image in YCBCR, the time not reduce. @homm

@freemedom
Copy link

Why are heic images about 10 times slower than jpg? (generate thumbnails) Because heic doesn't have hardware acceleration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants