parrocchetto/dsPIC_DSC_G.726A_src/encoder_annex.s
2019-04-17 21:32:44 +02:00

473 lines
16 KiB
ArmAsm

/**************************************************************************
*
* ITU-T SOFTWARE TOOLS' GENERAL PUBLIC LICENSE
*
* This "General Public License" is published in the Annex 1 of the
* ITU-T Recommendation on "SOFTWARE TOOLS FOR HOMOGENITY OF RESULTS
* IN THE STANDARDIZATION PROCESS OF SPEECH AND AUDIO CODERS",
* approved in Geneva, 2000.
*
* TERMS AND CONDITIONS
*
* 1. This License Agreement applies to any module or other work
* related to the ITU-T Software Tool Library, and developed by the
* User's Group on Software Tools. The "Module", below, refers to any
* such module or work, and a "work based on the Module" means either
* the Module or any work containing the Module or a portion of it,
* either verbatim or with modifications. Each licensee is addressed
* as "you".
*
* 2. You may copy and distribute verbatim copies of the Module's
* source code as you receive it, in any medium, provided that you:
* - conspicuously and appropriately publish on each copy an appropriate
* copyright notice and disclaimer of warranty;
* - keep intact all the notices that refer to this General Public
* License and to the absence of any warranty; and
* - give any other recipients of the Module a copy of this General
* Public License along with the Module.
* You may charge a fee for the physical act of transferring a copy.
*
* 3. You may modify your copy or copies of the Module or any portion
* of it, and copy and distribute such modifications under the terms
* of Paragraph 1 above, provided that you also do the following:
*
* o cause the modified files to carry prominent notices stating
* that you changed the files and the date of any change; and
*
* o cause the whole of any work that you distribute or publish,
* that in whole or in part contains the Module or any part
* thereof, either with or without modifications, to be licensed
* at no charge to all third parties under the terms of this
* General Public License (except that you may choose to grant
* warranty protection to some or all third parties, at your
* option).
*
* o If the modified module normally reads commands interactively
* when run, you must cause it, when started running for such
* interactive use in the simplest and most usual way, to print or
* display an announcement including an appropriate copyright
* notice and a notice that there is no warranty (or else, saying
* that you provide a warranty) and that users may redistribute
* the module under these conditions, and telling the user how to
* view a copy of this General Public License.
*
* You may charge a fee for the physical act of transferring a copy,
* and you may at your option offer warranty protection in exchange
* for a fee.
*
* Mere aggregation of another independent work with the Module (or
* its derivative) on a volume of a storage or distribution medium
* does not bring the other work under the scope of these terms.
*
* 4. You may copy and distribute the Module (or a portion or
* derivative of it, under Paragraph 2) in object code or executable
* form under the terms of Paragraphs 1 and 2 above provided that you
* also do one of the following:
*
* o accompany it with the complete corresponding machine-
* readable source code, which must be distributed under the terms
* of Paragraphs 1 and 2 above; or,
*
* o accompany it with a written offer, valid for at least three
* years, to give any third party free (except for a nominal
* charge for the cost of distribution) a complete machine-
* readable copy of the corresponding source code, to be
* distributed under the terms of Paragraphs 1 and 2 above; or,
*
* o accompany it with the information you received as to where
* the corresponding source code may be obtained. (This
* alternative is allowed only for noncommercial distribution and
* only if you received the module in object code or executable
* form alone.)
*
* Source code for a work means the preferred form of the work for
* making modifications to it. For an executable file, complete
* source code means all the source code for all modules it contains;
* but, as a special exception, it need not include source code for
* modules which are standard libraries that accompany the operating
* system on which the executable file runs, or for standard header
* files or definitions files that accompany that operating system.
*
* 5. You may not copy, modify, sublicense, distribute or transfer
* the Module except as expressly provided under this General Public
* License. Any attempt otherwise to copy, modify, sublicense,
* distribute or transfer the Module is void, and will automatically
* terminate your rights to use the Module under this License.
* However, parties who have received copies, or rights to use copies,
* from you under this General Public License will not have their
* licenses terminated so long as such parties remain in full
* compliance.
*
* 6. By copying, distributing or modifying the Module (or any work
* based on the Module) you indicate your acceptance of this license
* to do so, and all its terms and conditions.
*
* 7. Each time you redistribute the Module (or any work based on the
* Module), the recipient automatically receives a license from the
* original licensor to copy, distribute or modify the Module subject
* to these terms and conditions. You may not impose any further
* restrictions on the recipients' exercise of the rights granted
* herein.
*
* 8. The ITU-T may publish revised and/or new versions of this
* General Public License from time to time. Such new versions will
* be similar in spirit to the present version, but may differ in
* detail to address new problems or concerns.
*
* Each version is given a distinguishing version number. If the
* Module specifies a version number of the license which applies to
* it and "any later version", you have the option of following the
* terms and conditions either of that version or of any later version
* published by the ITU-T. If the Module does not specify a version
* number of the license, you may choose any version ever published by
* the ITU-T.
*
* 9. If you wish to incorporate parts of the Module into other free
* modules whose distribution conditions are different, write to the
* author to ask for permission. For software which is copyrighted by
* the ITU-T, write to the ITU-T Secretariat; exceptions may be made
* for this. This decision will be guided by the two goals of
* preserving the free status of all derivatives of this free software
* and of promoting the sharing and reuse of software generally.
*
*
* NO WARRANTY
*
* 10. BECAUSE THE MODULE IS LICENSED FREE OF CHARGE, THERE IS NO
* WARRANTY FOR THE MODULE, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
* EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS
* AND/OR OTHER PARTIES PROVIDE THE MODULE "AS IS" WITHOUT WARRANTY OF
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
* PERFORMANCE OF THE MODULE IS WITH YOU. SHOULD THE MODULE PROVE
* DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
* OR CORRECTION.
*
* 11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
* WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
* MODIFY AND/OR REDISTRIBUTE THE MODULE AS PERMITTED ABOVE, BE LIABLE
* TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
* CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
* THE MODULE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
* RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR
* A FAILURE OF THE MODULE TO OPERATE WITH ANY OTHER MODULES), EVEN IF
* SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
*
* END OF TERMS AND CONDITIONS
***************************************************************************/
;------------------------------------------------------------------------------
;Global Declarations:
;------------------------------------------------------------------------------
.global _G726AEncode
;------------------------------------------------------------------------------
;Code Section in Program Memory
;------------------------------------------------------------------------------
.section libg726a, code
/******************************************************************************
*
* Function Name: G726_encode
*
* System: RISC
*
* Platform: dsPIC33F
*
* Description: Initializes the codec state
*
* Cycle Count: 6434 - for 2nd block
*
* Input Parameters: w0 - Pointer to Encoder State
* w1 - Pointer to input buffer
* w2 - Pointer to output buffer
*
*
*
* Output Parameters: None
*
* History:
*
* Date | By | Remarks
* ---------------+-------------------+----------------------------------
* Oct-26-2005 Sharanabasava M. Created.
* Nov-17-2005 Sharanabasava M. Modified for G.726a
* Jan-2010 Sankaralingam.M & Thiyagarajan.P Modified
******************************************************************************/
.text
_G726AEncode:
push w8
push w9
push w10
push w11
push w12
push w13
mov w1,w10 ;input buffer
mov w2,w11 ;output buffer
add w0,#30,w13 ;encoder state
add w13,#30,w1 ;base address + 60
add w1,#8,w1 ;&rate
mov [w1++],w3 ;rate
mov [w1],w2 ;slen
dec w2,w12 ;w12-counter
lnk #46
mov w3,[w14+20]
clr w1
mov w1,[w14+28] ;idq = 0
mov w1,[w14+30] ;ids = 0
mov w1,[w14+40] ;iyl = 0
mov w1,[w14+42]
add w14,#28,w1
mov w1,[w14+44] ;&idq
add w14,#30,w1
mov w1,[w14+18] ;&ids
mov #40,w2
add w14,w2,w1
mov w1,[w14+16] ;&iyl
do w12,ENCODE
mov w14,w2
add w13,#6,w0
sub w13,#30,w1
call _G726_fmult_b
mov [w13 + 4],w0
mov [w13 + 2],w1
sub w13,#6,w2
add w14,#14,w3
dec2 w3,w4
mov w14,w8
call _G726_fmult
mov [w8++],w5
add w5,[w8++],w5 ;w5-sezi
add w5,[w8++],w5
add w5,[w8++],w5
add w5,[w8++],w5
add w5,[w8++],w5
add w5,[w8++],w6
add w6,[w8],w6 ;w6-sei
asr w5,w3
mov w3,[w14+38] ;isez ;Adeptte
asr w6,w3
mov w3,[w14+32] ;ise ;Adeptte
mov [w10++],w0
mov w0,[w14+34] ;isl ;Adeptte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov [w14+34],w2 ;isl
mov [w14+32],w3 ;ise
mov [w14+16],w4 ;iyl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sub w2,w3,w7 ;w7-d
mov [w13 + 24],w8
mov #256,w6
cp w8,w6
bra ge,SIXFOUR
asr w8,#2,w8
bra LOG
SIXFOUR:
mov #64,w8 ;w8-al
LOG:
mov [w13 + 32],w0
mov [w13 + 34],w1
mov.d w0,[w4]
mov w7,w0
mov [w14+18],w1 ;ids ;Adeptte
call _G726_log
mov w0,w9 ;w9-dl
mov [w14+16],w4 ;iyl ;Adeptte
mov [w13 + 18],w0
mov.d [w4],w2
mov w8,w1 ;last
call _G726_mix
mov w0,[w14+22] ;iy ;Adeptte
asr w0,#2,w8
sub w9,w8,w0 ;last
mov [w14+30],w1 ;ids
mov [w13+44],w2 ;_quan_fptr ;Adeptte
call w2
mov [w14+22],w5 ;iy
mov.b w0,[w11] ;Adeptte
mov w14,w0
ze [w11++],w2 ;Adeptte
mov w2,[w0++] ;Adeptte
mov w5,[w0++]
mov [w13 + 20],w2
mov w2,[w0++]
mov [w13 + 22],w2
mov w2,[w0++]
mov [w14+20],w2 ;irate ;Adeptte
mov w2,[w0]
mov w14,w0
mov [w14+44],w1 ;idq ;Adeptte
add w13,#18,w2
add w13,#30,w3
inc2 w3,w3
mov [w13+42],w4
call _G726_iaq_spd1_scale1
mov [w13 + 26],w0
mov [w14+16],w4 ;iyl ;Adeptte
mov [w14+28],w1 ;idq ;Adeptte
mov.d [w4],w2
call _G726_trans
mov w0,[w14+26] ;itr ;Adeptte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov [w13 + 30],w1
mov w1,[w14+36]
mov [w13 + 28],w1
mov w1,[w13 + 30]
mov [w14+28],w2
cp0 w2
bra ge,DQISTR
mov #0x8000,w3
sub w3,w2,w4
bra DQSEZSTR
DQISTR:
mov w2,w4 ;w4-dqi
DQSEZSTR:
mov [w14+38],w3 ;isez ;Adeptte
add w4,w3,w5 ;w5-dqsez
mov #0xffff,w3
btss w5,#15
mov #1,w3
mov w3,[w13 + 28] ;state->pk0
clr w3
cp0 w5
bra z,SIGPK
mov #1,w3 ;w3-sigpk
SIGPK:
mov [w14+32],w2 ;ise ;Adeptte
add w4,w2,w6 ;w6-sr
mov w6,[w14+24] ;isr ;Adeptte
mov w14,w8
mov w3,[w8++]
mov [w13 + 28],w1 ;state-pk0
mov [w13 + 30],w4 ;state-pk1
mul.uu w1,w4,w2
mov w2,[w8++]
mov [w14+36],w4 ;ipk2
mul.uu w1,w4,w2
add w13,#2,w3
mov w2,[w8++] ;to remove stalls
add w13,#4,w2
mov [w3],[w8++]
mov [w2],[w8++]
mov [w14+26],w4 ;itr
mov w4,[w8++]
mov w14,w0
mov w8,w1
call _G726_agen
mov #0xd200,w2
mov #1,w3 ;w3-tdp
cp w2,[w8]
bra gt,TONE
clr w3
TONE:
add w13,#26,w2
clr [w2] ;state->tdr
mov [w14+26],w4 ;itr ;Adeptte
cp0 w4
bra nz,TRIGB
mov w3,[w2] ;state->tdr=tdp
TRIGB:
mov [w13 + 20],w0
mov [w13 + 22],w1
mov [w14+22],w2 ;iy ;Adeptte
mov [w14+26],w4 ;itr ;Adeptte
mov [w13 + 24],w5
call _G726_speedcon_blk3
mov w0,[w13 + 24]
mov w14,w7
mov [w13 + 36],w0
mov w0,[w7++]
mov [w14+28],w0 ;idq ;Adeptte
mov w0,[w7++]
mov [w14+26],w0 ;itr ;Adeptte
mov w0,[w7]
mov w14,w0
sub w13,#30,w1
add w13,#6,w2
call _G726_bgen
sub w13,#4,w2
mov w13,w3
mov [w2--],[w3--]
mov [w2],[w3]
sub w13,#12,w4
sub w13,#8,w5
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4--],[w5--]
mov [w4],[w5]
mov [w14+24],w0 ;isr ;Adeptte
mov [w14+28],w1 ;idq ;Adeptte
mov w4,w3
call _G726_float_ab
ENCODE:
nop
ulnk
pop w13
pop w12
pop w11
pop w10
pop w9
pop w8
return
;--------End of All Code Sections ---------------------------------------------
.end ;End of program code in this file