Revision 140cb663 libavcodec/dsputil.c

View differences:

libavcodec/dsputil.c
1528 1528
//    dsputil_set_bit_exact_mmx();
1529 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

  

Also available in: Unified diff