diff options
author | Andreas Huber <andih@google.com> | 2012-11-01 15:48:44 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-11-01 15:48:44 -0700 |
commit | 96076964863ee6887f0bed9d0f11f424b48ab9b9 (patch) | |
tree | ff74d91d61bbcb4ddf8af89ea9f49f72e6d00da6 | |
parent | 90a92053219ae50ddf4bb54e3d54db2d309e2b8d (diff) | |
download | frameworks_av-96076964863ee6887f0bed9d0f11f424b48ab9b9.zip frameworks_av-96076964863ee6887f0bed9d0f11f424b48ab9b9.tar.gz frameworks_av-96076964863ee6887f0bed9d0f11f424b48ab9b9.tar.bz2 |
Make video encoders' bitrate mode (constant, variable, ...) configurable
through the desired output format. Configure the video encoder to use
constant bitrate mode for WFD.
Change-Id: Id7bd619598153c13448a9c5acd69d80f8a01f333
related-to-bug: 7459597
-rw-r--r-- | include/media/stagefright/ACodec.h | 5 | ||||
-rw-r--r-- | media/libstagefright/ACodec.cpp | 26 | ||||
-rw-r--r-- | media/libstagefright/wifi-display/source/Converter.cpp | 3 |
3 files changed, 28 insertions, 6 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index d27f463..cba8a6b 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -242,7 +242,10 @@ private: status_t setupAVCEncoderParameters(const sp<AMessage> &msg); status_t verifySupportForProfileAndLevel(int32_t profile, int32_t level); - status_t configureBitrate(int32_t bitrate); + + status_t configureBitrate( + int32_t bitrate, OMX_VIDEO_CONTROLRATETYPE bitrateMode); + status_t setupErrorCorrectionParameters(); status_t initNativeWindow(); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 2b4220f..0ca027b 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1636,6 +1636,15 @@ static OMX_U32 setPFramesSpacing(int32_t iFramesInterval, int32_t frameRate) { return ret; } +static OMX_VIDEO_CONTROLRATETYPE getBitrateMode(const sp<AMessage> &msg) { + int32_t tmp; + if (!msg->findInt32("bitrate-mode", &tmp)) { + return OMX_Video_ControlRateVariable; + } + + return static_cast<OMX_VIDEO_CONTROLRATETYPE>(tmp); +} + status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) { int32_t bitrate, iFrameInterval; if (!msg->findInt32("bitrate", &bitrate) @@ -1643,6 +1652,8 @@ status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) { return INVALID_OPERATION; } + OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg); + float frameRate; if (!msg->findFloat("frame-rate", &frameRate)) { int32_t tmp; @@ -1706,7 +1717,7 @@ status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) { return err; } - err = configureBitrate(bitrate); + err = configureBitrate(bitrate, bitrateMode); if (err != OK) { return err; @@ -1722,6 +1733,8 @@ status_t ACodec::setupH263EncoderParameters(const sp<AMessage> &msg) { return INVALID_OPERATION; } + OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg); + float frameRate; if (!msg->findFloat("frame-rate", &frameRate)) { int32_t tmp; @@ -1780,7 +1793,7 @@ status_t ACodec::setupH263EncoderParameters(const sp<AMessage> &msg) { return err; } - err = configureBitrate(bitrate); + err = configureBitrate(bitrate, bitrateMode); if (err != OK) { return err; @@ -1796,6 +1809,8 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) { return INVALID_OPERATION; } + OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg); + float frameRate; if (!msg->findFloat("frame-rate", &frameRate)) { int32_t tmp; @@ -1881,7 +1896,7 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) { return err; } - return configureBitrate(bitrate); + return configureBitrate(bitrate, bitrateMode); } status_t ACodec::verifySupportForProfileAndLevel( @@ -1910,7 +1925,8 @@ status_t ACodec::verifySupportForProfileAndLevel( } } -status_t ACodec::configureBitrate(int32_t bitrate) { +status_t ACodec::configureBitrate( + int32_t bitrate, OMX_VIDEO_CONTROLRATETYPE bitrateMode) { OMX_VIDEO_PARAM_BITRATETYPE bitrateType; InitOMXParams(&bitrateType); bitrateType.nPortIndex = kPortIndexOutput; @@ -1923,7 +1939,7 @@ status_t ACodec::configureBitrate(int32_t bitrate) { return err; } - bitrateType.eControlRate = OMX_Video_ControlRateVariable; + bitrateType.eControlRate = bitrateMode; bitrateType.nTargetBitrate = bitrate; return mOMX->setParameter( diff --git a/media/libstagefright/wifi-display/source/Converter.cpp b/media/libstagefright/wifi-display/source/Converter.cpp index 93ae9a3..01a394f 100644 --- a/media/libstagefright/wifi-display/source/Converter.cpp +++ b/media/libstagefright/wifi-display/source/Converter.cpp @@ -33,6 +33,8 @@ #include <media/stagefright/MediaDefs.h> #include <media/stagefright/MediaErrors.h> +#include <OMX_Video.h> + namespace android { Converter::Converter( @@ -152,6 +154,7 @@ status_t Converter::initEncoder() { mOutputFormat->setInt32("bitrate", audioBitrate); } else { mOutputFormat->setInt32("bitrate", videoBitrate); + mOutputFormat->setInt32("bitrate-mode", OMX_Video_ControlRateConstant); mOutputFormat->setInt32("frame-rate", 30); mOutputFormat->setInt32("i-frame-interval", 1); // Iframes every 1 secs mOutputFormat->setInt32("prepend-sps-pps-to-idr-frames", 1); |