react-native-alpha-video 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +903 -2
  3. package/THIRD_PARTY_NOTICES.md +30 -0
  4. package/android/av1/build.gradle +67 -0
  5. package/android/av1/consumer-rules.pro +4 -0
  6. package/android/av1/src/main/cpp/Av1Codec_jni.cpp +8 -0
  7. package/android/av1/src/main/cpp/CMakeLists.txt +34 -0
  8. package/android/av1/src/main/java/dev/mediacache/alphavideo/av1/Av1Codec.java +21 -0
  9. package/android/build.gradle +85 -0
  10. package/android/consumer-rules.pro +2 -0
  11. package/android/gradle.properties +1 -0
  12. package/android/publish.gradle +82 -0
  13. package/android/settings.gradle +5 -0
  14. package/android/src/main/AndroidManifest.xml +1 -0
  15. package/android/src/main/cpp/CMakeLists.txt +59 -0
  16. package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoCodecs.java +73 -0
  17. package/android/src/main/java/dev/mediacache/alphavideo/AlphaVideoView.java +1966 -0
  18. package/android/src/main/java/dev/mediacache/alphavideo/BufferedDualStreamPlayer.java +978 -0
  19. package/android/src/main/java/dev/mediacache/alphavideo/Fetcher.java +37 -0
  20. package/android/src/main/java/dev/mediacache/alphavideo/HttpFetcher.java +156 -0
  21. package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecColor.java +47 -0
  22. package/android/src/main/java/dev/mediacache/alphavideo/MediaCodecDecoders.java +135 -0
  23. package/android/src/main/java/dev/mediacache/alphavideo/RangeSourceLink.java +54 -0
  24. package/android/src/main/java/dev/mediacache/alphavideo/SourceReader.java +174 -0
  25. package/android/src/main/java/dev/mediacache/alphavideo/SurfaceTextureVideoDecoder.java +802 -0
  26. package/android/src/main/java/dev/mediacache/alphavideo/WebMAlphaPlayerNative.java +95 -0
  27. package/android/src/main/java/dev/mediacache/alphavideo/WebMFrame.java +54 -0
  28. package/android/src/main/java/dev/mediacache/alphavideo/WebMSource.java +160 -0
  29. package/android/src/rangesource/java/dev/mediacache/alphavideo/AppDataSource.java +50 -0
  30. package/android/vpx/build.gradle +67 -0
  31. package/android/vpx/consumer-rules.pro +4 -0
  32. package/android/vpx/src/main/cpp/CMakeLists.txt +34 -0
  33. package/android/vpx/src/main/cpp/VpxCodec_jni.cpp +8 -0
  34. package/android/vpx/src/main/java/dev/mediacache/alphavideo/vpx/VpxCodec.java +21 -0
  35. package/codecs/av1/Dav1dDecoderPlugin.cpp +157 -0
  36. package/codecs/av1/Dav1dDecoderPlugin.h +17 -0
  37. package/codecs/vpx/VpxDecoderPlugin.cpp +103 -0
  38. package/codecs/vpx/VpxDecoderPlugin.h +17 -0
  39. package/cpp/AlphaDemuxer.cpp +984 -0
  40. package/cpp/AlphaDemuxer.h +123 -0
  41. package/cpp/AlphaVideoDecoderPlugin.h +84 -0
  42. package/cpp/Av1SequenceHeader.cpp +175 -0
  43. package/cpp/Av1SequenceHeader.h +25 -0
  44. package/cpp/ByteSource.cpp +116 -0
  45. package/cpp/ByteSource.h +59 -0
  46. package/cpp/RangeSourceClient.h +40 -0
  47. package/cpp/VideoDecoder.cpp +157 -0
  48. package/cpp/VideoDecoder.h +83 -0
  49. package/cpp/WebMAlphaPlayer.cpp +1666 -0
  50. package/cpp/WebMAlphaPlayer.h +389 -0
  51. package/cpp/WebMAlphaPlayer_jni.cpp +1380 -0
  52. package/cpp/YuvToRgb.cpp +39 -0
  53. package/cpp/YuvToRgb.h +40 -0
  54. package/ios/Sources/AlphaVideo/AlphaVideoCodecs.mm +63 -0
  55. package/ios/Sources/AlphaVideo/AlphaVideoInternal.h +70 -0
  56. package/ios/Sources/AlphaVideo/AlphaVideoPlayer.mm +994 -0
  57. package/ios/Sources/AlphaVideo/AlphaVideoSource.mm +476 -0
  58. package/ios/Sources/AlphaVideo/AlphaVideoView.mm +374 -0
  59. package/ios/Sources/AlphaVideo/include/AlphaVideo.h +303 -0
  60. package/ios/Sources/AlphaVideoAV1/AlphaVideoAV1Codec.mm +16 -0
  61. package/ios/Sources/AlphaVideoAV1/include/AlphaVideoAV1.h +18 -0
  62. package/ios/Sources/AlphaVideoVPX/AlphaVideoVPXCodec.mm +16 -0
  63. package/ios/Sources/AlphaVideoVPX/include/AlphaVideoVPX.h +17 -0
  64. package/lib/commonjs/AlphaVideoView.js +187 -0
  65. package/lib/commonjs/AlphaVideoView.js.map +1 -0
  66. package/lib/commonjs/AlphaVideoViewNativeComponent.js +47 -0
  67. package/lib/commonjs/AlphaVideoViewNativeComponent.js.map +1 -0
  68. package/lib/commonjs/AlphaVideoViewNativeComponent.web.js +11 -0
  69. package/lib/commonjs/AlphaVideoViewNativeComponent.web.js.map +1 -0
  70. package/lib/commonjs/NativeAlphaVideoModule.js +10 -0
  71. package/lib/commonjs/NativeAlphaVideoModule.js.map +1 -0
  72. package/lib/commonjs/NativeAlphaVideoModule.web.js +9 -0
  73. package/lib/commonjs/NativeAlphaVideoModule.web.js.map +1 -0
  74. package/lib/commonjs/WebPlayer.js +12 -0
  75. package/lib/commonjs/WebPlayer.js.map +1 -0
  76. package/lib/commonjs/WebPlayer.web.js +92 -0
  77. package/lib/commonjs/WebPlayer.web.js.map +1 -0
  78. package/lib/commonjs/index.js +124 -0
  79. package/lib/commonjs/index.js.map +1 -0
  80. package/lib/module/AlphaVideoView.js +187 -0
  81. package/lib/module/AlphaVideoView.js.map +1 -0
  82. package/lib/module/AlphaVideoViewNativeComponent.js +47 -0
  83. package/lib/module/AlphaVideoViewNativeComponent.js.map +1 -0
  84. package/lib/module/AlphaVideoViewNativeComponent.web.js +11 -0
  85. package/lib/module/AlphaVideoViewNativeComponent.web.js.map +1 -0
  86. package/lib/module/NativeAlphaVideoModule.js +10 -0
  87. package/lib/module/NativeAlphaVideoModule.js.map +1 -0
  88. package/lib/module/NativeAlphaVideoModule.web.js +9 -0
  89. package/lib/module/NativeAlphaVideoModule.web.js.map +1 -0
  90. package/lib/module/WebPlayer.js +12 -0
  91. package/lib/module/WebPlayer.js.map +1 -0
  92. package/lib/module/WebPlayer.web.js +92 -0
  93. package/lib/module/WebPlayer.web.js.map +1 -0
  94. package/lib/module/index.js +124 -0
  95. package/lib/module/index.js.map +1 -0
  96. package/lib/typescript/react-native/src/AlphaVideoView.d.ts +189 -0
  97. package/lib/typescript/react-native/src/AlphaVideoView.d.ts.map +1 -0
  98. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts +109 -0
  99. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.d.ts.map +1 -0
  100. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts +5 -0
  101. package/lib/typescript/react-native/src/AlphaVideoViewNativeComponent.web.d.ts.map +1 -0
  102. package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts +21 -0
  103. package/lib/typescript/react-native/src/NativeAlphaVideoModule.d.ts.map +1 -0
  104. package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts +3 -0
  105. package/lib/typescript/react-native/src/NativeAlphaVideoModule.web.d.ts.map +1 -0
  106. package/lib/typescript/react-native/src/WebPlayer.d.ts +3 -0
  107. package/lib/typescript/react-native/src/WebPlayer.d.ts.map +1 -0
  108. package/lib/typescript/react-native/src/WebPlayer.web.d.ts +9 -0
  109. package/lib/typescript/react-native/src/WebPlayer.web.d.ts.map +1 -0
  110. package/lib/typescript/react-native/src/index.d.ts +77 -0
  111. package/lib/typescript/react-native/src/index.d.ts.map +1 -0
  112. package/licenses/dav1d-COPYING.txt +23 -0
  113. package/licenses/libvpx-LICENSE.txt +31 -0
  114. package/licenses/libvpx-PATENTS.txt +23 -0
  115. package/licenses/libwebm-LICENSE.txt +30 -0
  116. package/licenses/libwebm-PATENTS.txt +23 -0
  117. package/package.json +150 -4
  118. package/prebuilt/android/arm64-v8a/lib/libdav1d.a +0 -0
  119. package/prebuilt/android/arm64-v8a/lib/libvpx.a +0 -0
  120. package/prebuilt/android/armeabi-v7a/lib/libdav1d.a +0 -0
  121. package/prebuilt/android/armeabi-v7a/lib/libvpx.a +0 -0
  122. package/prebuilt/android/x86_64/lib/libdav1d.a +0 -0
  123. package/prebuilt/android/x86_64/lib/libvpx.a +0 -0
  124. package/prebuilt/include/dav1d/common.h +94 -0
  125. package/prebuilt/include/dav1d/data.h +117 -0
  126. package/prebuilt/include/dav1d/dav1d.h +329 -0
  127. package/prebuilt/include/dav1d/headers.h +440 -0
  128. package/prebuilt/include/dav1d/picture.h +157 -0
  129. package/prebuilt/include/dav1d/version.h +50 -0
  130. package/prebuilt/include/vpx/vp8.h +136 -0
  131. package/prebuilt/include/vpx/vp8dx.h +228 -0
  132. package/prebuilt/include/vpx/vpx_codec.h +475 -0
  133. package/prebuilt/include/vpx/vpx_decoder.h +365 -0
  134. package/prebuilt/include/vpx/vpx_frame_buffer.h +83 -0
  135. package/prebuilt/include/vpx/vpx_image.h +209 -0
  136. package/prebuilt/include/vpx/vpx_integer.h +40 -0
  137. package/prebuilt/ios/lib/libdav1d.a +0 -0
  138. package/prebuilt/ios/lib/libvpx.a +0 -0
  139. package/prebuilt/ios-simulator/include/dav1d/common.h +94 -0
  140. package/prebuilt/ios-simulator/include/dav1d/data.h +117 -0
  141. package/prebuilt/ios-simulator/include/dav1d/dav1d.h +329 -0
  142. package/prebuilt/ios-simulator/include/dav1d/headers.h +440 -0
  143. package/prebuilt/ios-simulator/include/dav1d/picture.h +157 -0
  144. package/prebuilt/ios-simulator/include/dav1d/version.h +50 -0
  145. package/prebuilt/ios-simulator/include/vpx/vp8.h +136 -0
  146. package/prebuilt/ios-simulator/include/vpx/vp8dx.h +228 -0
  147. package/prebuilt/ios-simulator/include/vpx/vpx_codec.h +475 -0
  148. package/prebuilt/ios-simulator/include/vpx/vpx_decoder.h +365 -0
  149. package/prebuilt/ios-simulator/include/vpx/vpx_frame_buffer.h +83 -0
  150. package/prebuilt/ios-simulator/include/vpx/vpx_image.h +209 -0
  151. package/prebuilt/ios-simulator/include/vpx/vpx_integer.h +40 -0
  152. package/prebuilt/ios-simulator/lib/libdav1d.a +0 -0
  153. package/prebuilt/ios-simulator/lib/libvpx.a +0 -0
  154. package/react-native/android/CMakeLists.txt +14 -0
  155. package/react-native/android/build.gradle +110 -0
  156. package/react-native/android/src/main/AndroidManifest.xml +1 -0
  157. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModule.java +102 -0
  158. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoPackage.java +50 -0
  159. package/react-native/android/src/main/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManager.java +317 -0
  160. package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +10 -0
  161. package/react-native/android/src/newarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +23 -0
  162. package/react-native/android/src/norangesource/java/dev/mediacache/alphavideo/AppDataSource.java +15 -0
  163. package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoModuleSpec.java +30 -0
  164. package/react-native/android/src/oldarch/java/dev/mediacache/alphavideo/reactnative/AlphaVideoViewManagerSpec.java +61 -0
  165. package/react-native/ios/RNAlphaVideoViewComponentView.mm +173 -0
  166. package/react-native/ios/RNAlphaVideoViewManager.mm +147 -0
  167. package/react-native/src/AlphaVideoView.tsx +329 -0
  168. package/react-native/src/AlphaVideoViewNativeComponent.ts +132 -0
  169. package/react-native/src/AlphaVideoViewNativeComponent.web.ts +5 -0
  170. package/react-native/src/NativeAlphaVideoModule.ts +22 -0
  171. package/react-native/src/NativeAlphaVideoModule.web.ts +2 -0
  172. package/react-native/src/WebPlayer.tsx +7 -0
  173. package/react-native/src/WebPlayer.web.tsx +60 -0
  174. package/react-native/src/index.tsx +144 -0
  175. package/react-native-alpha-video.podspec +99 -0
  176. package/react-native.config.js +12 -0
  177. package/scripts/build_codecs_android.sh +246 -0
  178. package/scripts/build_codecs_ios.sh +31 -0
  179. package/scripts/build_codecs_ios_device.sh +210 -0
  180. package/scripts/build_codecs_ios_simulator.sh +256 -0
  181. package/scripts/build_wasm.sh +230 -0
  182. package/scripts/build_xcframework.sh +49 -0
  183. package/scripts/fetch-prebuilt.sh +48 -0
  184. package/scripts/package_release.sh +107 -0
  185. package/scripts/publish-android.sh +85 -0
  186. package/scripts/vendor_range_source.sh +47 -0
  187. package/third_party/libwebm/AUTHORS.TXT +5 -0
  188. package/third_party/libwebm/LICENSE.TXT +30 -0
  189. package/third_party/libwebm/PATENTS.TXT +23 -0
  190. package/third_party/libwebm/README.md +7 -0
  191. package/third_party/libwebm/webm_parser/include/webm/buffer_reader.h +138 -0
  192. package/third_party/libwebm/webm_parser/include/webm/callback.h +363 -0
  193. package/third_party/libwebm/webm_parser/include/webm/dom_types.h +1781 -0
  194. package/third_party/libwebm/webm_parser/include/webm/element.h +208 -0
  195. package/third_party/libwebm/webm_parser/include/webm/file_reader.h +103 -0
  196. package/third_party/libwebm/webm_parser/include/webm/id.h +1085 -0
  197. package/third_party/libwebm/webm_parser/include/webm/istream_reader.h +99 -0
  198. package/third_party/libwebm/webm_parser/include/webm/reader.h +94 -0
  199. package/third_party/libwebm/webm_parser/include/webm/status.h +166 -0
  200. package/third_party/libwebm/webm_parser/include/webm/webm_parser.h +133 -0
  201. package/third_party/libwebm/webm_parser/src/ancestory.cc +334 -0
  202. package/third_party/libwebm/webm_parser/src/ancestory.h +83 -0
  203. package/third_party/libwebm/webm_parser/src/audio_parser.h +84 -0
  204. package/third_party/libwebm/webm_parser/src/bit_utils.cc +26 -0
  205. package/third_party/libwebm/webm_parser/src/bit_utils.h +24 -0
  206. package/third_party/libwebm/webm_parser/src/block_additions_parser.h +30 -0
  207. package/third_party/libwebm/webm_parser/src/block_group_parser.h +71 -0
  208. package/third_party/libwebm/webm_parser/src/block_header_parser.cc +76 -0
  209. package/third_party/libwebm/webm_parser/src/block_header_parser.h +65 -0
  210. package/third_party/libwebm/webm_parser/src/block_more_parser.h +32 -0
  211. package/third_party/libwebm/webm_parser/src/block_parser.cc +285 -0
  212. package/third_party/libwebm/webm_parser/src/block_parser.h +126 -0
  213. package/third_party/libwebm/webm_parser/src/bool_parser.h +95 -0
  214. package/third_party/libwebm/webm_parser/src/buffer_reader.cc +110 -0
  215. package/third_party/libwebm/webm_parser/src/byte_parser.h +144 -0
  216. package/third_party/libwebm/webm_parser/src/callback.cc +155 -0
  217. package/third_party/libwebm/webm_parser/src/chapter_atom_parser.h +42 -0
  218. package/third_party/libwebm/webm_parser/src/chapter_display_parser.h +34 -0
  219. package/third_party/libwebm/webm_parser/src/chapters_parser.h +28 -0
  220. package/third_party/libwebm/webm_parser/src/cluster_parser.h +48 -0
  221. package/third_party/libwebm/webm_parser/src/colour_parser.h +55 -0
  222. package/third_party/libwebm/webm_parser/src/content_enc_aes_settings_parser.h +32 -0
  223. package/third_party/libwebm/webm_parser/src/content_encoding_parser.h +38 -0
  224. package/third_party/libwebm/webm_parser/src/content_encodings_parser.h +30 -0
  225. package/third_party/libwebm/webm_parser/src/content_encryption_parser.h +37 -0
  226. package/third_party/libwebm/webm_parser/src/cue_point_parser.h +38 -0
  227. package/third_party/libwebm/webm_parser/src/cue_track_positions_parser.h +39 -0
  228. package/third_party/libwebm/webm_parser/src/cues_parser.h +27 -0
  229. package/third_party/libwebm/webm_parser/src/date_parser.cc +72 -0
  230. package/third_party/libwebm/webm_parser/src/date_parser.h +64 -0
  231. package/third_party/libwebm/webm_parser/src/ebml_parser.h +48 -0
  232. package/third_party/libwebm/webm_parser/src/edition_entry_parser.h +35 -0
  233. package/third_party/libwebm/webm_parser/src/element_parser.h +102 -0
  234. package/third_party/libwebm/webm_parser/src/file_reader.cc +142 -0
  235. package/third_party/libwebm/webm_parser/src/float_parser.cc +77 -0
  236. package/third_party/libwebm/webm_parser/src/float_parser.h +65 -0
  237. package/third_party/libwebm/webm_parser/src/id_element_parser.cc +49 -0
  238. package/third_party/libwebm/webm_parser/src/id_element_parser.h +56 -0
  239. package/third_party/libwebm/webm_parser/src/id_parser.cc +75 -0
  240. package/third_party/libwebm/webm_parser/src/id_parser.h +45 -0
  241. package/third_party/libwebm/webm_parser/src/info_parser.h +44 -0
  242. package/third_party/libwebm/webm_parser/src/int_parser.h +121 -0
  243. package/third_party/libwebm/webm_parser/src/istream_reader.cc +133 -0
  244. package/third_party/libwebm/webm_parser/src/master_parser.cc +298 -0
  245. package/third_party/libwebm/webm_parser/src/master_parser.h +230 -0
  246. package/third_party/libwebm/webm_parser/src/master_value_parser.h +533 -0
  247. package/third_party/libwebm/webm_parser/src/mastering_metadata_parser.h +57 -0
  248. package/third_party/libwebm/webm_parser/src/parser.h +34 -0
  249. package/third_party/libwebm/webm_parser/src/parser_utils.cc +34 -0
  250. package/third_party/libwebm/webm_parser/src/parser_utils.h +64 -0
  251. package/third_party/libwebm/webm_parser/src/projection_parser.h +40 -0
  252. package/third_party/libwebm/webm_parser/src/recursive_parser.h +93 -0
  253. package/third_party/libwebm/webm_parser/src/seek_head_parser.h +27 -0
  254. package/third_party/libwebm/webm_parser/src/seek_parser.h +37 -0
  255. package/third_party/libwebm/webm_parser/src/segment_parser.cc +86 -0
  256. package/third_party/libwebm/webm_parser/src/segment_parser.h +53 -0
  257. package/third_party/libwebm/webm_parser/src/simple_tag_parser.h +37 -0
  258. package/third_party/libwebm/webm_parser/src/size_parser.cc +56 -0
  259. package/third_party/libwebm/webm_parser/src/size_parser.h +43 -0
  260. package/third_party/libwebm/webm_parser/src/skip_callback.h +63 -0
  261. package/third_party/libwebm/webm_parser/src/skip_parser.cc +59 -0
  262. package/third_party/libwebm/webm_parser/src/skip_parser.h +35 -0
  263. package/third_party/libwebm/webm_parser/src/slices_parser.h +30 -0
  264. package/third_party/libwebm/webm_parser/src/tag_parser.h +37 -0
  265. package/third_party/libwebm/webm_parser/src/tags_parser.h +27 -0
  266. package/third_party/libwebm/webm_parser/src/targets_parser.h +35 -0
  267. package/third_party/libwebm/webm_parser/src/time_slice_parser.h +30 -0
  268. package/third_party/libwebm/webm_parser/src/track_entry_parser.h +65 -0
  269. package/third_party/libwebm/webm_parser/src/tracks_parser.h +27 -0
  270. package/third_party/libwebm/webm_parser/src/unknown_parser.cc +49 -0
  271. package/third_party/libwebm/webm_parser/src/unknown_parser.h +38 -0
  272. package/third_party/libwebm/webm_parser/src/var_int_parser.cc +71 -0
  273. package/third_party/libwebm/webm_parser/src/var_int_parser.h +56 -0
  274. package/third_party/libwebm/webm_parser/src/video_parser.h +122 -0
  275. package/third_party/libwebm/webm_parser/src/virtual_block_parser.cc +72 -0
  276. package/third_party/libwebm/webm_parser/src/virtual_block_parser.h +69 -0
  277. package/third_party/libwebm/webm_parser/src/void_parser.cc +49 -0
  278. package/third_party/libwebm/webm_parser/src/void_parser.h +41 -0
  279. package/third_party/libwebm/webm_parser/src/webm_parser.cc +282 -0
  280. package/third_party/range-source/LICENSE +21 -0
  281. package/third_party/range-source/README.md +8 -0
  282. package/third_party/range-source/include/range_source.h +395 -0
  283. package/third_party/range-source/include/range_source_download.h +309 -0
