From a57d13b71375a127820220efeb35d03288c43ac2 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <baptiste.coudurier@gmail.com> Date: Thu, 16 Nov 2006 09:58:34 +0000 Subject: [PATCH] throw error if unsupported resolution is used with h261 Originally committed as revision 7097 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h261.c | 2 +- libavcodec/mpegvideo.c | 4 ++++ libavcodec/mpegvideo.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/h261.c b/libavcodec/h261.c index b21d324c9c8..8d4ca08cd42 100644 --- a/libavcodec/h261.c +++ b/libavcodec/h261.c @@ -77,7 +77,7 @@ void ff_h261_loop_filter(MpegEncContext *s){ s->dsp.h261_loop_filter(dest_cr, uvlinesize); } -static int ff_h261_get_picture_format(int width, int height){ +int ff_h261_get_picture_format(int width, int height){ // QCIF if (width == 176 && height == 144) return 0; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index fda536c0689..2fac26d5ebc 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1208,6 +1208,10 @@ int MPV_encode_init(AVCodecContext *avctx) s->low_delay=1; break; case CODEC_ID_H261: + if (ff_h261_get_picture_format(s->width, s->height) < 0) { + av_log(avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the H.261 codec.\nValid sizes are 176x144, 352x288\n", s->width, s->height); + return -1; + } s->out_format = FMT_H261; avctx->delay=0; s->low_delay=1; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index fe533111163..011678a42d5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -824,6 +824,7 @@ void ff_h261_encode_mb(MpegEncContext *s, int motion_x, int motion_y); void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number); void ff_h261_encode_init(MpegEncContext *s); +int ff_h261_get_picture_format(int width, int height); /* h263.c, h263dec.c */ -- GitLab