annotate libswscale/swscale_bfin.c @ 25746:330af0160c2d

Fix code to prevent from accessing queue->packets[-1].pts that causes a crash. Found and patched by Reimar.
author ulion
date Thu, 17 Jan 2008 02:18:49 +0000
parents 5b10bd9793b8
children a8ff60976ccb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23584
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
1 /*
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
2 * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
3 *
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
4 * Blackfin Software Video SCALER Operations
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
5 *
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
6 * This file is part of FFmpeg.
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
7 *
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
12 *
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
16 * Lesser General Public License for more details.
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
17 *
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
21 */
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
22
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
23 #include <stdio.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
24 #include <stdlib.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
25 #include <string.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
26 #include <inttypes.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
27 #include <assert.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
28 #include "config.h"
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
29 #ifdef HAVE_MALLOC_H
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
30 #include <malloc.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
31 #endif
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
32 #include <unistd.h>
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
33 #include "rgb2rgb.h"
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
34 #include "swscale.h"
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
35 #include "swscale_internal.h"
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
36
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
37
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
38 extern int ff_bfin_uyvytoyv12 (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
39 long width, long height,
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
40 long lumStride, long chromStride, long srcStride) __attribute__ ((l1_text));
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
41
23813
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
42 extern int ff_bfin_yuyvtoyv12 (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
43 long width, long height,
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
44 long lumStride, long chromStride, long srcStride) __attribute__ ((l1_text));
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
45
23584
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
46 static int uyvytoyv12_unscaled (SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
47 int srcSliceH, uint8_t* dst[], int dstStride[])
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
48 {
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
49 uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
50 uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
51 uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
52 uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
53 int w = dstStride[0];
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
54
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
55 ff_bfin_uyvytoyv12 (ip, dsty, dstu, dstv, w, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
56
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
57 return srcSliceH;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
58 }
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
59
23813
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
60 static int yuyvtoyv12_unscaled (SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
61 int srcSliceH, uint8_t* dst[], int dstStride[])
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
62 {
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
63 uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
64 uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
65 uint8_t *dstv = dst[2] + dstStride[2]*srcSliceY/2;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
66 uint8_t *ip = src[0] + srcStride[0]*srcSliceY;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
67 int w = dstStride[0];
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
68
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
69 ff_bfin_yuyvtoyv12 (ip, dsty, dstu, dstv, w, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
70
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
71 return srcSliceH;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
72 }
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
73
23584
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
74
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
75 void ff_bfin_get_unscaled_swscale (SwsContext *c)
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
76 {
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
77 SwsFunc swScale = c->swScale;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
78 if (c->flags & SWS_CPU_CAPS_BFIN)
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
79 if (c->dstFormat == PIX_FMT_YUV420P)
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
80 if (c->srcFormat == PIX_FMT_UYVY422) {
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
81 av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized uyvytoyv12_unscaled\n");
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
82 c->swScale = uyvytoyv12_unscaled;
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
83 }
23813
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
84 if (c->dstFormat == PIX_FMT_YUV420P)
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
85 if (c->srcFormat == PIX_FMT_YUYV422) {
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
86 av_log (NULL, AV_LOG_VERBOSE, "selecting Blackfin optimized yuyvtoyv12_unscaled\n");
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
87 c->swScale = yuyvtoyv12_unscaled;
5b10bd9793b8 integrating blackfin optimized yuyvtoyv12 converter
mhoffman
parents: 23584
diff changeset
88 }
23584
a01f8876ea2c adding Blackfin swscale_bfin infrastructure, and the first swscale routine uyvy to yv12 video resampler
mhoffman
parents:
diff changeset
89 }