summaryrefslogtreecommitdiff
path: root/vpx_scale/wce/gen_scalers_armv4.asm
blob: 1c904edae2b94bce612f86ebe91ee32666051eb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
;
;  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
;
;  Use of this source code is governed by a BSD-style license and patent
;  grant that can be found in the LICENSE file in the root of the source
;  tree. All contributing project authors may be found in the AUTHORS
;  file in the root of the source tree.
;


    EXPORT  |horizontal_line_4_5_scale_armv4|
    EXPORT  |vertical_band_4_5_scale_armv4|
    EXPORT  |horizontal_line_2_3_scale_armv4|
    EXPORT  |vertical_band_2_3_scale_armv4|
    EXPORT  |horizontal_line_3_5_scale_armv4|
    EXPORT  |vertical_band_3_5_scale_armv4|
    EXPORT  |horizontal_line_3_4_scale_armv4|
    EXPORT  |vertical_band_3_4_scale_armv4|
    EXPORT  |horizontal_line_1_2_scale_armv4|
    EXPORT  |vertical_band_1_2_scale_armv4|

    AREA    |.text|, CODE, READONLY  ; name this block of code

src         RN  r0
srcw        RN  r1
dest        RN  r2
mask        RN  r12
c51_205     RN  r10
c102_154    RN  r11
;/****************************************************************************
; *
; *  ROUTINE       : horizontal_line_4_5_scale_armv4
; *
; *  INPUTS        : const unsigned char *source : Pointer to source data.
; *                  unsigned int source_width    : Stride of source.
; *                  unsigned char *dest         : Pointer to destination data.
; *                  unsigned int dest_width      : Stride of destination (NOT USED).
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Copies horizontal line of pixels from source to
; *                  destination scaling up by 4 to 5.
; *
; *  SPECIAL NOTES : None.
; *
; ****************************************************************************/
;void horizontal_line_4_5_scale_armv4
;(
;   r0 = UINT8 *source
;   r1 = UINT32 source_width
;   r2 = UINT8 *dest
;   r3 = UINT32 dest_width
;)
|horizontal_line_4_5_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    mov     mask, #255              ; mask for selection
    ldr     c51_205, =0x3300cd
    ldr     c102_154, =0x66009a

    ldr     r3, [src], #4

hl45_loop

    and     r4, r3, mask            ; a = src[0]
    and     r5, mask, r3, lsr #8    ; b = src[1]
    strb    r4, [dest], #1

    orr     r6, r4, r5, lsl #16     ; b | a
    and     r7, mask, r3, lsr #16   ; c = src[2]
    mul     r6, c51_205, r6         ; a * 51 + 205 * b

    orr     r5, r5, r7, lsl #16     ; c | b
    mul     r5, c102_154, r5        ; b * 102 + 154 * c
    add     r6, r6, #0x8000
    and     r8, mask, r3, lsr #24   ; d = src[3]
    mov     r6, r6, lsr #24
    strb    r6, [dest], #1

    orr     r7, r8, r7, lsl #16     ; c | d
    mul     r7, c102_154, r7        ; c * 154 + 102 * d
    add     r5, r5, #0x8000
    ldr     r3, [src], #4
    mov     r5, r5, lsr #24
    strb    r5, [dest], #1

    add     r7, r7, #0x8000
    and     r9, mask, r3            ; e = src[4]
    orr     r9, r9, r8, lsl #16     ; d | e
    mul     r9, c51_205, r9         ; d * 205 + 51 * e
    mov     r7, r7, lsr #24
    strb    r7, [dest], #1

    add     r9, r9, #0x8000
    subs    srcw, srcw, #4
    mov     r9, r9, lsr #24
    strb    r9, [dest], #1

    bne     hl45_loop

    and     r4, r3, mask
    and     r5, mask, r3, lsl #8
    strb    r4, [dest], #1

    orr     r6, r4, r5, lsl #16     ; b | a
    mul     r6, c51_205, r6

    and     r7, mask, r3, lsl #16
    orr     r5, r5, r7, lsl #16     ; c | b
    mul     r5, c102_154, r5
    add     r6, r6, #0x8000
    and     r8, mask, r3, lsl #24
    mov     r6, r6, lsr #24
    strb    r6, [dest], #1

    orr     r7, r8, r7, lsl #16     ; c | d
    mul     r7, c102_154, r7
    add     r5, r5, #0x8000
    mov     r5, r5, lsr #24
    strb    r5, [dest], #1

    add     r7, r7, #0x8000
    mov     r7, r7, lsr #24
    strb    r7, [dest], #1

    ldrb    r3, [src]
    strb    r3, [dest], #1

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vp8cx_horizontal_line_4_5_scale_c|

