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

Commit c174b9c3 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4751833 from 48710967 to pi-release

Change-Id: Ib2a85140d144ef957a456f925235a7eacb6b3c35
parents 284de865 48710967
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -893,7 +893,7 @@ int main(int argc, char **argv) {
                VideoFrame *frame = (VideoFrame *)mem->pointer();

                CHECK_EQ(writeJpegFile("/sdcard/out.jpg",
                            (uint8_t *)frame + sizeof(VideoFrame),
                            frame->getFlattenedData(),
                            frame->mWidth, frame->mHeight), 0);
            }

+0 −6
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
#include <android/hidl/manager/1.0/IServiceManager.h>

#include <binder/IMemory.h>
#include <cutils/native_handle.h>
#include <hidlmemory/FrameworkUtils.h>
#include <media/hardware/CryptoAPI.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -245,11 +244,6 @@ int32_t CryptoHal::setHeapBase(const sp<IMemoryHeap>& heap) {
        ALOGE("setHeapBase(): heap is NULL");
        return -1;
    }
    native_handle_t* nativeHandle = native_handle_create(1, 0);
    if (!nativeHandle) {
        ALOGE("setHeapBase(), failed to create native handle");
        return -1;
    }

    Mutex::Autolock autoLock(mLock);

+17 −105
Original line number Diff line number Diff line
@@ -25,96 +25,34 @@

