aboutsummaryrefslogtreecommitdiffstats
path: root/timingtest.c
blob: b39ebe9ed3b9d09bdd287442e376bbba324b44a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/time.h>
#include "videotools.h"

static inline void get_time( int64_t *const ptime )
{
   asm volatile ("rdtsc" : "=A" (*ptime));
}

static int timediff( struct timeval *large, struct timeval *small )
{
    return (   ( ( large->tv_sec * 1000 * 1000 ) + large->tv_usec )
             - ( ( small->tv_sec * 1000 * 1000 ) + small->tv_usec ) );
}

int main( int argc, char **argv )
{
    unsigned char *source422planar;
    unsigned char *dest422packed;
    int width, height;
    int i = 0;
    int64_t before;
    int64_t after;
    video_correction_t *vc = video_correction_new();

    width = 720;
    height = 480;

    source422planar = (unsigned char *) malloc( width * height * 2 );
    dest422packed = (unsigned char *) malloc( width * height * 2 );

    for( i = 0; i < width*height*2; i++ ) {
        source422planar[ i ] = i % 256;
    }
    usleep( 10000 );
    for( i = 0; i < 100; i++ ) {
        struct timeval time_before;
        struct timeval time_after;
        gettimeofday( &time_before, 0 );
        get_time( &before );
        video_correction_planar422_field_to_packed422_frame( vc, dest422packed,
            source422planar, source422planar + (width*height),
            source422planar + (width*height) + (width/2 * height), 0, width*2, width, width, height );
        get_time( &after );
        gettimeofday( &time_after, 0 );
        fprintf( stderr, "top: %10d\n", timediff( &time_after, &time_before ) );
        gettimeofday( &time_before, 0 );
        get_time( &before );
        video_correction_planar422_field_to_packed422_frame( vc, dest422packed,
            source422planar + width, source422planar + (width*height) + (width/2),
            source422planar + (width*height) + (width/2 * height) + (width/2), 1, width*2, width, width, height );
        get_time( &after );
        gettimeofday( &time_after, 0 );
        fprintf( stderr, "bot: %10d\n", timediff( &time_after, &time_before ) );
    }

    free( source422planar );
    free( dest422packed );
    return 0;
}

Privacy Policy