[HN Gopher] Hello, Video Codec
       ___________________________________________________________________
        
       Hello, Video Codec
        
       Author : todsacerdoti
       Score  : 80 points
       Date   : 2021-07-15 18:01 UTC (5 hours ago)
        
 (HTM) web link (blog.tempus-ex.com)
 (TXT) w3m dump (blog.tempus-ex.com)
        
       | ww520 wrote:
       | To find temporal redundancy in the video, some of these codecs
       | have a clever technique to do motion compensation. The old way is
       | to do a diff between the images of the current frame and the next
       | frame, and record the diff in the output in place of the next
       | frame to save space.
       | 
       | The newer way is to shift the current frame a little bit before
       | doing the diff, hoping that the motion in the video moves the
       | next frame in the same direction as the shifting direction. If
       | the image of the current shifted frame coincides with the next
       | frame, the diff produced should be very small. The output for the
       | next frame then consists of the shifting direction+amount and the
       | diff. The decoder can reverse the process by shifting the current
       | frame by the direction and amount, and applying the diff to get
       | to the next frame.
       | 
       | To find the optimized shifted diff, the codecs would try shifting
       | none, left, right, up, down, and even upper-left/upper-right/etc.
       | Then see which shifted direction produces the smallest diff and
       | use that for compression. Encoding is so expensive because of all
       | these searchings for the optimal compression.
        
         | userbinator wrote:
         | ...and "newer" is a relative term - motion compensation first
         | appeared in H.261 (1988), I believe.
        
           | ww520 wrote:
           | Good to know. Didn't know H.261 had it. I know MPEG4 (H.264)
           | has it. MPEG4 was like coming out in 1990s/2000s? It's pretty
           | old. But the idea is the same for all newer codecs. They just
           | have different ways to chop up a frame into blocks and do
           | shifting at the block level.
        
             | labawi wrote:
             | Modern codecs not only chop the frame into variable size
             | blocks, they also do fractional shifts, in many directions,
             | and predict the shift from past and future and parts of
             | current frame.
        
               | ww520 wrote:
               | I've heard some research into using triangle as
               | macroblock for future codecs. That would really change
               | things up.
        
               | ksec wrote:
               | Triangle partition mode was in VVC VTM 6, cant remember
               | if it made it into the final spec due to complexity
               | increase.
        
             | DesiLurker wrote:
             | its been there since VCD (MPEG), DVD (MPEG2) & HDDVD/BR
             | MPEG4-10 or H.264. its a very old idea. In fact it has been
             | used in implementing a temporal filter to create a cleaner
             | content for a bit too. I know because I worked on it all.
        
               | ww520 wrote:
               | Good know. Very interesting.
        
         | porphyra wrote:
         | You could also run optical flow, e.g. Lucas-Kanade flow [1] on
         | the past pair of frames to predict how things will move in the
         | next.
         | 
         | [1] https://en.wikipedia.org/wiki/Lucas%E2%80%93Kanade_method
        
           | ww520 wrote:
           | From what I've seen, most codecs just brute-force in -1/+1
           | directions, nothing like doing Lucas-Kanade analysis to get
           | an arbitrary direction. Not sure what the tradeoffs are. May
           | be newer codecs will use Lucas-Kanade?
        
             | hifly wrote:
             | really? it's this because it's too expensive to do an FFT?
             | this would give you all probable matches directly? no?
        
           | [deleted]
        
       ___________________________________________________________________
       (page generated 2021-07-15 23:02 UTC)