@@ -52,6 +52,13 @@ namespace android {
5252// buffers after 3 seconds.
5353const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL ;
5454
55+ // OMX Spec defines less than 50 color formats. If the query for
56+ // color format is executed for more than kMaxColorFormatSupported,
57+ // the query will fail to avoid looping forever.
58+ // 1000 is more than enough for us to tell whether the omx
59+ // component in question is buggy or not.
60+ const static uint32_t kMaxColorFormatSupported = 1000 ;
61+
5562struct CodecInfo {
5663 const char *mime;
5764 const char *codec;
@@ -818,6 +825,11 @@ status_t OMXCodec::setVideoPortFormatType(
818825 }
819826
820827 ++index;
828+ if (index >= kMaxColorFormatSupported ) {
829+ CODEC_LOGE (" color format %d or compression format %d is not supported" ,
830+ colorFormat, compressionFormat);
831+ return UNKNOWN_ERROR;
832+ }
821833 }
822834
823835 if (!found) {
@@ -901,22 +913,19 @@ status_t OMXCodec::isColorFormatSupported(
901913 // the incremented index (bug 2897413).
902914 CHECK_EQ (index, portFormat.nIndex );
903915 if (portFormat.eColorFormat == colorFormat) {
904- LOGV (" Found supported color format: %d" , portFormat.eColorFormat );
916+ CODEC_LOGV (" Found supported color format: %d" , portFormat.eColorFormat );
905917 return OK; // colorFormat is supported!
906918 }
907919 ++index;
908920 portFormat.nIndex = index;
909921
910- // OMX Spec defines less than 50 color formats
911- // 1000 is more than enough for us to tell whether the omx
912- // component in question is buggy or not.
913- if (index >= 1000 ) {
914- LOGE (" More than %ld color formats are supported???" , index);
922+ if (index >= kMaxColorFormatSupported ) {
923+ CODEC_LOGE (" More than %ld color formats are supported???" , index);
915924 break ;
916925 }
917926 }
918927
919- LOGE (" color format %d is not supported" , colorFormat);
928+ CODEC_LOGE (" color format %d is not supported" , colorFormat);
920929 return UNKNOWN_ERROR;
921930}
922931
0 commit comments