Mercurial > libavcodec.hg
comparison dsputil.c @ 909:8ae1e4c24e91 libavcodec
new PSNR code (now works with chroma, b frames, ...)
rename *_TYPE to FF_*_TYPE for the external API
allow user specified pict_type
author | michaelni |
---|---|
date | Wed, 04 Dec 2002 21:13:02 +0000 |
parents | 2cef5c4c0ca6 |
children | caa77cd960c0 |
comparison
equal
deleted
inserted
replaced
908:2ac4caad5ca6 | 909:8ae1e4c24e91 |
---|---|
1526 #ifdef HAVE_MMX | 1526 #ifdef HAVE_MMX |
1527 // FIXME - better set_bit_exact | 1527 // FIXME - better set_bit_exact |
1528 // dsputil_set_bit_exact_mmx(); | 1528 // dsputil_set_bit_exact_mmx(); |
1529 #endif | 1529 #endif |
1530 } | 1530 } |
1531 | |
1532 void get_psnr(UINT8 *orig_image[3], UINT8 *coded_image[3], | |
1533 int orig_linesize[3], int coded_linesize, | |
1534 AVCodecContext *avctx) | |
1535 { | |
1536 int quad, diff, x, y; | |
1537 UINT8 *orig, *coded; | |
1538 UINT32 *sq = squareTbl + 256; | |
1539 | |
1540 quad = 0; | |
1541 diff = 0; | |
1542 | |
1543 /* Luminance */ | |
1544 orig = orig_image[0]; | |
1545 coded = coded_image[0]; | |
1546 | |
1547 for (y=0;y<avctx->height;y++) { | |
1548 for (x=0;x<avctx->width;x++) { | |
1549 diff = *(orig + x) - *(coded + x); | |
1550 quad += sq[diff]; | |
1551 } | |
1552 orig += orig_linesize[0]; | |
1553 coded += coded_linesize; | |
1554 } | |
1555 | |
1556 avctx->psnr_y = (float) quad / (float) (avctx->width * avctx->height); | |
1557 | |
1558 if (avctx->psnr_y) { | |
1559 avctx->psnr_y = (float) (255 * 255) / avctx->psnr_y; | |
1560 avctx->psnr_y = 10 * (float) log10 (avctx->psnr_y); | |
1561 } else | |
1562 avctx->psnr_y = 99.99; | |
1563 } | |
1564 |