;/****************************************************************************
; *
; *  ROUTINE       : vertical_band_4_5_scale_armv4
; *
; *  INPUTS        : unsigned char *dest    : Pointer to destination data.
; *                  unsigned int dest_pitch : Stride of destination data.
; *                  unsigned int dest_width : Width of destination data.
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Scales vertical band of pixels by scale 4 to 5. The
; *                  height of the band scaled is 4-pixels.
; *
; *  SPECIAL NOTES : The routine uses the first line of the band below
; *                  the current band.
; *
; ****************************************************************************/
;void vertical_band_4_5_scale_armv4
;(
;   r0 = UINT8 *dest
;   r1 = UINT32 dest_pitch
;   r2 = UINT32 dest_width
;)
|vertical_band_4_5_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    ldr     c51_205, =0x3300cd
    ldr     c102_154, =0x66009a

vl45_loop
    mov     r3, src
    ldrb    r4, [r3], r1            ; a = des [0]
    ldrb    r5, [r3], r1            ; b = des [dest_pitch]
    ldrb    r7, [r3], r1            ; c = des[dest_pitch*2]
    add     lr, src, r1

    orr     r6, r4, r5, lsl #16     ; b | a
    mul     r6, c51_205, r6         ; a * 51 + 205 * b

    ldrb    r8, [r3], r1            ; d = des[dest_pitch*3]
    orr     r5, r5, r7, lsl #16     ; c | b
    mul     r5, c102_154, r5        ; b * 102 + 154 * c
    add     r6, r6, #0x8000
    orr     r7, r8, r7, lsl #16     ; c | d
    mov     r6, r6, lsr #24
    strb    r6, [lr], r1

    ldrb    r9, [r3, r1]            ; e = des [dest_pitch * 5]
    mul     r7, c102_154, r7        ; c * 154 + 102 * d
    add     r5, r5, #0x8000
    orr     r9, r9, r8, lsl #16     ; d | e
    mov     r5, r5, lsr #24
    strb    r5, [lr], r1

    mul     r9, c51_205, r9         ; d * 205 + 51 * e
    add     r7, r7, #0x8000
    add     src, src, #1
    mov     r7, r7, lsr #24
    strb    r7, [lr], r1

    add     r9, r9, #0x8000
    subs    r2, r2, #1
    mov     r9, r9, lsr #24
    strb    r9, [lr], r1

    bne     vl45_loop

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vertical_band_4_5_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : horizontal_line_2_3_scale_armv4
; *
; *  INPUTS        : const unsigned char *source : Pointer to source data.
; *                  unsigned int source_width    : Stride of source.
; *                  unsigned char *dest         : Pointer to destination data.
; *                  unsigned int dest_width      : Stride of destination (NOT USED).
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Copies horizontal line of pixels from source to
; *                  destination scaling up by 2 to 3.
; *
; *  SPECIAL NOTES : None.
; *
; *
; ****************************************************************************/
;void horizontal_line_2_3_scale_armv4
;(
;   const unsigned char *source,
;   unsigned int source_width,
;   unsigned char *dest,
;   unsigned int dest_width
;)
|horizontal_line_2_3_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}
    ldr     lr,  =85
    ldr     r12, =171

