[liblouis-liblouisxml] Re: Bert Frees: Use of Buffers

  • From: Bert Frees <bertfrees@xxxxxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 19 Jan 2012 14:52:53 +0100

Hi John,

outbuf1 is the buffer that was already there (used to be just outbuf I think). I've added 2 additional buffers that come after the first. Unlike the first, the 2nd and 3th can be bypassed. They are only needed in some special cases, which I will explain below:

Special case 1: The setting printPageNumberRange is set to yes, and the setting printPageNumberAt is set to top.

This means that the whole range of print pages contained in a Braille page is displayed at the top of the page. This is used a lot in Belgium. For example, if a braille page contains the last part of print page 10 and the first part of print page 11, the first line of the braille page will say: 10-11.

Because in this case, the first line of the page can not be created until the rest of the page is finished, lines 2 till N are first written to outbuf2. Then, the first line is written, bypassing outbuf2. Then, outbuf2 is read out. All this is done in the function nextBraillePage.

Special case 2: For some element, one or more of the style attributes dontSplit, keepWithNext or orphanControl are set to yes.

Processing such elements sometimes requires multiple iterations. For example, let's say dontSplit is set to yes. Before writing the element, the whole 'state' of the program (including outbuf1 and outbuf2) is stored. Then, outbuf3 is enabled and the first iteration is done. If the element fits on the Braille page, outbuf3 is read out and we can move on. If the element doesn't fit on the Braille page, the previous state is restored, outbuf3 is discarded and we do a second iteration. This time, we start the element on a new Braille page so that it will fit on this page. All this is done in transcribe_paragraph.c

I still like the idea of cascading multiple buffers, but I'm not sure if my implementation is very good, performance-wise. You may have to look at that.

Best,
Bert


On 18-jan-12, at 19:33, John J. Boyer wrote:

Hi Bert,

I am putting your changes into the utd functions in liblouisutdml. Could
you explain the use of the three buffers, outbuf1 outbuf2 outbuf3

Incidentally, I have moved the buffers off the stack and into user_data.
This makes them available for the string translation functions as well
for file translation functions. They also come in handy for utd and for
converting utd to other formats.

Thanks,
John

Other related posts: