[FFmpeg-devel] [PATCH] swscale: factorize plane copying code out of 2 functions
Michael Niedermayer
michaelni
Sat Sep 11 20:10:32 CEST 2010
On Sat, Sep 11, 2010 at 11:35:41AM -0300, Ramiro Polla wrote:
> On Sat, Sep 11, 2010 at 5:52 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sat, Sep 11, 2010 at 02:06:41AM -0300, Ramiro Polla wrote:
> >> $subj
> >
> >> ?swscale.c | ? 53 ++++++++++++++++++++++++-----------------------------
> >> ?1 file changed, 24 insertions(+), 29 deletions(-)
> >> 4c63fb8394923f3e5eff7b77cb81f76165f87f2e ?0005-swscale-factorize-plane-copying-code-out-of-2-funct.patch
> >> From 7b7fe1e8456abc5db5a0f06b2c7be5909f44d5b1 Mon Sep 17 00:00:00 2001
> >> From: Ramiro Polla <ramiro.polla at gmail.com>
> >> Date: Fri, 10 Sep 2010 22:45:04 -0300
> >> Subject: [PATCH] swscale: factorize plane copying code out of 2 functions
> >>
> >> ---
> >> ?swscale.c | ? 53 ++++++++++++++++++++++++-----------------------------
> >> ?1 files changed, 24 insertions(+), 29 deletions(-)
> >>
> >> diff --git a/swscale.c b/swscale.c
> >> index 570ac02..155bf1a 100644
> >> --- a/swscale.c
> >> +++ b/swscale.c
> >> @@ -1308,24 +1308,32 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
> >> ?#endif //!CONFIG_RUNTIME_CPUDETECT
> >> ?}
> >>
> >> -static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int srcSliceH, uint8_t* dstParam[], int dstStride[])
> >> +static void copyPlane(const uint8_t *src, int srcStride,
> >> + ? ? ? ? ? ? ? ? ? ? ?int srcSliceY, int srcSliceH, int width,
> >> + ? ? ? ? ? ? ? ? ? ? ?uint8_t *dst, int dstStride)
> >> ?{
> >> - ? ?uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
> >> - ? ?/* Copy Y plane */
> >> - ? ?if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
> >> - ? ? ? ?memcpy(dst, src[0], srcSliceH*dstStride[0]);
> >> - ? ?else {
> >> + ? ?if (dstStride == srcStride && srcStride > 0) {
> >> + ? ? ? ?memcpy(dst, src, srcSliceH * dstStride);
> >> + ? ?} else {
> >> ? ? ? ? ?int i;
> >
> >> - ? ? ? ?uint8_t *dstPtr= dst;
> >> - ? ? ? ?for (i=0; i<srcSliceH; i++) {
> >> + ? ? ? ?uint8_t *dstPtr = dst;
> >> + ? ? ? ?for (i = 0; i < srcSliceH; i++) {
> >
> > hmm
>
> Updated with lines that don't change left as-is.
> swscale.c | 49 ++++++++++++++++++++++---------------------------
> 1 file changed, 22 insertions(+), 27 deletions(-)
> 92af1cd640f3b04ccb3073506a34b51a7ee2aa07 copyPlane.diff
> Index: swscale.c
> ===================================================================
> --- swscale.c (revision 32157)
> +++ swscale.c (working copy)
> @@ -1308,24 +1308,32 @@
> #endif //!CONFIG_RUNTIME_CPUDETECT
> }
>
> -static int planarToNv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
> - int srcSliceH, uint8_t* dstParam[], int dstStride[])
> +static void copyPlane(const uint8_t *src, int srcStride,
> + int srcSliceY, int srcSliceH, int width,
> + uint8_t *dst, int dstStride)
> {
> - uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY;
> - /* Copy Y plane */
> - if (dstStride[0]==srcStride[0] && srcStride[0] > 0)
> - memcpy(dst, src[0], srcSliceH*dstStride[0]);
> - else {
> + if (dstStride == srcStride && srcStride > 0) {
> + memcpy(dst, src, srcSliceH * dstStride);
iam not sure this is safe if stride > width*bytes_per_sample
except that the patch should be ok
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100911/ade71d90/attachment.pgp>
More information about the ffmpeg-devel
mailing list