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

« back to all changes in this revision

Viewing changes to mpg123_artsplugin/mpg123/vbrhead.c

  • 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
 * This checks for the VBR Header defined by Xing(tm)
 
3
 */
 
4
 
 
5
#include "mpg123.h"
 
6
 
 
7
static unsigned long get32bits(unsigned char *buf) {
 
8
    unsigned long ret = 0;
 
9
 
 
10
    ret = (((unsigned long) buf[0]) << 24) |
 
11
        (((unsigned long) buf[1]) << 16) |
 
12
        (((unsigned long) buf[2]) << 8) |
 
13
        ((unsigned long) buf[3]) ;
 
14
 
 
15
    return ret;
 
16
}
 
17
 
 
18
int getVBRHeader(struct vbrHeader *head,unsigned char *buf, struct frame *fr) 
 
19
{
 
20
    int ssize;
 
21
 
 
22
    if(fr->lay != 3)
 
23
        return 0;
 
24
 
 
25
    if(fr->lsf)
 
26
        ssize = (fr->stereo == 1) ? 9 : 17;
 
27
    else
 
28
        ssize = (fr->stereo == 1) ? 17 : 32;
 
29
 
 
30
 
 
31
    buf += ssize;
 
32
 
 
33
    if(( buf[0] != 'X' ) || ( buf[1] != 'i' ) ||
 
34
       ( buf[2] != 'n' ) || ( buf[3] != 'g' ) ) 
 
35
        return 0;
 
36
    buf+=4;
 
37
    
 
38
    head->flags = get32bits(buf);
 
39
    buf+=4;
 
40
    
 
41
    if(head->flags & VBR_FRAMES_FLAG) {
 
42
        head->frames = get32bits(buf);
 
43
        buf += 4;
 
44
    }
 
45
 
 
46
    if(head->flags & VBR_BYTES_FLAG) {
 
47
        head->bytes  = get32bits(buf); 
 
48
        buf += 4;
 
49
    }
 
50
 
 
51
    if(head->flags & VBR_TOC_FLAG) {
 
52
        memcpy(head->toc,buf,100);
 
53
        buf += 100;
 
54
    }
 
55
 
 
56
    if(head->flags & VBR_SCALE_FLAG) {
 
57
        head->scale = get32bits(buf);
 
58
        buf += 4;
 
59
    }
 
60
 
 
61
    fprintf(stderr,"Found XING %04lx\n",head->flags);
 
62
 
 
63
    return 1;
 
64
 
 
65
}
 
66
 
 
67
 
 
68
 
 
69
 
 
70
 
 
71
 
 
72
 
 
73
 
 
74
 
 
75
 
 
76
 
 
77
 
 
78
 
 
79