Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db2d2066 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "stagefright: enable B-frames for AVC encoder and MPEG4 writer" into nyc-mr1-dev

parents 8dcd8205 826cbe4d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -4272,8 +4272,15 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
        h264type.eProfile = static_cast<OMX_VIDEO_AVCPROFILETYPE>(profile);
        h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(level);
    } else {
        // Use baseline profile for AVC recording if profile is not specified.
        // Use largest supported profile for AVC recording if profile is not specified.
        h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
        for (OMX_VIDEO_AVCPROFILETYPE profile : {
                OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCProfileMain }) {
            if (verifySupportForProfileAndLevel(profile, 0) == OK) {
                h264type.eProfile = profile;
                break;
            }
        }
    }

    ALOGI("setupAVCEncoderParameters with [profile: %s] [level: %s]",
+16 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "MPEG4Writer"

#include <algorithm>

#include <arpa/inet.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -30,6 +32,7 @@

#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/ColorUtils.h>
#include <media/stagefright/MPEG4Writer.h>
#include <media/stagefright/MediaBuffer.h>
@@ -256,6 +259,7 @@ private:
    int32_t mTrackId;
    int64_t mTrackDurationUs;
    int64_t mMaxChunkDurationUs;
    int64_t mLastDecodingTimeUs;

    int64_t mEstimatedTrackSizeBytes;
    int64_t mMdatSizeBytes;
@@ -1928,6 +1932,7 @@ status_t MPEG4Writer::Track::start(MetaData *params) {
    mEstimatedTrackSizeBytes = 0;
    mMdatSizeBytes = 0;
    mMaxChunkDurationUs = 0;
    mLastDecodingTimeUs = -1;

    pthread_create(&mThread, &attr, ThreadWrapper, this);
    pthread_attr_destroy(&attr);
@@ -2512,6 +2517,17 @@ status_t MPEG4Writer::Track::threadEntry() {
            int64_t decodingTimeUs;
            CHECK(meta_data->findInt64(kKeyDecodingTime, &decodingTimeUs));
            decodingTimeUs -= previousPausedDurationUs;

            // ensure non-negative, monotonic decoding time
            if (mLastDecodingTimeUs < 0) {
                decodingTimeUs = std::max((int64_t)0, decodingTimeUs);
            } else {
                // increase decoding time by at least 1 tick
                decodingTimeUs = std::max(
                        mLastDecodingTimeUs + divUp(1000000, mTimeScale), decodingTimeUs);
            }

            mLastDecodingTimeUs = decodingTimeUs;
            cttsOffsetTimeUs =
                    timestampUs + kMaxCttsOffsetTimeUs - decodingTimeUs;
            if (WARN_UNLESS(cttsOffsetTimeUs >= 0ll, "for %s track", trackName)) {