Browse code

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

Carl Eugen Hoyos authored on 2010/07/08 06:23:36
Showing 20 changed files
... ...
@@ -30,8 +30,8 @@
30 30
 #include "libavutil/avutil.h"
31 31
 
32 32
 #define LIBAVCODEC_VERSION_MAJOR 52
33
-#define LIBAVCODEC_VERSION_MINOR 79
34
-#define LIBAVCODEC_VERSION_MICRO  1
33
+#define LIBAVCODEC_VERSION_MINOR 80
34
+#define LIBAVCODEC_VERSION_MICRO  0
35 35
 
36 36
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
37 37
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -2713,6 +2713,7 @@ typedef struct AVCodec {
2713 2713
     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
2714 2714
     const enum SampleFormat *sample_fmts;   ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
2715 2715
     const int64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
2716
+    uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
2716 2717
 } AVCodec;
2717 2718
 
2718 2719
 /**
... ...
@@ -345,5 +345,6 @@ AVCodec bmp_decoder = {
345 345
     bmp_decode_end,
346 346
     bmp_decode_frame,
347 347
     CODEC_CAP_DR1,
348
+    .max_lowres = 5,
348 349
     .long_name = NULL_IF_CONFIG_SMALL("BMP image"),
349 350
 };
... ...
@@ -377,5 +377,6 @@ AVCodec cdgraphics_decoder = {
377 377
     cdg_decode_end,
378 378
     cdg_decode_frame,
379 379
     CODEC_CAP_DR1,
380
+    .max_lowres = 5,
380 381
     .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
381 382
 };
... ...
@@ -1304,6 +1304,7 @@ AVCodec dvvideo_decoder = {
1304 1304
     dvvideo_decode_frame,
1305 1305
     CODEC_CAP_DR1,
1306 1306
     NULL,
1307
+    .max_lowres = 3,
1307 1308
     .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
1308 1309
 };
1309 1310
 #endif
... ...
@@ -127,6 +127,7 @@ AVCodec flv_decoder = {
127 127
     ff_h263_decode_end,
128 128
     ff_h263_decode_frame,
129 129
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
130
+    .max_lowres= 3,
130 131
     .long_name= NULL_IF_CONFIG_SMALL("Flash Video (FLV) / Sorenson Spark / Sorenson H.263"),
131 132
     .pix_fmts= ff_pixfmt_list_420,
132 133
 };
... ...
@@ -651,5 +651,6 @@ AVCodec h261_decoder = {
651 651
     h261_decode_end,
652 652
     h261_decode_frame,
653 653
     CODEC_CAP_DR1,
654
+    .max_lowres = 3,
654 655
     .long_name = NULL_IF_CONFIG_SMALL("H.261"),
655 656
 };
... ...
@@ -738,6 +738,7 @@ AVCodec h263_decoder = {
738 738
     ff_h263_decode_frame,
739 739
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
740 740
     .flush= ff_mpeg_flush,
741
+    .max_lowres= 3,
741 742
     .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
742 743
     .pix_fmts= ff_hwaccel_pixfmt_list_420,
743 744
 };
... ...
@@ -172,5 +172,6 @@ AVCodec kgv1_decoder = {
172 172
     NULL,
173 173
     decode_end,
174 174
     decode_frame,
175
+    .max_lowres = 1,
175 176
     .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"),
176 177
 };
... ...
@@ -193,5 +193,6 @@ AVCodec libopenjpeg_decoder = {
193 193
     libopenjpeg_decode_close,
194 194
     libopenjpeg_decode_frame,
195 195
     CODEC_CAP_DR1,
196
+    .max_lowres = 5,
196 197
     .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"),
197 198
 } ;
... ...
@@ -156,5 +156,6 @@ AVCodec mjpegb_decoder = {
156 156
     mjpegb_decode_frame,
157 157
     CODEC_CAP_DR1,
158 158
     NULL,
159
+    .max_lowres = 3,
159 160
     .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
160 161
 };
... ...
@@ -1542,6 +1542,7 @@ AVCodec mjpeg_decoder = {
1542 1542
     ff_mjpeg_decode_frame,
1543 1543
     CODEC_CAP_DR1,
1544 1544
     NULL,
1545
+    .max_lowres = 8,
1545 1546
     .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
1546 1547
 };
1547 1548
 
... ...
@@ -1556,5 +1557,6 @@ AVCodec thp_decoder = {
1556 1556
     ff_mjpeg_decode_frame,
1557 1557
     CODEC_CAP_DR1,
1558 1558
     NULL,
1559
+    .max_lowres = 3,
1559 1560
     .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
1560 1561
 };
... ...
@@ -2511,6 +2511,7 @@ AVCodec mpeg1video_decoder = {
2511 2511
     mpeg_decode_frame,
2512 2512
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
2513 2513
     .flush= flush,
2514
+    .max_lowres= 3,
2514 2515
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
2515 2516
 };
2516 2517
 
... ...
@@ -2525,6 +2526,7 @@ AVCodec mpeg2video_decoder = {
2525 2525
     mpeg_decode_frame,
2526 2526
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
2527 2527
     .flush= flush,
2528
+    .max_lowres= 3,
2528 2529
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"),
2529 2530
 };
2530 2531
 
... ...
@@ -2540,6 +2542,7 @@ AVCodec mpegvideo_decoder = {
2540 2540
     mpeg_decode_frame,
2541 2541
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
2542 2542
     .flush= flush,
2543
+    .max_lowres= 3,
2543 2544
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"),
2544 2545
 };
2545 2546
 
... ...
@@ -2245,6 +2245,7 @@ AVCodec mpeg4_decoder = {
2245 2245
     ff_h263_decode_frame,
2246 2246
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
2247 2247
     .flush= ff_mpeg_flush,
2248
+    .max_lowres= 3,
2248 2249
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
2249 2250
     .pix_fmts= ff_hwaccel_pixfmt_list_420,
2250 2251
 };
... ...
@@ -1929,6 +1929,7 @@ AVCodec msmpeg4v1_decoder = {
1929 1929
     ff_h263_decode_end,
1930 1930
     ff_h263_decode_frame,
1931 1931
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
1932
+    .max_lowres= 3,
1932 1933
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
1933 1934
     .pix_fmts= ff_pixfmt_list_420,
1934 1935
 };
... ...
@@ -1943,6 +1944,7 @@ AVCodec msmpeg4v2_decoder = {
1943 1943
     ff_h263_decode_end,
1944 1944
     ff_h263_decode_frame,
1945 1945
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
1946
+    .max_lowres= 3,
1946 1947
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
1947 1948
     .pix_fmts= ff_pixfmt_list_420,
1948 1949
 };
... ...
@@ -1957,6 +1959,7 @@ AVCodec msmpeg4v3_decoder = {
1957 1957
     ff_h263_decode_end,
1958 1958
     ff_h263_decode_frame,
1959 1959
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
1960
+    .max_lowres= 3,
1960 1961
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
1961 1962
     .pix_fmts= ff_pixfmt_list_420,
1962 1963
 };
... ...
@@ -1971,6 +1974,7 @@ AVCodec wmv1_decoder = {
1971 1971
     ff_h263_decode_end,
1972 1972
     ff_h263_decode_frame,
1973 1973
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
1974
+    .max_lowres= 3,
1974 1975
     .long_name= NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
1975 1976
     .pix_fmts= ff_pixfmt_list_420,
1976 1977
 };
... ...
@@ -667,5 +667,6 @@ AVCodec png_decoder = {
667 667
     decode_frame,
668 668
     CODEC_CAP_DR1 /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
669 669
     NULL,
670
+    .max_lowres = 5,
670 671
     .long_name = NULL_IF_CONFIG_SMALL("PNG image"),
671 672
 };
... ...
@@ -199,6 +199,7 @@ AVCodec pgm_decoder = {
199 199
     pnm_decode_frame,
200 200
     CODEC_CAP_DR1,
201 201
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
202
+    .max_lowres = 5,
202 203
     .long_name = NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
203 204
 };
204 205
 #endif
... ...
@@ -215,6 +216,7 @@ AVCodec pgmyuv_decoder = {
215 215
     pnm_decode_frame,
216 216
     CODEC_CAP_DR1,
217 217
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
218
+    .max_lowres = 5,
218 219
     .long_name = NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
219 220
 };
220 221
 #endif
... ...
@@ -231,6 +233,7 @@ AVCodec ppm_decoder = {
231 231
     pnm_decode_frame,
232 232
     CODEC_CAP_DR1,
233 233
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
234
+    .max_lowres = 5,
234 235
     .long_name = NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
235 236
 };
236 237
 #endif
... ...
@@ -247,6 +250,7 @@ AVCodec pbm_decoder = {
247 247
     pnm_decode_frame,
248 248
     CODEC_CAP_DR1,
249 249
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
250
+    .max_lowres = 5,
250 251
     .long_name = NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
251 252
 };
252 253
 #endif
... ...
@@ -263,6 +267,7 @@ AVCodec pam_decoder = {
263 263
     pnm_decode_frame,
264 264
     CODEC_CAP_DR1,
265 265
     .pix_fmts  = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
266
+    .max_lowres = 5,
266 267
     .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
267 268
 };
268 269
 #endif
... ...
@@ -716,6 +716,7 @@ AVCodec rv10_decoder = {
716 716
     rv10_decode_end,
717 717
     rv10_decode_frame,
718 718
     CODEC_CAP_DR1,
719
+    .max_lowres = 3,
719 720
     .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
720 721
     .pix_fmts= ff_pixfmt_list_420,
721 722
 };
... ...
@@ -731,6 +732,7 @@ AVCodec rv20_decoder = {
731 731
     rv10_decode_frame,
732 732
     CODEC_CAP_DR1 | CODEC_CAP_DELAY,
733 733
     .flush= ff_mpeg_flush,
734
+    .max_lowres = 3,
734 735
     .long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
735 736
     .pix_fmts= ff_pixfmt_list_420,
736 737
 };
... ...
@@ -204,6 +204,7 @@ AVCodec sp5x_decoder = {
204 204
     sp5x_decode_frame,
205 205
     CODEC_CAP_DR1,
206 206
     NULL,
207
+    .max_lowres = 5,
207 208
     .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
208 209
 };
209 210
 
... ...
@@ -506,6 +506,13 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
506 506
     }
507 507
     avctx->frame_number = 0;
508 508
     if(avctx->codec->init){
509
+        if(avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
510
+           avctx->codec->max_lowres < avctx->lowres){
511
+            av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
512
+                   avctx->codec->max_lowres);
513
+            goto free_and_end;
514
+        }
515
+
509 516
         ret = avctx->codec->init(avctx);
510 517
         if (ret < 0) {
511 518
             goto free_and_end;
... ...
@@ -494,6 +494,7 @@ AVCodec wmv2_decoder = {
494 494
     wmv2_decode_end,
495 495
     ff_h263_decode_frame,
496 496
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
497
+    .max_lowres = 3,
497 498
     .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
498 499
     .pix_fmts= ff_pixfmt_list_420,
499 500
 };