Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Dev

[PATCH] USALS array overflow problem

 

 

MythTV dev RSS feed   Index | Next | Previous | View Threaded


yeasah at schwide

Apr 29, 2006, 10:18 AM

Post #1 of 2 (505 views)
Permalink
[PATCH] USALS array overflow problem

There's a problem with the USALS code in libs/libmythtv/dvbdiseqc.cpp
that causes the positioner gotox values to be calculated incorrectly for
certain positions. The problem is caused by an overrun of a table. The
index of a 10 element table is given by the following code:

CMD2 += DecimalLookup[(int)round(USALS*10)];

Where in that context USALS is a floating point value which can range
from 0.0 to 0.999999, which causes the resultant index to be from 0-10,
and thus overruns the end of the table by 1 (returning bogus positioning
data in this case). The simplest solution woud be to change the code to
use floor():

CMD2 += DecimalLookup[(int)floor(USALS*10)];

However, the presence of the table is silly anyway -- the spec shows a
lookup table as decimal only as a convenience, the encoding is actually
as a fixed point fraction. As such, the correct value would most easily
be calculated directly from the angle. Attached is a patch that
eliminates the table overrun problem, and is also more accurate (and
less complicated, too).

I would suggest that this be applied to 0.19-fixes as well as the trunk,
since the problem really does cause issues with positioning. In the
past, I've had to work around "bad" angles by adding some small value to
the angle I actually wanted.
Attachments: usals.diff (1.26 KB)


kuphal at dls

Apr 29, 2006, 10:32 AM

Post #2 of 2 (480 views)
Permalink
Re: [PATCH] USALS array overflow problem [In reply to]

Yeasah Pell wrote:
> There's a problem with the USALS code in libs/libmythtv/dvbdiseqc.cpp
> that causes the positioner gotox values to be calculated incorrectly
> for certain positions. The problem is caused by an overrun of a table.
> The index of a 10 element table is given by the following code:
>
> CMD2 += DecimalLookup[(int)round(USALS*10)];
>
> Where in that context USALS is a floating point value which can range
> from 0.0 to 0.999999, which causes the resultant index to be from
> 0-10, and thus overruns the end of the table by 1 (returning bogus
> positioning data in this case). The simplest solution woud be to
> change the code to use floor():
>
> CMD2 += DecimalLookup[(int)floor(USALS*10)];
>
> However, the presence of the table is silly anyway -- the spec shows a
> lookup table as decimal only as a convenience, the encoding is
> actually as a fixed point fraction. As such, the correct value would
> most easily be calculated directly from the angle. Attached is a patch
> that eliminates the table overrun problem, and is also more accurate
> (and less complicated, too).
>
> I would suggest that this be applied to 0.19-fixes as well as the
> trunk, since the problem really does cause issues with positioning. In
> the past, I've had to work around "bad" angles by adding some small
> value to the angle I actually wanted.
Thank you for the submission. Patches should be submitted to
http://svn.mythtv.org/trac as a new ticket.

Thanks,
Kevin
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

MythTV dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.