changeset 12108:c35d7bc64882 libavcodec

Add new decoder property max_lowres and do not init decoder if requested value is higher.
author cehoyos
date Wed, 07 Jul 2010 21:23:36 +0000
parents 1e4996a88ca5
children fb0ad62e952e
files avcodec.h bmp.c cdgraphics.c dv.c flvdec.c h261dec.c h263dec.c kgv1dec.c libopenjpeg.c mjpegbdec.c mjpegdec.c mpeg12.c mpeg4videodec.c msmpeg4.c pngdec.c pnmdec.c rv10.c sp5xdec.c utils.c wmv2dec.c
diffstat 20 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Wed Jul 07 20:23:56 2010 +0000
+++ b/avcodec.h	Wed Jul 07 21:23:36 2010 +0000
@@ -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 @@
     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;
 
 /**
--- a/bmp.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/bmp.c	Wed Jul 07 21:23:36 2010 +0000
@@ -345,5 +345,6 @@
     bmp_decode_end,
     bmp_decode_frame,
     CODEC_CAP_DR1,
+    .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("BMP image"),
 };
--- a/cdgraphics.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/cdgraphics.c	Wed Jul 07 21:23:36 2010 +0000
@@ -377,5 +377,6 @@
     cdg_decode_end,
     cdg_decode_frame,
     CODEC_CAP_DR1,
+    .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
 };
--- a/dv.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/dv.c	Wed Jul 07 21:23:36 2010 +0000
@@ -1304,6 +1304,7 @@
     dvvideo_decode_frame,
     CODEC_CAP_DR1,
     NULL,
+    .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
 };
 #endif
--- a/flvdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/flvdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -127,6 +127,7 @@
     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,
 };
--- a/h261dec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/h261dec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -651,5 +651,6 @@
     h261_decode_end,
     h261_decode_frame,
     CODEC_CAP_DR1,
+    .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("H.261"),
 };
--- a/h263dec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/h263dec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -738,6 +738,7 @@
     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,
 };
--- a/kgv1dec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/kgv1dec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -172,5 +172,6 @@
     NULL,
     decode_end,
     decode_frame,
+    .max_lowres = 1,
     .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"),
 };
--- a/libopenjpeg.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/libopenjpeg.c	Wed Jul 07 21:23:36 2010 +0000
@@ -193,5 +193,6 @@
     libopenjpeg_decode_close,
     libopenjpeg_decode_frame,
     CODEC_CAP_DR1,
+    .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"),
 } ;
--- a/mjpegbdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/mjpegbdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -156,5 +156,6 @@
     mjpegb_decode_frame,
     CODEC_CAP_DR1,
     NULL,
+    .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
 };
--- a/mjpegdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/mjpegdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -1542,6 +1542,7 @@
     ff_mjpeg_decode_frame,
     CODEC_CAP_DR1,
     NULL,
+    .max_lowres = 8,
     .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
 };
 
@@ -1556,5 +1557,6 @@
     ff_mjpeg_decode_frame,
     CODEC_CAP_DR1,
     NULL,
+    .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
 };
--- a/mpeg12.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/mpeg12.c	Wed Jul 07 21:23:36 2010 +0000
@@ -2511,6 +2511,7 @@
     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 @@
     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 @@
     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"),
 };
 
--- a/mpeg4videodec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/mpeg4videodec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -2245,6 +2245,7 @@
     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,
 };
--- a/msmpeg4.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/msmpeg4.c	Wed Jul 07 21:23:36 2010 +0000
@@ -1929,6 +1929,7 @@
     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 @@
     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 @@
     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 @@
     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,
 };
--- a/pngdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/pngdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -667,5 +667,6 @@
     decode_frame,
     CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
     NULL,
+    .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("PNG image"),
 };
--- a/pnmdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/pnmdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -199,6 +199,7 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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
--- a/rv10.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/rv10.c	Wed Jul 07 21:23:36 2010 +0000
@@ -716,6 +716,7 @@
     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 @@
     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,
 };
--- a/sp5xdec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/sp5xdec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -204,6 +204,7 @@
     sp5x_decode_frame,
     CODEC_CAP_DR1,
     NULL,
+    .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
 };
 
--- a/utils.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/utils.c	Wed Jul 07 21:23:36 2010 +0000
@@ -506,6 +506,13 @@
     }
     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;
--- a/wmv2dec.c	Wed Jul 07 20:23:56 2010 +0000
+++ b/wmv2dec.c	Wed Jul 07 21:23:36 2010 +0000
@@ -494,6 +494,7 @@
     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,
 };