comparison mpegaudiodec.c @ 11710:8e3a3bc4fb24 libavcodec

Factorize READ_FLIP_SIGN() optimization out
author michael
date Tue, 11 May 2010 21:20:33 +0000
parents 6f9b4c452130
children 7ca3795af11b
comparison
equal deleted inserted replaced
11709:6f9b4c452130 11710:8e3a3bc4fb24
1405 *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; 1405 *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos;
1406 *pos= get_bits_count(&s->gb); 1406 *pos= get_bits_count(&s->gb);
1407 } 1407 }
1408 } 1408 }
1409 1409
1410 /* Following is a optimized code for
1411 INTFLOAT v = *src
1412 if(get_bits1(&s->gb))
1413 v = -v;
1414 *dst = v;
1415 */
1416 #if CONFIG_FLOAT
1417 #define READ_FLIP_SIGN(dst,src)\
1418 v = AV_RN32A(src) ^ (get_bits1(&s->gb)<<31);\
1419 AV_WN32A(dst, v);
1420 #else
1421 #define READ_FLIP_SIGN(dst,src)\
1422 v= -get_bits1(&s->gb);\
1423 *(dst) = (*(src) ^ v) - v;
1424 #endif
1425
1410 static int huffman_decode(MPADecodeContext *s, GranuleDef *g, 1426 static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
1411 int16_t *exponents, int end_pos2) 1427 int16_t *exponents, int end_pos2)
1412 { 1428 {
1413 int s_index; 1429 int s_index;
1414 int i; 1430 int i;
1536 while(code){ 1552 while(code){
1537 static const int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; 1553 static const int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0};
1538 int v; 1554 int v;
1539 int pos= s_index+idxtab[code]; 1555 int pos= s_index+idxtab[code];
1540 code ^= 8>>idxtab[code]; 1556 code ^= 8>>idxtab[code];
1541 /* Following is a optimized code for 1557 READ_FLIP_SIGN(g->sb_hybrid+pos, RENAME(exp_table)+exponents[pos])
1542 INTFLOAT v = RENAME(exp_table)[ exponents[pos] ];
1543 if(get_bits1(&s->gb))
1544 v = -v;
1545 g->sb_hybrid[pos] = v;
1546 */
1547 #if CONFIG_FLOAT
1548 v = AV_RN32A(RENAME(exp_table)+exponents[pos]) ^ (get_bits1(&s->gb)<<31);
1549 AV_WN32A(g->sb_hybrid+pos, v);
1550 #else
1551 v= -get_bits1(&s->gb);
1552 g->sb_hybrid[pos] = (RENAME(exp_table)[ exponents[pos] ] ^ v) - v;
1553 #endif
1554 } 1558 }
1555 s_index+=4; 1559 s_index+=4;
1556 } 1560 }
1557 /* skip extension bits */ 1561 /* skip extension bits */
1558 bits_left = end_pos2 - get_bits_count(&s->gb); 1562 bits_left = end_pos2 - get_bits_count(&s->gb);