Add new decoder property max_lowres and do not init decoder if requested value is higher.

Originally committed as revision 24098 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Carl Eugen Hoyos 2010-07-07 21:23:36 +00:00
parent 38b0410902
commit 0fd0ef7947
20 changed files with 39 additions and 2 deletions

View File

@ -30,8 +30,8 @@
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 79
#define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_MINOR 80
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
@ -2713,6 +2713,7 @@ typedef struct AVCodec {
const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
} AVCodec;
/**

View File

@ -345,5 +345,6 @@ AVCodec bmp_decoder = {
bmp_decode_end,
bmp_decode_frame,
CODEC_CAP_DR1,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("BMP image"),
};

View File

@ -377,5 +377,6 @@ AVCodec cdgraphics_decoder = {
cdg_decode_end,
cdg_decode_frame,
CODEC_CAP_DR1,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
};

View File

@ -1304,6 +1304,7 @@ AVCodec dvvideo_decoder = {
dvvideo_decode_frame,
CODEC_CAP_DR1,
NULL,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
};
#endif

View File

@ -127,6 +127,7 @@ AVCodec flv_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
.pix_fmts= ff_pixfmt_list_420,
};

View File

@ -651,5 +651,6 @@ AVCodec h261_decoder = {
h261_decode_end,
h261_decode_frame,
CODEC_CAP_DR1,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("H.261"),
};

View File

@ -738,6 +738,7 @@ AVCodec h263_decoder = {
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
.pix_fmts= ff_hwaccel_pixfmt_list_420,
};

View File

@ -172,5 +172,6 @@ AVCodec kgv1_decoder = {
NULL,
decode_end,
decode_frame,
.max_lowres = 1,
.long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"),
};

View File

@ -193,5 +193,6 @@ AVCodec libopenjpeg_decoder = {
libopenjpeg_decode_close,
libopenjpeg_decode_frame,
CODEC_CAP_DR1,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"),
} ;

View File

@ -156,5 +156,6 @@ AVCodec mjpegb_decoder = {
mjpegb_decode_frame,
CODEC_CAP_DR1,
NULL,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
};

View File

@ -1542,6 +1542,7 @@ AVCodec mjpeg_decoder = {
ff_mjpeg_decode_frame,
CODEC_CAP_DR1,
NULL,
.max_lowres = 8,
.long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
};
@ -1556,5 +1557,6 @@ AVCodec thp_decoder = {
ff_mjpeg_decode_frame,
CODEC_CAP_DR1,
NULL,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
};

View File

@ -2511,6 +2511,7 @@ AVCodec mpeg1video_decoder = {
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
};
@ -2525,6 +2526,7 @@ AVCodec mpeg2video_decoder = {
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"),
};
@ -2540,6 +2542,7 @@ AVCodec mpegvideo_decoder = {
mpeg_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
};

View File

@ -2245,6 +2245,7 @@ AVCodec mpeg4_decoder = {
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
.pix_fmts= ff_hwaccel_pixfmt_list_420,
};

View File

@ -1929,6 +1929,7 @@ AVCodec msmpeg4v1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
.pix_fmts= ff_pixfmt_list_420,
};
@ -1943,6 +1944,7 @@ AVCodec msmpeg4v2_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
.pix_fmts= ff_pixfmt_list_420,
};
@ -1957,6 +1959,7 @@ AVCodec msmpeg4v3_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
.pix_fmts= ff_pixfmt_list_420,
};
@ -1971,6 +1974,7 @@ AVCodec wmv1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres= 3,
.long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
.pix_fmts= ff_pixfmt_list_420,
};

View File

@ -667,5 +667,6 @@ AVCodec png_decoder = {
decode_frame,
CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
NULL,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PNG image"),
};

View File

@ -199,6 +199,7 @@ AVCodec pgm_decoder = {
pnm_decode_frame,
CODEC_CAP_DR1,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
};
#endif
@ -215,6 +216,7 @@ AVCodec pgmyuv_decoder = {
pnm_decode_frame,
CODEC_CAP_DR1,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
};
#endif
@ -231,6 +233,7 @@ AVCodec ppm_decoder = {
pnm_decode_frame,
CODEC_CAP_DR1,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
};
#endif
@ -247,6 +250,7 @@ AVCodec pbm_decoder = {
pnm_decode_frame,
CODEC_CAP_DR1,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
};
#endif
@ -263,6 +267,7 @@ AVCodec pam_decoder = {
pnm_decode_frame,
CODEC_CAP_DR1,
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
};
#endif

View File

@ -716,6 +716,7 @@ AVCodec rv10_decoder = {
rv10_decode_end,
rv10_decode_frame,
CODEC_CAP_DR1,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
.pix_fmts= ff_pixfmt_list_420,
};
@ -731,6 +732,7 @@ AVCodec rv20_decoder = {
rv10_decode_frame,
CODEC_CAP_DR1 | CODEC_CAP_DELAY,
.flush= ff_mpeg_flush,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
.pix_fmts= ff_pixfmt_list_420,
};

View File

@ -204,6 +204,7 @@ AVCodec sp5x_decoder = {
sp5x_decode_frame,
CODEC_CAP_DR1,
NULL,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
};

View File

@ -506,6 +506,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
}
avctx->frame_number = 0;
if(avctx->codec->init){
if(avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
avctx->codec->max_lowres < avctx->lowres){
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
avctx->codec->max_lowres);
goto free_and_end;
}
ret = avctx->codec->init(avctx);
if (ret < 0) {
goto free_and_end;

View File

@ -494,6 +494,7 @@ AVCodec wmv2_decoder = {
wmv2_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.max_lowres = 3,
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
.pix_fmts= ff_pixfmt_list_420,
};