~ubuntu-dev/mplayer/ubuntu-feisty

« back to all changes in this revision

Viewing changes to libavcodec/imgresample.c

  • Committer: William Grant
  • Date: 2007-02-03 03:16:07 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: william.grant@ubuntu.org.au-20070203031607-08gc2ompbz6spt9i
Update to 1.0rc1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * High quality image resampling with polyphase filters
3
3
 * Copyright (c) 2001 Fabrice Bellard.
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
 
18
 * License along with FFmpeg; if not, write to the Free Software
17
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
 */
19
21
 
27
29
#include "dsputil.h"
28
30
 
29
31
#ifdef USE_FASTMEMCPY
30
 
#include "fastmemcpy.h"
 
32
#include "libvo/fastmemcpy.h"
31
33
#endif
32
34
 
33
35
#define NB_COMPONENTS 3
674
676
    av_free(ctx);
675
677
}
676
678
 
 
679
 
 
680
/**
 
681
 * Checks if context is valid or reallocs a new one instead.
 
682
 * If context is NULL, just calls sws_getContext() to get a new one.
 
683
 * Otherwise, checks if the parameters are the same already saved in context.
 
684
 * If that is the case, returns the current context.
 
685
 * Otherwise, frees context and gets a new one.
 
686
 *
 
687
 * Be warned that srcFilter, dstFilter are not checked, they are
 
688
 * asumed to remain valid.
 
689
 */
 
690
struct SwsContext *sws_getCachedContext(struct SwsContext *ctx,
 
691
                        int srcW, int srcH, int srcFormat,
 
692
                        int dstW, int dstH, int dstFormat, int flags,
 
693
                        SwsFilter *srcFilter, SwsFilter *dstFilter, double *param)
 
694
{
 
695
    if (ctx != NULL) {
 
696
        if ((ctx->resampling_ctx->iwidth != srcW) ||
 
697
                        (ctx->resampling_ctx->iheight != srcH) ||
 
698
                        (ctx->src_pix_fmt != srcFormat) ||
 
699
                        (ctx->resampling_ctx->owidth != dstW) ||
 
700
                        (ctx->resampling_ctx->oheight != dstH) ||
 
701
                        (ctx->dst_pix_fmt != dstFormat))
 
702
        {
 
703
            sws_freeContext(ctx);
 
704
            ctx = NULL;
 
705
        }
 
706
    }
 
707
    if (ctx == NULL) {
 
708
        return sws_getContext(srcW, srcH, srcFormat,
 
709
                        dstW, dstH, dstFormat, flags,
 
710
                        srcFilter, dstFilter, param);
 
711
    }
 
712
    return ctx;
 
713
}
 
714
 
677
715
int sws_scale(struct SwsContext *ctx, uint8_t* src[], int srcStride[],
678
716
              int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[])
679
717
{
756
794
            res = -1;
757
795
            goto the_end;
758
796
        }
 
797
    } else if (resampled_picture != &dst_pict) {
 
798
        img_copy(&dst_pict, resampled_picture, current_pix_fmt,
 
799
                        ctx->resampling_ctx->owidth, ctx->resampling_ctx->oheight);
759
800
    }
760
801
 
761
802
the_end: