don't fail on bad encodings
[swftools.git] / lib / bladeenc / common.c
blob0ffddc2cbca616068f7e9c5c2d3f2bfb560f0e8b
1 /*
2 (c) Copyright 1998-2000 - Tord Jansson
3 ======================================
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.
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.
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.
21 ------------ Changes ------------
23 2000-11-22 Andre Piotrowski
25 - bug fix: mem_alloc() - no lomger a need to allocate block*2 bytes
28 /***********************************************************************
30 * Global Include Files
32 ***********************************************************************/
34 #include <string.h> /* 1995-07-11 shn */
35 #include <ctype.h>
36 #include <stdlib.h>
38 #include "common.h"
44 /***********************************************************************
46 * Global Variable Definitions
48 ***********************************************************************/
50 /* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */
51 double s_freq[2][4] =
53 {22.05, 24, 16, 0},
54 {44.1 , 48, 32, 0}
57 /* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */
58 int bitratex[2][15] =
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}
68 /*******************************************************************************
70 * Allocate number of bytes of memory equal to "block".
72 *******************************************************************************/
74 void *mem_alloc (unsigned int block, char *item)
76 void *ptr;
78 ptr = (void *) malloc (block);
80 memset (ptr, 0, block);
82 return ptr;
89 /****************************************************************************
91 * Free memory pointed to by "*ptr_addr".
93 *****************************************************************************/
95 void mem_free (void **ptr_addr)
97 if (*ptr_addr != NULL)
99 free (*ptr_addr);
100 *ptr_addr = NULL;