namespace android {

// Represents a color converted (RGB-based) video frame
// with bitmap pixels stored in FrameBuffer
// Represents a color converted (RGB-based) video frame with bitmap
// pixels stored in FrameBuffer.
// In a VideoFrame struct stored in IMemory, frame data and ICC data
// come after the VideoFrame structure. Their locations can be retrieved
// by getFlattenedData() and getFlattenedIccData();
class VideoFrame
{
public:
    // Construct a VideoFrame object with the specified parameters,
    // will allocate frame buffer if |allocate| is set to true, will
    // allocate buffer to hold ICC data if |iccData| and |iccSize|
    // indicate its presence.
    // will calculate frame buffer size if |hasData| is set to true.
    VideoFrame(uint32_t width, uint32_t height,
            uint32_t displayWidth, uint32_t displayHeight,
            uint32_t angle, uint32_t bpp, bool allocate,
            const void *iccData, size_t iccSize):
            uint32_t angle, uint32_t bpp, bool hasData, size_t iccSize):
        mWidth(width), mHeight(height),
        mDisplayWidth(displayWidth), mDisplayHeight(displayHeight),
        mRotationAngle(angle), mBytesPerPixel(bpp), mRowBytes(bpp * width),
        mSize(0), mIccSize(0), mReserved(0), mData(0), mIccData(0) {
        if (allocate) {
            mSize = mRowBytes * mHeight;
            mData = new uint8_t[mSize];
            if (mData == NULL) {
                mSize = 0;
            }
        }

        if (iccData != NULL && iccSize > 0) {
            mIccSize = iccSize;
            mIccData = new uint8_t[iccSize];
            if (mIccData != NULL) {
                memcpy(mIccData, iccData, iccSize);
            } else {
                mIccSize = 0;
            }
        }
        mSize(hasData ? (bpp * width * height) : 0),
        mIccSize(iccSize), mReserved(0) {
    }

    // Deep copy of both the information fields and the frame data
    VideoFrame(const VideoFrame& copy) {
        copyInfoOnly(copy);

        mSize = copy.mSize;
        mData = NULL;  // initialize it first
        if (mSize > 0 && copy.mData != NULL) {
            mData = new uint8_t[mSize];
            if (mData != NULL) {
                memcpy(mData, copy.mData, mSize);
            } else {
                mSize = 0;
            }
        }

        mIccSize = copy.mIccSize;
        mIccData = NULL;  // initialize it first
        if (mIccSize > 0 && copy.mIccData != NULL) {
            mIccData = new uint8_t[mIccSize];
            if (mIccData != NULL) {
                memcpy(mIccData, copy.mIccData, mIccSize);
    void init(const VideoFrame& copy, const void* iccData, size_t iccSize) {
        *this = copy;
        if (mIccSize == iccSize && iccSize > 0 && iccData != NULL) {
            memcpy(getFlattenedIccData(), iccData, iccSize);
        } else {
            mIccSize = 0;
        }
    }
    }

    ~VideoFrame() {
        if (mData != 0) {
            delete[] mData;
        }
        if (mIccData != 0) {
            delete[] mIccData;
        }
    }

    // Copy |copy| to a flattened VideoFrame in IMemory, 'this' must point to
    // a chunk of memory back by IMemory of size at least getFlattenedSize()
    // of |copy|.
    void copyFlattened(const VideoFrame& copy) {
        copyInfoOnly(copy);

        mSize = copy.mSize;
        mData = NULL;  // initialize it first
        if (copy.mSize > 0 && copy.mData != NULL) {
            memcpy(getFlattenedData(), copy.mData, copy.mSize);
        }

        mIccSize = copy.mIccSize;
        mIccData = NULL;  // initialize it first
        if (copy.mIccSize > 0 && copy.mIccData != NULL) {
            memcpy(getFlattenedIccData(), copy.mIccData, copy.mIccSize);
        }
    }

    // Calculate the flattened size to put it in IMemory
    size_t getFlattenedSize() const {
@@ -139,35 +77,9 @@ public:
    int32_t  mRotationAngle;   // Rotation angle, clockwise, should be multiple of 90
    uint32_t mBytesPerPixel;   // Number of bytes per pixel
    uint32_t mRowBytes;        // Number of bytes per row before rotation
    uint32_t mSize;            // Number of bytes in mData
    uint32_t mIccSize;         // Number of bytes in mIccData
    uint32_t mSize;            // Number of bytes of frame data
    uint32_t mIccSize;         // Number of bytes of ICC data
    uint32_t mReserved;        // (padding to make mData 64-bit aligned)

    // mData should be 64-bit aligned to prevent additional padding
    uint8_t* mData;            // Actual binary data
    // pad structure so it's the same size on 64-bit and 32-bit
    char     mPadding[8 - sizeof(mData)];

    // mIccData should be 64-bit aligned to prevent additional padding
    uint8_t* mIccData;            // Actual binary data
    // pad structure so it's the same size on 64-bit and 32-bit
    char     mIccPadding[8 - sizeof(mIccData)];

private:
    //
    // Utility methods used only within VideoFrame struct
    //

    // Copy the information fields only
    void copyInfoOnly(const VideoFrame& copy) {
        mWidth = copy.mWidth;
        mHeight = copy.mHeight;
        mDisplayWidth = copy.mDisplayWidth;
        mDisplayHeight = copy.mDisplayHeight;
        mRotationAngle = copy.mRotationAngle;
        mBytesPerPixel = copy.mBytesPerPixel;
        mRowBytes = copy.mRowBytes;
    }
};

}; // namespace android
+9 −1
Original line number Diff line number Diff line
@@ -360,7 +360,15 @@ void BlockIterator::advance_l() {

            res = mCluster->Parse(pos, len);
            ALOGV("Parse (2) returned %ld", res);
            CHECK_GE(res, 0);

            if (res < 0) {
                // I/O error

                ALOGE("Cluster::Parse returned result %ld", res);

                mCluster = NULL;
                break;
            }

            mBlockEntryIndex = 0;
            continue;
+1 −1
Original line number Diff line number Diff line
@@ -628,7 +628,7 @@ status_t MPEG4Extractor::readMetaData() {
            track->meta.setInt32(kKeyTrackID, imageIndex);
            track->includes_expensive_metadata = false;
            track->skipTrack = false;
            track->timescale = 0;
            track->timescale = 1000000;
        }
    }

Loading