Bug 222

Summary: JPEG optimizations
Product: Libre-SOC's first SoC Reporter: cand
Component: Source CodeAssignee: Jacob Lifshay <programmerjake>
Status: RESOLVED FIXED    
Severity: enhancement CC: libre-soc-bugs, lkcl, programmerjake
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Linux   
See Also: http://bugs.libre-riscv.org/show_bug.cgi?id=230
https://bugs.libre-soc.org/show_bug.cgi?id=659
https://bugs.libre-soc.org/show_bug.cgi?id=935
NLnet milestone: NLNet.2019.10.031.Video total budget (EUR) for completion of task and all subtasks: 1500
budget (EUR) for this task, excluding subtasks' budget: 1500 parent task for budget allocation: 137
child tasks for budget allocation: The table of payments (in EUR) for this task; TOML format:
lkcl = { amount = 300, submitted = 2022-10-04, paid = 2022-10-11 } [jacob] amount = 1200 submitted = 2022-10-03 paid = 2022-10-14
Bug Depends on: 933    
Bug Blocks: 137    

Description cand 2020-03-13 09:55:55 GMT
Optimizing JPEG code in libjpeg-turbo with new instructions.
Comment 1 Jacob Lifshay 2022-09-19 18:33:07 BST
I'd like to work on the huffman coding, since that seems like the least straightforward part that has been SIMD-ified before (all of the other parts are simple image format conversions or DCT stuff):

SSE2 assembly:
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/2cad2169aeed95569b0e25b0a2abef045a2a4eb9/simd/x86_64/jchuff-sse2.asm
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/2cad2169aeed95569b0e25b0a2abef045a2a4eb9/simd/x86_64/jcphuff-sse2.asm
Comment 2 Luke Kenneth Casson Leighton 2022-09-19 19:03:37 BST
intriguing one - involving frequency-identification and sorting.
https://www.programiz.com/dsa/huffman-coding
Comment 3 Jacob Lifshay 2022-09-20 01:40:30 BST
jpeg spec: https://www.w3.org/Graphics/JPEG/itu-t81.pdf

reading through it (annoyingly it has no section links, so it makes it harder to find stuff), looks kinda complex so far...may have to reduce scope in order to finish before nlnet's deadline
Comment 4 Luke Kenneth Casson Leighton 2022-09-20 08:19:02 BST
(In reply to Jacob Lifshay from comment #3)
> jpeg spec: https://www.w3.org/Graphics/JPEG/itu-t81.pdf
> 
> reading through it (annoyingly it has no section links, so it makes it
> harder to find stuff), looks kinda complex so far...may have to reduce scope
> in order to finish before nlnet's deadline

that was always the plan: there is far too much to take on otherwise.
absolute maximum 60-100 lines of assembler, one key function.
Comment 5 Jacob Lifshay 2022-09-27 05:10:01 BST
working on adding a minimal JPEG decoder for extracting test data that's 90% of what's needed:

commit f930c453550ca201e441f266623c3eb40fd6d9af (HEAD -> master, origin/master, origin/HEAD)
Author: Jacob Lifshay <programmerjake@gmail.com>
Date:   Mon Sep 26 21:05:38 2022 -0700

    add WIP jpeg decoder demo
    
    this includes a tiny test jpeg that's <2kB, so should be fine to be in git.
Comment 6 Jacob Lifshay 2022-09-27 05:12:09 BST
(In reply to Jacob Lifshay from comment #5)
> working on adding a minimal JPEG decoder for extracting test data that's 90%
> of what's needed:

I realized that I wasn't very clear: I meant that I have that test-data-extracting decoder 90% completed.
Comment 7 Jacob Lifshay 2022-10-03 23:29:18 BST
Marking this resolved -- pcdec. is working and has working unit tests -- see #933.

#933 will stay open because pcdec. still has some design that needs to be done -- mostly deciding which exact set of 4 modes are needed.