On 10/24/2011 11:11 AM, Måns Rullgård wrote:

> Justin Ruggles <[email protected]> writes:
> 
>> On 10/24/2011 10:04 AM, Måns Rullgård wrote:
>>
>>> Justin Ruggles <[email protected]> writes:
>>>
>>>> ---
>>>>  libavcodec/tta.c |    2 +-
>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/libavcodec/tta.c b/libavcodec/tta.c
>>>> index 5a11436..9330e2d 100644
>>>> --- a/libavcodec/tta.c
>>>> +++ b/libavcodec/tta.c
>>>> @@ -182,7 +182,7 @@ static int tta_get_unary(GetBitContext *gb)
>>>>      int ret = 0;
>>>>  
>>>>      // count ones
>>>> -    while(get_bits1(gb))
>>>> +    while (get_bits_left(gb) > 0 && get_bits1(gb))
>>>>          ret++;
>>>>      return ret;
>>>>  }
>>>> -- 
>>>
>>> Patch OK.
>>>
>>> What is the maximum legal length here?  If the value is likely to fit in
>>> the bitstream cache, this can be optimised considerably.
>>
>> The rice param, k, can be 0. So the limit on unary length is the range
>> of the prediction error, which is about the same as the input sample range.
> 
> If that happens frequently, unary coding is probably not the best
> choice.  In fact, exp-golomb is more efficient if the average value is
> greater than 4, and that gives way to other codings for moderately large
> values.  Thus, either the tta designers were stupid (certainly a
> possibility) or these values are small most of the time.  If anyone
> cares about performance, this might be a place to look.


Well, yes, they should be small in most cases. The rice param in TTA is
adaptive, not coded, so it can probably keep up ok with changing values.

In a quick test, a 16-bit sample had max unary length of 122. 24-bit had
max length of 508. But the vast majority of lengths were very small.

  0 = 43.75200%
  1 = 25.50936%
  2 = 15.78154%
  3 =  8.25406%
  4 =  3.83340%
  5 =  1.65253%
  6 =  0.68521%
  7 =  0.28336%
  8 =  0.11941%
  9 =  0.05273%
 10 =  0.02456%
 11 =  0.01347%
 12 =  0.00725%
 13 =  0.00506%
 14 =  0.00410%
 15 =  0.00263%
 16 =  0.00240%
 17 =  0.00173%
 18 =  0.00153%
 19 =  0.00155%
 20 =  0.00088%
 21 =  0.00099%
 22 =  0.00080%
 23 =  0.00059%
 24 =  0.00068%
 25 =  0.00055%
 26 =  0.00039%
 27 =  0.00049%
 28 =  0.00029%
 29 =  0.00032%
 30 =  0.00030%
 31 =  0.00030%
 32 =  0.00018%
...
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to