comparison imgresample.c @ 6433:d42d5a90f7de libavcodec

Provide non null class name to avoid crash with ffmpeg -h.
author michael
date Mon, 03 Mar 2008 19:53:27 +0000
parents bc22d052c6e5
children 442f96044f19
comparison
equal deleted inserted replaced
6432:f22e4bdf4ad8 6433:d42d5a90f7de
510 { 510 {
511 av_free(s->line_buf); 511 av_free(s->line_buf);
512 av_free(s); 512 av_free(s);
513 } 513 }
514 514
515 static const AVClass context_class = { "imgresample", NULL, NULL };
516
515 struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, 517 struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
516 int dstW, int dstH, int dstFormat, 518 int dstW, int dstH, int dstFormat,
517 int flags, SwsFilter *srcFilter, 519 int flags, SwsFilter *srcFilter,
518 SwsFilter *dstFilter, double *param) 520 SwsFilter *dstFilter, double *param)
519 { 521 {
520 struct SwsContext *ctx; 522 struct SwsContext *ctx;
521 523
522 ctx = av_malloc(sizeof(struct SwsContext)); 524 ctx = av_malloc(sizeof(struct SwsContext));
523 if (ctx) 525 if (!ctx) {
524 ctx->av_class = av_mallocz(sizeof(AVClass));
525 if (!ctx || !ctx->av_class) {
526 av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n"); 526 av_log(NULL, AV_LOG_ERROR, "Cannot allocate a resampling context!\n");
527 527
528 return NULL; 528 return NULL;
529 } 529 }
530 ctx->av_class = &context_class;
530 531
531 if ((srcH != dstH) || (srcW != dstW)) { 532 if ((srcH != dstH) || (srcW != dstW)) {
532 if ((srcFormat != PIX_FMT_YUV420P) || (dstFormat != PIX_FMT_YUV420P)) { 533 if ((srcFormat != PIX_FMT_YUV420P) || (dstFormat != PIX_FMT_YUV420P)) {
533 av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n"); 534 av_log(NULL, AV_LOG_INFO, "PIX_FMT_YUV420P will be used as an intermediate format for rescaling\n");
534 } 535 }