]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/huffyuvdsp_mmx.c
avcodec/on2avc: Fix out of array access
[ffmpeg] / libavcodec / x86 / huffyuvdsp_mmx.c
1 /*
2  * Copyright (c) 2009 Loren Merritt <lorenm@u.washington.edu>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #include "config.h"
22 #include "libavutil/x86/asm.h"
23 #include "huffyuvdsp.h"
24
25 #if HAVE_INLINE_ASM && HAVE_7REGS && ARCH_X86_32
26 void ff_add_hfyu_median_pred_cmov(uint8_t *dst, const uint8_t *top,
27                                   const uint8_t *diff, intptr_t w,
28                                   int *left, int *left_top)
29 {
30     x86_reg w2 = -w;
31     x86_reg x;
32     int l  = *left     & 0xff;
33     int tl = *left_top & 0xff;
34     int t;
35     __asm__ volatile (
36         "mov          %7, %3            \n"
37         "1:                             \n"
38         "movzbl (%3, %4), %2            \n"
39         "mov          %2, %k3           \n"
40         "sub         %b1, %b3           \n"
41         "add         %b0, %b3           \n"
42         "mov          %2, %1            \n"
43         "cmp          %0, %2            \n"
44         "cmovg        %0, %2            \n"
45         "cmovg        %1, %0            \n"
46         "cmp         %k3, %0            \n"
47         "cmovg       %k3, %0            \n"
48         "mov          %7, %3            \n"
49         "cmp          %2, %0            \n"
50         "cmovl        %2, %0            \n"
51         "add    (%6, %4), %b0           \n"
52         "mov         %b0, (%5, %4)      \n"
53         "inc          %4                \n"
54         "jl           1b                \n"
55         : "+&q"(l), "+&q"(tl), "=&r"(t), "=&q"(x), "+&r"(w2)
56         : "r"(dst + w), "r"(diff + w), "rm"(top + w)
57     );
58     *left     = l;
59     *left_top = tl;
60 }
61 #endif