4

Is there any available documentation about Color_FormatSurface (AndroidOpaque) color format? My video encoder currently does not support this format, and I am supposed to add that feature, but I cannot find anything about it.

Any help would be appreciated.

Rajko
  • 55
  • 1
  • 7

2 Answers2

7

There is no documentation on it, because it is opaque. That's "opaque" in the programming sense, not the alpha-blending sense.

The idea behind the "opaque" format is that it's whatever the device manufacturer decides is most appropriate for the device. YV12, NV21, RGBA, BGRA, whatever... on qcom devices it's probably one of their wacky formats. The video encoder and the GPU need to agree on what the format is, so that they can pass surfaces to each other, but applications are expected to use the GPU to read or write the data.

The surface's format is specified in the gralloc buffer meta-data. To read an "opaque" surface you might need to reverse-engineer a proprietary format. To write an "opaque" surface you can allocate a gralloc buffer and set the color format manually... since "opaque" just means "whatever the encoder feels like", you have some freedom of choice, but bear in mind that GPUs may not handle all formats, and some formats may be handled significantly more efficiently than others.

fadden
  • 51,356
  • 5
  • 116
  • 166
  • 1
    … and sometimes this opaque data is not exposed to your program at all, because the buffer only holds some pointers (handles) to pixels that are delivered directly to GPU – Alex Cohn Apr 23 '18 at 10:57
0

In Android 5.0, the software encoders also became able to use surface for input. This commit shows how that was implemented: https://android.googlesource.com/platform/frameworks/av/+/2edda09a%5E%21/

mstorsjo
  • 12,983
  • 2
  • 39
  • 62
  • Excellent! I didn't know that went in. I wonder if Grafika works on the AOSP emulator now... – fadden Jan 22 '15 at 16:44
  • Not sure about the full Grafika example, but at least EncodeDecodeTest should pass now, for both surface and buffer input, but for lower resolutions only. (The 720p test passes as well, if https://android-review.googlesource.com/82133 gets applied.) – mstorsjo Jan 22 '15 at 16:50