hl23_loop

    ldrb    r3, [src], #1           ; a
    ldrb    r4, [src], #1           ; b
    ldrb    r5, [src]               ; c

    strb    r3, [dest], #1
    mul     r4, r12, r4             ; b * 171
    mla     r6, lr, r3, r4          ; a * 85
    mla     r7, lr, r5, r4          ; c * 85

    add     r6, r6, #128
    mov     r6, r6, lsr #8
    strb    r6, [dest], #1

    add     r7, r7, #128
    mov     r7, r7, lsr #8
    strb    r7, [dest], #1

    subs    srcw, srcw, #2
    bne     hl23_loop

    ldrb    r4, [src, #1]           ; b
    strb    r5, [dest], #1
    strb    r4, [dest, #1]

    mul     r4, r12, r4             ; b * 171
    mla     r6, lr, r5, r4          ; a * 85 + b *171

    add     r6, r6, #128
    mov     r6, r6, lsr #8
    strb    r6, [dest]

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|horizontal_line_2_3_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : vertical_band_2_3_scale_armv4
; *
; *  INPUTS        : unsigned char *dest    : Pointer to destination data.
; *                  unsigned int dest_pitch : Stride of destination data.
; *                  unsigned int dest_width : Width of destination data.
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Scales vertical band of pixels by scale 2 to 3. The
; *                  height of the band scaled is 2-pixels.
; *
; *  SPECIAL NOTES : The routine uses the first line of the band below
; *                  the current band.
; *
; ****************************************************************************/
;void vertical_band_2_3_scale_armv4
;(
;   r0 = UINT8 *dest
;   r1 = UINT32 dest_pitch
;   r2 = UINT32 dest_width
;)
|vertical_band_2_3_scale_armv4| PROC
    stmdb   sp!, {r4 - r8, lr}
    ldr     lr,  =85
    ldr     r12, =171
    add     r3, r1, r1, lsl #1      ; 3 * dest_pitch

vl23_loop
    ldrb    r4, [src]               ; a = des [0]
    ldrb    r5, [src, r1]           ; b = des [dest_pitch]
    ldrb    r7, [src, r3]           ; c = des [dest_pitch*3]
    subs    r2, r2, #1

    mul     r5, r12, r5             ; b * 171
    mla     r6, lr, r4, r5          ; a * 85
    mla     r8, lr, r7, r5          ; c * 85

    add     r6, r6, #128
    mov     r6, r6, lsr #8
    strb    r6, [src, r1]

    add     r8, r8, #128
    mov     r8, r8, lsr #8
    strb    r8, [src, r1, lsl #1]

    add     src, src, #1

    bne     vl23_loop

    ldmia   sp!, {r4 - r8, pc}
    ENDP    ;|vertical_band_2_3_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : vp8cx_horizontal_line_3_5_scale_c
; *
; *  INPUTS        : const unsigned char *source : Pointer to source data.
; *                  unsigned int source_width    : Stride of source.
; *                  unsigned char *dest         : Pointer to destination data.
; *                  unsigned int dest_width      : Stride of destination (NOT USED).
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Copies horizontal line of pixels from source to
; *                  destination scaling up by 3 to 5.
; *
; *  SPECIAL NOTES : None.
; *
; *
; ****************************************************************************/
;void vp8cx_horizontal_line_3_5_scale_c
;(
;   const unsigned char *source,
;   unsigned int source_width,
;   unsigned char *dest,
;   unsigned int dest_width
;)
|horizontal_line_3_5_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    ldr     c51_205, =0x3300cd
    ldr     c102_154, =0x66009a

    ldrb    r4, [src], #1           ; a = src[0]

hl35_loop

    ldrb    r8, [src], #1           ; b = src[1]
    strb    r4, [dest], #1

    orr     r6, r4, r8, lsl #16     ; b | a
    ldrb    r9, [src], #1           ; c = src[2]
    mul     r6, c102_154, r6        ; a * 102 + 154 * b

    orr     r5, r9, r8, lsl #16     ; b | c
    mul     r5, c51_205, r5         ; b * 205 + 51 * c
    add     r6, r6, #0x8000
    ldrb    r4, [src], #1           ; d = src[3]
    mov     r6, r6, lsr #24
    strb    r6, [dest], #1

    orr     r7, r8, r9, lsl #16     ; c | b
    mul     r7, c51_205, r7         ; c * 205 + 154 * b
    add     r5, r5, #0x8000
    mov     r5, r5, lsr #24
    strb    r5, [dest], #1

    orr     r9, r4, r9, lsl #16     ; c | d
    mul     r9, c102_154, r9        ; c * 154 + 102 * d
    add     r7, r7, #0x8000
    mov     r7, r7, lsr #24
    strb    r7, [dest], #1

    add     r9, r9, #0x8000
    subs    srcw, srcw, #3
    mov     r9, r9, lsr #24
    strb    r9, [dest], #1

    bpl     hl35_loop

    ldrb    r5, [src], #1           ; b = src[1]
    strb    r4, [dest], #1

    orr     r6, r4, r8, lsl #16     ; b | a
    ldrb    r9, [src], #1           ; c = src[2]
    mul     r6, c102_154, r6        ; a * 102 + 154 * b

    orr     r5, r9, r8, lsl #16     ; b | c
    mul     r5, c51_205, r5         ; b * 205 + 51 * c
    add     r6, r6, #0x8000
    mov     r6, r6, lsr #24
    strb    r6, [dest], #1

    orr     r7, r8, r9, lsl #16     ; c | b
    mul     r7, c51_205, r7         ; c * 205 + 154 * b
    add     r5, r5, #0x8000
    mov     r5, r5, lsr #24
    strb    r5, [dest], #1

    add     r7, r7, #0x8000
    mov     r7, r7, lsr #24
    strb    r7, [dest], #1
    strb    r9, [dest], #1

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vp8cx_horizontal_line_3_5_scale_c|


;/****************************************************************************
; *
; *  ROUTINE       : vp8cx_vertical_band_3_5_scale_c
; *
; *  INPUTS        : unsigned char *dest    : Pointer to destination data.
; *                  unsigned int dest_pitch : Stride of destination data.
; *                  unsigned int dest_width : Width of destination data.
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Scales vertical band of pixels by scale 3 to 5. The
; *                  height of the band scaled is 3-pixels.
; *
; *  SPECIAL NOTES : The routine uses the first line of the band below
; *                  the current band.
; *
; ****************************************************************************/
;void vertical_band_4_5_scale_armv4
;(
;   r0 = UINT8 *dest
;   r1 = UINT32 dest_pitch
;   r2 = UINT32 dest_width
;)
|vertical_band_3_5_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    ldr     c51_205, =0x3300cd
    ldr     c102_154, =0x66009a

vl35_loop
    mov     r3, src
    ldrb    r4, [r3], r1            ; a = des [0]
    ldrb    r5, [r3], r1            ; b = des [dest_pitch]
    ldrb    r7, [r3], r1            ; c = des[dest_pitch*2]
    add     lr, src, r1

    orr     r8, r4, r5, lsl #16     ; b | a
    mul     r6, c102_154, r8        ; a * 102 + 154 * b

    ldrb    r8, [r3, r1, lsl #1]    ; d = des[dest_pitch*5]
    orr     r3, r7, r5, lsl #16     ; b | c
    mul     r9, c51_205, r3         ; b * 205 + 51 * c
    add     r6, r6, #0x8000
    orr     r3, r5, r7, lsl #16     ; c | b
    mov     r6, r6, lsr #24
    strb    r6, [lr], r1

    mul     r5, c51_205, r3         ; c * 205 + 154 * b
    add     r9, r9, #0x8000
    orr     r3, r8, r7, lsl #16     ; c | d
    mov     r9, r9, lsr #24
    strb    r9, [lr], r1

    mul     r7, c102_154, r3        ; c * 154 + 102 * d
    add     r5, r5, #0x8000
    add     src, src, #1
    mov     r5, r5, lsr #24
    strb    r5, [lr], r1

    add     r7, r7, #0x8000
    subs    r2, r2, #1
    mov     r7, r7, lsr #24
    strb    r7, [lr], r1


    bne     vl35_loop

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vertical_band_3_5_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : horizontal_line_3_4_scale_armv4
; *
; *  INPUTS        : const unsigned char *source : Pointer to source data.
; *                  unsigned int source_width    : Stride of source.
; *                  unsigned char *dest         : Pointer to destination data.
; *                  unsigned int dest_width      : Stride of destination (NOT USED).
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Copies horizontal line of pixels from source to
; *                  destination scaling up by 3 to 4.
; *
; *  SPECIAL NOTES : None.
; *
; *
; ****************************************************************************/
;void horizontal_line_3_4_scale_armv4
;(
;   const unsigned char *source,
;   unsigned int source_width,
;   unsigned char *dest,
;   unsigned int dest_width
;)
|horizontal_line_3_4_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    ldr     r10, =64
    ldr     r11, =192
    mov     r9, #128

    ldrb    r4, [src], #1           ; a = src[0]

hl34_loop

    ldrb    r8, [src], #1           ; b = src[1]
    ldrb    r7, [src], #1           ; c = src[2]
    strb    r4, [dest], #1

    mla     r4, r10, r4, r9         ; a*64 + 128
    mla     r4, r11, r8, r4         ; a*64 + b*192 + 1

    add     r8, r8, #1              ; b + 1
    add     r8, r8, r7              ; b + c + 1
    mov     r8, r8, asr #1          ; (b + c + 1) >> 1

    mov     r4, r4, asr #8          ; (a*64 + b*192 + 1) >> 8
    strb    r4, [dest], #1

    strb    r8, [dest], #1

    ldrb    r4, [src], #1           ; [a+1]

    mla     r7, r11, r7, r9         ; c*192 + 128
    mla     r7, r4, r10, r7         ; a*64 + b*192 + 128

    subs    srcw, srcw, #3

    mov     r7, r7, asr #8          ; (a*64 + b*192 + 128) >> 8
    strb    r7, [dest], #1

    bpl     hl34_loop

    ldrb    r8, [src], #1           ; b = src[1]
    ldrb    r7, [src], #1           ; c = src[2]
    strb    r4, [dest], #1

    mla     r4, r10, r4, r9         ; a*64 + 128
    mla     r4, r11, r8, r4         ; a*64 + b*192 + 1
    mov     r4, r4, asr #8          ; (a*64 + b*192 + 1) >> 8
    strb    r4, [dest], #1

    add     r8, r8, #1              ; b + 1
    add     r8, r8, r7              ; b + c + 1
    mov     r8, r8, asr #1          ; (b + c + 1) >> 1
    strb    r8, [dest], #1
    strb    r7, [dest], #1

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vp8cx_horizontal_line_3_4_scale_c|


;/****************************************************************************
; *
; *  ROUTINE       : vertical_band_3_4_scale_armv4
; *
; *  INPUTS        : unsigned char *dest    : Pointer to destination data.
; *                  unsigned int dest_pitch : Stride of destination data.
; *                  unsigned int dest_width : Width of destination data.
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Scales vertical band of pixels by scale 3 to 4. The
; *                  height of the band scaled is 3-pixels.
; *
; *  SPECIAL NOTES : The routine uses the first line of the band below
; *                  the current band.
; *
; ****************************************************************************/
;void vertical_band_3_4_scale_armv4
;(
;   r0 = UINT8 *dest
;   r1 = UINT32 dest_pitch
;   r2 = UINT32 dest_width
;)
|vertical_band_3_4_scale_armv4| PROC
    stmdb   sp!, {r4 - r11, lr}

    ldr     r10, =64
    ldr     r11, =192
    mov     r9, #128

;   ldr     r1,[r1]
vl34_loop
    mov     r3, src
    ldrb    r4, [r3], r1            ; a = des [0]
    ldrb    r5, [r3], r1            ; b = des [dest_pitch]
    ldrb    r7, [r3], r1            ; c = des [dest_pitch*2]
    add     lr, src, r1

    mla     r4, r10, r4, r9         ; a*64 + 128
    mla     r4, r11, r5, r4         ; a*64 + b*192 + 1

    add     r5, r5, #1              ; b + 1
    add     r5, r5, r7              ; b + c + 1
    mov     r5, r5, asr #1          ; (b + c + 1) >> 1

    mov     r4, r4, asr #8          ; (a*64 + b*192 + 1) >> 8
    strb    r4, [lr], r1

    ldrb    r4, [r3, r1]            ; a = des [dest_pitch*4]

    strb    r5, [lr], r1

    mla     r7, r11, r7, r9         ; c*192 + 128
    mla     r7, r4, r10, r7         ; a*64 + b*192 + 128
    mov     r7, r7, asr #8          ; (a*64 + b*192 + 128) >> 8

    add     src, src, #1
    subs    r2, r2, #1

    strb    r7, [lr]

    bne     vl34_loop

    ldmia   sp!, {r4 - r11, pc}
    ENDP    ;|vertical_band_3_4_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : vp8cx_horizontal_line_1_2_scale_c
; *
; *  INPUTS        : const unsigned char *source : Pointer to source data.
; *                  unsigned int source_width    : Stride of source.
; *                  unsigned char *dest         : Pointer to destination data.
; *                  unsigned int dest_width      : Stride of destination (NOT USED).
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Copies horizontal line of pixels from source to
; *                  destination scaling up by 1 to 2.
; *
; *  SPECIAL NOTES : None.
; *
; ****************************************************************************/
;void vp8cx_horizontal_line_1_2_scale_c
;(
;   const unsigned char *source,
;   unsigned int source_width,
;   unsigned char *dest,
;   unsigned int dest_width
;)
|horizontal_line_1_2_scale_armv4| PROC
    stmdb   sp!, {r4 - r5, lr}

    sub     srcw, srcw, #1

    ldrb    r3, [src], #1
    ldrb    r4, [src], #1
hl12_loop
    subs    srcw, srcw, #1

    add     r5, r3, r4
    add     r5, r5, #1
    mov     r5, r5, lsr #1

    orr     r5, r3, r5, lsl #8
    strh    r5, [dest], #2

    mov     r3, r4

    ldrneb  r4, [src], #1
    bne     hl12_loop

    orr     r5, r4, r4, lsl #8
    strh    r5, [dest]

    ldmia   sp!, {r4 - r5, pc}
    ENDP    ;|vertical_band_3_5_scale_armv4|

;/****************************************************************************
; *
; *  ROUTINE       : vp8cx_vertical_band_1_2_scale_c
; *
; *  INPUTS        : unsigned char *dest    : Pointer to destination data.
; *                  unsigned int dest_pitch : Stride of destination data.
; *                  unsigned int dest_width : Width of destination data.
; *
; *  OUTPUTS       : None.
; *
; *  RETURNS       : void
; *
; *  FUNCTION      : Scales vertical band of pixels by scale 1 to 2. The
; *                  height of the band scaled is 1-pixel.
; *
; *  SPECIAL NOTES : The routine uses the first line of the band below
; *                  the current band.
; *
; ****************************************************************************/
;void vp8cx_vertical_band_1_2_scale_c
;(
;   r0 = UINT8 *dest
;   r1 = UINT32 dest_pitch
;   r2 = UINT32 dest_width
;)
|vertical_band_1_2_scale_armv4| PROC
    stmdb   sp!, {r4 - r7, lr}

    ldr     mask, =0xff00ff             ; mask for selection
    ldr     lr, = 0x010001

vl12_loop
    mov     r3, src
    ldr     r4, [r3], r1
    ldr     r5, [r3, r1]

    add     src, src, #4
    subs    r2, r2, #4

    and     r6, r4, mask
    and     r7, r5, mask

    add     r6, r7, r6
    add     r6, r6, lr

    and     r4, mask, r4, lsr #8
    and     r5, mask, r5, lsr #8

    mov     r6, r6, lsr #1
    and     r6, r6, mask

    add     r4, r5, r4
    add     r4, r4, lr

    mov     r4, r4, lsr #1
    and     r4, r4, mask

    orr     r5, r6, r4, lsl #8

    str     r5, [r3]

    bpl     vl12_loop

    ldmia   sp!, {r4 - r7, pc}
    ENDP    ;|vertical_band_3_5_scale_armv4|

    END