replaced libart with new polygon code
[swftools.git] / lib / bladeenc / common.c
1 /*
2                         (c) Copyright 1998-2000 - Tord Jansson
3                         ======================================
4
5                 This file is part of the BladeEnc MP3 Encoder, based on
6                 ISO's reference code for MPEG Layer 3 compression, and might
7                 contain smaller or larger sections that are directly taken
8                 from ISO's reference code.
9
10                 All changes to the ISO reference code herein are either
11                 copyrighted by Tord Jansson (tord.jansson@swipnet.se)
12                 or sublicensed to Tord Jansson by a third party.
13
14         BladeEnc is free software; you can redistribute this file
15         and/or modify it under the terms of the GNU Lesser General Public
16         License as published by the Free Software Foundation; either
17         version 2.1 of the License, or (at your option) any later version.
18
19
20
21         ------------    Changes    ------------
22
23         2000-11-22  Andre Piotrowski
24
25         -       bug fix: mem_alloc() - no lomger a need to allocate block*2 bytes
26 */
27
28 /***********************************************************************
29 *
30 *  Global Include Files
31 *
32 ***********************************************************************/
33
34 #include        <string.h> /* 1995-07-11 shn */
35 #include        <ctype.h>
36 #include        <stdlib.h>
37
38 #include    "common.h"
39
40
41
42
43
44 /***********************************************************************
45 *
46 *  Global Variable Definitions
47 *
48 ***********************************************************************/
49
50 /* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */
51 double                                  s_freq[2][4] =
52 {
53         {22.05, 24, 16, 0},
54         {44.1 , 48, 32, 0}
55 };
56
57 /* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */
58 int                                             bitratex[2][15] =
59 {
60         {   0,  8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160},
61         {   0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320}
62 };
63
64
65
66
67
68 /*******************************************************************************
69 *
70 *  Allocate number of bytes of memory equal to "block".
71 *
72 *******************************************************************************/
73
74 void                                    *mem_alloc (unsigned int block, char *item)
75 {
76         void                                    *ptr;
77
78         ptr = (void *) malloc (block);
79
80         memset (ptr, 0, block);
81
82         return ptr;
83 }
84
85
86
87
88
89 /****************************************************************************
90 *
91 *  Free memory pointed to by "*ptr_addr".
92 *
93 *****************************************************************************/
94
95 void                                    mem_free (void **ptr_addr)
96 {
97         if (*ptr_addr != NULL)
98         {
99                 free (*ptr_addr);
100                 *ptr_addr = NULL;
101         }
102 }
103
104
105