[FFmpeg-devel] [PATCH] Make bubblesort() a common function

Vitor Sessak vitor1001
Mon Nov 23 09:21:53 CET 2009


Pascal Massimino wrote:
> On Sun, Nov 22, 2009 at 2:26 PM, Vitor Sessak <vitor1001 at gmail.com> wrote:
> 
>> Michael Niedermayer wrote:
>>
>>> On Sun, Nov 22, 2009 at 09:05:55PM +0000, M?ns Rullg?rd wrote:
>>>
>>>> Vitor Sessak <vitor1001 at gmail.com> writes:
>>>>
>>>>  $subj, useful for SIPR, maybe also for WMAVoice.
>>>>> -Vitor
>>>>> Index: libavcodec/lsp.c
>>>>> ===================================================================
>>>>> --- libavcodec/lsp.c    (revision 20569)
>>>>> +++ libavcodec/lsp.c    (working copy)
>>>>> @@ -173,3 +173,14 @@
>>>>>         lpc2[-lp_half_order] = 0.5*(paf-qaf);
>>>>>     }
>>>>>  }
>>>>> +
>>>>> +void ff_bubblesort(float *lsp, int lp_order)
>>>>>
>>>> Whats wrong with qsort?  It's even standard C.
>>>>
>>> its slow for the case here AFAIK
>>>
>> Exactly.
> 
> 
> Any reasonably implemented qsort() switches to insertion sort when the
> length to sort goes under MAGIC_LEN
> constant (insert your best guess for MAGIC_LEN. I like '11' but that's just
> me).

It is not faster because of the length, it is faster because the vector 
is nearly sorted (the loop over "j" runs at most once for the concerned 
data).

-Vitor



More information about the ffmpeg-devel mailing list