comparison imgresample.c @ 4036:207c22206d53 libavcodec

Implement sws_getCachedContext() in swscale emulation
author lucabe
date Tue, 17 Oct 2006 10:26:37 +0000
parents c8c591fe26f8
children 93163e2a2398
comparison
equal deleted inserted replaced
4035:b7f31a32bb30 4036:207c22206d53
672 img_resample_close(ctx->resampling_ctx); 672 img_resample_close(ctx->resampling_ctx);
673 } else { 673 } else {
674 av_free(ctx->resampling_ctx); 674 av_free(ctx->resampling_ctx);
675 } 675 }
676 av_free(ctx); 676 av_free(ctx);
677 }
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;
677 } 713 }
678 714
679 int sws_scale(struct SwsContext *ctx, uint8_t* src[], int srcStride[], 715 int sws_scale(struct SwsContext *ctx, uint8_t* src[], int srcStride[],
680 int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) 716 int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[])
681 { 717 {