swscale_bfin.c 3.19 KB
Newer Older
1 2 3
/*
 * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
 *
4
 * Blackfin software video scaler operations
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

23
#include <stdint.h>
24

25
#include "config.h"
26
#include "libswscale/swscale_internal.h"
27

28
#if defined (__FDPIC__) && CONFIG_SRAM
29
#define L1CODE __attribute__((l1_text))
30 31 32
#else
#define L1CODE
#endif
33

34 35
int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
                       uint8_t *vdst, int width, int height,
36
                       int lumStride, int chromStride, int srcStride) L1CODE;
37

38 39
int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
                       uint8_t *vdst, int width, int height,
40
                       int lumStride, int chromStride, int srcStride) L1CODE;
41

42 43 44
static int uyvytoyv12_unscaled(SwsContext *c, const uint8_t *src[],
                               int srcStride[], int srcSliceY, int srcSliceH,
                               uint8_t *dst[], int dstStride[])
45
{
46 47 48
    uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
    uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
    uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
49
    const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
50
    int w = dstStride[0];
51

52 53
    ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
                       dstStride[0], dstStride[1], srcStride[0]);
54 55 56 57

    return srcSliceH;
}

58 59 60
static int yuyvtoyv12_unscaled(SwsContext *c, const uint8_t *src[],
                               int srcStride[], int srcSliceY, int srcSliceH,
                               uint8_t *dst[], int dstStride[])
61
{
62 63 64
    uint8_t *dsty = dst[0] + dstStride[0] * srcSliceY;
    uint8_t *dstu = dst[1] + dstStride[1] * srcSliceY / 2;
    uint8_t *dstv = dst[2] + dstStride[2] * srcSliceY / 2;
65
    const uint8_t *ip = src[0] + srcStride[0] * srcSliceY;
66
    int w = dstStride[0];
67

68 69
    ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
                       dstStride[0], dstStride[1], srcStride[0]);
70 71 72 73

    return srcSliceH;
}

74
void ff_bfin_get_unscaled_swscale(SwsContext *c)
75
{
76
    if (c->dstFormat == AV_PIX_FMT_YUV420P && c->srcFormat == AV_PIX_FMT_UYVY422) {
77 78
        av_log(NULL, AV_LOG_VERBOSE,
               "selecting Blackfin optimized uyvytoyv12_unscaled\n");
79 80
        c->swScale = uyvytoyv12_unscaled;
    }
81
    if (c->dstFormat == AV_PIX_FMT_YUV420P && c->srcFormat == AV_PIX_FMT_YUYV422) {
82 83
        av_log(NULL, AV_LOG_VERBOSE,
               "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
84 85
        c->swScale = yuyvtoyv12_unscaled;
    }
86
}