aboutsummaryrefslogtreecommitdiffhomepage
path: root/libvo/vo_md5.c
blob: 17334c384bc0633ada1ce47f80f8b84aae8031a9 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* 
 * video_out_pgm.c, pgm interface
 *
 *
 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. 
 *
 * Hacked into mpeg2dec by
 * 
 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
 *
 * 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr>
 *
 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include "config.h"
#include "video_out.h"
#include "video_out_internal.h"

static vo_info_t info = 
{
	"MD5 sum",
	"md5",
	"walken",
	""
};

LIBVO_EXTERN (md5)

extern vo_functions_t video_out_pgm;
extern char vo_pgm_filename[24];

static FILE * md5_file = NULL;
static char * md5_filename = NULL;

static uint32_t
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
{
    md5_file = fopen (md5_filename?md5_filename:"md5", "w");
    if (!md5_file)
	return -1;
    return video_out_pgm.config (width, height, d_width,d_height,fullscreen, title, format);
}

static void draw_osd(void)
{
}

static void flip_page (void)
{
    char buf2[100];
    FILE * f;
    int i;

    video_out_pgm.flip_page();

    snprintf (buf2, 100, "md5sum %s", vo_pgm_filename);
    f = popen (buf2, "r");
    if (!f) {
	snprintf (buf2, 100, "md5 %s", vo_pgm_filename);
	f = popen(buf2, "r");
    }
    if (f) {
    i = fread (buf2, 1, sizeof(buf2), f);
    pclose (f);
    fwrite (buf2, 1, i, md5_file);
    }
    remove (vo_pgm_filename);
}

//static uint32_t draw_slice(uint8_t * src[], uint32_t slice_num)
static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
{
    return video_out_pgm.draw_slice(image,stride,w,h,x,y);
}

//extern uint32_t output_pgm_frame (char * fname, uint8_t * src[]);

static uint32_t draw_frame(uint8_t * src[])
{
    return 0;
}

static uint32_t
query_format(uint32_t format)
{
    return video_out_pgm.control(VOCTRL_QUERY_FORMAT, &format);
}


static void
uninit(void)
{
    video_out_pgm.uninit();
    if (md5_file)
    {
	fflush(md5_file);
	fclose(md5_file);
	md5_file = NULL;
    }
    if (md5_filename)
    {
	free(md5_filename);
	md5_filename = NULL;
    }
}


static void check_events(void)
{
}

static uint32_t preinit(const char *arg)
{
    if(arg) 
	md5_filename = strdup(arg);
    return 0;
}

static uint32_t control(uint32_t request, void *data, ...)
{
  switch (request) {
  case VOCTRL_QUERY_FORMAT:
    return query_format(*((uint32_t*)data));
  }
  return VO_NOTIMPL;
}