comparison apedec.c @ 10631:79f3ead3ebc1 libavcodec

inline to allow constant propagation 50% faster predictor_update_filter, 1-10% faster ape decoding on core2
author lorenm
date Thu, 03 Dec 2009 17:44:08 +0000
parents e5a8a6b9a717
children 54982e4c4478
comparison
equal deleted inserted replaced
10630:84cca0a953c5 10631:79f3ead3ebc1
515 /** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero) */ 515 /** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero) */
516 static inline int APESIGN(int32_t x) { 516 static inline int APESIGN(int32_t x) {
517 return (x < 0) - (x > 0); 517 return (x < 0) - (x > 0);
518 } 518 }
519 519
520 static int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB) 520 static av_always_inline int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB)
521 { 521 {
522 int32_t predictionA, predictionB; 522 int32_t predictionA, predictionB;
523 523
524 p->buf[delayA] = p->lastA[filter]; 524 p->buf[delayA] = p->lastA[filter];
525 p->buf[adaptA] = APESIGN(p->buf[delayA]); 525 p->buf[adaptA] = APESIGN(p->buf[delayA]);
576 return p->filterA[filter]; 576 return p->filterA[filter];
577 } 577 }
578 578
579 static void predictor_decode_stereo(APEContext * ctx, int count) 579 static void predictor_decode_stereo(APEContext * ctx, int count)
580 { 580 {
581 int32_t predictionA, predictionB;
582 APEPredictor *p = &ctx->predictor; 581 APEPredictor *p = &ctx->predictor;
583 int32_t *decoded0 = ctx->decoded0; 582 int32_t *decoded0 = ctx->decoded0;
584 int32_t *decoded1 = ctx->decoded1; 583 int32_t *decoded1 = ctx->decoded1;
585 584
586 while (count--) { 585 while (count--) {
587 /* Predictor Y */ 586 /* Predictor Y */
588 predictionA = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB); 587 *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB);
589 predictionB = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB); 588 decoded0++;
590 *(decoded0++) = predictionA; 589 *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB);
591 *(decoded1++) = predictionB; 590 decoded1++;
592 591
593 /* Combined */ 592 /* Combined */
594 p->buf++; 593 p->buf++;
595 594
596 /* Have we filled the history buffer? */ 595 /* Have we filled the history buffer? */