Skip to content

update docs on scaling limits #15

Closed

Description

@focalintent

Need to make some of the side effects of inline scaling clearer (eg 255 scales to 254 and 1 to 0)

Activity

  1. kriegsman commented on Jan 24, 2014

    @kriegsman
    Member

    I sometimes wonder if we should somehow provide a way of disabling scaling -- or adjust the scaling math so that a brightness of "255" has the effect of 'no scaling'.

    We currently have:

    output = scale8( input, scalefactor);
    

    The 'new math' would be (in it's worst case, see below for improvement) :

    if( input == 0 || scalefactor == 0) {
      output = 0;
    } else {
      output = scale8( input, scalefactor);
      output++; // new adjustment
    }
    

    I hate having to special case the '|| scalefactor == 0' in the conditional like that. If we had one test at the start of the loop to see if scalefactor == 0, and if so, just basically showColor( CRGB::Black), then all we'd have for each byte is:

    if( input == 0 ) {
      output = 0;
    } else {
      output = scale8( input, scalefactor);
      output++; // new adjustment
    }
    

    Given the AVR instruction set it might be better to do it this way:

    output = scale8( input, scalefactor);
    if( input != 0) {
      output++;
    }
    

    There's another way to get to the same result (or a similarly good one) using temporal dithering, but that's another can of split loom cable ducting.

  2. kriegsman commented on Jan 24, 2014

    @kriegsman
    Member

    Er, now that I think about it, scale8 could do rounding with two more instructions.

    Right now, it does

    output = highByte( input * scalefactor );
    

    But what's really going on is

    r1,r0 = input * scalefactor;
    output = r1;
    

    A 'rounding version' could do this:

    r1,r0 = input * scalefactor;
    if( r0 & 0x80 ) {
      r1++;
    }
    output = r1;
    

    Just thinking out loud.

  3. kriegsman commented on Feb 24, 2014

    @kriegsman
    Member

    Never mind. See also: Moon.

    But we will need to update the docs. A bit.

  4. self-assigned this
    on Apr 18, 2014
  5. kriegsman commented on Apr 18, 2014

    @kriegsman
    Member

    I'm going to close this ticket since due to Moon (temporal dithering et al) in v2.1, it's a completely different game.

    The work for ticket #49 could touch on this, but again, it's a very different situation now and I think the need to document scaling in the way envisioned by this ticket is pretty much gone now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions