Mercurial > libavcodec.hg
comparison utils.c @ 12494:94eaea836bf4 libavcodec
Check avctx width/height more thoroughly (e.g. all values 0 except width would
have been accepted before).
Also do not fail if they are invalid but instead override them to 0.
This allows decoding e.g. MPEG video when only the container values are corrupted.
For encoding a value of 0,0 of course makes no sense, but was allowed
through before and will be caught by an extra check in the encode function.
author | reimar |
---|---|
date | Wed, 15 Sep 2010 04:46:55 +0000 |
parents | 8cd356429e9f |
children | 776789af0304 |
comparison
equal
deleted
inserted
replaced
12493:8e7fd2d2193f | 12494:94eaea836bf4 |
---|---|
483 if(avctx->coded_width && avctx->coded_height) | 483 if(avctx->coded_width && avctx->coded_height) |
484 avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); | 484 avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height); |
485 else if(avctx->width && avctx->height) | 485 else if(avctx->width && avctx->height) |
486 avcodec_set_dimensions(avctx, avctx->width, avctx->height); | 486 avcodec_set_dimensions(avctx, avctx->width, avctx->height); |
487 | 487 |
488 if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height) | |
489 && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0 | |
490 || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) { | |
491 av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n"); | |
492 avcodec_set_dimensions(avctx, 0, 0); | |
493 } | |
494 | |
488 #define SANE_NB_CHANNELS 128U | 495 #define SANE_NB_CHANNELS 128U |
489 if (((avctx->coded_width || avctx->coded_height) | 496 if (avctx->channels > SANE_NB_CHANNELS) { |
490 && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx)) | |
491 || avctx->channels > SANE_NB_CHANNELS) { | |
492 ret = AVERROR(EINVAL); | 497 ret = AVERROR(EINVAL); |
493 goto free_and_end; | 498 goto free_and_end; |
494 } | 499 } |
495 | 500 |
496 avctx->codec = codec; | 501 avctx->codec = codec; |