]> git.sesse.net Git - ffmpeg/blob - libswscale/bfin/swscale_bfin.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libswscale / bfin / swscale_bfin.c
1 /*
2  * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
3  *
4  * Blackfin software video scaler operations
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <inttypes.h>
27 #include <assert.h>
28 #include "config.h"
29 #include <unistd.h>
30
31 #include "libswscale/rgb2rgb.h"
32 #include "libswscale/swscale.h"
33 #include "libswscale/swscale_internal.h"
34
35 #if defined (__FDPIC__) && CONFIG_SRAM
36 #define L1CODE __attribute__((l1_text))
37 #else
38 #define L1CODE
39 #endif
40
41 int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
42                        uint8_t *vdst, int width, int height,
43                        int lumStride, int chromStride, int srcStride) L1CODE;
44
45 int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
46                        uint8_t *vdst, int width, int height,
47                        int lumStride, int chromStride, int srcStride) L1CODE;
48
49 static int uyvytoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
50                                int srcSliceY, int srcSliceH, uint8_t *dst[],
51                                int dstStride[])
52 {
53     uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
54     uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
55     uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
56     uint8_t *ip   = src[0] + srcStride[0] * srcSliceY;
57     int w = dstStride[0];
58
59     ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
60                        dstStride[0], dstStride[1], srcStride[0]);
61
62     return srcSliceH;
63 }
64
65 static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t *src[], int srcStride[],
66                                int srcSliceY, int srcSliceH, uint8_t *dst[],
67                                int dstStride[])
68 {
69     uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
70     uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
71     uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
72     uint8_t *ip   = src[0] + srcStride[0] * srcSliceY;
73     int w = dstStride[0];
74
75     ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
76                        dstStride[0], dstStride[1], srcStride[0]);
77
78     return srcSliceH;
79 }
80
81 void ff_bfin_get_unscaled_swscale(SwsContext *c)
82 {
83     if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_UYVY422) {
84         av_log(NULL, AV_LOG_VERBOSE,
85                "selecting Blackfin optimized uyvytoyv12_unscaled\n");
86         c->swScale = uyvytoyv12_unscaled;
87     }
88     if (c->dstFormat == PIX_FMT_YUV420P && c->srcFormat == PIX_FMT_YUYV422) {
89         av_log(NULL, AV_LOG_VERBOSE,
90                "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
91         c->swScale = yuyvtoyv12_unscaled;
92     }
93 }