[FFmpeg-devel] [PATCH] h264.c/decode_cabac_residual optimization
Siarhei Siamashka
siarhei.siamashka
Tue Jul 1 21:26:25 CEST 2008
On Tue, Jul 1, 2008 at 9:44 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Tue, Jul 01, 2008 at 01:14:56PM -0400, Alexander Strange wrote:
> [...]
>
>> diff -ru --exclude='*svn*' ffmpeg-/libavcodec/h264.c ffmpeg/libavcodec/h264.c
>> --- ffmpeg-/libavcodec/h264.c 2008-06-30 14:47:53.000000000 -0400
>> +++ ffmpeg/libavcodec/h264.c 2008-06-30 14:47:59.000000000 -0400
>> @@ -5517,7 +5517,7 @@
>> }
>> }
>>
>> - for( coeff_count--; coeff_count >= 0; coeff_count-- ) {
>> + while( coeff_count-- ) {
>> uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base;
>>
>> int j= scantable[index[coeff_count]];
>
> ok if faster or same speed
Typically pre-decrement is always preferred in code optimized for
performance as it is generally faster. Something like this would be
better (also it is closer to the old code):
while( --coeff_count >= 0 ) {
...
}
You can try to compile this sample with the best possible
optimizations, look at the assembly output and check where the
generated code is better and why:
/**********************/
int q();
void f1(int n)
{
while (--n >= 0) {
q();
}
}
void f2(int n)
{
while (n--) {
q();
}
}
/**********************/
More information about the ffmpeg-devel
mailing list