summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmpeg3/dump.c
blob: 71587123a985ffb48dbaf8ff6d6ad3f469e4bf46 (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
#include "libmpeg3.h"
#include <stdlib.h>

#define BUFSIZE 4096

int main(int argc, char *argv[])
{
	mpeg3_t *file;
	int i, result = 0;
	unsigned char *output, **output_rows;
	float *audio_output_f;
	short *audio_output_i;
	long total_samples = 0;

	if(argc < 2)
	{
		printf("Need an MPEG stream.\n");
		exit(1);
	}

	file = mpeg3_open(argv[1]);
	if(file)
	{
		fprintf(stderr, "MMX supported %d\n", file->have_mmx);
		fprintf(stderr, "Audio streams: %d\n", mpeg3_total_astreams(file));
		for(i = 0; i < mpeg3_total_astreams(file); i++)
		{
			fprintf(stderr, "  Stream %d: channels %d sample rate %d total samples %ld\n", 
				i, 
				mpeg3_audio_channels(file, i), 
				mpeg3_sample_rate(file, i),
				mpeg3_audio_samples(file, i));
		}
		fprintf(stderr, "Video streams: %d\n", mpeg3_total_vstreams(file));
		for(i = 0; i < mpeg3_total_vstreams(file); i++)
		{
			fprintf(stderr, "  Stream %d: width %d height %d frame rate %0.3f total frames %ld\n", 
				i, 
				mpeg3_video_width(file, i), 
				mpeg3_video_height(file, i), 
				mpeg3_frame_rate(file, i),
				mpeg3_video_frames(file, i));
		}
fprintf(stderr,"S");

		mpeg3_set_cpus(file, 1);
fprintf(stderr,"s");
/* 		audio_output_f = malloc(BUFSIZE * sizeof(float)); */
		audio_output_i = (short*)malloc(BUFSIZE * 2 * sizeof(short));
fprintf(stderr,"x");
/*		mpeg3_set_sample(file, 11229518, 0); */
  		/*result = mpeg3_read_audio(file, audio_output_f, 0, 0, BUFSIZE, 0);*/
		for (i=0; i<100; i++) {
fprintf(stderr,"c");
		result = mpeg3_read_audio(file, 0, audio_output_i, 0, BUFSIZE, 0);
fprintf(stderr,"read\n");
		}
 		//fwrite(audio_output_i, BUFSIZE, 1, stdout);

  		output = (unsigned char*)malloc(mpeg3_video_width(file, 0) * mpeg3_video_height(file, 0) * 3 + 4);
  		output_rows = (unsigned char**)malloc(sizeof(unsigned char*) * mpeg3_video_height(file, 0));
  		for(i = 0; i < mpeg3_video_height(file, 0); i++)
  			output_rows[i] = &output[i * mpeg3_video_width(file, 0) * 3];
// 		mpeg3_set_frame(file, 1000, 0);
 		result = mpeg3_read_frame(file, 
 					output_rows, 
 					0, 
 					0, 
 					mpeg3_video_width(file, 0), 
					mpeg3_video_height(file, 0), 
 					mpeg3_video_width(file, 0), 
 					mpeg3_video_height(file, 0), 
					MPEG3_RGB888, 
 					0);

		mpeg3_close(file);
	}
	return 0;
}