0

On Android 4.1 and above, I am using MediaCodec framework to decode H264 data. I see the codec instance that I'm using (via createDecoderByType) supports multiple color-formats. However, it always gives the output in the 1st-indexed color-format (from its supported list).

Is there a way to force the decoder to give out decoded data in a particular color-format from the ColorFormats it supports? I know the developer docs does mention that the key KEY_COLOR_FORMAT can only be set for encoders, but then help me understand what is the rational of having multiple supported color-formats for decoders?

Gagan
  • 1,497
  • 1
  • 12
  • 27

1 Answers1

2

No, there is currently no way to specify the color format for the decoder output.

This is especially annoying on devices that use undocumented proprietary buffer layouts.

Directing the output to a Surface results in more consistent and portable behavior, but as of API 19 there's still no convenient way to get at the pixel data (ImageReader doesn't work with MediaCodec output formats, glReadPixels() can be slow and works in RGB, etc). If you can do what you need with OpenGL shaders then things work pretty well (see e.g. the effects in "show + capture camera").

fadden
  • 51,356
  • 5
  • 116
  • 166
  • Or are there native color-filters available for converting decoder output data from one format to another? – Gagan Aug 13 '14 at 19:01
  • None are provided via public API in the platform. The ByteBuffer output of the video decoder is not very useful unless you're only targeting specific devices. – fadden Aug 14 '14 at 04:15