Mercurial > mplayer.hg
comparison libswscale/swscale.c @ 19661:7b24faac56fd
Add sws_getCachedContext(), which checks if context is valid or reallocs a new one instead.
Patch by Victor Paesa <wzrlpy@arsystel.com>
Original thread:
Date: Aug 31, 2006 7:15 PM
Subject: [Ffmpeg-devel] [PATCH] Add sws_getCachedContext() to swscale library
author | gpoirier |
---|---|
date | Mon, 04 Sep 2006 09:38:24 +0000 |
parents | 4678e9f81334 |
children | 7d3d6f1533ee |
comparison
equal
deleted
inserted
replaced
19660:7d1bf72f5276 | 19661:7b24faac56fd |
---|---|
2752 c->yuvTable=NULL; | 2752 c->yuvTable=NULL; |
2753 | 2753 |
2754 av_free(c); | 2754 av_free(c); |
2755 } | 2755 } |
2756 | 2756 |
2757 /** | |
2758 * Checks if context is valid or reallocs a new one instead. | |
2759 * If context is NULL, just calls sws_getContext() to get a new one. | |
2760 * Otherwise, checks if the parameters are the same already saved in context. | |
2761 * If that is the case, returns the current context. | |
2762 * Otherwise, frees context and gets a new one. | |
2763 * | |
2764 * Be warned that srcFilter, dstFilter are not checked, they are | |
2765 * asumed to remain valid. | |
2766 */ | |
2767 struct SwsContext *sws_getCachedContext(struct SwsContext *context, | |
2768 int srcW, int srcH, int srcFormat, | |
2769 int dstW, int dstH, int dstFormat, int flags, | |
2770 SwsFilter *srcFilter, SwsFilter *dstFilter, double *param) | |
2771 { | |
2772 if (context != NULL) { | |
2773 if ((context->srcW != srcW) || (context->srcH != srcH) || | |
2774 (context->srcFormat != srcFormat) || | |
2775 (context->dstW != dstW) || (context->dstH != dstH) || | |
2776 (context->dstFormat != dstFormat) || (context->flags != flags) || | |
2777 (context->param != param)) | |
2778 { | |
2779 sws_freeContext(context); | |
2780 context = NULL; | |
2781 } | |
2782 } | |
2783 if (context == NULL) { | |
2784 return sws_getContext(srcW, srcH, srcFormat, | |
2785 dstW, dstH, dstFormat, flags, | |
2786 srcFilter, dstFilter, param); | |
2787 } | |
2788 return context; | |
2789 } | |
2790 |