{"id":13732034,"url":"https://github.com/richgel999/bc7enc16","last_synced_at":"2025-05-02T22:31:22.407Z","repository":{"id":81004126,"uuid":"131220142","full_name":"richgel999/bc7enc16","owner":"richgel999","description":"Fast single source file BC7/BPTC texture encoder with perceptual metric support","archived":false,"fork":false,"pushed_at":"2023-04-24T01:46:00.000Z","size":136,"stargazers_count":154,"open_issues_count":1,"forks_count":10,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-07T07:43:04.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richgel999.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-04-26T23:14:20.000Z","updated_at":"2025-02-18T14:02:09.000Z","dependencies_parsed_at":"2024-01-31T04:12:35.746Z","dependency_job_id":"c922224b-4c04-4485-881f-7acb2ad79f91","html_url":"https://github.com/richgel999/bc7enc16","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richgel999%2Fbc7enc16","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richgel999%2Fbc7enc16/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richgel999%2Fbc7enc16/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richgel999%2Fbc7enc16/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richgel999","download_url":"https://codeload.github.com/richgel999/bc7enc16/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252116252,"owners_count":21697342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T02:01:44.411Z","updated_at":"2025-05-02T22:31:17.399Z","avatar_url":"https://github.com/richgel999.png","language":"C++","funding_links":[],"categories":["Graphics"],"sub_categories":[],"readme":"bc7enc16 - Fast, single source file BC7/BPTC GPU texture encoder with perceptual colorspace metric support\n\nNote: Since this repo was created, we've released two new codecs with better BC7 encoders:\nhttps://github.com/richgel999/bc7enc_rdo\nhttps://github.com/BinomialLLC/bc7e\n\nbc7enc16 purposely only supports modes 1 and 6. This is a strong opaque texture encoder, with basic\nsupport for alpha channels (using mode 6). The intended use case is opaque textures, or opaque textures \nwith relatively simple alpha channels. It also acts as a relatively simple to understand example.\n\nIf alpha is highly correlated compared to RGB, or alpha is relatively simple\n(think simple masks where lots of blocks are either all-transparent or\nall-opaque), it should work great. For complex alpha channels more modes (such\nas 4, 5 or maybe 7) are necessary.\n\nThis codec supports a perceptual mode, where it computes colorspace error in\nweighted YCbCr space (like etc2comp), and it also supports weighted RGBA\nmetrics. It's particular strong in perceptual mode, beating the current state of\nthe art CPU encoder (Intel's ispc_texcomp) by a wide margin when measured by\nLuma PSNR, even though it only supports 2 modes and isn't vectorized.\n\nWhy only modes 1 and 6?\nBecause with these two modes you have a complete encoder that supports both\nopaque and transparent textures in a small amount (~1400 lines) of\nunderstandable plain C code. Mode 6 excels on smooth blocks, and mode 1 is\nstrong with complex blocks, and a strong encoder that combines both modes can be\nquite high quality. Fast mode 6-only encoders will have noticeable block\nartifacts which this codec avoids by fully supporting mode 1.\n\nModes 1 and 6 are typically the most used modes on many textures using other\nencoders. Mode 1 has two subsets, 64 possible partitions, and 3-bit indices,\nwhile mode 6 has large 4-bit indices and high precision 7777.1 endpoints. This\ncodec produces output that is far higher quality than any BC1 encoder, and\napproaches (or in perceptual mode exceeds!) the quality of other full BC7\nencoders.\n\nWhy is bc7enc16 so fast in perceptual mode?\nComputing error in YCbCr space is more expensive than in RGB space, yet bc7enc16\nin perceptual mode is stronger than ispc_texcomp (see the benchmark below) -\neven without SSE/AVX vectorization and with only 2 modes to work with!\n\nMost BC7 encoders only support linear RGB colorspace metrics, which is a\nfundamental weakness. Some support weighted RGB metrics, which is better. With\nlinear RGB metrics, encoding error is roughly balanced between each channel, and\nencoders have to work *very* hard (examining large amounts of RGB search space)\nto get overall quality up. With perceptual colorspace metrics, RGB error tends\nto become a bit unbalanced, with green quality favored more highly than red and\nblue, and blue quality favored the least. A perceptual encoder is tuned to\nprefer exploring solutions along the luma axis, where it's much less work to find\nsolutions with less luma error. bc7enc16 is, as far as I know, the first BC7\ncodec to support computing error in weighted YCbCr colorspace.\n\nNote: Most of the timings here (except for the ispc_texcomp \"fast\" mode timings at the very bottom)\nare for the *original* release, before I added several more optimizations. The latest version of \nbc7enc16.c is around 8-27% faster than the initial release at same quality (when mode 1 is enabled - \nthere's no change with just mode 6).\n\nSome benchmarks across 31 images (kodim corpus+others):\n\nPerceptual (average REC709 Luma PSNR - higher is better quality):\n\niscp_texcomp slow vs. bc7enc16 uber4/max_partitions 64\niscp_texcomp:   355.4 secs 48.6 dB\nbc7enc16:       122.6 secs 50.0 dB\n\niscp_texcomp slow vs. bc7enc16 uber0/max_partitions 64\niscp_texcomp:   355.4 secs 48.6 dB\nbc7enc16:       38.3 secs 49.6 dB\n\niscp_texcomp basic vs. bc7enc16 uber0/max_partitions 16\nispc_texcomp:   100.2 secs 48.3 dB\nbc7enc16:       20.8 secs 49.3 dB \n\niscp_texcomp fast vs. bc7enc16 uber0/max_partitions 16\niscp_texcomp:   41.5 secs 48.0 dB \nbc7enc16:       20.8 secs 49.3 dB\n\niscp_texcomp ultrafast vs. bc7enc16 uber0/max_partitions 0\niscp_texcomp:   1.9 secs 46.2 dB\nbc7enc16:       8.9 secs 48.4 dB \n\nNon-perceptual (average RGB PSNR):\n\niscp_texcomp slow vs. bc7enc16 uber4/max_partitions 64\niscp_texcomp:   355.4 secs 46.8 dB \nbc7enc16:       51 secs 46.1 dB\n\niscp_texcomp slow vs. bc7enc16 uber0/max_partitions 64\niscp_texcomp:   355.4 secs 46.8 dB\nbc7enc16:       29.3 secs 45.8 dB\n\niscp_texcomp basic vs. bc7enc16 uber4/max_partitions 64\niscp_texcomp:   99.9 secs 46.5 dB\nbc7enc16:       51 secs 46.1 dB\n\niscp_texcomp fast vs. bc7enc16 uber1/max_partitions 16\nispc_texcomp:   41.5 secs 46.1 dB\nbc7enc16:       19.8 secs 45.5 dB\n\niscp_texcomp fast vs. bc7enc16 uber0/max_partitions 8\nispc_texcomp:   41.5 secs 46.1 dB\nbc7enc16:       10.46 secs 44.4 dB\n\niscp_texcomp ultrafast vs. bc7enc16 uber0/max_partitions 0\nispc_texcomp:   1.9 secs 42.7 dB \nbc7enc16:       3.8 secs 42.7 dB\n\nDirectXTex CPU in \"mode 6 only\" mode vs. bc7enc16 uber1/max_partions 0 (mode 6 only), non-perceptual:\n\nDirectXTex:     466.4 secs 41.9 dB \nbc7enc16:       6.7 secs 42.8 dB\n\nDirectXTex CPU in (default - no 3 subset modes) vs. bc7enc16 uber1/max_partions 64, non-perceptual:\n\nDirectXTex:     9485.1 secs 45.6 dB \nbc7enc16:       36 secs 46.0 dB\n\n(Note this version of DirectXTex has a key pbit bugfix which I've submitted but\nis still waiting to be accepted. Non-bugfixed versions will be slightly lower\nquality.)\n\nUPDATE: To illustrate how strong the mode 1+6 implementation is in bc7enc16, let's compare ispc_texcomp \nfast vs. the latest version of bc7enc16 uber4/max_partitions 64:\n\nWithout filterbank optimizations:\n\n                Time       RGB PSNR   Y PSNR\nispc_texcomp:   41.45 secs 46.09 dB   48.0 dB\nbc7enc16:       41.42 secs 46.03 dB   48.2 dB\n\nWith filterbank optimizations enabled:\nbc7enc16:       38.78 secs 45.94 dB   48.12 dB\n\nThey both have virtually the same average RGB PSNR with these settings (.06 dB is basically noise), but \nbc7enc16 is just as fast as ispc_texcomp fast, even though it's not vectorized. Interestingly, our Y PSNR is better, \nalthough bc7enc16 wasn't using perceptual metrics in these benchmarks. \n\nThis was a multithreaded benchmark (using OpenMP) on a dual Xeon workstation.\nispc_texcomp was called with 64-blocks at a time and used AVX instructions.\nTimings are for encoding only.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichgel999%2Fbc7enc16","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichgel999%2Fbc7enc16","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichgel999%2Fbc7enc16/lists"}