summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/gray_scroll_down8.c
blob: db716baee7dd8fc61e9e7becb768ee005b33225e (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
/***************************************************************************
*             __________               __   ___.
*   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
*   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
*   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
*   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
*                     \/            \/     \/    \/            \/
* $Id$
*
* Grayscale framework
* gray_scroll_down8() function
*
* This is a generic framework to use grayscale display within Rockbox
* plugins. It obviously does not work for the player.
*
* Copyright (C) 2004 Jens Arnold
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/

#ifndef SIMULATOR /* not for simulator by now */
#include "plugin.h"

#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
#include "gray.h"

/*---------------------------------------------------------------------------
 Scroll the whole grayscale buffer down by 8 pixels
 ----------------------------------------------------------------------------
 black_border determines if the pixels scrolled in at the top are black
 or white

 Scrolling up/down by 8 pixels is very fast.
 */
void gray_scroll_down8(bool black_border)
{
    int by, d;
    unsigned filler;
    unsigned char *ptr;

    filler = black_border ? 0xFF : 0;

    /* Scroll row by row to minimize flicker (byte rows = 8 pixels each) */
    for (by = _graybuf->bheight - 1; by > 0; by--)
    {
        ptr = _graybuf->data + MULU16(_graybuf->width, by);
        for (d = 0; d < _graybuf->depth; d++)
        {
            _gray_rb->memcpy(ptr, ptr - _graybuf->width, _graybuf->width);
            ptr += _graybuf->plane_size;
        }
    }
    /* fill first row */
    ptr = _graybuf->data;
    for (d = 0; d < _graybuf->depth; d++) 
    {
        _gray_rb->memset(ptr, filler, _graybuf->width);
        ptr += _graybuf->plane_size;
    }
}

#endif // #ifdef HAVE_LCD_BITMAP
#endif // #ifndef SIMULATOR

> 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
@ motion_comp_arm_s.S
@ Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
@
@ This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
@ See http://libmpeg2.sourceforge.net/ for updates.
@
@ mpeg2dec is free software; you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation; either version 2 of the License, or
@ (at your option) any later version.
@
@ mpeg2dec is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program; if not, write to the Free Software
@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
@
@ $Id$

#include "config.h" /* Rockbox: ARM architecture version */

        .text
        
@ ----------------------------------------------------------------
        .align
        .global MC_put_o_16
MC_put_o_16:
        @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
        @@ pld [r1]
        stmfd sp!, {r4-r7, lr} @ R14 is also called LR
        and r4, r1, #3
        ldr pc, [pc, r4, lsl #2]
        .word 0
        .word MC_put_o_16_align0
        .word MC_put_o_16_align1
        .word MC_put_o_16_align2
        .word MC_put_o_16_align3

MC_put_o_16_align0:
        ldmia r1, {r4-r7}
        add r1, r1, r2
        @@ pld [r1]
        stmia r0, {r4-r7}
        subs r3, r3, #1
        add r0, r0, r2
        bne MC_put_o_16_align0
        ldmpc regs=r4-r7 @@ update PC with LR content.

.macro  ADJ_ALIGN_QW shift, R0, R1, R2, R3, R4
        mov \R0, \R0, lsr #(\shift)
        orr \R0, \R0, \R1, lsl #(32 - \shift)
        mov \R1, \R1, lsr #(\shift)
        orr \R1, \R1, \R2, lsl #(32 - \shift)
        mov \R2, \R2, lsr #(\shift)
        orr \R2, \R2, \R3, lsl #(32 - \shift)
        mov \R3, \R3, lsr #(\shift)
        orr \R3, \R3, \R4, lsl #(32 - \shift)
        mov \R4, \R4, lsr #(\shift)
.endm

MC_put_o_16_align1:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r7, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 8, r4, r5, r6, r7, r12
        stmia r0, {r4-r7}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r7 @@ update PC with LR content.

MC_put_o_16_align2:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r7, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 16, r4, r5, r6, r7, r12
        stmia r0, {r4-r7}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r7 @@ update PC with LR content.

MC_put_o_16_align3:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r7, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 24, r4, r5, r6, r7, r12
        stmia r0, {r4-r7}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r7 @@ update PC with LR content.

@ ----------------------------------------------------------------
        .align
        .global MC_put_o_8
MC_put_o_8:
        @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
        @@ pld [r1]
        stmfd sp!, {r4, r5, lr} @ R14 is also called LR
        and r4, r1, #3
        ldr pc, [pc, r4, lsl #2]
        .word 0
        .word MC_put_o_8_align0
        .word MC_put_o_8_align1
        .word MC_put_o_8_align2
        .word MC_put_o_8_align3

MC_put_o_8_align0:
        ldmia r1, {r4, r5}
        add r1, r1, r2
        @@ pld [r1]
        stmia r0, {r4, r5}
        add r0, r0, r2
        subs r3, r3, #1
        bne MC_put_o_8_align0
        ldmpc regs=r4-r5 @@ update PC with LR content.

.macro  ADJ_ALIGN_DW shift, R0, R1, R2
        mov \R0, \R0, lsr #(\shift)
        orr \R0, \R0, \R1, lsl #(32 - \shift)
        mov \R1, \R1, lsr #(\shift)
        orr \R1, \R1, \R2, lsl #(32 - \shift)
        mov \R2, \R2, lsr #(\shift)
.endm

MC_put_o_8_align1:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4, r5, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 8, r4, r5, r12
        stmia r0, {r4, r5}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r5 @@ update PC with LR content.

MC_put_o_8_align2:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4, r5, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 16, r4, r5, r12
        stmia r0, {r4, r5}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r5 @@ update PC with LR content.

MC_put_o_8_align3:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4, r5, r12}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 24, r4, r5, r12
        stmia r0, {r4, r5}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-r5 @@ update PC with LR content.

@ ----------------------------------------------------------------
.macro  AVG_PW rW1, rW2
        mov \rW2, \rW2, lsl #24
        orr \rW2, \rW2, \rW1, lsr #8
        eor r9, \rW1, \rW2
#if ARM_ARCH >= 6
        uhadd8 \rW2, \rW1, \rW2
#else
        and \rW2, \rW1, \rW2
        and r10, r9, r11
        add \rW2, \rW2, r10, lsr #1
#endif
        and r9, r9, r12
        add \rW2, \rW2, r9
.endm

#if ARM_ARCH >= 6
#define HIGHEST_REG r9
#else
#define HIGHEST_REG r11
#endif

        .align
        .global MC_put_x_16
MC_put_x_16:
        @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
        @@ pld [r1]
        stmfd sp!, {r4-HIGHEST_REG, lr} @ R14 is also called LR
        and r4, r1, #3
        ldr r12, 2f
#if ARM_ARCH < 6
        mvn r11, r12
#endif
        ldr pc, [pc, r4, lsl #2]
2:      .word 0x01010101
        .word MC_put_x_16_align0
        .word MC_put_x_16_align1
        .word MC_put_x_16_align2
        .word MC_put_x_16_align3

MC_put_x_16_align0:
        ldmia r1, {r4-r8}
        add r1, r1, r2
        @@ pld [r1]
        AVG_PW r7, r8
        AVG_PW r6, r7
        AVG_PW r5, r6
        AVG_PW r4, r5
        stmia r0, {r5-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne MC_put_x_16_align0
        ldmpc regs=r4-HIGHEST_REG @@ update PC with LR content.

MC_put_x_16_align1:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 8, r4, r5, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        AVG_PW r5, r6
        AVG_PW r4, r5
        stmia r0, {r5-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-HIGHEST_REG @@ update PC with LR content.

MC_put_x_16_align2:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 16, r4, r5, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        AVG_PW r5, r6
        AVG_PW r4, r5
        stmia r0, {r5-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-HIGHEST_REG @@ update PC with LR content.

MC_put_x_16_align3:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r4-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_QW 24, r4, r5, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        AVG_PW r5, r6
        AVG_PW r4, r5
        stmia r0, {r5-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r4-HIGHEST_REG @@ update PC with LR content.

@ ----------------------------------------------------------------
        .align
        .global MC_put_x_8
MC_put_x_8:
        @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
        @@ pld [r1]
        stmfd sp!, {r6-HIGHEST_REG, lr} @ R14 is also called LR
        and r6, r1, #3
        ldr r12, 2f
#if ARM_ARCH < 6
        mvn r11, r12
#endif
        ldr pc, [pc, r6, lsl #2]
2:      .word 0x01010101
        .word MC_put_x_8_align0
        .word MC_put_x_8_align1
        .word MC_put_x_8_align2
        .word MC_put_x_8_align3

MC_put_x_8_align0:
        ldmia r1, {r6-r8}
        add r1, r1, r2
        @@ pld [r1]
        AVG_PW r7, r8
        AVG_PW r6, r7
        stmia r0, {r7-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne MC_put_x_8_align0
        ldmpc regs=r6-HIGHEST_REG @@ update PC with LR content.

MC_put_x_8_align1:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r6-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 8, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        stmia r0, {r7-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r6-HIGHEST_REG @@ update PC with LR content.

MC_put_x_8_align2:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r6-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 16, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        stmia r0, {r7-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r6-HIGHEST_REG @@ update PC with LR content.

MC_put_x_8_align3:
        and r1, r1, #0xFFFFFFFC
1:      ldmia r1, {r6-r8}
        add r1, r1, r2
        @@ pld [r1]
        ADJ_ALIGN_DW 24, r6, r7, r8
        AVG_PW r7, r8
        AVG_PW r6, r7
        stmia r0, {r7-r8}
        subs r3, r3, #1
        add r0, r0, r2
        bne 1b
        ldmpc regs=r6-HIGHEST_REG @@ update PC with LR content.