15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci QCOM_motion_estimation 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_QCOM_motion_estimation 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jonathan Wicks 125bd8deadSopenharmony_ci Sam Holmes 135bd8deadSopenharmony_ci Jeff Leger 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ciContacts 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ci Jeff Leger <jleger@qti.qualcomm.com> 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciStatus 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Complete 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciVersion 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Last Modified Date: March 19, 2020 265bd8deadSopenharmony_ci Revision: 1.0 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ciNumber 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci OpenGL ES Extension #326 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciDependencies 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci Requires OpenGL ES 2.0 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci This extension is written against the OpenGL ES 3.2 Specification. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci This extension interacts with OES_EGL_image_external. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciOverview 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci Motion estimation, also referred to as optical flow, is the process of 435bd8deadSopenharmony_ci producing motion vectors that convey the 2D transformation from a reference 445bd8deadSopenharmony_ci image to a target image. There are various uses of motion estimation, such as 455bd8deadSopenharmony_ci frame extrapolation, compression, object tracking, etc. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci This extension adds support for motion estimation in OpenGL ES by adding 485bd8deadSopenharmony_ci functions which take the reference and target images and populate an 495bd8deadSopenharmony_ci output texture containing the corresponding motion vectors. 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ciNew Procedures and Functions 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci void TexEstimateMotionQCOM(uint ref, 545bd8deadSopenharmony_ci uint target, 555bd8deadSopenharmony_ci uint output); 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci void TexEstimateMotionRegionsQCOM(uint ref, 585bd8deadSopenharmony_ci uint target, 595bd8deadSopenharmony_ci uint output, 605bd8deadSopenharmony_ci uint mask); 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ciNew Tokens 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetIntegerv, GetInteger64v, and GetFloatv: 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 0x8C90 675bd8deadSopenharmony_ci MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 0x8C91 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciAdditions to the OpenGL ES 3.2 Specification 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci Add two new rows in Table 21.40 "Implementation Dependent Values" 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ci Get Value Type Get Command Minimum Value Description Sec 745bd8deadSopenharmony_ci --------- ---- ----------- ------------- ----------- ------ 755bd8deadSopenharmony_ci MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM Z+ GetIntegerv 1 The block size in X 8.19 765bd8deadSopenharmony_ci MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM Z+ GetIntegerv 1 The block size in Y 8.19 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL ES 3.2 Specification 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci The commands 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci void TexEstimateMotionQCOM(uint ref, 835bd8deadSopenharmony_ci uint target, 845bd8deadSopenharmony_ci uint output); 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci void TexEstimateMotionRegionsQCOM(uint ref, 875bd8deadSopenharmony_ci uint target, 885bd8deadSopenharmony_ci uint output, 895bd8deadSopenharmony_ci uint mask); 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci are called to perfom the motion estimation based on the contents of the two input 925bd8deadSopenharmony_ci textures, <ref> and <target>. The results of the motion estimation are stored in 935bd8deadSopenharmony_ci the <output> texture. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci The <ref> and <target> must be either be GL_R8 2D textures, or backed by EGLImages where 965bd8deadSopenharmony_ci the underlying format contain a luminance plane. The <ref> and <target> dimension must 975bd8deadSopenharmony_ci be identical and must be an exact multiple of the search block size. While <ref> and <target> 985bd8deadSopenharmony_ci can have multiple levels, the implementation only reads from the base level. 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci The resulting motion vectors are stored in a 2D texture <output> of the format GL_RGBA16F, 1015bd8deadSopenharmony_ci ready to be used by other application shaders and stages. While <output> can have multiple 1025bd8deadSopenharmony_ci levels, the implementation only writes to the base level. The <output> dimensions 1035bd8deadSopenharmony_ci must be set as follows so that it can hold one vector per search block: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci output.width = ref.width / MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 1065bd8deadSopenharmony_ci output.height = ref.height / MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci Each texel in the <output> texture represents the estimated motion in pixels, for the supported 1095bd8deadSopenharmony_ci search block size, from the <ref> texture to the <target> target texture. Implementations may 1105bd8deadSopenharmony_ci generate sub-pixel motion vectors, in which case the returned vector components may have fractional 1115bd8deadSopenharmony_ci values. The motion vector X and Y components are provided in the R and G channels respectively. 1125bd8deadSopenharmony_ci The B and A components are currently undefined and left for future expansion. If no motion is 1135bd8deadSopenharmony_ci detected for a block, or if the <mask> texture indicates that the block should be skipped, then 1145bd8deadSopenharmony_ci the R and G channels will be set to zero, indicating no motion. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci The <mask> texture is used to control the region-of-interest which can help to reduce the 1175bd8deadSopenharmony_ci overall workload. The <mask> texture dimensions must exactly match that of the <output> 1185bd8deadSopenharmony_ci texture and the format must be GL_R8UI. While <mask> can have multiple levels, the 1195bd8deadSopenharmony_ci implementation only reads from the base level. For any texel with a value of 0 in the <mask> 1205bd8deadSopenharmony_ci motion estimation will not be performed for the corresponding block. Any non-zero texel value 1215bd8deadSopenharmony_ci will produce a motion vector result in the <output> result. The <mask> only controls the vector 1225bd8deadSopenharmony_ci basepoint. Therefore it is possible for an unmasked block to produce a vector that lands in the 1235bd8deadSopenharmony_ci masked block. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ciErrors 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci INVALID_OPERATION is generated if any of the textures passed in are invalid 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci INVALID_OPERATION is generated if the texture types are not TEXTURE_2D or TEXTURE_EXTERNAL_OES 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci INVALID_OPERATION is generated if <ref> is not of the format GL_R8, or when backed by an EGLImage, 1325bd8deadSopenharmony_ci when the underlying internal format does not contain a luminance plane. 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci INVALID_OPERATION is generated if <target> is not of the format GL_R8, or when backed by an EGLImage, 1355bd8deadSopenharmony_ci when the underlying internal format does not contain a luminance plane. 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci INVALID_OPERATION is generated if the <ref> and <target> textures do not have 1385bd8deadSopenharmony_ci identical dimensions 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci INVALID_OPERATION is generated if the <output> texture is not of the format GL_RGBA16F 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci INVALID_OPERATION is generated if the <mask> texture is not of the format GL_R8UI 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci INVALID_OPERATION is generated if the <output> or <mask> dimensions are not 1455bd8deadSopenharmony_ci ref.[width/height] / MOTION_ESTIMATION_SEARCH_BLOCK_[X,Y]_QCOM 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ciInteractions with OES_EGL_image_external 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci If OES_EGL_image_external is supported, then the <ref> and/or <target> parameters to 1505bd8deadSopenharmony_ci TexEstimateMotionQCOM and TexEstimateMotionRegionsQCOM may be backed by an EGLImage. 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ciIssues 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci (1) What should the pixel data of the input textures <ref> and <target> contain? 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci Resolved: Motion estimation tracks the brightness across the input textures. To produce 1575bd8deadSopenharmony_ci the best results, it is recommended that the texels in the <ref> and <target> textures 1585bd8deadSopenharmony_ci represent some measure of the luminance/luma. OpenGL ES does not currently expose 1595bd8deadSopenharmony_ci a Y8 or Y plane only format, so GL_R8 can be used. Alternatively, a texture backed by 1605bd8deadSopenharmony_ci and EGLImage, which has an underlying format where luminance is contained in a separate plane, 1615bd8deadSopenharmony_ci can also be used. If starting with an RGBA8 texture one way to convert it to GL_R8 would be 1625bd8deadSopenharmony_ci to perform a copy and use code such as the following: 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci fragColor = rgb_2_yuv(texture(tex, texcoord).rgb, itu_601_full_range).r;\n" 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci (2) Why use GL_RGBA16F instead of GL_RG16F for storing the motion vector output? 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci Resolved: While only the R and G channels are currently used, it was decided to use 1695bd8deadSopenharmony_ci a format with more channels for future expansion. A floating point format was chosen 1705bd8deadSopenharmony_ci to support implementations with sub-pixel precision without enforcing any particular precision 1715bd8deadSopenharmony_ci requirements other than what can be represented in a 16-bit floating point number. 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci (3) Why is the motion estimation quality not defined? 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci Resolved: The intention of this specification is to estimate the motion between 1765bd8deadSopenharmony_ci the two input textures. Implementations should aim to produce the highest quality estimations 1775bd8deadSopenharmony_ci but since the results are estimations there are no prescribed steps for how the vectors 1785bd8deadSopenharmony_ci must be generated. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ciRevision History 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci Rev. Date Author Changes 1845bd8deadSopenharmony_ci ---- ---------- -------- ----------------------------------------- 1855bd8deadSopenharmony_ci 1.0 03/19/2020 Jonathan Wicks Initial public version 186