~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/lib/tplay/tplayfunctions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * tplay - buffered audio player
 
3
 *
 
4
 * (c) 1997 ilkka karvinen <ik@iki.fi>
 
5
 *
 
6
 * Copyright under the GNU GENERAL PUBLIC LICENSE
 
7
 *   (see the file COPYING in this directory)
 
8
 *
 
9
 * 
 
10
 *   common functions
 
11
 */
 
12
 
 
13
#include <stdio.h>
 
14
#include <stdlib.h>
 
15
#include <stdarg.h>
 
16
 
 
17
#include "tplayfunctions.h"
 
18
 
 
19
DWORD read_big_endian_long(char * buf)
 
20
{
 
21
   DWORD byte0, byte1, byte2, byte3;
 
22
   unsigned char* buffer=(unsigned char*) buf;
 
23
 
 
24
   byte0 = (DWORD) buffer[0];
 
25
   byte1 = (DWORD) buffer[1];
 
26
   byte2 = (DWORD) buffer[2];
 
27
   byte3 = (DWORD) buffer[3];
 
28
   return (byte0 << 24 | byte1 << 16 | byte2 << 8 | byte3);
 
29
}
 
30
 
 
31
void write_big_endian_long(char * buf, DWORD value)
 
32
{
 
33
   unsigned char* buffer=(unsigned char*) buf;
 
34
   buffer[0] = (unsigned char) (value >> 24 & 0xFF);
 
35
   buffer[1] = (unsigned char) (value >> 16 & 0xFF);
 
36
   buffer[2] = (unsigned char) (value >> 8 & 0xFF);
 
37
   buffer[3] = (unsigned char) (value & 0xFF);
 
38
}
 
39
 
 
40
DWORD read_little_endian_long(char* buf) {
 
41
   DWORD byte0, byte1, byte2, byte3;
 
42
   unsigned char* buffer=(unsigned char*) buf;
 
43
 
 
44
   byte0 = (DWORD) buffer[0];
 
45
   byte1 = (DWORD) buffer[1];
 
46
   byte2 = (DWORD) buffer[2];
 
47
   byte3 = (DWORD) buffer[3];
 
48
   return (byte3 << 24 | byte2 << 16 | byte1 << 8 | byte0);
 
49
}
 
50
 
 
51
WORD read_little_endian_word(char * buf)
 
52
{
 
53
   WORD byte0, byte1;
 
54
   unsigned char* buffer=(unsigned char*) buf;
 
55
   
 
56
   byte0 = (WORD) buffer[0];
 
57
   byte1 = (WORD) buffer[1];
 
58
   return (byte1 << 8 | byte0);
 
59
}
 
60
 
 
61
void errprintf(char *fmt,...)
 
62
{
 
63
   va_list ap;
 
64
 
 
65
   va_start(ap, fmt);
 
66
   vfprintf(stderr, fmt, ap);
 
67
}
 
68
 
 
69
 
 
70
 
 
71
void die(const char *str)
 
72
{
 
73
   fprintf(stderr, "%s: \n", str);
 
74
   exit(-1);
 
75
}
 
76
 
 
77
void errdie(const char *str)
 
78
{
 
79
   fprintf(stderr, "Error: %s\n", str);
 
80
   exit(-1);
 
81
}
 
82
 
 
83
 
 
84