0

Assume I have a ref (key) frame I encoded. Now I want to inter-predict the next frame called delta frame P. To do that I calculate motion vectors and find diff between compensated P and I. However, this diff can be quite huge in some cases. Given that my input color values are in range [0, 255] then the diff can be in [-255, 255] range. This is one more bit of information. How is this usually approached? Is this range scaled down to [-127, 127] or something like that? Or do we just compress higher-precision delta data?

EDIT:

Okay, so I did a few experiments:

a) compressing ref frame - resulting compression ratio x26

Then I took two similar frames and tested and got this:

b) before converting to luma-chroma, I take both frames in RGB, compute their xor and run luma-chroma and DCT - compression ratio x39 - severe artifacts show up

c) I take difference frame1-frame2 and output clamp(frame1-frame2, -0.5, 0.5) + 0.5 - compression ratio - x76

d) I compute DCT of both frame1 and frame2 and compute xor on that - compression ratio x72

So I don't see how b) would work - xoring input RGB doesn't make much sense for me. I think most efficient is c) as it also allows for blurring frame1 and frame2 before taking diff and thus greatly enhances compression

maxest
  • 89
  • 1
  • 10
  • use XOR to calculate the difference instead of subtraction. – szatmary Oct 21 '17 at 16:19
  • Sounds like a great idea. I've tried it but I'm getting quite a pixelated result. But please let me elaborate on how I do compression because that might me important. I started off with simple JPEGing each frame doing a full-blown implementation (one from here https://en.wikipedia.org/wiki/JPEG). That is, I calculate the whole floating-point DCT. So, my algorithm goes more or less like this: `sample colors and convert to [0, 1]; diff; RGB to LumaChroma; DCT 8x8 blocks` Now, with your suggestion, in "diff" I temporarily convert to uints to make xor. Is that legit way? – maxest Oct 23 '17 at 09:21
  • To sum up: I think that doing floating-point DCT after I have xor'ed something is at the very least suspicious. But I'm not sure how to get around this. Do I need to use H.264 integer DCT transform? – maxest Oct 23 '17 at 09:33
  • Diff the raw pixels not the transformed coefficients. Then transform the result. – szatmary Oct 23 '17 at 14:25
  • Updated my answer – maxest Nov 22 '17 at 16:34

0 Answers0