ETC AP77016-B19

User’s Manual
µSAP77016-B19
MP3 Audio Encoder Middleware
Target Device
µ PD77110
µ PD77113A
µ PD77114
µ PD77115
µ PD77210
µ PD77213
Document No. U16553EJ1V0UM00 (1st edition)
Date Published March 2003 NS CP(N)
2003
Printed in Japan
[MEMO]
2
User’s Manual U16553EJ1V0UM
Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States
and/or other countries.
• The information in this document is current as of March, 2003. The information is subject to change
without notice. For actual design-in, refer to the latest publications of NEC Electronics data sheets or
data books, etc., for the most up-to-date specifications of NEC Electronics products. Not all
products and/or types are available in every country. Please check with an NEC Electronics sales
representative for availability and additional information.
• No part of this document may be copied or reproduced in any form or by any means without the prior
written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may
appear in this document.
• NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual
property rights of third parties by or arising from the use of NEC Electronics products listed in this document
or any other liability arising from the use of such products. No license, express, implied or otherwise, is
granted under any patents, copyrights or other intellectual property rights of NEC Electronics or others.
• Descriptions of circuits, software and other related information in this document are provided for illustrative
purposes in semiconductor product operation and application examples. The incorporation of these
circuits, software and information in the design of a customer's equipment shall be done under the full
responsibility of the customer. NEC Electronics assumes no responsibility for any losses incurred by
customers or third parties arising from the use of these circuits, software and information.
• While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products,
customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To
minimize risks of damage to property or injury (including death) to persons arising from defects in NEC
Electronics products, customers must incorporate sufficient safety measures in their design, such as
redundancy, fire-containment and anti-failure features.
• NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and
"Specific".
The "Specific" quality grade applies only to NEC Electronics products developed based on a customerdesignated "quality assurance program" for a specific application. The recommended applications of an NEC
Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of
each NEC Electronics product before using it in a particular application.
"Standard": Computers, office equipment, communications equipment, test and measurement equipment, audio
and visual equipment, home electronic appliances, machine tools, personal electronic equipment
and industrial robots.
"Special": Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster
systems, anti-crime systems, safety equipment and medical equipment (not specifically designed
for life support).
"Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life
support systems and medical equipment for life support, etc.
The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC
Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications
not intended by NEC Electronics, they must contact an NEC Electronics sales representative in advance to
determine NEC Electronics' willingness to support a given application.
(Note)
(1) "NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its
majority-owned subsidiaries.
(2) "NEC Electronics products" means any product developed or manufactured by or for NEC Electronics (as
defined above).
M8E 02. 11-1
User’s Manual U16553EJ1V0UM
3
Regional Information
Some information contained in this document may vary from country to country. Before using any NEC
Electronics product in your application, pIease contact the NEC Electronics office in your country to
obtain a list of authorized representatives and distributors. They will verify:
•
Device availability
•
Ordering information
•
Product release schedule
•
Availability of related technical literature
•
Development environment specifications (for example, specifications for third-party tools and
components, host computers, power plugs, AC supply voltages, and so forth)
•
Network requirements
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary
from country to country.
NEC Electronics America, Inc. (U.S.)
Santa Clara, California
Tel: 408-588-6000
800-366-9782
Fax: 408-588-6130
800-729-9288
NEC Electronics (Europe) GmbH
Duesseldorf, Germany
Tel: 0211-65 03 01
Fax: 0211-65 03 327
• Sucursal en España
Madrid, Spain
Tel: 091-504 27 87
Fax: 091-504 28 60
• Succursale Française
Vélizy-Villacoublay, France
Tel: 01-30-67 58 00
Fax: 01-30-67 58 99
• Filiale Italiana
Milano, Italy
Tel: 02-66 75 41
Fax: 02-66 75 42 99
NEC Electronics Hong Kong Ltd.
• Branch The Netherlands
Eindhoven, The Netherlands
Tel: 040-244 58 45
Fax: 040-244 45 80
NEC Electronics Hong Kong Ltd.
Hong Kong
Tel: 2886-9318
Fax: 2886-9022/9044
Seoul Branch
Seoul, Korea
Tel: 02-528-0303
Fax: 02-528-4411
• Tyskland Filial
Taeby, Sweden
Tel: 08-63 80 820
Fax: 08-63 80 388
NEC Electronics Shanghai, Ltd.
• United Kingdom Branch
Milton Keynes, UK
Tel: 01908-691-133
Fax: 01908-670-290
NEC Electronics Taiwan Ltd.
Shanghai, P.R. China
Tel: 021-6841-1138
Fax: 021-6841-1137
Taipei, Taiwan
Tel: 02-2719-2377
Fax: 02-2719-5951
NEC Electronics Singapore Pte. Ltd.
Novena Square, Singapore
Tel: 6253-8311
Fax: 6250-3583
J02.11
4
User’s Manual U16553EJ1V0UM
PREFACE
Target Readers
This manual is for users who design and develop µ PD77016 Family application systems.
µ PD77016 Family is the generic name for the µ PD7701x family (µ PD77015, 77016,
77017, 77018A, 77019), the µ PD77111 Family (µ PD77110, 77111, 77112, 77113A,
77114, 77115) and the µ PD77210 Family (µ PD77210, 77213). However, this manual is
for µ PD77110, 77113A, 77114, 77115, 77210, and 77213 devices.
Purpose
The purpose of this manual is to help users understand the supporting middleware when
designing and developing µ PD77016 Family application systems.
Organization
This manual consists of the following contents.
• OVERVIEW
• LIBRARY SPECIFICATIONS
• INSTALLATION
• SYSTEM EXAMPLE
• SAMPLE PROGRAM SOURCE
How to Read This Manual
It is assumed that the reader of this manual has general knowledge in the fields of
electrical engineering, logic circuits, microcontrollers, and the C language.
To learn about µ PD77111 Family hardware functions
→ Refer to µ PD77111 Family User’s Manual Architecture.
To learn about µ PD77210 Family hardware functions
→ Refer to µ PD77210 Family User’s Manual Architecture.
To learn about µ PD77016 Family instructions
→ Refer to µ PD77016 Family User’s Manual Instruction.
Conventions
Data significance:
Higher digits on the left and lower digits on the right
Active low representation:
XXX (overscore over pin or signal name)
Note:
Footnote for item marked with Note in the text
Caution:
Information requiring particular attention
Remark:
Supplementary information
Numerical representation:
Binary ... XXXX or 0bXXXX
Decimal ... XXXX
Hexadecimal ... 0xXXXX
User’s Manual U16553EJ1V0UM
5
Related Documents
The related documents listed below may include preliminary versions.
However,
preliminary versions are not marked as such.
Documents Related to Devices
Part Number
µ PD77110
Pamphlet
U12395E
Data Sheet
U12801E
User’s Manual
Application Note
Architecture
Instructions
Basic Software
U14623E
U13116E
U11958E
µ PD77111
µ PD77112
µ PD77113A
U14373E
µ PD77114
µ PD77115
U14867E
µ PD77210
U15203E
U15807E
µ PD77213
Documents Related to Development Tools
Document Name
RX77016 User’s Manual
RX77016 Application Note
Document No.
Function
U14397E
Configuration Tool
U14404E
HOST API
U14371E
Document Name
Document No.
Documents Related to Middleware
µ SAP77106-B07 User's Manual (MP3 Decoder)
U15134E
µ SAP77106-B19 User's Manual (MP3 Encoder)
This manual
Documents Related to Standard
Document Name
ISO/IEC 11172-3:1993 Information technology - Coding of moving pictures and associated audio for digital storage Media
at up to about 1.5 Mbit/s - Part3
JIS X 4323-1995 Information technology of Japan Industrial Standard - Coding of moving pictures and associated audio
for digital storage Media at up to about 1.5 Mbit/s - Part3: Audio (MR-4284 1995.10.27)
ISO/IEC 13818-3 Information technology - Generic coding of moving pictures and associated audio information - Part 3:
Audio
JIS X 4327 Generic coding of moving pictures and associated audio information - Part 3: Audio
Caution
The related documents listed above are subject to change without notice. Be sure to use the latest
version of each document for designing.
6
User’s Manual U16553EJ1V0UM
CONTENTS
CHAPTER 1 OVERVIEW ..........................................................................................................................10
1.1 Middleware....................................................................................................................................................10
1.2 MP3 Audio Encoder .....................................................................................................................................10
1.2.1 Encoder outline .................................................................................................................................11
1.3 Compressed Data Format ...........................................................................................................................14
1.3.1 Header ..............................................................................................................................................15
1.3.2 CRC ..................................................................................................................................................16
1.3.3 Side information ................................................................................................................................17
1.3.4 Audio data .........................................................................................................................................17
1.3.5 Additional data ..................................................................................................................................17
1.4 Product Overview.........................................................................................................................................18
1.4.1 Features ............................................................................................................................................18
1.4.2 Function ............................................................................................................................................18
1.4.3 Operating environment......................................................................................................................19
1.4.4 Performance......................................................................................................................................20
1.4.5 Directory configuration ......................................................................................................................21
CHAPTER 2 LIBRARY SPECIFICATIONS .............................................................................................22
2.1 Library Overview..........................................................................................................................................22
2.2 Application Processing Flow ......................................................................................................................23
2.3 Function Specifications ..............................................................................................................................24
2.3.1 MP3ENC_Start function ....................................................................................................................24
2.3.2 MP3ENC_Encode function ...............................................................................................................25
2.3.3 MP3ENC_Stop function ....................................................................................................................26
2.3.4 MP3ENC_GetVersion function ..........................................................................................................27
2.4 Parameters Necessary for Compression ...................................................................................................28
2.5 Memory Structure ........................................................................................................................................29
2.5.1 Scratch area......................................................................................................................................29
2.5.2 Static area .........................................................................................................................................29
2.5.3 Input buffer ........................................................................................................................................30
2.5.4 Output buffer .....................................................................................................................................31
CHAPTER 3 INSTALLATION ...................................................................................................................32
3.1 Installation Procedure .................................................................................................................................32
3.2 Sample Program Creation Procedure ........................................................................................................33
3.3 Symbol Naming Conventions .....................................................................................................................34
CHAPTER 4 SYSTEM EXAMPLE ...........................................................................................................35
4.1 Simulation Environment Using Timing File ...............................................................................................35
4.2 Operation ......................................................................................................................................................35
User’s Manual U16553EJ1V0UM
7
APPENDIX SAMPLE PROGRAM SOURCE ..........................................................................................36
A.1 Header File (mp3enc.h)............................................................................................................................... 36
A.2 Sample Source File (sample.asm) ............................................................................................................. 37
A.3 Timing File for Parameter Information (value.tmg) .............................................................................. 47
A.4 Timing File for Data Input (pcm_in.tmg) ................................................................................................... 49
A.5 Timing File for Data Output (stream_out.tmg).......................................................................................... 52
8
User’s Manual U16553EJ1V0UM
LIST OF FIGURES
Figure No.
Title
Page
1-1. Encoder Configuration Example ..........................................................................................................................11
1-2. System Configuration Example............................................................................................................................11
1-3. Timing Diagram....................................................................................................................................................13
1-4. Compressed Data Format....................................................................................................................................14
2-1. Application Processing Flow ................................................................................................................................23
2-2. Structure Consisting of Parameters Necessary for Compression ........................................................................28
2-3. User-Defined Input Buffer (PCM Buffer)...............................................................................................................30
2-4. Output Buffer (Bit Stream Buffer) .........................................................................................................................31
LIST OF TABLES
Table No.
Title
Page
1-1. Sampling Frequencies .........................................................................................................................................10
1-2. Number of Words of Input Data ...........................................................................................................................11
1-3. Selectable Bit Rates.............................................................................................................................................12
1-4. Details of Header Section ....................................................................................................................................15
1-5. Relationship of Bit Values to Bit Rates.................................................................................................................16
1-6. Relationship of Bit Values to Sampling Frequencies............................................................................................16
1-7. Size of Side Information .......................................................................................................................................17
1-8. Required Memory Sizes.......................................................................................................................................19
1-9. Software Tools......................................................................................................................................................19
1-10. MIPS Values of 1-Frame Compression Processing (Measured Values) ............................................................20
2-1. List of Library Functions.......................................................................................................................................22
2-2. Values to Specify Sampling Frequency................................................................................................................28
2-3. Symbol Name/Memory Sizes...............................................................................................................................29
2-4. Input Buffer Size...................................................................................................................................................30
3-1. Symbol Naming Conventions ...............................................................................................................................34
User’s Manual U16553EJ1V0UM
9
CHAPTER 1 OVERVIEW
1.1 Middleware
Middleware is the name given to a group of software that has been tuned so that it draws out the maximum
performance of the processor and enables processing that is conventionally performed by hardware to be performed
by software.
The concept of middleware was introduced with the development of a new high-speed processor, the DSP, in order
to facilitate operation of the environments integrated in the system.
By providing appropriate speech codec and image data compression/decompression-type middleware, NEC
Electronics is offering users the kind of technology essential in the realization of a multimedia system for the
µ PD77016 Family, and is continuing its promotion of system development.
µ SAP77016-B19 is middleware that provides MP3-technology encoding functions.
1.2 MP3 Audio Encoder
MP3 is a method used for coding or decoding high-quality audio signals for storage media. It includes MPEG-1
Audio Layer-3 and MPEG-2 Audio Layer-3 LSF (Low Sampling Frequency). The µ SAP77016-B19 conforms to this
coding method.
The compressed data format of MPEG-1 Audio Layer-3 conforms to “ISO/IEC 11172-3”, and that of MPEG-2 Audio
Layer-3 conforms to “ISO/IEC 13818-3”. MP3 handles 16-bit linear PCM audio data sampled at a frequency from 16
kHz to 48 kHz (refer to Table 1-1).
Table 1-1. Sampling Frequencies
10
MPEG-1 Audio Layer-3
[Hz]
MPEG-2 Audio Layer-3 LSF
[Hz]
32000
16000
44100
22050
48000
24000
User’s Manual U16553EJ1V0UM
CHAPTER 1 OVERVIEW
1.2.1 Encoder outline
Figure 1-1 shows an example of the configuration of an encoder using the µ SAP77016-B19. Figure 1-2 shows an
example of the configuration of a system that includes an encoder using the µ SAP77016-B19.
Figure 1-1. Encoder Configuration Example
IN
(Analog audio data)
16-bit
ADC
Sampling frequency
16 kHz to 48 kHz
Selectable bit rates
8 kbps to 320 kbps
Encoder (MP3)
OUT
(Compression data)
(16-bit linear
PCM data)
Figure 1-2. System Configuration Example
CD
player
Evaluation board
AUDIO SERIAL INTERFACE
LINE IN
DSP
PARALLEL PORT
PC
(1) Input data
The input data is 16-bit linear PCM data sampled at 16 kHz to 48 kHz (refer to Table 1-1).
Table 1-2 shows the number of words of input data per frame.
Table 1-2. Number of Words of Input Data
Compression Ratio
Number of
Channels
Number of Words of
Input Audio Data
MPEG-1
1
1152
Audio Layer-3
2
2304
MPEG-2
1
576
Audio Layer-3 LSF
2
1152
Remark 1 word = 16 bits
User’s Manual U16553EJ1V0UM
11
CHAPTER 1 OVERVIEW
(2) MP3 audio encoder
The MP3 audio encoder reads 16-bit linear PCM data and outputs data while controlling the code quantity at a set
bit rate. The bit rate per frame is variable.
Table 1-3 shows the bit rates that can be set.
Table 1-3. Selectable Bit Rates
MPEG-1 Audio Layer-3
[kbps]
12
MPEG-2 Audio Layer-3 LSF
[kbps]
32
8
40
16
48
24
56
32
64
40
80
48
96
56
112
64
128
80
160
96
192
112
224
128
256
144
320
160
User’s Manual U16553EJ1V0UM
CHAPTER 1 OVERVIEW
(3) Timing diagram
Figure 1-3 shows the timing diagram of the MP3 audio encoder.
Figure 1-3. Timing Diagram
16-bit linear PCM data of 1 frame
Compressed data of 1 frame
Audio serial input
interrupt handler
<1>
MP3 compression
processing
<2>
Bit stream output
<3>
User application
<4>
0
Time
Audio input data length of 1 frame
<1> 16-bit linear PCM data of one frame is input.
<2> The 16-bit linear PCM data of one frame is buffered and compressed.
<3> The compressed data is buffered and output.
<4> The user performs appropriate processing.
User’s Manual U16553EJ1V0UM
13
CHAPTER 1 OVERVIEW
1.3 Compressed Data Format
The compressed data format conforms to ISO/IEC 11172-3 and/or JIS X4323. However, the µ SAP77016-B19
does not support the free format when the bitrate_index is 0000. The compressed data consists of a number of bit
streams, each of which is called a frame.
Figure 1-4 shows the structure of the compressed data format.
Figure 1-4. Compressed Data Format
Compressed data (1 file)
Frame
Frame
Frame
Frame
Frame
1 frame
Header
14
CRC
Side information
Audio data
User’s Manual U16553EJ1V0UM
Additional data
CHAPTER 1 OVERVIEW
1.3.1 Header
Headers contain information such as the sampling frequency, bit rate, and mode for synchronizing.
Table 1-4. Details of Header Section
Information
Number of
Bits Used
Frame sync word
12
ID
1
Value
‘1111 1111 1111’: Fixed value
‘1’: MPEG-1
‘0’: MPEG-2
Layer
2
‘11’: Layer1/‘10’: Layer2/‘01’: Layer3
Protection bit
1
Bit rate
4
Refer to Table 1-5 Relationship of Bit Values to Bit Rates.
Sampling frequency
2
Refer to Table 1-6 Relationship of Bit Values to Sampling
Frequencies.
Padding bit
1
‘1’: 1 byte is added to frameNote 1
Private bit
1
Mode
2
(Fixed to 01 in the µ SAP77016-B19.)
‘0': Has CRC
‘1’: No CRC
(Fixed to 1 in the µ SAP77016-B19.)
‘0’: 1 byte not added to frame
Not used (Fixed to 0 in the µ SAP77016-B19.)
‘00’: stereo
‘01’: joint_stereo
‘10’: dual_channel
‘11’: single_channel
(In the µ SAP77016-B19, fixed to 01 in the case of stereo,
and 11 in the case of mono.)
Mode extensionNote 2
2
‘00’: is_off, ms_off
‘01’: is_on, ms_off
‘10’: is_off, ms_on
‘11’: is_on, ms_on
(Fixed to 10 in the µ SAP77016-B19.)
Copyright
1
‘0’: no copyright
‘1’: copyright protected
(Fixed to 0 in the µ SAP77016-B19.)
Original/copy distinction
1
‘0’: copy
‘1’: original
(Fixed to 1 in the µ SAP77016-B19.)
Emphasis
2
‘00’: no emphasis
‘01’: 50/15 µ s
‘10’: reserved
‘11’: CCITT J.17
(Fixed to 00 in the µ SAP77016-B19.)
Notes 1. For a sampling frequency of 44.1 kHz, 1 byte is added to adjust frame ends.
2. “is” designates intensity stereo and “ms” MS stereo.
User’s Manual U16553EJ1V0UM
15
CHAPTER 1 OVERVIEW
Table 1-5. Relationship of Bit Values to Bit Rates
Value
MPEG-1 Audio Layer-3
[kbps]
MPEG-2 Audio Layer-3 LSF
[kbps]
Free formatNote
‘0000’
‘0001’
32
8
‘0010’
40
16
‘0011’
48
24
‘0100’
56
32
‘0101’
64
40
‘0110’
80
48
‘0111’
96
56
‘1000’
112
64
‘1001’
128
80
‘1010’
160
96
‘1011’
192
112
‘1100’
224
128
‘1101’
256
144
‘1110’
320
160
‘1111’
Setting prohibited
Note Not supported by µ SAP77016-B19
Table 1-6. Relationship of Bit Values to Sampling Frequencies
Value
MPEG-1 Audio Layer-3
[Hz]
MPEG-2 Audio Layer-3 LSF
[Hz]
‘00’
44100
22050
‘01’
48000
24000
‘10’
32000
‘11’
16000
Setting prohibited
1.3.2 CRC
There are two bytes of information that follow the header only when the header protection bit indicates that CRC is
in effect. If it is not in effect, the two bytes of information do not exist.
In the case of the µ SAP77016-B19, the data is output without CRC.
16
User’s Manual U16553EJ1V0UM
CHAPTER 1 OVERVIEW
1.3.3 Side information
Side information includes information such as the starting position of audio data in a frame and the decoding
method as information needed in decoding audio data.
The size of side information is shown in Table 1-7.
Table 1-7. Size of Side Information
MPEG-1 Audio Layer-3
[byte]
MPEG-2 Audio Layer-3 LSF
[byte]
Mono
17
9
Stereo
32
17
1.3.4 Audio data
This is data related to an audio sample. The starting position of the audio data is set in the side information. Audio
data can start in the same frame as the side information that shows the position of the audio data or it can start in a
preceding frame.
Moreover, the starting position of audio data is not limited to one frame before. It also can start two frames before.
Refer to ISO/IEC 11172-3 for details about audio data.
1.3.5 Additional data
This is a segment in which data that the user can define is loaded. This data sometimes does not exist in a frame.
This data is not appended in the µ SAP77016-B19.
User’s Manual U16553EJ1V0UM
17
CHAPTER 1 OVERVIEW
1.4 Product Overview
1.4.1 Features
• Supports mono (single channel) and stereo (joint stereo).
• 16-bit linear PCM data input.
• Code quantity control at set bit rate (refer to Table 1-5 Relationship of Bit Values to Bit Rates). The bit rate
per frame is variable. A variable bit rate (VBR) is not supported.
• Sampling frequency: 32 kHz/44.1 kHz/48 kHz for MPEG-1 Audio Layer-3; 16 kHz/22.05 kHz/24 kHz for
MPEG-2 Audio Layer-3 LSF (refer to Table 1-6 Relationship of Bit Values to Sampling Frequencies).
• In mono mode (1 channel), codes 1152 samples/frame for MPEG-1 Audio Layer-3, and 576 samples/frame for
MPEG-2 Audio Layer-3 LSF.
• In stereo mode (2 channels), codes 2304 samples/frame for MPEG-1 Audio Layer-3, and 1152 samples/frame
for MPEG-2 Audio Layer-3 LSF.
• MS stereo supported; intensity stereo not supported.
1.4.2 Function
The µ SAP77016-B19 converts 16-bit linear PCM data of one frame into compressed data.
18
User’s Manual U16553EJ1V0UM
CHAPTER 1 OVERVIEW
1.4.3 Operating environment
(1) Operable DSPs:
µ PD77110, 77113A, 77114, 77115, 77210, 77213
(2) Required memory size:
The µ SAP77016-B19 requires memory sizes shown in the following table.
Table 1-8. Required Memory Sizes
Memory
Instruction
memory
X memory
RAM
Type
Size [Kwords]
–
6.6
Scratch area
4.9
Static area
2.3
ROM
Y memory
RAM
3.1
Scratch area
2.5
Static area
3.2
Library area
0.2
ROM
Caution
0.8
Place the X memory and Y memory areas used for the library in the internal ROM/RAM
space.
The µ SAP77016-B19 uses a certain area as both a scratch area and bit stream buffer
area. The required memory size shown above does not include the input buffer (PCM
buffer) for audio data. Refer to 2.5.3 Input buffer.
Remark
One word of instruction memory is 32 bits.
One word of X memory or Y memory is 16 bits.
(3) Required A/D converter specifications
2 channels, 16-bit resolution, sampling frequency shown in Table 1-1 Sampling Frequencies.
(4) Software tools (Windows® version)
Table 1-9. Software Tools
Relevant DSP
Software Tools
µ PD77110 Family
WB77016 (Workbench (Assembler/Linker))
HSM77016 (High-speed simulator)
ID77016 (Debugger)
µ PD77210 Family
Atair Developer Studio (Workbench (Assembler/Linker))
µ PD7721x High-speed simulator
µ PD7721x Debugger
Remark These DSP software tools are produced by Atair Software GmbH.
User’s Manual U16553EJ1V0UM
19
CHAPTER 1 OVERVIEW
1.4.4 Performance
Table 1-10 shows the MIPS values (measured values) necessary for real-time execution of processing of one
frame.
• Measurement conditions
Simulator: HSM77016 (µ PD77016 high-speed simulator)
Evaluation result: The processing speed is measured when a stereo/mono audio file is compressed, and the
average value and maximum value are calculated.
The processing speed of only the MP3ENC_Encode function is included in compression. The
processing speed of the other functions and interrupt handlers is not included.
Table 1-10. MIPS Values of 1-Frame Compression Processing (Measured Values)
(a) MPEG-1 Audio Layer-3
Sampling frequency [kHz]
Setting bit rate [kbps]
32
44.1
48
64
96
128
64
96
128
64
96
128
Stereo
44.5
45.0
47.5
49.3
50.0
53.8
51.4
51.6
56.0
[MIPS]
Mono
22.7
23.0
23.0
25.1
25.9
25.9
26.2
26.9
27.0
Maximum value
Stereo
68.0
69.2
70.7
77.3
75.5
79.1
76.2
73.7
84.2
[MIPS]
Mono
37.6
38.0
38.3
42.4
42.6
40.9
41.3
42.7
44.0
Average value
(b) MPEG-2 Audio Layer-3 LSF
Sampling frequency [kHz]
Setting bit rate [kbps]
16
22.05
64
96
128
64
96
128
64
96
128
Average value
Stereo
22.6
23.0
23.2
30.8
31.1
31.5
31.7
34.1
34.8
[MIPS]
Mono
11.2
11.5
11.9
15.3
15.5
15.8
17.1
16.9
17.4
Maximum value
Stereo
36.2
37.4
36.8
51.7
48.8
51.9
54.7
53.4
56.5
[MIPS]
Mono
21.2
20.9
20.7
27.6
28.2
29.0
30.3
33.7
33.6
Remark
These MIPS values were measured when evaluation was made by NEC Electronics. The maximum
values do not guarantee the worst values.
20
24
User’s Manual U16553EJ1V0UM
CHAPTER 1 OVERVIEW
1.4.5 Directory configuration
The directory configuration of the µ PSAP77016-B19 is shown below.
library
smp
mp3enc
m3eram.lib:
Library for µ PD77110, 77115, 77210
m3erom.lib:
Library for µ PD77113A, 77114, 77213
mp3enc.h:
Header file
sample.prj:
Project file
sample.asm:
Sample source file
value.tmg:
Timing file for parameter information
pcm_in.tmg:
Timing file for data input
stream_out.tmg: Timing file for data output
A summary of each directory is shown below.
• library
This directory contains library files.
• smp/mp3enc
This directory contains sample program source files, header files and timing files.
User’s Manual U16553EJ1V0UM
21
CHAPTER 2 LIBRARY SPECIFICATIONS
2.1 Library Overview
µ SAP77016-B19 provides the following four functions.
Table 2-1. List of Library Functions
Function Name
22
Function
MP3ENC_Start
Initialization
MP3ENC_Encode
Compression process
MP3ENC_Stop
Termination process
MP3ENC_GetVersion
Obtain version information
User’s Manual U16553EJ1V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.2 Application Processing Flow
Figure 2-1 shows an example of the processing of an application that uses µ SAP77016-B19.
Figure 2-1. Application Processing Flow
Start
Data I/O initialization processing
· AD initial setup
· Interrupt enable, etc.
Muted data input to PCM buffer
Encoder initialization
call MP3ENC_Start
Audio serial input
interrupt handler
16-bit liner PCM
data input
End of encoder?
Yes
No
No
Processing to output compressed data
of bit stream buffer from host I/F
Encode processing
call MP3ENC_Encode
Processing to output compressed data
of bit stream buffer from host I/F
1 frame of
sampling count?
Termination processing
call MP3ENC_Stop
Yes
Processing to input data to
PCM buffer
Remark
Encode processing
call MP3ENC_Encode
Encode processing
call MP3ENC_Encode
Encode processing
call MP3ENC_Encode
Processing to output compressed data
of bit stream buffer from host I/F
Processing to output compressed data
of bit stream buffer from host I/F
Termination processing
call MP3ENC_Stop
The 16-bit linear PCM data input processing of the interrupt handler is dependent upon the hardware of
the target system. Therefore, the user should design the input processing in accordance with their
target system.
User’s Manual U16553EJ1V0UM
23
CHAPTER 2 LIBRARY SPECIFICATIONS
2.3 Function Specifications
2.3.1 MP3ENC_Start function
The MP3ENC_Start function initializes each parameter used by the encoder. Call this function only once before
using the MP3ENC_Encode function.
[Classification]
MP3 encoder initialization processing
[Function name]
[Summary of function]
MP3ENC_Start
Initializes the parameters used by the µ SAP77016-B19
[Format]
call MP3ENC_Start
[Arguments]
R0L
First address of static area in X memoryNote
R1L
First address of scratch area in X memoryNote
R2L
First address of static area in Y memoryNote
R3L
First address of scratch area in Y memoryNote
[Return value]
None
[Registers used]
r0, r1, r2, r3, r4, r7,
dp0, dp4, dp5
[Hardware resources]
Maximum stack level
2
Maximum loop stack level
1
Maximum number of repeats
3214
Maximum number of cycles
11642
Note For the memory, refer to 2.5 Memory Structure.
Caution
24
Secure the scratch memory area and static memory area before calling this function.
User’s Manual U16553EJ1V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.3.2 MP3ENC_Encode function
The MP3ENC_Encode function compresses audio data equivalent to the number of words of data shown in Table
1-2 Number of Words of Input Data at a specified bit rate.
[Classification]
MP3 encode processing
[Function name]
MP3ENC_Encode
[Summary of function]
Compresses the 16-bit linear PCM data in the PCM buffer and then outputs the compressed
data to the bit stream buffer.
[Format]
call MP3ENC_Encode
[Arguments]
R0L
First address of structure consisting of parameters necessary for compressing in X
memoryNote 1
R1L
First address of input buffer (PCM buffer) for data input for encoder in X memoryNote 2
R2L
First address of output buffer (bit stream buffer) for data output from encoder in X
memoryNote 2, 3
R3L
First address of static area in X memoryNote 2
R4L
First address of static area in Y memoryNote 2
[Return value]
R0L
When 0 or greater: Size of compressed bit stream (number of bytes)
[Registers used]
r0, r1, r2, r3, r4, r5, r6, r7,
When negative: Error
dp0, dp1, dp2, dp3, dp4, dp5, dp6, dp7,
dn0, dn1, dn2, dn3, dn4, dn5, dn6, dn7,
dmx, dmy
[Hardware resources]
Maximum stack level
7
Maximum loop stack level
2
Maximum number of repeats
31
Maximum MIPS value
84.2 MIPS (48 kHz sampling, 128 kbps, stereo)
Notes 1. For the parameters necessary for compression, refer to 2.4 Parameters Necessary for Compression.
2. For the memory area and I/O buffers, refer to 2.5 Memory Structure.
3. The first address of the output buffer (bit stream buffer) is the same as that of the scratch area in X
memory.
Caution
On completion of encoding, the user should perform the following procedure. This can prevent the
previous audio data from affecting compression of the next audio data.
(1) Input muted data of 1 frame to the PCM buffer frame (refer to Table 1-2 Number of Words of
Input Data).
(2) Call the MP3ENC_Encode function twice.
(3) Call the MP3ENC_Stop function once.
(4) Call the MP3ENC_Encode function once.
(5) Call the MP3ENC_Stop function once.
User’s Manual U16553EJ1V0UM
25
CHAPTER 2 LIBRARY SPECIFICATIONS
2.3.3 MP3ENC_Stop function
The MP3ENC_Stop function terminates encoder processing. For the procedure after terminating encoding, refer to
Figure 2-1 Application Processing Flow.
[Classification]
MP3 encoder termination processing
[Function name]
[Function]
MP3ENC_Stop
Terminates the encoder processing of the µ SAP77016-B19.
[Format]
call MP3ENC_Stop
[Arguments]
R0L:
1 (during the encode termination processing: first call)
0 (during the encode termination processing: second call)
During the encode terminating processing, when calling the MP3ENC_Stop function for the
first time, set 1; for the second time, set 0.
[Return value]
None
[Registers used]
r0, r7,
dp4, dp5
[Hardware resources]
26
Maximum stack level
2
Maximum loop stack level
1
Maximum number of repeats
0
Maximum number of cycles
79
User’s Manual U16553EJ1V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.3.4 MP3ENC_GetVersion function
The MP3ENC_GetVersion function returns the version number of the µ SAP77016-B19.
[Classification]
Version information acquisition
[Function name]
[Function]
MP3ENC_GetVersion
Returns the version number of the µ SAP77016-B19 library in a 32-bit value.
Version when R0 = 0x00’0x0001’0x0100: V1.01
[Format]
call MP3ENC_GetVersion
[Arguments]
None
[Return value]
R0H
Major version number
R0L
Minor version number
[Registers used]
r0
[Hardware resources]
Maximum stack level
0
Maximum loop stack level
0
Maximum number of repeats
0
Maximum number of cycles
6
User’s Manual U16553EJ1V0UM
27
CHAPTER 2 LIBRARY SPECIFICATIONS
2.4 Parameters Necessary for Compression
Secure a structure (refer to Figure 2-2) consisting of the parameters necessary for compression on X memory.
Set the information for each parameter to this structure just once between the execution of the MP3ENC_Start and
MP3ENC_Encoder functions.
Figure 2-2. Structure Consisting of Parameters Necessary for Compression
First address of
structure: R0L
<1> _Header_bitrate_index: 1 word
<2> _Header_sampling_frequency: 1 word
<3> _Header_padding_bit: 1 word
5 words
<4> _Header_mode: 1 word
<5> _Header_mode_extension: 1 word
<1> _Header_bitrate_index (1 word): This parameter sets the bit rate. For the setting values, refer to Table
1-5 Relationship of Bit Values to Bit Rates.
For example, to set a bit rate of 16 kbps using MPEG-2 Audio Layer-3 LSF, set 0x2.
<2> _Header_sampling_frequency (1 word): This parameter specifies the sampling frequency. The setting
values for this word are listed in Table 2-2.
For example, to set a frequency of 16000 Hz using MPEG-2 Audio Layer-3 LSF, set 0x6.
Table 2-2. Values to Specify Sampling Frequency
Compression Method
Value
Frequency [Hz]
MPEG-1
0x0
44100
Audio Layer-3
0x1
48000
0x2
32000
0x3
Setting prohibited
MPEG-2
0x4
22050
Audio Layer-3 LSF
0x5
24000
0x6
16000
0x7
Setting prohibited
<3> _Header_padding_bit (1 word): This parameter does not need to be specified by users. Set any values
here.
<4> _Header_mode (1 word): Set 0x3 when the number of channels is one and 0x1 when two.
<5> _Header_mode_extension (1 word): This parameter does not need to be specified by users. Set any
values here.
28
User’s Manual U16553EJ1V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.5 Memory Structure
With the µ SAP77016-B19, the user must define the memory area and input buffer area necessary for processing.
The scratch memory area and static memory area must be separately defined. For the size of each memory area,
refer to Table 2-3.
Table 2-3. Symbol Name/Memory Sizes
Symbol Name
Caution
Size [Words]
X/Y Plane
Description
scratch_x_area
5000
X
Scratch area
scratch_y_area
2533
Y
Scratch area
static_x_area
2304
X
Static area
static_y_area
3214
Y
Static area
Place the X memory and Y memory areas used for the library in the internal ROM/RAM space.
The size of the scratch memory area and static memory area shown above does not include the
input buffer (PCM buffer). Refer to 2.5.3 Input buffer.
2.5.1 Scratch area
The scratch area is a memory area that can be discarded when it is not used by the µ SAP77016-B19.
The user can use the scratch area freely after encoding processing of one frame.
When the µ SAP77016-B19 uses this area again, however, the information set by the user to this area is not
guaranteed.
Example
Caution
SCRATCH_X
xramseg
scratch_x_area:
ds
SCRATCH_Y
yramseg
scratch_y_area:
ds
5000
2533
The µ SAP77016-B19 also uses the scratch area in X memory as the bit stream buffer.
Therefore, copy the encode data (bit stream) that is output to the scratch area (bit stream
buffer) in X memory to another area after completing encoding of one frame, and then perform
the encoding for the next frame.
2.5.2 Static area
The static area is a memory area that cannot be discarded even when the µ SAP77016-B19 does not operate. The
user must not use the static area.
If the user manipulates this area after initialization, the correct operation of the µ SAP77016-B19 cannot be
guaranteed.
Example
STATIC_X
xramseg
static_x_area:
ds
2304
STATIC_Y
yramseg
static_y_area:
ds
3214
User’s Manual U16553EJ1V0UM
29
CHAPTER 2 LIBRARY SPECIFICATIONS
2.5.3 Input buffer
The input buffer is an area to which audio data (16-bit linear PCM data) is input. The user must secure an area for
the input buffer in X memory. The required input buffer size is shown in Table 2-4.
The user can freely use the input buffer area after encoding of one frame. If the input buffer area is manipulated
during encoding, correct operation is not guaranteed.
Table 2-4. Input Buffer Size
Compression Ratio
Number of
Channels
Number of Words of
Input Audio Data
Required Input
Buffer Size [word]
MPEG-1
1
1152
1152 or more
Audio Layer-3
2
2304
2304 or more
MPEG-2
1
576
576 or more
Audio Layer-3 LSF
2
1152
1152 or more
Remark 1 word = 16 bits
Figure 2-3. User-Defined Input Buffer (PCM Buffer)
First address of
input buffer: R1L
L
R
Size of input buffer
MPEG-1 Audio Layer-3
Mono (1 channel): 1152 words or more
Stereo (2 channels): 2304 words or more
MPEG-2 Audio Layer-3 LSF
Mono (1 channel): 576 words or more
Stereo (2 channels): 1152 words or more
30
User’s Manual U16553EJ1V0UM
CHAPTER 2 LIBRARY SPECIFICATIONS
2.5.4 Output buffer
The output buffer (bit stream buffer) is an area from which bit stream data is output. The µ SAP77016-B19
specifies a certain area as both a scratch area and bit stream buffer area. Therefore, the user does not need to
secure the output buffer in an area other than the scratch area in X memory.
After encoding of one frame, the user can use the output buffer area freely when the output encode data (bit
stream)Note is copied to another area. If the output buffer area is manipulated during encoding, correct operation is
not guaranteed.
Note The maximum size of the bit stream that is output during encoding of one frame is 1872 words.
Caution
The µ SAP77016-B19 also uses the scratch area in X memory as the bit stream buffer. Therefore,
copy the encode data (bit stream) that is output to the scratch area (bit stream buffer) in X memory
to another area after completing encoding of one frame, and then perform the encoding for the next
frame.
Figure 2-4. Output Buffer (Bit Stream Buffer)
First address of
output buffer: R2L
Size of output buffer
5000 words
Remark The first address of the output buffer (bit stream buffer) is the same as that of the scratch area in X memory.
User’s Manual U16553EJ1V0UM
31
CHAPTER 3 INSTALLATION
3.1 Installation Procedure
The µ SAP77016-B19 (MP3 audio encoder middleware) is supplied on a CD-ROM. The procedure for installing the
µ SAP77016-B19 in the host machine is outlined below.
<1> Set the CD-ROM in the CD-ROM drive and copy the files to the directory where WB77016 and HSM77016
(DSP tools) are used (e.g. C:\DSPTools).
The following is an example of when files are copied from the Q drive to the C drive.
Q:\>xcopy /s *.* C:\DSPTools<CR>
<2> Confirm that the files have been copied. Refer to 1.4.5
directories.
C:\>dir C:\DSPTools<CR>
32
User’s Manual U16553EJ1V0UM
Directory configuration for details on the
CHAPTER 3 INSTALLATION
3.2 Sample Program Creation Procedure
A sample program is stored in the smp directory.
The sample program operates on HSM77016 (high-speed simulator) Ver. 2.32 or later. Using the timing files
described later makes it possible to simulate data I/O.
Refer to APPENDIX
SAMPLE PROGRAM SOURCE
regarding timing files.
The following is an explanation of how to build a sample program of the µ SAP77016-B19.
<1> Start up the WB77016 (workbench) Ver.2.4 or later.
<2> Open the sample.prj project file.
Example Specify sample.prj with the Open Project command on the Project menu.
<3> Execute Build and confirm that sample.lnk has been created.
Example The sample.lnk file can be created by selecting the Build All command from the Make menu.
<4> Start up the HSM77016 (high-speed simulator) Ver.2.32 or later.
<5> Open the sample.lnk file.
Example Specify sample.lnk with the Open command on the File menu.
<6> Open timing files (value.tmg, pcm_in.tmg, stream_out.tmg).
Example Specify value.tmg with the Open command on the File menu.
User’s Manual U16553EJ1V0UM
33
CHAPTER 3 INSTALLATION
3.3 Symbol Naming Conventions
Table 3-1 shows the naming conventions of the symbols used for the µ SAP77016-B19. Do not use symbol names
in duplicate when other applications are used in combination.
Table 3-1. Symbol Naming Conventions
Classification
Convention
Function name, code segment name (IMSEG),
constant segment name (ROMSEG/RAMSEG),
constant name, variable area name
Remark
34
MP3ENC_XXXX
XXXX is an alphanumeric character string.
User’s Manual U16553EJ1V0UM
CHAPTER 4 SYSTEM EXAMPLE
4.1 Simulation Environment Using Timing File
The simulation environment of the compression processing of the µ SAP77016-B19 is shown below. Audio data
(16-bit linear PCM data) is input and compressed in 1-frame units, and the compressed data is output.
[Software environment]
• High-speed simulator: HSM77016 Ver.2.32 or later
• Sample program: sample.lnk (created in 3.2 Sample Program Creation Procedure)
• Timing file: value.tmg, pcm_in.tmg, stream_out.tmg
4.2 Operation
<1> Start up the high-speed simulator.
<2> Open sample.lnk created in 3.2 Sample Program Creation Procedure.
Example Specify sample.lnk by clicking ‘file → open’.
<3> Open the timing files (value.tmg, pcm_in.tmg, stream_out.tmg).
Example Specify value.tmg by clicking ‘file → open’.
<4> Execute using Run.
User’s Manual U16553EJ1V0UM
35
APPENDIX SAMPLE PROGRAM SOURCE
A.1 Header File (mp3enc.h)
/*----------------------------------------------------------------------*/
/*
File Information
*/
/*----------------------------------------------------------------------*/
/*
Name
: mp3enc.h
*/
/*
Type
: header file
*/
/*
Version
: 1.00
*/
/*
Date
: 2002 Nov 26
*/
/*
CPU
: uPD7701x Family
*/
/*
Assembler : WB77016 Ver 2.4
*/
/*
About
: Header
*/
/*
*/
/*----------------------------------------------------------------------*/
/*
Copyright (C) NEC Electronics Corporation 2002
*/
/*
NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
*/
/*
All rights reserved by NEC Electronics Corporation.
*/
/*
Use of copyright notice does not evidence publication
*/
/*----------------------------------------------------------------------*/
#ifndef
#define
_ _ mp3enc_h
_ _ mp3enc_h
#define
#define
#define
#define
MP3ENC_SCRATCH_AREA_X_SIZE
MP3ENC_SCRATCH_AREA_Y_SIZE
MP3ENC_STATIC_AREA_X_SIZE
MP3ENC_STATIC_AREA_Y_SIZE
5000
2533
2304
3214
#define
HeaderSize
5
;typedef struct {
;
short
bitrate_index
;
short
sampling_frequency
;
short
padding_bit
;
short
mode
;
short
mode_extension
;}
extrn
extrn
extrn
extrn
MP3ENC_Start
MP3ENC_Encode
MP3ENC_Stop
MP3ENC_GetVersion
#endif
36
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
A.2 Sample Source File (sample.asm)
(1/10)
/*----------------------------------------------------------------------*/
/*
File Information
*/
/*----------------------------------------------------------------------*/
/*
Name
: sample.asm
*/
/*
Type
: Assembler program module
*/
/*
Version
: 1.00
*/
/*
Date
: 2002 Nov 26
*/
/*
CPU
: uPD7701x Family
*/
/*
Assembler : WB77016 Ver 2.4
*/
/*
About
: sample
*/
/*
*/
/*----------------------------------------------------------------------*/
/*
Copyright (C) NEC Electronics Corporation 2002
*/
/*
NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
*/
/*
All rights reserved by NEC Electronics Corporation.
*/
/*
Use of copyright notice does not evidence publication
*/
/*----------------------------------------------------------------------*/
#include "mp3enc.h"
/*----------------------------------------------------------------------*/
#defineBitstreamBufferSize
MP3ENC_SCRATCH_AREA_X_SIZE
#definePcmBufferSize
1152*2
#defineheader_bitrate_index
#defineheader_sampling_frequency
#defineheader_padding_bit
#defineheader_mode
#defineheader_mode_extension
_Header_bitrate_index:x
_Header_sampling_frequency:x
_Header_padding_bit:x
_Header_mode:x
_Header_mode_extension:x
#defineOutputBufferFlag
#definevalued
#defineBitstreamLength_H
#defineBitstreamLength_L
#defineframe
_OutputBufferFlag:x
_valued:x
_BitstreamLength:x
_BitstreamLength+1:x
_frame:x
#defineChannel
_Channel:x
#definebitrate_H
_bitrate:x
#definebitrate_L
_bitrate+1:x
#definestream_length
_stream_length:x
#defineFW_out_flag
_FW_out_flag:x
#defineFW_run_flag
_FW_run_flag:x
/*----------------------------------------------------------------------*/
MAIN_CTRL_WORKxramseg at 0x0ff0
_Channel:
ds
_bitrate:
ds
_OutputBufferFlag:
ds
_valued:
ds
1
2
1
1
User’s Manual U16553EJ1V0UM
37
APPENDIX SAMPLE PROGRAM SOURCE
(2/10)
Header:
_Header_bitrate_index:
_Header_sampling_frequency:
_Header_padding_bit:
_Header_mode:
_Header_mode_extension:
ds
ds
ds
ds
ds
1
1
1
1
1
_BitstreamLength:
_frame:
ds
ds
2
1
_stream_length:
_FW_out_flag:
_FW_run_flag:
ds
ds
ds
1
1
1
ds
PcmBufferSize
MAIN_Y_WORK
yramseg at 0x2000
OutBitstreamBuffer:
ds
0x1000
STATIC_X
xramseg
static_x_area:
ds
MP3ENC_STATIC_AREA_X_SIZE
SCRATCH_X
xramseg
_ _ BitstreamBuffer:
ds
MP3ENC_SCRATCH_AREA_X_SIZE
STATIC_Y
yramseg
static_y_area:
ds
MP3ENC_STATIC_AREA_Y_SIZE
SCRATCH_Y
yramseg
scratch_y_area:
ds
MP3ENC_SCRATCH_AREA_Y_SIZE
MAIN_X_WORK1
PCM:
; use in timing file
; use in timing file
; use in timing file
; use in timing file
xramseg at 0x2000
;-----------------------------------------------VECTOR imseg at 0x200
%define (JmpVect(addr))
(
jmp addr;
nop;
nop;
nop;
)
%define (NopVect)
(
nop;
reti;
nop;
nop;
)
38
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
(3/10)
ivReset:
%JmpVect(StartUp)
%NopVect
%NopVect
%NopVect
ivINT1:
%NopVect
ivINT2:
%NopVect
ivINT3:
%NopVect
ivINT4:
%NopVect
ivINT5:
%NopVect
ivINT6:
%NopVect
ivINT7:
%NopVect
ivINT8:
%NopVect
ivINT9:
%NopVect
ivINT10:
%NopVect
ivINT11:
%NopVect
ivINT12:
%NopVect
MAIN
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
imseg at 0x240
%define(Initialize)
(
clr (r0)
r1 = r0
r2 = r0
r3 = r0
r4 = r0
r5 = r0
r6 = r0
r7 = r0
dp0 = r0l
dp1 = r0l
dp2 = r0l
dp3 = r0l
dp4 = r0l
dp5 = r0l
dp6 = r0l
dp7 = r0l
dn0 = r0l
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
User’s Manual U16553EJ1V0UM
39
APPENDIX SAMPLE PROGRAM SOURCE
(4/10)
dn1 = r0l
dn2 = r0l
dn3 = r0l
dn4 = r0l
dn5 = r0l
dn6 = r0l
dn7 = r0l
dmx = r0l
dmy = r0l
sp = r0l
lsp = r0l
r0l = 0xffff
sr = r0l
eir = r0l
;
;
;
;
;
;
;
;
;
;
;
;
;
;
)
StartUp:
%Initialize
;
clr (r0)
dp0 = _ _ BitstreamBuffer
rep BitstreamBufferSize
*dp0++ = r0h
dp0 = PCM
rep PcmBufferSize
*dp0++ = r0h
;
;
;
;
;
;
;
*OutputBufferFlag = r0h
*valued = r0h
*stream_length = r0h
;
;
;
r0l = static_x_area
r1l = _ _ BitstreamBuffer
r2l = static_y_area
r3l = scratch_y_area
call MP3ENC_Start
;MP3ENC_Start (static_x_area, (scratch_y_area=)__BitstreamBuffer,
;
static_y_area, scratch_y_area)
;
;
;
clr (r0)
*FW_run_flag = r0h
r0 = *FW_run_flag
if (r0 == 0) jmp $-1
;run_flag = 0
;
;while (run_flag == 0) {}
;
;; header analysis ;; (MSB) ;; 22+2+4+16 = 44byte -> 22word
dp0 = PCM
;
rep 22/2
;fread (buff, 1, 22, fi)
r0 = *dp0++
;
r0 = *dp0++
;fread (&Channel, 1, 2, fi)
*Channel = r0h
;
r0l = *dp0++
;fread (&freq, 1, 4, fi)
r0eh = *dp0++
;
;fread (buff, 1, 16, fi)
40
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
(5/10)
clr (r1)
r2 = r0 if (r2 ==
r1 = r1 +
r2 = r0 if (r2 ==
r1 = r1 +
r2 = r0 if (r2 ==
r1 = r1 +
r2 = r0 if (r2 ==
r1 = r1 +
r2 = r0 if (r2 ==
r1 = r1 +
r2 = r0 if (r2 ==
jmp $
44100
0) jmp _break
1
48000
0) jmp _break
1
32000
0) jmp
2
22050
0) jmp
1
24000
0) jmp
1
16000
0) jmp
;index = 0
;switch (freq) {
;case 44100: index = 0;
;
;case 48000: index = 1;
;
;
;case 32000: index = 2;
break
break
break
_break
;
;
;case 22050: index = 4;
break
_break
;
;
;case 24000: index = 5;
break
_break
;
;
;case 16000: index = 6;
break
_break
;
;defualt:
exit
_break:
;}
*header_sampling_frequency = r1l;header.sampling_frequency = index
clr (r0)
r1 = r0 + 1
r0l = *Channel
r2 = r0 - 2
if (r2 != 0) r1 = r1 + 1
if (r2 != 0) r1 = r1 + 1
*header_mode = r1l
;
;k = 1
;if (Channel != 2)
;
k += 2
;
;
;header.mode = k
clr (r1)
r0 = r1 + 64000
nop
*bitrate_H = r0h
*bitrate_L = r0l
;
;64kbps
;
;
;
r1l = *header_sampling_frequency;
r2 = r1 - 4
;
r0 = *bitrate_H
;
r0l = *bitrate_L
;
clr (r1)
;
if (r2 >= 0) jmp _MPEG2
;if (header.sampling_frequency < 4) {
_MPEG1:
;
r2 = r0 & 7
;
switch (bitrate) {
if (r2 != 0) jmp _break2
;
r0 = r0 sra 3
;
r2 = r0 - (32000/8)
;
case 32000:
r1 = r1 + 1
;
index = 1
if (r2 == 0) jmp _break2
;
break
r2 = r0 - (40000/8)
;
case 40000:
r1 = r1 + 1
;
index = 2
User’s Manual U16553EJ1V0UM
41
APPENDIX SAMPLE PROGRAM SOURCE
(6/10)
if (r2 == 0) jmp _break2
r2 = r0 - (48000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (56000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (64000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (80000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (96000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (112000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (128000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (160000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (192000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (224000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (256000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
r2 = r0 - (320000/8)
r1 = r1 + 1
if (r2 == 0) jmp _break2
clr (r1)
jmp _break2
_MPEG2:
r2
if
r0
r2
r1
if
r2
r1
if
r2
r1
42
= r0 & 3
(r2 != 0) jmp _break2
= r0 sra 2
= r0 - (8000/4)
= r1 + 1
(r2 == 0) jmp _break2
= r0 - (16000/4)
= r1 + 1
(r2 == 0) jmp _break2
= r0 - (24000/4)
= r1 + 1
;
break
;
case 48000:
;
index = 3
;
break
;
case 56000:
;
index = 4
;
break
;
case 64000:
;
index = 5
;
break
;
case 80000:
;
index = 6
;
break
;
case 96000:
;
index = 7
;
break
;
case 112000:
;
index = 8
;
break
;
case 128000:
;
index = 9
;
break
;
case 160000:
;
index = 10
;
break
;
case 192000:
;
index = 11
;
break
;
case 224000:
;
index = 12
;
break
;
case 256000:
;
index = 13
;
break
;
case 320000:
;
index = 14
;
;
default:
;
index = 0
;
}
;} else {
;
switch (bitrate) {
;
;
;
case 8000:
;
index = 1
;
break
;
case 16000:
;
index = 2
;
break
;
case 24000:
;
index = 3
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
(7/10)
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
r2 = r0 r1 = r1 +
if (r2 ==
clr (r1)
0) jmp _break2
(32000/4)
1
0) jmp _break2
(40000/4)
1
0) jmp _break2
(48000/4)
1
0) jmp _break2
(56000/4)
1
0) jmp _break2
(64000/4)
1
0) jmp _break2
(80000/4)
1
0) jmp _break2
(96000/4)
1
0) jmp _break2
(112000/4)
1
0) jmp _break2
(128000/4)
1
0) jmp _break2
(144000/4)
1
0) jmp _break2
(160000/4)
1
0) jmp _break2
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
_break2:
;}
*header_bitrate_index = r1l ;
clr (r0)
*frame = r0h
*BitstreamLength_H = r0h
*BitstreamLength_L = r0l
_while1:
clr (r0)
*FW_run_flag = r0h
r0 = *FW_run_flag
if (r0 == 0) jmp $-1
if (r0 < 0) jmp _break1
break
case 32000:
index
break
case 40000:
index
break
case 48000:
index
break
case 56000:
index
break
case 64000:
index
break
case 80000:
index
break
case 96000:
index
break
case 112000:
index
break
case 128000:
index
break
case 144000:
index
break
case 160000:
index
= 4
= 5
= 6
= 7
= 8
= 9
= 10
= 11
= 12
= 13
= 14
default:
index = 0
}
;
;frame = 0
;BitstreamLength = 0
;
;while
;
;
;
;
;
(1) {
run_flag = 0
while (run_flag == 0) {}
if (run_flag < 0) break
User’s Manual U16553EJ1V0UM
43
APPENDIX SAMPLE PROGRAM SOURCE
(8/10)
r0l = Header
r1l = PCM
r2l = _ _ BitstreamBuffer
r3l = static_x_area
r4l = static_y_area
call MP3ENC_Encode
if (r0 < 0) jmp _exit
call CopyOutputBuffer
;
;
;
;
;
;
;
;
r1l = *frame
r1 = r1 + 1
*frame = r1l
;
;
;
jmp _while1
;}
_break1:
;; MP3ENC_Stop process ;;
clr (r0)
dp0 = PCM
rep 1152*2
*dp0++ = r0h
;
;
;
;
44
ret = MP3ENC_Encode (&Header, PCM, BitstreamBuffer,
static_x_area, static_y_area)
if (ret < 0) exit(ret)
CopyOutputBuffer (ret, BitstreamBuffer)
frame++
r1 = r0 + PCM
r2 = r0 + _ _ BitstreamBuffer
r0l = Header
r3l = static_x_area
r4l = static_y_area
call MP3ENC_Encode
if (r0 < 0) jmp _exit
call CopyOutputBuffer
r0l = Header
r1l = PCM
r2l = _ _ BitstreamBuffer
r3l = static_x_area
r4l = static_y_area
call MP3ENC_Encode
if (r0 < 0) jmp _exit
call CopyOutputBuffer
;ret = MP3ENC_Encode (&Header, PCM, BitstreamBuffer,
;
static_x_area, static_y_area)
;
;
;
;
;if (ret < 0) exit(ret)
;CopyOutputBuffer (ret, BitstreamBuffer)
;ret = MP3ENC_Encode (&Header, PCM, BitstreamBuffer,
;
static_x_area, static_y_area)
;
;
;
;
;if (ret < 0) exit(ret)
;CopyOutputBuffer (ret, BitstreamBuffer)
r0l = 1
call MP3ENC_Stop
;FinalFrame = 1
;
r0l = Header
r1l = PCM
r2l = _ _ BitstreamBuffer
r3l = static_x_area
r4l = static_y_area
call MP3ENC_Encode
if (r0 < 0) jmp _exit
call CopyOutputBuffer
;ret = MP3ENC_Encode (&Header, PCM, BitstreamBuffer,
;
static_x_area, static_y_area)
;
;
;
;
;if (ret < 0) exit(ret)
;CopyOutputBuffer (ret, BitstreamBuffer)
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
(9/10)
clr (r0)
call MP3ENC_Stop
;FinalFrame = 0
;
r0 = *OutputBufferFlag
;
if (r0 == 0) jmp _exit
;
r0 = *valued
;
*OutBitstreamBuffer:y = r0h ;
r0l = 1
;
*stream_length = r0l
;
clr (r1)
*FW_out_flag = r1h
r1 = *FW_out_flag
if (r1 == 0) jmp $-1
;
;
;
;
_exit:
clr (r0)
r0l = 0x2222
*stream_length = r0l
*FW_out_flag = r0h
*FW_run_flag = r0h
jmp StartUp
;
;length = 0x2222
;
;out_flag = 0
;run_flag = 0
;
;; Copy from BitstreamBuffer to output buffer ;;
CopyOutputBuffer:
if (r0 == 0) ret
;
r1 = *BitstreamLength_H
r1l = *BitstreamLength_L
r1 += r0
*BitstreamLength_H = r1h
*BitstreamLength_L = r1l
;
;
;
;
;
dp4 = OutBitstreamBuffer
dp0 = _ _ BitstreamBuffer
r2 = *OutputBufferFlag
if (r2 != 0) jmp _L1
;wpt = OutBitstreamBuffer
;rpt = BitstreamBuffer
;if (OutputBufferFlag == 0) {
;
r1 = r0 sra 1
*stream_length = r1l
r2 = r0 & 1
loop r1l {
r1 = *dp0++
*dp4++ = r1h
}
*OutputBufferFlag = r2l
if (r2 == 0) jmp _L2
r1 = *dp0
*valued = r1h
;
;
;
;
;
;
;
;
;
;
;
count = len >> 1
for ( ; count > 0; count--) {
tmp = *rpt++
*wpt++ = tmp
}
if (len & 1) {
valued = *rpt
}
User’s Manual U16553EJ1V0UM
45
APPENDIX SAMPLE PROGRAM SOURCE
(10/10)
jmp _L2
_L1:
r1 = r0 sra 1
r2 = r0 & 1
if (r2 != 0) r1 = r1 + 1
*stream_length = r1l
r0 = *valued
r0 = r0 sra 8
loop r1l {
r0l = *dp0++
r0 = r0 sll 8
*dp4++ = r0h
r0 = r0 sll 8
}
r0 = r0 sll 8
*valued = r0h
clr (r1)
if (r2 == 0) r1 = r1 + 1
*OutputBufferFlag = r1l
_L2:
;}
;else {
;
count = len >> 1
;
if (len & 1)
;
count++
;
;
tmp = valued << 8
;
;
for ( ; count > 0; count--) {
;
tmp |= *rpt++
;
tmp <<= 8
;
*wpt++ = (tmp >> 16)
;
tmp <<= 8
;
}
;
;
valued = tmp >> 16
;
*wpt = valued
;
;
;}
clr (r1)
*FW_out_flag = r1l
r1 = *FW_out_flag
if (r1 == 0) jmp $-1
;
;
;
;
ret
;return
end
46
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
A.3 Timing File for Parameter Information (value.tmg)
(1/2)
;;---------------------------------------------------------------------;; File Information
;;---------------------------------------------------------------------;; Name
: value.tmg
;; Type
: Timing File
;; Version
: 1.00
;; Date
: 2002 Nov 26
;; CPU
: uPD7701x Family
;; Assembler : WB77016 Ver2.4
;; About
: for MP3 audio encoder Version 1.00
;;
;;---------------------------------------------------------------------;; Copyright (C) NEC Electronics Corporation 2002
;; NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
;; All rights reserved by NEC Corporation.
;; Use of copyright notice does not evidence publication
;;---------------------------------------------------------------------global Channel, FW_run_flag, FW_out_flag, stream_length, pcm_start, stream_start
global InstAddrBitrate, InstAddrLSF, Sampling
; MPEG1 / 32kHz / stereo
global s32_01, s32_02, s32_03
; bitrate
global b320, b256, b224, b192
; for MPEG1
global b144, b024, b016, b008
; for MPEG2
global b160, b128, b112, b096, b080, b064, b056, b048, b040, b032
local
; for MPEG1/2
MPEG1_MASK, MPEG2_MASK
;;; address setting ;;;
set
Channel
set
Sampling
set
stream_length
set
FW_out_flag
set
FW_run_flag
set
pcm_start
set
stream_start
=
=
=
=
=
=
=
set
set
= 0x0296;;
= 0x02fd;;
InstAddrBitrate
InstAddrLSF
0x0ff0;;
0x0ff6;;
0x0ffd;;
0x0ffe;;
0x0fff;;
0x2000;;
0x2000;;
;;; bitrate flag setting ;;;
set
b320 = 1 << 17
set
b256 = 1 << 16
set
b224 = 1 << 15
set
b192 = 1 << 14
set
b160 = 1 << 13
set
b144 = 1 << 12
set
b128 = 1 << 11
User’s Manual U16553EJ1V0UM
47
APPENDIX SAMPLE PROGRAM SOURCE
(2/2)
set
set
set
set
set
set
set
set
set
set
set
b112
b096
b080
b064
b056
b048
b040
b032
b024
b016
b008
=
=
=
=
=
=
=
=
=
=
=
1
1
1
1
1
1
1
1
1
1
1
<<
<<
<<
<<
<<
<<
<<
<<
<<
<<
<<
10
9
8
7
6
5
4
3
2
1
0
;;; mask flag setting ;;;
set
MPEG1_MASK = b320|b256|b224|b192|b160|b128|b112|b096|b080|b064|b056|b048|b040|b032
set
MPEG2_MASK = b160|b144|b128|b112|b096|b080|b064|b056|b048|b040|b032|b024|b016|b008
sub FlagClear
;;; zero clear ;;;
set
s32_01 = 0
set
s32_02 = 0
set
s32_03 = 0
endsub
sub FlagMask
;;; masking ;;;
set
s32_01 = s32_01 & MPEG1_MASK
set
s32_02 = s32_02 & MPEG1_MASK
set
s32_03 = s32_03 & MPEG1_MASK
endsub
;;; main ;;;
FlagClear
set s32_02 = b040
FlagMask
end
48
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
A.4 Timing File for Data Input (pcm_in.tmg)
(1/3)
;;---------------------------------------------------------------------;; File Information
;;---------------------------------------------------------------------;; Name
: pcm_in.tmg
;; Type
: Timing File
;; Version
: 1.00
;; Date
: 2002 Nov 26
;; CPU
: uPD7701x Family
;; Assembler : WB77016 Ver2.4
;; About
: for MP3 audio encoder Version 1.00
;;
;;---------------------------------------------------------------------;; Copyright (C) NEC Electronics Corporation 2002
;; NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
;; All rights reserved by NEC Corporation.
;; Use of copyright notice does not evidence publication
;;---------------------------------------------------------------------global Channel, FW_run_flag, FW_out_flag, stream_length, pcm_start
global InstAddrBitrate, InstAddrLSF, Sampling
; MPEG1 / 32kHz / stereo
global s32_01, s32_02, s32_03
; bitrate
global b320, b256, b224, b192
; for MPEG1
global b144, b024, b016, b008
; for MPEG2
global b160, b128, b112, b096, b080, b064, b056, b048, b040, b032
; for MPEG1/2
global size, sz
local data, pcm
local bitrate
sub hanten
; (data)
set data = ((data >> 8) & 0xff) | ((data & 0xff) << 8)
endsub
sub WriteData
hanten
set *pcm:x = data
set pcm = pcm + 1
endsub
sub Writting
local
; (size, sz)
tmp
set pcm = pcm_start
if (size >= sz)
rept sz
input data
WriteData
endrept
User’s Manual U16553EJ1V0UM
49
APPENDIX SAMPLE PROGRAM SOURCE
(2/3)
set size = size - sz
else
set tmp = sz - size
rept size
input data
WriteData
endrept
set data = 0
rept tmp
WriteData
endrept
set size = 0
endif
endsub
sub wave2stream
input format hex
input size
set *FW_run_flag:x = 1
wait cond (*FW_run_flag:x != 1)
set sz = 22
Writting
set *FW_run_flag:x = 1
wait cond ip == InstAddrBitrate
set r0 = bitrate
wait cond ip == InstAddrLSF
set sz = 576
if (*Sampling:x < 4)
set sz = sz << 1
endif
if (*Channel:x != 1)
set sz = sz << 1
endif
do
set *FW_run_flag:x = 1
wait cond (*FW_run_flag:x != 1)
exit (size < sz)
Writting
enddo
set *FW_run_flag:x = -1
wait cond (*FW_run_flag:x != -1)
endsub
50
User’s Manual U16553EJ1V0UM
APPENDIX SAMPLE PROGRAM SOURCE
(3/3)
;;; Wait for initialize ;;;
wait 1
if (s32_02)
if (s32_02 & b040)
open input "02u32.dat"
set bitrate = 40000
wave2stream
close input
endif
endif
break
end
User’s Manual U16553EJ1V0UM
51
APPENDIX SAMPLE PROGRAM SOURCE
A.5 Timing File for Data Output (stream_out.tmg)
(1/2)
;;---------------------------------------------------------------------;; File Information
;;---------------------------------------------------------------------;; Name
: stream_out.tmg
;; Type
: Timing File
;; Version
: 1.00
;; Date
: 2002 Nov 26
;; CPU
: uPD7701x Family
;; Assembler : WB77016 Ver2.4
;; About
: for MP3 audio encoder Version 1.00
;;
;;---------------------------------------------------------------------;; Copyright (C) NEC Electronics Corporation 2002
;; NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
;; All rights reserved by NEC Corporation.
;; Use of copyright notice does not evidence publication
;;---------------------------------------------------------------------global FW_out_flag, stream_length, stream_start
; MPEG1 / 32kHz / stereo
global s32_01, s32_02, s32_03
; bitrate
global b320, b256, b224, b192
; for MPEG1
global b144, b024, b016, b008
; for MPEG2
global b160, b128, b112, b096, b080, b064, b056, b048, b040, b032
sub wave2stream2
local data, rpt, length
output #10 format dec
do
set *FW_out_flag:x = 1
wait cond *FW_out_flag:x != 1
set length = *stream_length:x
exit length >= 0x2000
if (length)
set rpt = stream_start
rept length
set data = *rpt:y
output #10 data
set rpt = rpt + 1
endrept
endif
enddo
endsub
52
User’s Manual U16553EJ1V0UM
; for MPEG1/2
APPENDIX SAMPLE PROGRAM SOURCE
(2/2)
;;; main ;;;
wait 1
if (s32_02)
if (s32_02 & b040)
open output #10 "02u32u40.dat"
wave2stream2
close output #10
endif
endif
end
User’s Manual U16553EJ1V0UM
53
[MEMO]
54
User’s Manual U16553EJ1V0UM