@@ -0,0 +1,365 @@
1
+ /*
2
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+ #ifndef VPX_VPX_VPX_DECODER_H_
11
+ #define VPX_VPX_VPX_DECODER_H_
12
+
13
+ /*!\defgroup decoder Decoder Algorithm Interface
14
+ * \ingroup codec
15
+ * This abstraction allows applications using this decoder to easily support
16
+ * multiple video formats with minimal code duplication. This section describes
17
+ * the interface common to all decoders.
18
+ * @{
19
+ */
20
+
21
+ /*!\file
22
+ * \brief Describes the decoder algorithm interface to applications.
23
+ *
24
+ * This file describes the interface between an application and a
25
+ * video decoder algorithm.
26
+ *
27
+ */
28
+ #ifdef __cplusplus
29
+ extern "C" {
30
+ #endif
31
+
32
+ #include "./vpx_codec.h"
33
+ #include "./vpx_frame_buffer.h"
34
+
35
+ /*!\brief Current ABI version number
36
+ *
37
+ * \internal
38
+ * If this file is altered in any way that changes the ABI, this value
39
+ * must be bumped. Examples include, but are not limited to, changing
40
+ * types, removing or reassigning enums, adding/removing/rearranging
41
+ * fields to structures
42
+ */
43
+ #define VPX_DECODER_ABI_VERSION \
44
+ (3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
45
+
46
+ /*! \brief Decoder capabilities bitfield
47
+ *
48
+ * Each decoder advertises the capabilities it supports as part of its
49
+ * ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
50
+ * or functionality, and are not required to be supported by a decoder.
51
+ *
52
+ * The available flags are specified by VPX_CODEC_CAP_* defines.
53
+ */
54
+ #define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
55
+ #define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
56
+ #define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
57
+ /*!\brief Can conceal errors due to packet loss */
58
+ #define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
59
+ /*!\brief Can receive encoded frames one fragment at a time */
60
+ #define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
61
+ /*!\brief Can support frame-based multi-threading */
62
+ #define VPX_CODEC_CAP_FRAME_THREADING 0x200000
63
+ /*!brief Can support external frame buffers */
64
+ #define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
65
+
66
+ /*! \brief Initialization-time Feature Enabling
67
+ *
68
+ * Certain codec features must be known at initialization time, to allow for
69
+ * proper memory allocation.
70
+ *
71
+ * The available flags are specified by VPX_CODEC_USE_* defines.
72
+ */
73
+ #define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
74
+ /*!\brief Conceal errors in decoded frames */
75
+ #define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
76
+ /*!\brief The input frame should be passed to the decoder one fragment at a
77
+ * time */
78
+ #define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
79
+ /*!\brief Enable frame-based multi-threading */
80
+ #define VPX_CODEC_USE_FRAME_THREADING 0x80000
81
+
82
+ /*!\brief Stream properties
83
+ *
84
+ * This structure is used to query or set properties of the decoded
85
+ * stream. Algorithms may extend this structure with data specific
86
+ * to their bitstream by setting the sz member appropriately.
87
+ */
88
+ typedef struct vpx_codec_stream_info {
89
+ unsigned int sz; /**< Size of this structure */
90
+ unsigned int w; /**< Width (or 0 for unknown/default) */
91
+ unsigned int h; /**< Height (or 0 for unknown/default) */
92
+ unsigned int is_kf; /**< Current frame is a keyframe */
93
+ } vpx_codec_stream_info_t;
94
+
95
+ /* REQUIRED FUNCTIONS
96
+ *
97
+ * The following functions are required to be implemented for all decoders.
98
+ * They represent the base case functionality expected of all decoders.
99
+ */
100
+
101
+ /*!\brief Initialization Configurations
102
+ *
103
+ * This structure is used to pass init time configuration options to the
104
+ * decoder.
105
+ */
106
+ typedef struct vpx_codec_dec_cfg {
107
+ unsigned int threads; /**< Maximum number of threads to use, default 1 */
108
+ unsigned int w; /**< Width */
109
+ unsigned int h; /**< Height */
110
+ } vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
111
+
112
+ /*!\brief Initialize a decoder instance
113
+ *
114
+ * Initializes a decoder context using the given interface. Applications
115
+ * should call the vpx_codec_dec_init convenience macro instead of this
116
+ * function directly, to ensure that the ABI version number parameter
117
+ * is properly initialized.
118
+ *
119
+ * If the library was configured with --disable-multithread, this call
120
+ * is not thread safe and should be guarded with a lock if being used
121
+ * in a multithreaded context.
122
+ *
123
+ * \param[in] ctx Pointer to this instance's context.
124
+ * \param[in] iface Pointer to the algorithm interface to use.
125
+ * \param[in] cfg Configuration to use, if known. May be NULL.
126
+ * \param[in] flags Bitfield of VPX_CODEC_USE_* flags
127
+ * \param[in] ver ABI version number. Must be set to
128
+ * VPX_DECODER_ABI_VERSION
129
+ * \retval #VPX_CODEC_OK
130
+ * The decoder algorithm has been initialized.
131
+ * \retval #VPX_CODEC_MEM_ERROR
132
+ * Memory allocation failed.
133
+ */
134
+ vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
135
+ vpx_codec_iface_t *iface,
136
+ const vpx_codec_dec_cfg_t *cfg,
137
+ vpx_codec_flags_t flags, int ver);
138
+
139
+ /*!\brief Convenience macro for vpx_codec_dec_init_ver()
140
+ *
141
+ * Ensures the ABI version parameter is properly set.
142
+ */
143
+ #define vpx_codec_dec_init(ctx, iface, cfg, flags) \
144
+ vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
145
+
146
+ /*!\brief Parse stream info from a buffer
147
+ *
148
+ * Performs high level parsing of the bitstream. Construction of a decoder
149
+ * context is not necessary. Can be used to determine if the bitstream is
150
+ * of the proper format, and to extract information from the stream.
151
+ *
152
+ * \param[in] iface Pointer to the algorithm interface
153
+ * \param[in] data Pointer to a block of data to parse
154
+ * \param[in] data_sz Size of the data buffer
155
+ * \param[in,out] si Pointer to stream info to update. The size member
156
+ * \ref MUST be properly initialized, but \ref MAY be
157
+ * clobbered by the algorithm. This parameter \ref MAY
158
+ * be NULL.
159
+ *
160
+ * \retval #VPX_CODEC_OK
161
+ * Bitstream is parsable and stream information updated
162
+ */
163
+ vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
164
+ const uint8_t *data,
165
+ unsigned int data_sz,
166
+ vpx_codec_stream_info_t *si);
167
+
168
+ /*!\brief Return information about the current stream.
169
+ *
170
+ * Returns information about the stream that has been parsed during decoding.
171
+ *
172
+ * \param[in] ctx Pointer to this instance's context
173
+ * \param[in,out] si Pointer to stream info to update. The size member
174
+ * \ref MUST be properly initialized, but \ref MAY be
175
+ * clobbered by the algorithm. This parameter \ref MAY
176
+ * be NULL.
177
+ *
178
+ * \retval #VPX_CODEC_OK
179
+ * Bitstream is parsable and stream information updated
180
+ */
181
+ vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
182
+ vpx_codec_stream_info_t *si);
183
+
184
+ /*!\brief Decode data
185
+ *
186
+ * Processes a buffer of coded data. If the processing results in a new
187
+ * decoded frame becoming available, put_slice and put_frame callbacks may be
188
+ * invoked, as appropriate. Encoded data \ref MUST be passed in DTS (decode
189
+ * time stamp) order. Frames produced will always be in PTS (presentation
190
+ * time stamp) order.
191
+ * If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
192
+ * data and data_sz can contain a fragment of the encoded frame. Fragment
193
+ * \#n must contain at least partition \#n, but can also contain subsequent
194
+ * partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
195
+ * be empty. When no more data is available, this function should be called
196
+ * with NULL as data and 0 as data_sz. The memory passed to this function
197
+ * must be available until the frame has been decoded.
198
+ *
199
+ * \param[in] ctx Pointer to this instance's context
200
+ * \param[in] data Pointer to this block of new coded data. If
201
+ * NULL, the put_frame callback is invoked for
202
+ * the previously decoded frame.
203
+ * \param[in] data_sz Size of the coded data, in bytes.
204
+ * \param[in] user_priv Application specific data to associate with
205
+ * this frame.
206
+ * \param[in] deadline Soft deadline the decoder should attempt to meet,
207
+ * in us. Set to zero for unlimited.
208
+ *
209
+ * \return Returns #VPX_CODEC_OK if the coded data was processed completely
210
+ * and future pictures can be decoded without error. Otherwise,
211
+ * see the descriptions of the other error codes in ::vpx_codec_err_t
212
+ * for recoverability capabilities.
213
+ */
214
+ vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
215
+ unsigned int data_sz, void *user_priv,
216
+ long deadline);
217
+
218
+ /*!\brief Decoded frames iterator
219
+ *
220
+ * Iterates over a list of the frames available for display. The iterator
221
+ * storage should be initialized to NULL to start the iteration. Iteration is
222
+ * complete when this function returns NULL.
223
+ *
224
+ * The list of available frames becomes valid upon completion of the
225
+ * vpx_codec_decode call, and remains valid until the next call to
226
+ * vpx_codec_decode.
227
+ *
228
+ * \param[in] ctx Pointer to this instance's context
229
+ * \param[in,out] iter Iterator storage, initialized to NULL
230
+ *
231
+ * \return Returns a pointer to an image, if one is ready for display. Frames
232
+ * produced will always be in PTS (presentation time stamp) order.
233
+ */
234
+ vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
235
+
236
+ /*!\defgroup cap_put_frame Frame-Based Decoding Functions
237
+ *
238
+ * The following function is required to be implemented for all decoders
239
+ * that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling this
240
+ * function for codecs that don't advertise this capability will result in
241
+ * an error code being returned, usually VPX_CODEC_INCAPABLE.
242
+ * @{
243
+ */
244
+
245
+ /*!\brief put frame callback prototype
246
+ *
247
+ * This callback is invoked by the decoder to notify the application of
248
+ * the availability of decoded image data.
249
+ */
250
+ typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
251
+ const vpx_image_t *img);
252
+
253
+ /*!\brief Register for notification of frame completion.
254
+ *
255
+ * Registers a given function to be called when a decoded frame is
256
+ * available.
257
+ *
258
+ * \param[in] ctx Pointer to this instance's context
259
+ * \param[in] cb Pointer to the callback function
260
+ * \param[in] user_priv User's private data
261
+ *
262
+ * \retval #VPX_CODEC_OK
263
+ * Callback successfully registered.
264
+ * \retval #VPX_CODEC_ERROR
265
+ * Decoder context not initialized.
266
+ * \retval #VPX_CODEC_INCAPABLE
267
+ * Algorithm not capable of posting frame completion.
268
+ */
269
+ vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
270
+ vpx_codec_put_frame_cb_fn_t cb,
271
+ void *user_priv);
272
+
273
+ /*!@} - end defgroup cap_put_frame */
274
+
275
+ /*!\defgroup cap_put_slice Slice-Based Decoding Functions
276
+ *
277
+ * The following function is required to be implemented for all decoders
278
+ * that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling this
279
+ * function for codecs that don't advertise this capability will result in
280
+ * an error code being returned, usually VPX_CODEC_INCAPABLE.
281
+ * @{
282
+ */
283
+
284
+ /*!\brief put slice callback prototype
285
+ *
286
+ * This callback is invoked by the decoder to notify the application of
287
+ * the availability of partially decoded image data.
288
+ */
289
+ typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
290
+ const vpx_image_t *img,
291
+ const vpx_image_rect_t *valid,
292
+ const vpx_image_rect_t *update);
293
+
294
+ /*!\brief Register for notification of slice completion.
295
+ *
296
+ * Registers a given function to be called when a decoded slice is
297
+ * available.
298
+ *
299
+ * \param[in] ctx Pointer to this instance's context
300
+ * \param[in] cb Pointer to the callback function
301
+ * \param[in] user_priv User's private data
302
+ *
303
+ * \retval #VPX_CODEC_OK
304
+ * Callback successfully registered.
305
+ * \retval #VPX_CODEC_ERROR
306
+ * Decoder context not initialized.
307
+ * \retval #VPX_CODEC_INCAPABLE
308
+ * Algorithm not capable of posting slice completion.
309
+ */
310
+ vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
311
+ vpx_codec_put_slice_cb_fn_t cb,
312
+ void *user_priv);
313
+
314
+ /*!@} - end defgroup cap_put_slice*/
315
+
316
+ /*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
317
+ *
318
+ * The following function is required to be implemented for all decoders
319
+ * that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
320
+ * Calling this function for codecs that don't advertise this capability
321
+ * will result in an error code being returned, usually VPX_CODEC_INCAPABLE.
322
+ *
323
+ * \note
324
+ * Currently this only works with VP9.
325
+ * @{
326
+ */
327
+
328
+ /*!\brief Pass in external frame buffers for the decoder to use.
329
+ *
330
+ * Registers functions to be called when libvpx needs a frame buffer
331
+ * to decode the current frame and a function to be called when libvpx does
332
+ * not internally reference the frame buffer. This set function must
333
+ * be called before the first call to decode or libvpx will assume the
334
+ * default behavior of allocating frame buffers internally.
335
+ *
336
+ * \param[in] ctx Pointer to this instance's context
337
+ * \param[in] cb_get Pointer to the get callback function
338
+ * \param[in] cb_release Pointer to the release callback function
339
+ * \param[in] cb_priv Callback's private data
340
+ *
341
+ * \retval #VPX_CODEC_OK
342
+ * External frame buffers will be used by libvpx.
343
+ * \retval #VPX_CODEC_INVALID_PARAM
344
+ * One or more of the callbacks were NULL.
345
+ * \retval #VPX_CODEC_ERROR
346
+ * Decoder context not initialized.
347
+ * \retval #VPX_CODEC_INCAPABLE
348
+ * Algorithm not capable of using external frame buffers.
349
+ *
350
+ * \note
351
+ * When decoding VP9, the application may be required to pass in at least
352
+ * #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
353
+ * buffers.
354
+ */
355
+ vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
356
+ vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
357
+ vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
358
+
359
+ /*!@} - end defgroup cap_external_frame_buffer */
360
+
361
+ /*!@} - end defgroup decoder*/
362
+ #ifdef __cplusplus
363
+ }
364
+ #endif
365
+ #endif // VPX_VPX_VPX_DECODER_H_
@@ -0,0 +1,83 @@
1
+ /*
2
+ * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+
11
+ #ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
12
+ #define VPX_VPX_VPX_FRAME_BUFFER_H_
13
+
14
+ /*!\file
15
+ * \brief Describes the decoder external frame buffer interface.
16
+ */
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ #include "./vpx_integer.h"
23
+
24
+ /*!\brief The maximum number of work buffers used by libvpx.
25
+ * Support maximum 4 threads to decode video in parallel.
26
+ * Each thread will use one work buffer.
27
+ * TODO(hkuang): Add support to set number of worker threads dynamically.
28
+ */
29
+ #define VPX_MAXIMUM_WORK_BUFFERS 8
30
+
31
+ /*!\brief The maximum number of reference buffers that a VP9 encoder may use.
32
+ */
33
+ #define VP9_MAXIMUM_REF_BUFFERS 8
34
+
35
+ /*!\brief External frame buffer
36
+ *
37
+ * This structure holds allocated frame buffers used by the decoder.
38
+ */
39
+ typedef struct vpx_codec_frame_buffer {
40
+ uint8_t *data; /**< Pointer to the data buffer */
41
+ size_t size; /**< Size of data in bytes */
42
+ void *priv; /**< Frame's private data */
43
+ } vpx_codec_frame_buffer_t;
44
+
45
+ /*!\brief get frame buffer callback prototype
46
+ *
47
+ * This callback is invoked by the decoder to retrieve data for the frame
48
+ * buffer in order for the decode call to complete. The callback must
49
+ * allocate at least min_size in bytes and assign it to fb->data. The callback
50
+ * must zero out all the data allocated. Then the callback must set fb->size
51
+ * to the allocated size. The application does not need to align the allocated
52
+ * data. The callback is triggered when the decoder needs a frame buffer to
53
+ * decode a compressed image into. This function may be called more than once
54
+ * for every call to vpx_codec_decode. The application may set fb->priv to
55
+ * some data which will be passed back in the vpx_image_t and the release
56
+ * function call. |fb| is guaranteed to not be NULL. On success the callback
57
+ * must return 0. Any failure the callback must return a value less than 0.
58
+ *
59
+ * \param[in] priv Callback's private data
60
+ * \param[in] min_size Size in bytes needed by the buffer
61
+ * \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
62
+ */
63
+ typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
64
+ vpx_codec_frame_buffer_t *fb);
65
+
66
+ /*!\brief release frame buffer callback prototype
67
+ *
68
+ * This callback is invoked by the decoder when the frame buffer is not
69
+ * referenced by any other buffers. |fb| is guaranteed to not be NULL. On
70
+ * success the callback must return 0. Any failure the callback must return
71
+ * a value less than 0.
72
+ *
73
+ * \param[in] priv Callback's private data
74
+ * \param[in] fb Pointer to vpx_codec_frame_buffer_t
75
+ */
76
+ typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
77
+ vpx_codec_frame_buffer_t *fb);
78
+
79
+ #ifdef __cplusplus
80
+ } // extern "C"
81
+ #endif
82
+
83
+ #endif // VPX_VPX_VPX_FRAME_BUFFER_H_
@@ -0,0 +1,209 @@
1
+ /*
2
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+
11
+ /*!\file
12
+ * \brief Describes the vpx image descriptor and associated operations
13
+ *
14
+ */
15
+ #ifndef VPX_VPX_VPX_IMAGE_H_
16
+ #define VPX_VPX_VPX_IMAGE_H_
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ /*!\brief Current ABI version number
23
+ *
24
+ * \internal
25
+ * If this file is altered in any way that changes the ABI, this value
26
+ * must be bumped. Examples include, but are not limited to, changing
27
+ * types, removing or reassigning enums, adding/removing/rearranging
28
+ * fields to structures
29
+ */
30
+ #define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
31
+
32
+ #define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
33
+ #define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
34
+ #define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
35
+ #define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
36
+
37
+ /*!\brief List of supported image formats */
38
+ typedef enum vpx_img_fmt {
39
+ VPX_IMG_FMT_NONE,
40
+ VPX_IMG_FMT_YV12 =
41
+ VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
42
+ VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
43
+ VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
44
+ VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
45
+ VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
46
+ VPX_IMG_FMT_NV12 = VPX_IMG_FMT_PLANAR | 9,
47
+ VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
48
+ VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
49
+ VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
50
+ VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
51
+ } vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
52
+
53
+ /*!\brief List of supported color spaces */
54
+ typedef enum vpx_color_space {
55
+ VPX_CS_UNKNOWN = 0, /**< Unknown */
56
+ VPX_CS_BT_601 = 1, /**< BT.601 */
57
+ VPX_CS_BT_709 = 2, /**< BT.709 */
58
+ VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
59
+ VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
60
+ VPX_CS_BT_2020 = 5, /**< BT.2020 */
61
+ VPX_CS_RESERVED = 6, /**< Reserved */
62
+ VPX_CS_SRGB = 7 /**< sRGB */
63
+ } vpx_color_space_t; /**< alias for enum vpx_color_space */
64
+
65
+ /*!\brief List of supported color range */
66
+ typedef enum vpx_color_range {
67
+ VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
68
+ VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
69
+ } vpx_color_range_t; /**< alias for enum vpx_color_range */
70
+
71
+ /**\brief Image Descriptor */
72
+ typedef struct vpx_image {
73
+ vpx_img_fmt_t fmt; /**< Image Format */
74
+ vpx_color_space_t cs; /**< Color Space */
75
+ vpx_color_range_t range; /**< Color Range */
76
+
77
+ /* Image storage dimensions */
78
+ unsigned int w; /**< Stored image width */
79
+ unsigned int h; /**< Stored image height */
80
+ unsigned int bit_depth; /**< Stored image bit-depth */
81
+
82
+ /* Image display dimensions */
83
+ unsigned int d_w; /**< Displayed image width */
84
+ unsigned int d_h; /**< Displayed image height */
85
+
86
+ /* Image intended rendering dimensions */
87
+ unsigned int r_w; /**< Intended rendering image width */
88
+ unsigned int r_h; /**< Intended rendering image height */
89
+
90
+ /* Chroma subsampling info */
91
+ unsigned int x_chroma_shift; /**< subsampling order, X */
92
+ unsigned int y_chroma_shift; /**< subsampling order, Y */
93
+
94
+ /* Image data pointers. */
95
+ #define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
96
+ #define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
97
+ #define VPX_PLANE_U 1 /**< U (Chroma) plane */
98
+ #define VPX_PLANE_V 2 /**< V (Chroma) plane */
99
+ #define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
100
+ unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
101
+ int stride[4]; /**< stride between rows for each plane */
102
+
103
+ int bps; /**< bits per sample (for packed formats) */
104
+
105
+ /*!\brief The following member may be set by the application to associate
106
+ * data with this image.
107
+ */
108
+ void *user_priv;
109
+
110
+ /* The following members should be treated as private. */
111
+ unsigned char *img_data; /**< private */
112
+ int img_data_owner; /**< private */
113
+ int self_allocd; /**< private */
114
+
115
+ void *fb_priv; /**< Frame buffer data associated with the image. */
116
+ } vpx_image_t; /**< alias for struct vpx_image */
117
+
118
+ /**\brief Representation of a rectangle on a surface */
119
+ typedef struct vpx_image_rect {
120
+ unsigned int x; /**< leftmost column */
121
+ unsigned int y; /**< topmost row */
122
+ unsigned int w; /**< width */
123
+ unsigned int h; /**< height */
124
+ } vpx_image_rect_t; /**< alias for struct vpx_image_rect */
125
+
126
+ /*!\brief Open a descriptor, allocating storage for the underlying image
127
+ *
128
+ * Returns a descriptor for storing an image of the given format. The
129
+ * storage for the descriptor is allocated on the heap.
130
+ *
131
+ * \param[in] img Pointer to storage for descriptor. If this parameter
132
+ * is NULL, the storage for the descriptor will be
133
+ * allocated on the heap.
134
+ * \param[in] fmt Format for the image
135
+ * \param[in] d_w Width of the image
136
+ * \param[in] d_h Height of the image
137
+ * \param[in] align Alignment, in bytes, of the image buffer and
138
+ * each row in the image(stride).
139
+ *
140
+ * \return Returns a pointer to the initialized image descriptor. If the img
141
+ * parameter is non-null, the value of the img parameter will be
142
+ * returned.
143
+ */
144
+ vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
145
+ unsigned int d_w, unsigned int d_h,
146
+ unsigned int align);
147
+
148
+ /*!\brief Open a descriptor, using existing storage for the underlying image
149
+ *
150
+ * Returns a descriptor for storing an image of the given format. The
151
+ * storage for descriptor has been allocated elsewhere, and a descriptor is
152
+ * desired to "wrap" that storage.
153
+ *
154
+ * \param[in] img Pointer to storage for descriptor. If this
155
+ * parameter is NULL, the storage for the descriptor
156
+ * will be allocated on the heap.
157
+ * \param[in] fmt Format for the image
158
+ * \param[in] d_w Width of the image
159
+ * \param[in] d_h Height of the image
160
+ * \param[in] stride_align Alignment, in bytes, of each row in the image.
161
+ * \param[in] img_data Storage to use for the image
162
+ *
163
+ * \return Returns a pointer to the initialized image descriptor. If the img
164
+ * parameter is non-null, the value of the img parameter will be
165
+ * returned.
166
+ */
167
+ vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
168
+ unsigned int d_h, unsigned int stride_align,
169
+ unsigned char *img_data);
170
+
171
+ /*!\brief Set the rectangle identifying the displayed portion of the image
172
+ *
173
+ * Updates the displayed rectangle (aka viewport) on the image surface to
174
+ * match the specified coordinates and size. Specifically, sets img->d_w,
175
+ * img->d_h, and elements of the img->planes[] array.
176
+ *
177
+ * \param[in] img Image descriptor
178
+ * \param[in] x leftmost column
179
+ * \param[in] y topmost row
180
+ * \param[in] w width
181
+ * \param[in] h height
182
+ *
183
+ * \return 0 if the requested rectangle is valid, nonzero (-1) otherwise.
184
+ */
185
+ int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
186
+ unsigned int w, unsigned int h);
187
+
188
+ /*!\brief Flip the image vertically (top for bottom)
189
+ *
190
+ * Adjusts the image descriptor's pointers and strides to make the image
191
+ * be referenced upside-down.
192
+ *
193
+ * \param[in] img Image descriptor
194
+ */
195
+ void vpx_img_flip(vpx_image_t *img);
196
+
197
+ /*!\brief Close an image descriptor
198
+ *
199
+ * Frees all allocated storage associated with an image descriptor.
200
+ *
201
+ * \param[in] img Image descriptor
202
+ */
203
+ void vpx_img_free(vpx_image_t *img);
204
+
205
+ #ifdef __cplusplus
206
+ } // extern "C"
207
+ #endif
208
+
209
+ #endif // VPX_VPX_VPX_IMAGE_H_
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3
+ *
4
+ * Use of this source code is governed by a BSD-style license
5
+ * that can be found in the LICENSE file in the root of the source
6
+ * tree. An additional intellectual property rights grant can be found
7
+ * in the file PATENTS. All contributing project authors may
8
+ * be found in the AUTHORS file in the root of the source tree.
9
+ */
10
+
11
+ #ifndef VPX_VPX_VPX_INTEGER_H_
12
+ #define VPX_VPX_VPX_INTEGER_H_
13
+
14
+ /* get ptrdiff_t, size_t, wchar_t, NULL */
15
+ #include <stddef.h>
16
+
17
+ #if defined(_MSC_VER)
18
+ #define VPX_FORCE_INLINE __forceinline
19
+ #define VPX_INLINE __inline
20
+ #else
21
+ #define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
22
+ // TODO(jbb): Allow a way to force inline off for older compilers.
23
+ #define VPX_INLINE inline
24
+ #endif
25
+
26
+ /* Assume platforms have the C99 standard integer types. */
27
+
28
+ #if defined(__cplusplus)
29
+ #if !defined(__STDC_FORMAT_MACROS)
30
+ #define __STDC_FORMAT_MACROS
31
+ #endif
32
+ #if !defined(__STDC_LIMIT_MACROS)
33
+ #define __STDC_LIMIT_MACROS
34
+ #endif
35
+ #endif // __cplusplus
36
+
37
+ #include <inttypes.h>
38
+ #include <stdint.h>
39
+
40
+ #endif // VPX_VPX_VPX_INTEGER_H_