Forums - Galaxy S4 and Nexus 4, with Adreno GPUs, crash while encoding from surface with certain contents

2 posts / 0 new
Last post
Galaxy S4 and Nexus 4, with Adreno GPUs, crash while encoding from surface with certain contents
bogru
Join Date: 26 Nov 14
Posts: 2
Posted: Fri, 2014-11-28 10:05

I found an error appearing while encoding from a GPU generated surface using the hardware h264 encoder on Galaxy S4. It happens 100% for selected images and device. We could reproduce it with the Grafika software, available on github, developed by Google employees.

Modified version of Grafika renders an image first to a texture, and then the texture is rendered to both display and the encoder surface. For certain images, the encoder crashes when a key frame is following, 100% in the same place. The crash happens sooner if bitrate is increased (for 720p, 7 Mbps determines a crash within the first 3 keyframes). For other images, the crash happens later.

In order to reproduce, in Grafika sofware: https://github.com/google/grafika replace the recordfboactivity with the one attached. (the changes: instead of geometric forms, just render an image to the texture, and increase the bitrate from 4 to 7) The logcat is also attached, and the error. (they are separate as the error fills the logcat very fast). The image should be placed in Movies/android_mediaclips. Start the application, select "Record GL app", turn it in landscape mode, select "Rec: FBO blit x2" and then Start recording. It should freeze after 300 frames. (third key frame - one key frame is generated every 5 seconds in grafika. To change that, check IFRAME_INTERVAL in VideoEncoderCore.java. There could be useful a logcat message to show last data sent to muxer, i.e. after mMuxer.writeSampleData(mTrackIndex, encodedData, mBufferInfo);
put Log.d(TAG, "sent " + mBufferInfo.size + " bytes to muxer, ts=" + mBufferInfo.presentationTimeUs/1000);

I observed that if instead of texture with static image I have an external texture with video, the error does not appear. Also, if I blend the image from frame to frame with a variable texture, the crash is delayed or does not appear. I was thinking that due to very small/no variations from frame to frame, encoded predicted frames are very small, while the intra frames are very large. This might cause issues with bitrate algorithm, or some other problems.

I am not interested in a driver solution, but rather in understanding what goes wrong, and how I can create a workaround so that we can release our application for qualcomm devices too. Grafika was used just to reproduce our issue.

  • Up0
  • Down0
bogru
Join Date: 26 Nov 14
Posts: 2
Posted: Wed, 2014-12-03 04:55

The issue is also reproduced on Nexus 4, with Adreno GPU, but not on Galaxy S3 with Mali 400 GPU. 

The render to texture is not relevant to reproduce it. It can also be reproduce if the texture containing the image is rendered to the input surface of the encoder directly.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.