-
Notifications
You must be signed in to change notification settings - Fork 122
Mode Bm #53
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
Mode Bm #53
Conversation
Autodetect will work for B, 4C, and the new experimental mode Bm. (using the old 8c icon as a placeholder, but will get that sorted out shortly)
7561ff0a Update other cli tools to work with new config paradigm 8983eff9 Update cli tools (send/recv) to support new config system baaa4581 Add a rotate_window (enc) c api call and remove the js-side rotation hack 26b0dc29 weird hacks dept: fix issue where nav button is on top of canvas 736daf64 Shrink mode selection UI to one nav line 905c6390 Add "mode Bm" option to cimbar_send page 98fca1cf Merge pull request #145 from sz3/improve-encode-capi 4086d16f Add a test for the no-op/flush cimbare_encode() usage + ... 7793a330 JS encoder: split file encode into multiple calls, and loop over the file 00a7f472 Reorganizing the encoder c api to (hopefully) lessen OOM errors a10cbde4 Merge pull request #144 from sz3/simplify-decode-capi b8b90e1a Actually delete the dead code :) 9b9d523d Fix race condition in test, and add test timeout e3a3fe5a Fix the js test; fix a bug d7f669b2 Just use resize event listener, what are we doing man 41bfb600 Switch web decoder to use new C api pattern 55abfdbb The simplified capi for decodes. cab0eaab I don't think we actually want to store more than one of these at a time. 8d624091 Merge pull request #143 from sz3/config-system-update f0b16a55 Fix configuration for web encoder/decoder 30d14477 Push more config methods into GridConf so we can query a non-loaded config 4f1be773 Update other grid configs in the new config syntax 73a246cf Lazy eval the config inside the Decoder::decode() functions 49fd1227 Fix tests, fix refactor 92f02cd3 WIP: rewrite of config checks to use static threadlocal a6a45cd2 fix build warnings git-subtree-dir: app/src/cpp/libcimbar git-subtree-split: 7561ff0a3fa8a45d7a753ca9db1137817201f636
Mergin sz3/libcimbar#146, a.k.a libcimbar:7561ff0a3fa8a45d7a753ca9db1137817201f636. Will be equivalent to the 0.6.3 libcimbar release. Includes mode Bm and the new config system (sz3/libcimbar#143)
| int color_correction = legacy_mode? 1 : 2; | ||
| unsigned color_mode = legacy_mode? 0 : 1; | ||
| unsigned decodeRes = _dec.decode_fountain(img, _writer, color_mode, should_preprocess, color_correction); | ||
| int color_correction = modeVal==4? 1 : 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a (minor) footgun that libcimbar probably needs to handle better: color_correction==2 should be (and is) the default, but it doesn't work for the original version of the format (mode 4C). In fact, that's the whole reason mode B exists to begin with...
| unsigned modeVal = _modeVal; | ||
| if (modeVal == 0) | ||
| { | ||
| switch (count%3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mod 2, now we mod 3.
At some number of distinct configs this will fall over, but for now it's still ok to cycle through all configs.
| unsigned MultiThreadedDecoder::fountain_chunk_size(int mode_val) | ||
| { | ||
| return cimbar::Config::fountain_chunk_size(cimbar::Config::ecc_bytes(), cimbar::Config::symbol_bits() + cimbar::Config::color_bits(), mode_val==4); | ||
| return cimbar::Config::temp_conf(mode_val).fountain_chunk_size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much nicer.
| @Override | ||
| public void run() { | ||
| mModeSwitch.setChecked(true); | ||
| mModeSwitch.setModeVal(detectedMode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting rid of the hack.
| super(context, attrs); | ||
| } | ||
|
|
||
| public ModeSelToggle(Context context, AttributeSet attrs, int defStyleAttr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used some LLM-generated code to get the boilerplate right here. My current method is to generate something, take it apart, search the docs/internet, generate it a couple more times (in a fresh context) to see what's different, then manually distill all that into something that doesn't seem like a copypasted stackoverflow answer (not that there's anything wrong with that...)
| @Override | ||
| protected int[] onCreateDrawableState(int extraSpace) { | ||
| // 1. Get the current standard drawable states (includes state_checked) | ||
| final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think +1 should be ok here, but I'm not 100% sure. +2 would be safer but seems (hopefully?) unnecessary.
| app:state_modebm="true" | ||
| android:drawable="@drawable/ic_modebm"/> | ||
|
|
||
| <item android:state_checked="true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are evaluated top to bottom, so the default (as long as it's at the bottom) doesn't need any state_* check.
to quote myself from sz3/libcimbar#146
As far as usage goes, all you have to do is select "Bm" when using the web encoder (or pass
--mode Bmto thecimbar_sendcli), and the autodetect logic on the decoder should figure it out.Code changes:
state_activatedand hoping for the best. Now things are done the correct way (afaik), with custom state passed to represent our "3 different states of 'on'" on/off button. The result is the same as before: "off" represents autodetect, while "on" shows whatever the current autodetected mode is.