]> git.sesse.net Git - ffmpeg/commit
avcodec/jpeglsenc: Only use one line at a time as spare buffer
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 3 Sep 2020 17:02:59 +0000 (19:02 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 8 Mar 2021 03:28:52 +0000 (04:28 +0100)
commit3aee27a9751bcf6c35e89e7a1a01e67e5f6351f7
treeac38e75f94b69c454e6b3dc3a441ba462c2fa4ab
parentfefe69c5c9c6d4cfa2b1329a72a805ffd89a97c3
avcodec/jpeglsenc: Only use one line at a time as spare buffer

ls_encode_line() encodes one line of input from left to right and
to do so it uses the values of the left, upper left, upper and upper
right pixels for prediction (i.e. the values that a decoder gets when it
decodes the already encoded part of the picture). So a simple algorithm
would use a buffer that can hold two lines, namely the current line as
well as the last line and swap the pointers to the two lines after
decoding each line. Yet if one is currently encoding the pixel with
index k of a line, one doesn't need any pixel with index < k - 1 of the
last line at all and similarly, no pixels with index >= k have been
written yet. So the overlap in the effective lifetime is pretty limited
and since the last patch (which stopped reading the upper left pixel and
instead reused the value of the upper pixel from the last iteration of
the loop) it is inexistent. Ergo one only needs one line and doesn't
need to swap the lines out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/jpeglsenc.c