Closed Bug 1006285 Opened 11 years ago Closed 11 years ago

Problems with setting bitrate for HW H.264 encoder

Categories

(Core :: WebRTC: Audio/Video, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32
feature-b2g 2.0

People

(Reporter: jesup, Assigned: jesup)

References

Details

Attachments

(1 file)

Two problems have been noticed: 1. If the bitrate was initially set to 2Mbps (via configure()), subsequent calls to setBitRate() don't seem to work; the rate remained too high. I haven't gone back to re-verify since I recoded it to use configureDirect(); perhaps the way-over-bitrate at the start put it in a "bad" state that was hard to get out of. 2. If we use the new configureDirect() (or probably if tweak configure() to start at 300Kbps/10fps), then it appears to work - however, my measurements show that with a setting of 600, the bitrate appears to go over, generally wandering between 90000 and 120000 bits per frame at a configure input rate of 10fps. When the average goes over 60000-75000 bits/frame or so, decoder delay jumps up from ~1s to ~1.5-1.75s (and the rate may drop below 10fps) Note some addition verification of the input rate needs to be done, but the delta measurements on decoder events indicates 10fps.
Blocks: 1003040
To set the bitrate, MediaCodec::setParameters(AMessage params) should have a parameter key "video-bitrate". It seems like there is a typo in OMXCodecWrapper where the parameter name provided is "videoBitrate" [1]. [1] https://mxr.mozilla.org/mozilla-central/source/content/media/omx/OMXCodecWrapper.cpp#427
(In reply to sachins from comment #1) > To set the bitrate, MediaCodec::setParameters(AMessage params) should have a > parameter key "video-bitrate". It seems like there is a typo in > OMXCodecWrapper where the parameter name provided is "videoBitrate" [1]. I'm having trouble finding clear documentation on what the allowed values are, but what I can find says "bitrate", not "video-bitrate" (and not "videoBitrate"). Do you have a link to docs for setParameters and the allowed settings names?
Flags: needinfo?(sachins)
Looks like the key has been changed from "videoBitrate" to "video-bitrate" at commit 530fdbdc [1] The revision sync-ed by "config.sh flame" still uses "videoBitrate" so I suppose it should at least work on Flame. However, this also means that in order to support different stagefright versions, we might need to maintain a list of correct key strings (probably in Gonk) and expose them to Gecko. [1] https://android.googlesource.com/platform/frameworks/av/+/530fdbdc1b5491f3fbf172752834d1515701e142%5E!/#F0
> The revision sync-ed by "config.sh flame" still uses "videoBitrate" so I > suppose it should at least work on Flame. > However, this also means that in order to support different stagefright > versions, we might need to maintain a list of correct key strings (probably > in Gonk) and expose them to Gecko. Ok, that explains why it appeared to work (after I changed the config code). Is the new version in the KK builds being tried by Vikram/Diego? We also could set *both* values. Also, is there anything that keys us to the underlying version base of Gonk (KK or JB/etc)? I presume there is.
> Is the new version in the KK builds being tried by Vikram/Diego? Yes. > Also, is there anything that keys us to the underlying version base of Gonk (KK or JB/etc)? http://dxr.mozilla.org/mozilla-central/search?q=ANDROID_VERSION
Attachment #8420653 - Flags: review?(jolin)
Comment on attachment 8420653 [details] [diff] [review] make MediaCodec bitrate setting work for KitKat-based builds Review of attachment 8420653 [details] [diff] [review]: ----------------------------------------------------------------- ::: content/media/omx/OMXCodecWrapper.cpp @@ +444,5 @@ > { > sp<AMessage> msg = new AMessage(); > +#if ANDROID_VERSION >= 19 > + // XXX Do we need a runtime check here? > + msg->setInt32("bitrate", aKbps * 1000 /* kbps -> bps */); nit: s/bitrate/video-bitrate/
Attachment #8420653 - Flags: review?(jolin) → review+
feature-b2g: --- → 2.0
(In reply to Randell Jesup [:jesup] from comment #2) > I'm having trouble finding clear documentation on what the allowed values > are, but what I can find says "bitrate", not "video-bitrate" (and not > "videoBitrate"). Do you have a link to docs for setParameters and the > allowed settings names? Seems like these parameters are only documented at Java SDK level [1] for MediaCodec as I believe MediaCodec is not supported at NDK level. For native side, you can always look at the ACodec::setParameters() [1] http://developer.android.com/reference/android/media/MediaCodec.html#PARAMETER_KEY_VIDEO_BITRATE
Flags: needinfo?(sachins)
Assignee: nobody → rjesup
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: