diff options
Diffstat (limited to 'media/omx/1.0')
5 files changed, 439 insertions, 547 deletions
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp index 369db5b6..b8a16344 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp | |||
@@ -813,7 +813,7 @@ TEST_F(AudioDecHidlTest, DecodeTest) { | |||
813 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | 813 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); |
814 | // set state to idle | 814 | // set state to idle |
815 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 815 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
816 | // set state to loaded | 816 | // set state to executing |
817 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 817 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
818 | kPortIndexInput, kPortIndexOutput); | 818 | kPortIndexInput, kPortIndexOutput); |
819 | } | 819 | } |
@@ -872,7 +872,7 @@ TEST_F(AudioDecHidlTest, EOSTest_M) { | |||
872 | 872 | ||
873 | // set state to idle | 873 | // set state to idle |
874 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 874 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
875 | // set state to loaded | 875 | // set state to executing |
876 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 876 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
877 | kPortIndexInput, kPortIndexOutput); | 877 | kPortIndexInput, kPortIndexOutput); |
878 | } | 878 | } |
@@ -979,7 +979,7 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) { | |||
979 | 979 | ||
980 | // set state to idle | 980 | // set state to idle |
981 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 981 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
982 | // set state to loaded | 982 | // set state to executing |
983 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 983 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
984 | kPortIndexInput, kPortIndexOutput); | 984 | kPortIndexInput, kPortIndexOutput); |
985 | } | 985 | } |
@@ -1065,7 +1065,7 @@ TEST_F(AudioDecHidlTest, SimpleEOSTest) { | |||
1065 | 1065 | ||
1066 | // set state to idle | 1066 | // set state to idle |
1067 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1067 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1068 | // set state to loaded | 1068 | // set state to executing |
1069 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1069 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1070 | kPortIndexInput, kPortIndexOutput); | 1070 | kPortIndexInput, kPortIndexOutput); |
1071 | } | 1071 | } |
@@ -1169,7 +1169,7 @@ TEST_F(AudioDecHidlTest, FlushTest) { | |||
1169 | 1169 | ||
1170 | // set state to idle | 1170 | // set state to idle |
1171 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1171 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1172 | // set state to loaded | 1172 | // set state to executing |
1173 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1173 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1174 | kPortIndexInput, kPortIndexOutput); | 1174 | kPortIndexInput, kPortIndexOutput); |
1175 | } | 1175 | } |
diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp index 5367a4d5..dd5f16af 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp | |||
@@ -535,7 +535,7 @@ TEST_F(AudioEncHidlTest, SimpleEncodeTest) { | |||
535 | 535 | ||
536 | // set state to idle | 536 | // set state to idle |
537 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 537 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
538 | // set state to loaded | 538 | // set state to executing |
539 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 539 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
540 | kPortIndexInput, kPortIndexOutput); | 540 | kPortIndexInput, kPortIndexOutput); |
541 | } | 541 | } |
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp index eeca5997..070dc4c1 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp | |||
@@ -671,8 +671,8 @@ android::DescribeColorFormatParams::DescribeColorFormatParams( | |||
671 | bUsingNativeBuffers = params.bUsingNativeBuffers; | 671 | bUsingNativeBuffers = params.bUsingNativeBuffers; |
672 | }; | 672 | }; |
673 | 673 | ||
674 | bool isColorFormatFlexibleYUV420(sp<IOmxNode> omxNode, | 674 | bool isColorFormatFlexibleYUV(sp<IOmxNode> omxNode, |
675 | OMX_COLOR_FORMATTYPE eColorFormat) { | 675 | OMX_COLOR_FORMATTYPE eColorFormat) { |
676 | android::hardware::media::omx::V1_0::Status status; | 676 | android::hardware::media::omx::V1_0::Status status; |
677 | unsigned int index = OMX_IndexMax, index2 = OMX_IndexMax; | 677 | unsigned int index = OMX_IndexMax, index2 = OMX_IndexMax; |
678 | omxNode->getExtensionIndex( | 678 | omxNode->getExtensionIndex( |
@@ -740,11 +740,7 @@ bool isColorFormatFlexibleYUV420(sp<IOmxNode> omxNode, | |||
740 | return false; | 740 | return false; |
741 | } | 741 | } |
742 | 742 | ||
743 | // get default color format for output port. | 743 | // get default color format for output port |
744 | // Recommended Order of Supported Color Formats : | ||
745 | // 1. most efficient hardware format | ||
746 | // 2. most efficient flexible YUV format | ||
747 | // 3. other formats | ||
748 | void getDefaultColorFormat(sp<IOmxNode> omxNode, OMX_U32 kPortIndexOutput, | 744 | void getDefaultColorFormat(sp<IOmxNode> omxNode, OMX_U32 kPortIndexOutput, |
749 | PortMode oPortMode, | 745 | PortMode oPortMode, |
750 | OMX_COLOR_FORMATTYPE* eColorFormat) { | 746 | OMX_COLOR_FORMATTYPE* eColorFormat) { |
@@ -758,21 +754,13 @@ void getDefaultColorFormat(sp<IOmxNode> omxNode, OMX_U32 kPortIndexOutput, | |||
758 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; | 754 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) break; |
759 | EXPECT_EQ(portFormat.eCompressionFormat, OMX_VIDEO_CodingUnused); | 755 | EXPECT_EQ(portFormat.eCompressionFormat, OMX_VIDEO_CodingUnused); |
760 | if (oPortMode != PortMode::PRESET_BYTE_BUFFER) { | 756 | if (oPortMode != PortMode::PRESET_BYTE_BUFFER) { |
761 | // In GraphicBuffermode pick first format in the list as the desired | ||
762 | // format | ||
763 | *eColorFormat = portFormat.eColorFormat; | 757 | *eColorFormat = portFormat.eColorFormat; |
764 | break; | 758 | break; |
765 | } | 759 | } |
766 | // FlexibleYUV color format is supported in both graphic and shared mem | 760 | if (isColorFormatFlexibleYUV(omxNode, portFormat.eColorFormat)) { |
767 | // mode | ||
768 | if (isColorFormatFlexibleYUV420(omxNode, portFormat.eColorFormat)) { | ||
769 | *eColorFormat = portFormat.eColorFormat; | 761 | *eColorFormat = portFormat.eColorFormat; |
770 | break; | 762 | break; |
771 | } | 763 | } |
772 | // Video components must support either OMX_COLOR_FormatYUV420Planar | ||
773 | // or OMX_COLOR_FormatYUV420SemiPlanar format in shared memory mode. | ||
774 | // Android treats Packed formats identical to the unpacked version as | ||
775 | // as all raw video buffers must be packed (nSliceHeight = height) | ||
776 | if (OMX_COLOR_FormatYUV420SemiPlanar == portFormat.eColorFormat || | 764 | if (OMX_COLOR_FormatYUV420SemiPlanar == portFormat.eColorFormat || |
777 | OMX_COLOR_FormatYUV420Planar == portFormat.eColorFormat || | 765 | OMX_COLOR_FormatYUV420Planar == portFormat.eColorFormat || |
778 | OMX_COLOR_FormatYUV420PackedPlanar == portFormat.eColorFormat || | 766 | OMX_COLOR_FormatYUV420PackedPlanar == portFormat.eColorFormat || |
@@ -854,102 +842,84 @@ TEST_F(VideoDecHidlTest, DecodeTest) { | |||
854 | eleInfo >> flags; | 842 | eleInfo >> flags; |
855 | eleInfo >> timestamp; | 843 | eleInfo >> timestamp; |
856 | Info.push_back({bytesCount, flags, timestamp}); | 844 | Info.push_back({bytesCount, flags, timestamp}); |
845 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) | ||
846 | timestampUslist.push_back(timestamp); | ||
857 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; | 847 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; |
858 | } | 848 | } |
859 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); | ||
860 | eleInfo.close(); | 849 | eleInfo.close(); |
861 | 850 | ||
851 | // As the frame sizes are known ahead, use it to configure i/p buffer size | ||
852 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); | ||
853 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); | ||
854 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
855 | |||
856 | // Change the port modes arbitrarily at the start before finialising on the | ||
857 | // desired values. | ||
862 | PortMode dummyPM[] = { | 858 | PortMode dummyPM[] = { |
863 | PortMode::PRESET_BYTE_BUFFER, PortMode::PRESET_ANW_BUFFER, | 859 | PortMode::PRESET_BYTE_BUFFER, PortMode::PRESET_ANW_BUFFER, |
864 | PortMode::PRESET_SECURE_BUFFER, PortMode::DYNAMIC_ANW_BUFFER, | 860 | PortMode::PRESET_SECURE_BUFFER, PortMode::DYNAMIC_ANW_BUFFER, |
865 | PortMode::DYNAMIC_NATIVE_HANDLE, | 861 | PortMode::DYNAMIC_NATIVE_HANDLE, |
866 | }; | 862 | }; |
867 | PortMode pmArray[] = {PortMode::PRESET_BYTE_BUFFER, | 863 | for (size_t k = 0; k < sizeof(dummyPM) / sizeof(dummyPM[0]); k++) { |
868 | PortMode::DYNAMIC_ANW_BUFFER, | 864 | // ports may or may not support these modes. These are not the final |
869 | PortMode::PRESET_ANW_BUFFER}; | 865 | // values. This init is done to test if causes any problems. |
870 | 866 | status = omxNode->setPortMode(kPortIndexInput, dummyPM[k]); | |
871 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 867 | status = omxNode->setPortMode(kPortIndexOutput, dummyPM[k]); |
872 | // Change the port modes arbitrarily at the start before finialising | 868 | } |
873 | // on the desired values. | ||
874 | for (size_t k = 0; k < sizeof(dummyPM) / sizeof(dummyPM[0]); k++) { | ||
875 | // ports may or may not support these modes. These are not the final | ||
876 | // values. This init is done to test if causes any problems. | ||
877 | status = omxNode->setPortMode(kPortIndexInput, dummyPM[k]); | ||
878 | status = omxNode->setPortMode(kPortIndexOutput, dummyPM[k]); | ||
879 | } | ||
880 | // set port mode | ||
881 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
882 | portMode[1] = pmArray[j]; | ||
883 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
884 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
885 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
886 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
887 | continue; | ||
888 | } | ||
889 | 869 | ||
890 | // The input width and height information is necessary for the component | 870 | // set port mode |
891 | // to configure the size of the input buffer. But this is not available. | 871 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; |
892 | // As the frame sizes are known ahead, use it to configure i/p buffer | 872 | portMode[1] = PortMode::DYNAMIC_ANW_BUFFER; |
893 | // size. | 873 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
894 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); | 874 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
875 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
876 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
877 | portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
878 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
895 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 879 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
896 | |||
897 | // prepare list of input timestamps | ||
898 | for (size_t frameID = 0; frameID < Info.size(); frameID++) { | ||
899 | if (timestampDevTest && | ||
900 | (Info[frameID].flags != OMX_BUFFERFLAG_CODECCONFIG)) | ||
901 | timestampUslist.push_back(Info[frameID].timestamp); | ||
902 | } | ||
903 | |||
904 | // set Port Params | ||
905 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
906 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | ||
907 | &nFrameHeight, &xFramerate); | ||
908 | // get default color format | ||
909 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
910 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
911 | &eColorFormat); | ||
912 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
913 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | ||
914 | OMX_VIDEO_CodingUnused, eColorFormat, | ||
915 | xFramerate); | ||
916 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
917 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
918 | eColorFormat, nFrameWidth, nFrameHeight, 0, | ||
919 | xFramerate); | ||
920 | |||
921 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
922 | |||
923 | // set state to idle | ||
924 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
925 | kPortIndexInput, kPortIndexOutput, portMode, | ||
926 | true); | ||
927 | // set state to executing | ||
928 | changeStateIdletoExecute(omxNode, observer); | ||
929 | |||
930 | // Port Reconfiguration | ||
931 | eleStream.open(mURL, std::ifstream::binary); | ||
932 | ASSERT_EQ(eleStream.is_open(), true); | ||
933 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
934 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | ||
935 | portMode[1]); | ||
936 | eleStream.close(); | ||
937 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
938 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
939 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | ||
940 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | ||
941 | nullptr); | ||
942 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
943 | eosFlag = false; | ||
944 | timestampUslist.clear(); | ||
945 | framesReceived = 0; | ||
946 | timestampUs = 0; | ||
947 | // set state to idle | ||
948 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
949 | // set state to loaded | ||
950 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
951 | kPortIndexInput, kPortIndexOutput); | ||
952 | } | 880 | } |
881 | |||
882 | // set Port Params | ||
883 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
884 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | ||
885 | &xFramerate); | ||
886 | // get default color format | ||
887 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
888 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
889 | &eColorFormat); | ||
890 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
891 | status = | ||
892 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
893 | eColorFormat, xFramerate); | ||
894 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
895 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
896 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | ||
897 | |||
898 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
899 | |||
900 | // set state to idle | ||
901 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
902 | kPortIndexInput, kPortIndexOutput, portMode, true); | ||
903 | // set state to executing | ||
904 | changeStateIdletoExecute(omxNode, observer); | ||
905 | |||
906 | // Port Reconfiguration | ||
907 | eleStream.open(mURL, std::ifstream::binary); | ||
908 | ASSERT_EQ(eleStream.is_open(), true); | ||
909 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
910 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | ||
911 | portMode[1]); | ||
912 | eleStream.close(); | ||
913 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
914 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
915 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | ||
916 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | ||
917 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
918 | // set state to idle | ||
919 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
920 | // set state to executing | ||
921 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
922 | kPortIndexInput, kPortIndexOutput); | ||
953 | } | 923 | } |
954 | 924 | ||
955 | // Test for adaptive playback support | 925 | // Test for adaptive playback support |
@@ -971,153 +941,127 @@ TEST_F(VideoDecHidlTest, AdaptivePlaybackTest) { | |||
971 | kPortIndexOutput = kPortIndexInput + 1; | 941 | kPortIndexOutput = kPortIndexInput + 1; |
972 | } | 942 | } |
973 | 943 | ||
974 | bool apbSupport = false; | 944 | // set port mode |
975 | PortMode pmArray[] = { | 945 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; |
976 | PortMode::PRESET_BYTE_BUFFER, PortMode::DYNAMIC_ANW_BUFFER, | 946 | portMode[1] = PortMode::DYNAMIC_ANW_BUFFER; |
977 | PortMode::PRESET_ANW_BUFFER, | 947 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
978 | }; | 948 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
979 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 949 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
980 | // set port mode | 950 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { |
981 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | 951 | portMode[1] = PortMode::PRESET_BYTE_BUFFER; |
982 | portMode[1] = pmArray[j]; | ||
983 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
984 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
985 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | 952 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
986 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | 953 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
987 | continue; | 954 | } |
988 | } | ||
989 | 955 | ||
990 | // prepare for adaptive playback | 956 | // prepare for adaptive playback |
991 | uint32_t adaptiveMaxWidth = 320; | 957 | uint32_t adaptiveMaxWidth = 320; |
992 | uint32_t adaptiveMaxHeight = 240; | 958 | uint32_t adaptiveMaxHeight = 240; |
993 | status = omxNode->prepareForAdaptivePlayback( | 959 | status = omxNode->prepareForAdaptivePlayback( |
994 | kPortIndexOutput, true, adaptiveMaxWidth, adaptiveMaxHeight); | 960 | kPortIndexOutput, true, adaptiveMaxWidth, adaptiveMaxHeight); |
995 | if (strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11) == 0) { | 961 | if (strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11) == 0) { |
996 | // SoftOMX Decoders donot support graphic buffer modes. So for them | 962 | // SoftOMX Decoders donot support graphic buffer modes. So for them |
997 | // support for adaptive play back is mandatory in Byte Buffer mode | 963 | // support for adaptive play back is mandatory in Byte Buffer mode |
998 | ASSERT_EQ(status, | 964 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
999 | ::android::hardware::media::omx::V1_0::Status::OK); | 965 | } else { |
1000 | } else { | 966 | // for vendor codecs, support for adaptive play back is optional |
1001 | // Adaptive playback not supported | 967 | // in byte buffer mode. |
1002 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) | 968 | if (portMode[1] == PortMode::PRESET_BYTE_BUFFER) return; |
1003 | continue; | 969 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) return; |
1004 | // for vendor codecs, support for adaptive play back is optional | 970 | } |
1005 | // in byte buffer mode. But they must be supported in atleast one | 971 | |
1006 | // graphic buffer mode | 972 | // TODO: Handle this better !!! |
1007 | if (portMode[1] == PortMode::PRESET_BYTE_BUFFER || | 973 | // Without the knowledge of the maximum resolution of the frame to be |
1008 | apbSupport == true) | 974 | // decoded it is not possible to choose the size of the input buffer. |
1009 | continue; | 975 | // The value below is based on the info. files of clips in res folder. |
1010 | else | 976 | status = setPortBufferSize(omxNode, kPortIndexInput, 482304); |
1011 | apbSupport = true; | 977 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
978 | |||
979 | // set Port Params | ||
980 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
981 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | ||
982 | &xFramerate); | ||
983 | // get default color format | ||
984 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
985 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
986 | &eColorFormat); | ||
987 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
988 | status = | ||
989 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
990 | eColorFormat, xFramerate); | ||
991 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
992 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
993 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | ||
994 | |||
995 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
996 | |||
997 | // set state to idle | ||
998 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
999 | kPortIndexInput, kPortIndexOutput, portMode, true); | ||
1000 | // set state to executing | ||
1001 | changeStateIdletoExecute(omxNode, observer); | ||
1002 | |||
1003 | timestampDevTest = true; | ||
1004 | uint32_t timestampOffset = 0; | ||
1005 | for (uint32_t i = 0; i < STREAM_COUNT * 2; i++) { | ||
1006 | std::ifstream eleStream, eleInfo; | ||
1007 | char mURL[512], info[512]; | ||
1008 | android::Vector<FrameData> Info; | ||
1009 | strcpy(mURL, gEnv->getRes().c_str()); | ||
1010 | strcpy(info, gEnv->getRes().c_str()); | ||
1011 | GetURLForComponent(compName, mURL, info, i % STREAM_COUNT); | ||
1012 | eleInfo.open(info); | ||
1013 | ASSERT_EQ(eleInfo.is_open(), true); | ||
1014 | int bytesCount = 0; | ||
1015 | uint32_t flags = 0; | ||
1016 | uint32_t timestamp = 0; | ||
1017 | uint32_t timestampMax = 0; | ||
1018 | while (1) { | ||
1019 | if (!(eleInfo >> bytesCount)) break; | ||
1020 | eleInfo >> flags; | ||
1021 | eleInfo >> timestamp; | ||
1022 | timestamp += timestampOffset; | ||
1023 | Info.push_back({bytesCount, flags, timestamp}); | ||
1024 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) | ||
1025 | timestampUslist.push_back(timestamp); | ||
1026 | if (timestampMax < timestamp) timestampMax = timestamp; | ||
1012 | } | 1027 | } |
1028 | timestampOffset = timestampMax; | ||
1029 | eleInfo.close(); | ||
1013 | 1030 | ||
1014 | // TODO: Handle this better !!! | 1031 | // Port Reconfiguration |
1015 | // Without the knowledge of the maximum resolution of the frame to be | 1032 | eleStream.open(mURL, std::ifstream::binary); |
1016 | // decoded it is not possible to choose the size of the input buffer. | 1033 | ASSERT_EQ(eleStream.is_open(), true); |
1017 | // The value below is based on the info. files of clips in res folder. | 1034 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1018 | status = setPortBufferSize(omxNode, kPortIndexInput, 482304); | 1035 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), |
1019 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1036 | portMode[1], false); |
1037 | eleStream.close(); | ||
1020 | 1038 | ||
1021 | // set Port Params | ||
1022 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
1023 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | 1039 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, |
1024 | &nFrameHeight, &xFramerate); | 1040 | &nFrameHeight, &xFramerate); |
1025 | // get default color format | 1041 | if ((nFrameWidth > adaptiveMaxWidth) || |
1026 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | 1042 | (nFrameHeight > adaptiveMaxHeight)) { |
1027 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | 1043 | if (nFrameWidth > adaptiveMaxWidth) adaptiveMaxWidth = nFrameWidth; |
1028 | &eColorFormat); | 1044 | if (nFrameHeight > adaptiveMaxHeight) |
1029 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | 1045 | adaptiveMaxHeight = nFrameHeight; |
1030 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | 1046 | EXPECT_TRUE(portSettingsChange); |
1031 | OMX_VIDEO_CodingUnused, eColorFormat, | 1047 | } else { |
1032 | xFramerate); | 1048 | // In DynamicANW Buffer mode, its ok to do a complete |
1033 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1049 | // reconfiguration even if a partial reconfiguration is sufficient. |
1034 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 1050 | if (portMode[1] != PortMode::DYNAMIC_ANW_BUFFER) |
1035 | eColorFormat, nFrameWidth, nFrameHeight, 0, | 1051 | EXPECT_FALSE(portSettingsChange); |
1036 | xFramerate); | ||
1037 | |||
1038 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1039 | |||
1040 | // set state to idle | ||
1041 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1042 | kPortIndexInput, kPortIndexOutput, portMode, | ||
1043 | true); | ||
1044 | // set state to executing | ||
1045 | changeStateIdletoExecute(omxNode, observer); | ||
1046 | |||
1047 | timestampDevTest = true; | ||
1048 | uint32_t timestampOffset = 0; | ||
1049 | for (uint32_t i = 0; i < STREAM_COUNT * 2; i++) { | ||
1050 | std::ifstream eleStream, eleInfo; | ||
1051 | char mURL[512], info[512]; | ||
1052 | android::Vector<FrameData> Info; | ||
1053 | strcpy(mURL, gEnv->getRes().c_str()); | ||
1054 | strcpy(info, gEnv->getRes().c_str()); | ||
1055 | GetURLForComponent(compName, mURL, info, i % STREAM_COUNT); | ||
1056 | eleInfo.open(info); | ||
1057 | ASSERT_EQ(eleInfo.is_open(), true); | ||
1058 | int bytesCount = 0; | ||
1059 | uint32_t flags = 0; | ||
1060 | uint32_t timestamp = 0; | ||
1061 | uint32_t timestampMax = 0; | ||
1062 | while (1) { | ||
1063 | if (!(eleInfo >> bytesCount)) break; | ||
1064 | eleInfo >> flags; | ||
1065 | eleInfo >> timestamp; | ||
1066 | timestamp += timestampOffset; | ||
1067 | Info.push_back({bytesCount, flags, timestamp}); | ||
1068 | if (timestampDevTest && (flags != OMX_BUFFERFLAG_CODECCONFIG)) | ||
1069 | timestampUslist.push_back(timestamp); | ||
1070 | if (timestampMax < timestamp) timestampMax = timestamp; | ||
1071 | } | ||
1072 | timestampOffset = timestampMax; | ||
1073 | eleInfo.close(); | ||
1074 | |||
1075 | // Port Reconfiguration | ||
1076 | eleStream.open(mURL, std::ifstream::binary); | ||
1077 | ASSERT_EQ(eleStream.is_open(), true); | ||
1078 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, | ||
1079 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, | ||
1080 | 0, (int)Info.size(), portMode[1], false); | ||
1081 | eleStream.close(); | ||
1082 | |||
1083 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | ||
1084 | &nFrameHeight, &xFramerate); | ||
1085 | if ((nFrameWidth > adaptiveMaxWidth) || | ||
1086 | (nFrameHeight > adaptiveMaxHeight)) { | ||
1087 | if (nFrameWidth > adaptiveMaxWidth) | ||
1088 | adaptiveMaxWidth = nFrameWidth; | ||
1089 | if (nFrameHeight > adaptiveMaxHeight) | ||
1090 | adaptiveMaxHeight = nFrameHeight; | ||
1091 | EXPECT_TRUE(portSettingsChange); | ||
1092 | } else { | ||
1093 | // In DynamicANW Buffer mode, it is ok to do a complete | ||
1094 | // reconfiguration even if a partial reconfiguration is | ||
1095 | // sufficient. | ||
1096 | if (portMode[1] != PortMode::DYNAMIC_ANW_BUFFER) | ||
1097 | EXPECT_FALSE(portSettingsChange); | ||
1098 | } | ||
1099 | portSettingsChange = false; | ||
1100 | } | 1052 | } |
1101 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | 1053 | portSettingsChange = false; |
1102 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1103 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1104 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | ||
1105 | nullptr); | ||
1106 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
1107 | eosFlag = false; | ||
1108 | timestampUslist.clear(); | ||
1109 | framesReceived = 0; | ||
1110 | timestampUs = 0; | ||
1111 | // set state to idle | ||
1112 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1113 | // set state to loaded | ||
1114 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1115 | kPortIndexInput, kPortIndexOutput); | ||
1116 | } | 1054 | } |
1117 | // For Vendor components ensure apb is supported in atleast one graphic | 1055 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, |
1118 | // buffer mode | 1056 | kPortIndexInput, kPortIndexOutput, portMode[1]); |
1119 | if (strncmp(gEnv->getComponent().c_str(), "OMX.google.", 11) != 0) | 1057 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, |
1120 | EXPECT_TRUE(apbSupport); | 1058 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); |
1059 | if (timestampDevTest) EXPECT_EQ(timestampUslist.empty(), true); | ||
1060 | // set state to idle | ||
1061 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1062 | // set state to executing | ||
1063 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1064 | kPortIndexInput, kPortIndexOutput); | ||
1121 | } | 1065 | } |
1122 | 1066 | ||
1123 | // end of sequence test | 1067 | // end of sequence test |
@@ -1136,62 +1080,50 @@ TEST_F(VideoDecHidlTest, EOSTest_M) { | |||
1136 | kPortIndexOutput = kPortIndexInput + 1; | 1080 | kPortIndexOutput = kPortIndexInput + 1; |
1137 | } | 1081 | } |
1138 | 1082 | ||
1139 | PortMode pmArray[] = {PortMode::PRESET_BYTE_BUFFER, | 1083 | // set port mode |
1140 | PortMode::DYNAMIC_ANW_BUFFER, | 1084 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
1141 | PortMode::PRESET_ANW_BUFFER}; | 1085 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1142 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 1086 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
1143 | // set port mode | 1087 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1144 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
1145 | portMode[1] = pmArray[j]; | ||
1146 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1147 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1148 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1149 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1150 | continue; | ||
1151 | } | ||
1152 | 1088 | ||
1153 | // set Port Params | 1089 | // set Port Params |
1154 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 1090 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
1155 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | 1091 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
1156 | &nFrameHeight, &xFramerate); | 1092 | &xFramerate); |
1157 | // get default color format | 1093 | // get default color format |
1158 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | 1094 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; |
1159 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | 1095 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], |
1160 | &eColorFormat); | 1096 | &eColorFormat); |
1161 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | 1097 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); |
1162 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | 1098 | status = |
1163 | OMX_VIDEO_CodingUnused, eColorFormat, | 1099 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1164 | xFramerate); | 1100 | eColorFormat, xFramerate); |
1165 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1101 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1166 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | 1102 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1167 | eColorFormat, nFrameWidth, nFrameHeight, 0, | 1103 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
1168 | xFramerate); | 1104 | |
1169 | 1105 | android::Vector<BufferInfo> iBuffer, oBuffer; | |
1170 | android::Vector<BufferInfo> iBuffer, oBuffer; | 1106 | |
1171 | 1107 | // set state to idle | |
1172 | // set state to idle | 1108 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, |
1173 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | 1109 | kPortIndexInput, kPortIndexOutput, portMode, true); |
1174 | kPortIndexInput, kPortIndexOutput, portMode, | 1110 | // set state to executing |
1175 | true); | 1111 | changeStateIdletoExecute(omxNode, observer); |
1176 | // set state to executing | 1112 | |
1177 | changeStateIdletoExecute(omxNode, observer); | 1113 | // request EOS at the start |
1178 | // request EOS at the start | 1114 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, |
1179 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | 1115 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); |
1180 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | 1116 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, |
1181 | nullptr); | 1117 | kPortIndexOutput); |
1182 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1118 | EXPECT_GE(framesReceived, 0U); |
1183 | kPortIndexOutput); | 1119 | framesReceived = 0; |
1184 | EXPECT_GE(framesReceived, 0U); | 1120 | timestampUs = 0; |
1185 | eosFlag = false; | 1121 | |
1186 | timestampUslist.clear(); | 1122 | // set state to idle |
1187 | framesReceived = 0; | 1123 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1188 | timestampUs = 0; | 1124 | // set state to executing |
1189 | // set state to idle | 1125 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1190 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1126 | kPortIndexInput, kPortIndexOutput); |
1191 | // set state to loaded | ||
1192 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1193 | kPortIndexInput, kPortIndexOutput); | ||
1194 | } | ||
1195 | } | 1127 | } |
1196 | 1128 | ||
1197 | // end of sequence test | 1129 | // end of sequence test |
@@ -1229,101 +1161,82 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) { | |||
1229 | Info.push_back({bytesCount, flags, timestamp}); | 1161 | Info.push_back({bytesCount, flags, timestamp}); |
1230 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; | 1162 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; |
1231 | } | 1163 | } |
1232 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); | ||
1233 | eleInfo.close(); | 1164 | eleInfo.close(); |
1234 | 1165 | ||
1235 | PortMode pmArray[] = {PortMode::PRESET_BYTE_BUFFER, | 1166 | // As the frame sizes are known ahead, use it to configure i/p buffer size |
1236 | PortMode::DYNAMIC_ANW_BUFFER, | 1167 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); |
1237 | PortMode::PRESET_ANW_BUFFER}; | 1168 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); |
1238 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 1169 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1239 | // set port mode | ||
1240 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
1241 | portMode[1] = pmArray[j]; | ||
1242 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1243 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1244 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1245 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1246 | continue; | ||
1247 | } | ||
1248 | |||
1249 | // As the frame sizes are known ahead, use it to configure i/p buffer | ||
1250 | // size | ||
1251 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); | ||
1252 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1253 | |||
1254 | // set Port Params | ||
1255 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
1256 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | ||
1257 | &nFrameHeight, &xFramerate); | ||
1258 | // get default color format | ||
1259 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1260 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1261 | &eColorFormat); | ||
1262 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1263 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | ||
1264 | OMX_VIDEO_CodingUnused, eColorFormat, | ||
1265 | xFramerate); | ||
1266 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1267 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1268 | eColorFormat, nFrameWidth, nFrameHeight, 0, | ||
1269 | xFramerate); | ||
1270 | |||
1271 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1272 | |||
1273 | // set state to idle | ||
1274 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1275 | kPortIndexInput, kPortIndexOutput, portMode, | ||
1276 | true); | ||
1277 | // set state to executing | ||
1278 | changeStateIdletoExecute(omxNode, observer); | ||
1279 | |||
1280 | // request EOS for thumbnail | ||
1281 | size_t i = 0; | ||
1282 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; | ||
1283 | eleStream.open(mURL, std::ifstream::binary); | ||
1284 | ASSERT_EQ(eleStream.is_open(), true); | ||
1285 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1286 | kPortIndexOutput, eleStream, &Info, 0, i + 1, | ||
1287 | portMode[1]); | ||
1288 | eleStream.close(); | ||
1289 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1290 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1291 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | ||
1292 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | ||
1293 | nullptr); | ||
1294 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1295 | kPortIndexOutput); | ||
1296 | EXPECT_GE(framesReceived, 1U); | ||
1297 | eosFlag = false; | ||
1298 | timestampUslist.clear(); | ||
1299 | framesReceived = 0; | ||
1300 | timestampUs = 0; | ||
1301 | 1170 | ||
1302 | eleStream.open(mURL, std::ifstream::binary); | 1171 | // set port mode |
1303 | ASSERT_EQ(eleStream.is_open(), true); | 1172 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
1304 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1173 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1305 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1], | 1174 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
1306 | false); | 1175 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1307 | eleStream.close(); | ||
1308 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1309 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1310 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1311 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | ||
1312 | nullptr); | ||
1313 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1314 | kPortIndexOutput); | ||
1315 | EXPECT_GE(framesReceived, 1U); | ||
1316 | eosFlag = false; | ||
1317 | timestampUslist.clear(); | ||
1318 | framesReceived = 0; | ||
1319 | timestampUs = 0; | ||
1320 | 1176 | ||
1321 | // set state to idle | 1177 | // set Port Params |
1322 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1178 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
1323 | // set state to loaded | 1179 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
1324 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1180 | &xFramerate); |
1325 | kPortIndexInput, kPortIndexOutput); | 1181 | // get default color format |
1326 | } | 1182 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; |
1183 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1184 | &eColorFormat); | ||
1185 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1186 | status = | ||
1187 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1188 | eColorFormat, xFramerate); | ||
1189 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1190 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1191 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | ||
1192 | |||
1193 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1194 | |||
1195 | // set state to idle | ||
1196 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1197 | kPortIndexInput, kPortIndexOutput, portMode, true); | ||
1198 | // set state to executing | ||
1199 | changeStateIdletoExecute(omxNode, observer); | ||
1200 | |||
1201 | // request EOS for thumbnail | ||
1202 | size_t i = 0; | ||
1203 | while (!(Info[i].flags & OMX_BUFFERFLAG_SYNCFRAME)) i++; | ||
1204 | eleStream.open(mURL, std::ifstream::binary); | ||
1205 | ASSERT_EQ(eleStream.is_open(), true); | ||
1206 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1207 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1]); | ||
1208 | eleStream.close(); | ||
1209 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1210 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1211 | testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode, | ||
1212 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | ||
1213 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1214 | kPortIndexOutput); | ||
1215 | EXPECT_GE(framesReceived, 1U); | ||
1216 | framesReceived = 0; | ||
1217 | timestampUs = 0; | ||
1218 | |||
1219 | eleStream.open(mURL, std::ifstream::binary); | ||
1220 | ASSERT_EQ(eleStream.is_open(), true); | ||
1221 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1222 | kPortIndexOutput, eleStream, &Info, 0, i + 1, portMode[1], | ||
1223 | false); | ||
1224 | eleStream.close(); | ||
1225 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1226 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1227 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1228 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | ||
1229 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1230 | kPortIndexOutput); | ||
1231 | EXPECT_GE(framesReceived, 1U); | ||
1232 | framesReceived = 0; | ||
1233 | timestampUs = 0; | ||
1234 | |||
1235 | // set state to idle | ||
1236 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1237 | // set state to executing | ||
1238 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1239 | kPortIndexInput, kPortIndexOutput); | ||
1327 | } | 1240 | } |
1328 | 1241 | ||
1329 | // end of sequence test | 1242 | // end of sequence test |
@@ -1361,79 +1274,70 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) { | |||
1361 | Info.push_back({bytesCount, flags, timestamp}); | 1274 | Info.push_back({bytesCount, flags, timestamp}); |
1362 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; | 1275 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; |
1363 | } | 1276 | } |
1364 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); | ||
1365 | eleInfo.close(); | 1277 | eleInfo.close(); |
1366 | 1278 | ||
1367 | PortMode pmArray[] = {PortMode::PRESET_BYTE_BUFFER, | 1279 | // As the frame sizes are known ahead, use it to configure i/p buffer size |
1368 | PortMode::DYNAMIC_ANW_BUFFER, | 1280 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); |
1369 | PortMode::PRESET_ANW_BUFFER}; | 1281 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); |
1370 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 1282 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1371 | // set port mode | ||
1372 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
1373 | portMode[1] = pmArray[j]; | ||
1374 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1375 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1376 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1377 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1378 | continue; | ||
1379 | } | ||
1380 | 1283 | ||
1381 | // As the frame sizes are known ahead, use it to configure i/p buffer | 1284 | // set port mode |
1382 | // size | 1285 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; |
1383 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); | 1286 | portMode[1] = PortMode::PRESET_ANW_BUFFER; |
1287 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1288 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1289 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1290 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1291 | portMode[1] = PortMode::PRESET_BYTE_BUFFER; | ||
1292 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1384 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | 1293 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1385 | |||
1386 | // set Port Params | ||
1387 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
1388 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | ||
1389 | &nFrameHeight, &xFramerate); | ||
1390 | // get default color format | ||
1391 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1392 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1393 | &eColorFormat); | ||
1394 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1395 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | ||
1396 | OMX_VIDEO_CodingUnused, eColorFormat, | ||
1397 | xFramerate); | ||
1398 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1399 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1400 | eColorFormat, nFrameWidth, nFrameHeight, 0, | ||
1401 | xFramerate); | ||
1402 | |||
1403 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1404 | |||
1405 | // set state to idle | ||
1406 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1407 | kPortIndexInput, kPortIndexOutput, portMode, | ||
1408 | true); | ||
1409 | // set state to executing | ||
1410 | changeStateIdletoExecute(omxNode, observer); | ||
1411 | |||
1412 | // request EOS at the end | ||
1413 | eleStream.open(mURL, std::ifstream::binary); | ||
1414 | ASSERT_EQ(eleStream.is_open(), true); | ||
1415 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1416 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | ||
1417 | portMode[1], false); | ||
1418 | eleStream.close(); | ||
1419 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1420 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1421 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1422 | portReconfiguration, kPortIndexInput, kPortIndexOutput, | ||
1423 | nullptr); | ||
1424 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1425 | kPortIndexOutput); | ||
1426 | eosFlag = false; | ||
1427 | timestampUslist.clear(); | ||
1428 | framesReceived = 0; | ||
1429 | timestampUs = 0; | ||
1430 | |||
1431 | // set state to idle | ||
1432 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1433 | // set state to loaded | ||
1434 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1435 | kPortIndexInput, kPortIndexOutput); | ||
1436 | } | 1294 | } |
1295 | |||
1296 | // set Port Params | ||
1297 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | ||
1298 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, | ||
1299 | &xFramerate); | ||
1300 | // get default color format | ||
1301 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1302 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1303 | &eColorFormat); | ||
1304 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1305 | status = | ||
1306 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1307 | eColorFormat, xFramerate); | ||
1308 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1309 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1310 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); | ||
1311 | |||
1312 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1313 | |||
1314 | // set state to idle | ||
1315 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1316 | kPortIndexInput, kPortIndexOutput, portMode, true); | ||
1317 | // set state to executing | ||
1318 | changeStateIdletoExecute(omxNode, observer); | ||
1319 | |||
1320 | // request EOS at the end | ||
1321 | eleStream.open(mURL, std::ifstream::binary); | ||
1322 | ASSERT_EQ(eleStream.is_open(), true); | ||
1323 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1324 | kPortIndexOutput, eleStream, &Info, 0, (int)Info.size(), | ||
1325 | portMode[1], false); | ||
1326 | eleStream.close(); | ||
1327 | waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, | ||
1328 | kPortIndexInput, kPortIndexOutput, portMode[1]); | ||
1329 | testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode, | ||
1330 | portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr); | ||
1331 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1332 | kPortIndexOutput); | ||
1333 | framesReceived = 0; | ||
1334 | timestampUs = 0; | ||
1335 | |||
1336 | // set state to idle | ||
1337 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1338 | // set state to executing | ||
1339 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1340 | kPortIndexInput, kPortIndexOutput); | ||
1437 | } | 1341 | } |
1438 | 1342 | ||
1439 | // test input/output port flush | 1343 | // test input/output port flush |
@@ -1471,96 +1375,84 @@ TEST_F(VideoDecHidlTest, FlushTest) { | |||
1471 | Info.push_back({bytesCount, flags, timestamp}); | 1375 | Info.push_back({bytesCount, flags, timestamp}); |
1472 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; | 1376 | if (maxBytesCount < bytesCount) maxBytesCount = bytesCount; |
1473 | } | 1377 | } |
1474 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); | ||
1475 | eleInfo.close(); | 1378 | eleInfo.close(); |
1476 | 1379 | ||
1477 | PortMode pmArray[] = {PortMode::PRESET_BYTE_BUFFER, | 1380 | // As the frame sizes are known ahead, use it to configure i/p buffer size |
1478 | PortMode::DYNAMIC_ANW_BUFFER, | 1381 | maxBytesCount = ALIGN_POWER_OF_TWO(maxBytesCount, 10); |
1479 | PortMode::PRESET_ANW_BUFFER}; | 1382 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); |
1480 | for (size_t j = 0; j < sizeof(pmArray) / sizeof(pmArray[0]); j++) { | 1383 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1481 | // set port mode | ||
1482 | portMode[0] = PortMode::PRESET_BYTE_BUFFER; | ||
1483 | portMode[1] = pmArray[j]; | ||
1484 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); | ||
1485 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1486 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); | ||
1487 | if (status != ::android::hardware::media::omx::V1_0::Status::OK) { | ||
1488 | continue; | ||
1489 | } | ||
1490 | |||
1491 | // As the frame sizes are known ahead, use it to configure i/p buffer | ||
1492 | // size | ||
1493 | status = setPortBufferSize(omxNode, kPortIndexInput, maxBytesCount); | ||
1494 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1495 | 1384 | ||
1496 | // set Port Params | 1385 | // set port mode |
1497 | uint32_t nFrameWidth, nFrameHeight, xFramerate; | 1386 | status = omxNode->setPortMode(kPortIndexInput, portMode[0]); |
1498 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, | 1387 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1499 | &nFrameHeight, &xFramerate); | 1388 | status = omxNode->setPortMode(kPortIndexOutput, portMode[1]); |
1500 | // get default color format | 1389 | ASSERT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1501 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; | ||
1502 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], | ||
1503 | &eColorFormat); | ||
1504 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); | ||
1505 | status = setVideoPortFormat(omxNode, kPortIndexOutput, | ||
1506 | OMX_VIDEO_CodingUnused, eColorFormat, | ||
1507 | xFramerate); | ||
1508 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); | ||
1509 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, | ||
1510 | eColorFormat, nFrameWidth, nFrameHeight, 0, | ||
1511 | xFramerate); | ||
1512 | |||
1513 | android::Vector<BufferInfo> iBuffer, oBuffer; | ||
1514 | |||
1515 | // set state to idle | ||
1516 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1517 | kPortIndexInput, kPortIndexOutput, portMode, | ||
1518 | true); | ||
1519 | // set state to executing | ||
1520 | changeStateIdletoExecute(omxNode, observer); | ||
1521 | |||
1522 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a | ||
1523 | // key frame after this so that the below section can be convered for | ||
1524 | // all components | ||
1525 | int nFrames = 128; | ||
1526 | eleStream.open(mURL, std::ifstream::binary); | ||
1527 | ASSERT_EQ(eleStream.is_open(), true); | ||
1528 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1529 | kPortIndexOutput, eleStream, &Info, 0, nFrames, | ||
1530 | portMode[1], false); | ||
1531 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1532 | kPortIndexOutput); | ||
1533 | framesReceived = 0; | ||
1534 | 1390 | ||
1535 | // Seek to next key frame and start decoding till the end | 1391 | // set Port Params |
1536 | int index = nFrames; | 1392 | uint32_t nFrameWidth, nFrameHeight, xFramerate; |
1537 | bool keyFrame = false; | 1393 | getInputChannelInfo(omxNode, kPortIndexInput, &nFrameWidth, &nFrameHeight, |
1538 | while (index < (int)Info.size()) { | 1394 | &xFramerate); |
1539 | if ((Info[index].flags & OMX_BUFFERFLAG_SYNCFRAME) == | 1395 | // get default color format |
1540 | OMX_BUFFERFLAG_SYNCFRAME) { | 1396 | OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused; |
1541 | timestampUs = Info[index - 1].timestamp; | 1397 | getDefaultColorFormat(omxNode, kPortIndexOutput, portMode[1], |
1542 | keyFrame = true; | 1398 | &eColorFormat); |
1543 | break; | 1399 | ASSERT_NE(eColorFormat, OMX_COLOR_FormatUnused); |
1544 | } | 1400 | status = |
1545 | eleStream.ignore(Info[index].bytesCount); | 1401 | setVideoPortFormat(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1546 | index++; | 1402 | eColorFormat, xFramerate); |
1547 | } | 1403 | EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK); |
1548 | if (keyFrame) { | 1404 | setDefaultPortParam(omxNode, kPortIndexOutput, OMX_VIDEO_CodingUnused, |
1549 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, | 1405 | eColorFormat, nFrameWidth, nFrameHeight, 0, xFramerate); |
1550 | kPortIndexInput, kPortIndexOutput, eleStream, &Info, | 1406 | |
1551 | index, Info.size() - index, portMode[1], false); | 1407 | android::Vector<BufferInfo> iBuffer, oBuffer; |
1408 | |||
1409 | // set state to idle | ||
1410 | changeStateLoadedtoIdle(omxNode, observer, &iBuffer, &oBuffer, | ||
1411 | kPortIndexInput, kPortIndexOutput, portMode, true); | ||
1412 | // set state to executing | ||
1413 | changeStateIdletoExecute(omxNode, observer); | ||
1414 | |||
1415 | // Decode 128 frames and flush. here 128 is chosen to ensure there is a key | ||
1416 | // frame after this so that the below section can be convered for all | ||
1417 | // components | ||
1418 | int nFrames = 128; | ||
1419 | eleStream.open(mURL, std::ifstream::binary); | ||
1420 | ASSERT_EQ(eleStream.is_open(), true); | ||
1421 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1422 | kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1], | ||
1423 | false); | ||
1424 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1425 | kPortIndexOutput); | ||
1426 | framesReceived = 0; | ||
1427 | |||
1428 | // Seek to next key frame and start decoding till the end | ||
1429 | int index = nFrames; | ||
1430 | bool keyFrame = false; | ||
1431 | while (index < (int)Info.size()) { | ||
1432 | if ((Info[index].flags & OMX_BUFFERFLAG_SYNCFRAME) == | ||
1433 | OMX_BUFFERFLAG_SYNCFRAME) { | ||
1434 | timestampUs = Info[index - 1].timestamp; | ||
1435 | keyFrame = true; | ||
1436 | break; | ||
1552 | } | 1437 | } |
1553 | eleStream.close(); | 1438 | eleStream.ignore(Info[index].bytesCount); |
1554 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | 1439 | index++; |
1555 | kPortIndexOutput); | 1440 | } |
1556 | framesReceived = 0; | 1441 | if (keyFrame) { |
1557 | 1442 | decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | |
1558 | // set state to idle | 1443 | kPortIndexOutput, eleStream, &Info, index, |
1559 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1444 | Info.size() - index, portMode[1], false); |
1560 | // set state to loaded | ||
1561 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1562 | kPortIndexInput, kPortIndexOutput); | ||
1563 | } | 1445 | } |
1446 | eleStream.close(); | ||
1447 | flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, | ||
1448 | kPortIndexOutput); | ||
1449 | framesReceived = 0; | ||
1450 | |||
1451 | // set state to idle | ||
1452 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | ||
1453 | // set state to executing | ||
1454 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | ||
1455 | kPortIndexInput, kPortIndexOutput); | ||
1564 | } | 1456 | } |
1565 | 1457 | ||
1566 | int main(int argc, char** argv) { | 1458 | int main(int argc, char** argv) { |
diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index 24eeea71..df90ccce 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp | |||
@@ -1161,7 +1161,7 @@ TEST_F(VideoEncHidlTest, BufferSourceCallBacks) { | |||
1161 | // set state to idle | 1161 | // set state to idle |
1162 | changeStateExecutetoIdle(omxNode, observer, &buffersource->iBuffer, | 1162 | changeStateExecutetoIdle(omxNode, observer, &buffersource->iBuffer, |
1163 | &buffersource->oBuffer); | 1163 | &buffersource->oBuffer); |
1164 | // set state to loaded | 1164 | // set state to executing |
1165 | changeStateIdletoLoaded(omxNode, observer, &buffersource->iBuffer, | 1165 | changeStateIdletoLoaded(omxNode, observer, &buffersource->iBuffer, |
1166 | &buffersource->oBuffer, kPortIndexInput, | 1166 | &buffersource->oBuffer, kPortIndexInput, |
1167 | kPortIndexOutput); | 1167 | kPortIndexOutput); |
@@ -1273,7 +1273,7 @@ TEST_F(VideoEncHidlTest, EncodeTest) { | |||
1273 | 1273 | ||
1274 | // set state to idle | 1274 | // set state to idle |
1275 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1275 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1276 | // set state to loaded | 1276 | // set state to executing |
1277 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1277 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1278 | kPortIndexInput, kPortIndexOutput); | 1278 | kPortIndexInput, kPortIndexOutput); |
1279 | } | 1279 | } |
@@ -1432,7 +1432,7 @@ TEST_F(VideoEncHidlTest, EncodeTestBufferMetaModes) { | |||
1432 | // set state to idle | 1432 | // set state to idle |
1433 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1433 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1434 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); | 1434 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); |
1435 | // set state to loaded | 1435 | // set state to executing |
1436 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1436 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1437 | kPortIndexInput, kPortIndexOutput); | 1437 | kPortIndexInput, kPortIndexOutput); |
1438 | 1438 | ||
@@ -1543,7 +1543,7 @@ TEST_F(VideoEncHidlTest, EncodeTestEOS) { | |||
1543 | // set state to idle | 1543 | // set state to idle |
1544 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); | 1544 | changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer); |
1545 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); | 1545 | EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers); |
1546 | // set state to loaded | 1546 | // set state to executing |
1547 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, | 1547 | changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer, |
1548 | kPortIndexInput, kPortIndexOutput); | 1548 | kPortIndexInput, kPortIndexOutput); |
1549 | 1549 | ||
diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp index f9b78339..91aecf22 100644 --- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.cpp | |||
@@ -89,7 +89,7 @@ void setupRAWPort(sp<IOmxNode> omxNode, OMX_U32 portIndex, OMX_U32 nFrameWidth, | |||
89 | portDef.format.video.nFrameWidth = nFrameWidth; | 89 | portDef.format.video.nFrameWidth = nFrameWidth; |
90 | portDef.format.video.nFrameHeight = nFrameHeight; | 90 | portDef.format.video.nFrameHeight = nFrameHeight; |
91 | portDef.format.video.nStride = (((nFrameWidth + 15) >> 4) << 4); | 91 | portDef.format.video.nStride = (((nFrameWidth + 15) >> 4) << 4); |
92 | portDef.format.video.nSliceHeight = nFrameHeight; | 92 | portDef.format.video.nSliceHeight = (((nFrameHeight + 15) >> 4) << 4); |
93 | portDef.format.video.nBitrate = nBitrate; | 93 | portDef.format.video.nBitrate = nBitrate; |
94 | portDef.format.video.xFramerate = xFramerate; | 94 | portDef.format.video.xFramerate = xFramerate; |
95 | portDef.format.video.bFlagErrorConcealment = OMX_TRUE; | 95 | portDef.format.video.bFlagErrorConcealment = OMX_TRUE; |