# Search:

Type: Posts; User: hamster_nz

Page 1 of 13 1

1. ## Thread: Help with C combinatronics problem

by hamster_nz
Replies
14
Views
411

### opps... sorry for the error in my code. Glad...

opps... sorry for the error in my code. Glad john.c picked it up.

Oh, and yes, I have pretty much the same picture that john.c drew scribbled on a bit of scrap paper. The hard bit is deciding...
2. ## Thread: Help with C combinatronics problem

by hamster_nz
Replies
14
Views
411

### If you draw a picture of what can follow what (a...

If you draw a picture of what can follow what (a state diagram), and allow for the fact that you have to end where you can start (so it is a loop) you get

necklace_length( t, r, s, e )
if...

by hamster_nz
Replies
10
Views
443

### Hi Alin, I've written a PNG file decoder...

Hi Alin,

I've written a PNG file decoder earlier this year. Here's how it works,

There is a small wrapper that has the signature, image size and some other details in it, including color depth...
4. ## Thread: de-filtering a 4 bit depth png image

by hamster_nz
Replies
8
Views
733

### Here's my equivalent: int32_t...

Here's my equivalent:

int32_t a=0,b=0,c=0;
if(x > bytes_per_pixel) {
a = img->scanline[y]->data[x-bytes_per_pixel];
}
if(y >...
5. ## Thread: Shift array elements

by hamster_nz
Replies
5
Views
426

### Maybe you might want to add a couple of...

Maybe you might want to add a couple of functions, making you 'main()' function look something like this:

int main ()
{
int p[5]={15,30,28,19,61};

printArray("Before shift", p,...
6. ## Thread: de-filtering a 4 bit depth png image

by hamster_nz
Replies
8
Views
733

### expected = 000003F7, actual = CF2F0849 ?

expected = 000003F7, actual = CF2F0849

?
7. ## Thread: What should I learn after C standard syntax?

by hamster_nz
Replies
2
Views
390

### The printf/scanf format strings.

The printf/scanf format strings.
8. ## Thread: 'unit8_t' undeclared (first use in this function)

by hamster_nz
Replies
6
Views
513

### You are seeing 3 because overflows are not...

You are seeing 3 because overflows are not errors.

Think of it like being 'clock' arithmetic, where 11:00 plus 3 hours equals 2:00.

For 8-bit unsigned numbers 0 follows after 255.
9. ## Thread: 'unit8_t' undeclared (first use in this function)

by hamster_nz
Replies
6
Views
513

### You have a typo. It is uint8_t not unit8_t.

You have a typo. It is uint8_t not unit8_t.
10. ## Thread: Final filter test failing

by hamster_nz
Replies
3
Views
410

### Just by eyeballing them I can tell that they are...

Just by eyeballing them I can tell that they are good. They start at "all zeros" and end at "all ones".

But will supply a table when I finish work (in about 9 hours or so).

by hamster_nz
Replies
2
Views
366

### For a given block of data, prior_key is ...

For a given block of data, prior_key is 0x00000001 for the first time the function is called, and from then on whatever was returned by this function the last time it was called.
12. ## Thread: Scaling integer values without FPNs

by hamster_nz
Replies
4
Views
383

### The usual way to scale an n-bit value into a...

The usual way to scale an n-bit value into a 2n-bit value is to multiply by 2^n+1.

e.g. from a 4-bit value to an 8-bit value is to multiply by 17.

Coding it is usually a shift-and-add:

...
13. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### Here's 37 lines that does those 200 lines...

Here's 37 lines that does those 200 lines correctly. Note how everything is handled identically.

static const int32_t lut_code[19] = { 0, 1, 2, 3, 4, 5, 6, 7, 8,...
14. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

You still need to adjust the rest of your code accordingly too.

This change means that you will only need to add entries to your table in one place in your code, rather than handling those 16 and...
15. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### I think you might end up with cleaner code if you...

I think you might end up with cleaner code if you realized that

ZLIB_IMPLIED implied_type_data =
{
/* get extra bits */
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,...
16. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### Looking at your output, the first table seems...

Looking at your output, the first table seems perfect.

The second one has literals that should not occur. 386? 404? 382?

code_symbols[ 0]: _tt = false, src = 138, lit = 283, use = ...
17. ## Thread: Dynamic memory allocation

by hamster_nz
Replies
20
Views
1,223

### It is very hard to track down if you mave a...

It is very hard to track down if you mave a memory leak in your code if it doesn't free all resources before exiting.

Also, usually tidying up before exiting can involve such things as writing...
18. ## Thread: Dynamic memory allocation

by hamster_nz
Replies
20
Views
1,223

### I strongly disagree with this advice....

I strongly disagree with this advice. "Maintaining a lost of allocated memory blocks" is exactly what malloc(), free(), realloc() and so on do on the inside, and usually do it in a far more nuanced...
19. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### As requested Note that "x:y" is value x, with...

As requested

Note that "x:y" is value x, with repeat count y.

Image is properly decoded.

Last block = true
Compressed (dynamic dictionary)
20. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### If you can supply me a test '.gz' data file you...

If you can supply me a test '.gz' data file you are using, I can send back what the correct codeword tables should be for that file.
21. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### Here's the whole algorithm at a very high level:...

Here's the whole algorithm at a very high level:

1. Read in the three 5-bit values, hlit, hdist and hclen. Note that these need to have 257, 1 and 4 added to the 5-bit binary values that are read....
22. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### I did try taking a look at your code, but without...

I did try taking a look at your code, but without comments to let me know what each step was doing I was unable to follow what was being attempted.
23. ## Thread: Finding a reference error by mathematical conditioning

by hamster_nz
Replies
5
Views
438

### It is a pretty common pattern that people use....

It is a pretty common pattern that people use. Not because it is particularly nice, but just because it fits on one line.
24. ## Thread: Finding a reference error by mathematical conditioning

by hamster_nz
Replies
5
Views
438

### '?' is the ternary operator. It is clamping x...

'?' is the ternary operator.

It is clamping x to between 0.0 an 0.35

Translated:

If x > 0.35 then
Use 0.35

Else If x < 0.0 then
25. ## Thread: Increment gone wrong

by hamster_nz
Replies
125
Views
8,320

### What you said there makes little sense to me. I...

What you said there makes little sense to me. I think you need to carefully consider the structure of the file and re-evaluate how you are processing it.

Map out what the possible inputs are (the...
Results 1 to 25 of 309
Page 1 of 13 1