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

Commit e4a52e74 authored by Shalaj Jain's avatar Shalaj Jain Committed by Steve Kondik
Browse files

libstagefright: Add support for frame-by-frame mode

- Set decoder in frame-by-frame mode always, except for interlaced
  content, for which arbitary mode should be set

Change-Id: I8195a40549898b43a0e03d65663c7148f458c448
parent 63614c13
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -94,6 +94,8 @@ struct QCOMXCodec {
    static void     setQCSpecificVideoFormat(const sp<MetaData> &meta, sp<IOMX> OMXhandle,
                                               IOMX::node_id nodeID, char* componentName );

    static void     checkIfInterlaced(const uint8_t *ptr, const sp<MetaData> &meta);

};

}
+7 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <utils/String8.h>
#ifdef QCOM_HARDWARE
#include <QCMediaDefs.h>
#include <QCMetaData.h>
#endif

namespace android {
@@ -2002,6 +2003,12 @@ MPEG4Source::MPEG4Source(
        // The number of bytes used to encode the length of a NAL unit.
        mNALLengthSize = 1 + (ptr[4] & 3);
    }

#ifdef QCOM_HARDWARE
    //MPEG4 extractor can give complete frames,
    //set arbitrary mode to false
    mFormat->setInt32(kKeyUseArbitraryMode, 0);
#endif
}

MPEG4Source::~MPEG4Source() {
+5 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2009 The Android Open Source Project
 * Copyright (c) 2010 - 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2010 - 2013, The Linux Foundation. All rights reserved.
 *
 * Not a Contribution, Apache license notifications and license are retained
 * for attribution purposes only.
@@ -611,6 +611,10 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
                return err;
            }

#ifdef QCOM_HARDWARE
            QCOMXCodec::checkIfInterlaced((const uint8_t *)data, meta);
#endif

            CODEC_LOGI(
                    "AVC profile = %u (%s), level = %u",
                    profile, AVCProfileToString(profile), level);
+19 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -45,6 +45,7 @@
#include <OMX_Component.h>
#include <QOMX_AudioExtensions.h>

#include "include/avc_utils.h"

namespace android {

@@ -589,4 +590,21 @@ void QCOMXCodec::setQCSpecificVideoFormat(const sp<MetaData> &meta, sp<IOMX> OMX
    }
}

void QCOMXCodec::checkIfInterlaced(const uint8_t *ptr, const sp<MetaData> &meta)
{
    uint16_t spsSize = (((uint16_t)ptr[6]) << 8) + (uint16_t)(ptr[7]);
    int32_t width = 0, height = 0, isInterlaced = 0;
    const uint8_t *spsStart = &ptr[8];

    sp<ABuffer> seqParamSet = new ABuffer(spsSize);
    memcpy(seqParamSet->data(), spsStart, spsSize);
    FindAVCDimensions(seqParamSet, &width, &height, &isInterlaced);

    ALOGV("height is %d, width is %d, isInterlaced is %d\n", height, width, isInterlaced);
    if (isInterlaced) {
        meta->setInt32(kKeyUseArbitraryMode, 1);
    }
    return;
}

}
+5 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ unsigned parseUE(ABitReader *br) {

// Determine video dimensions from the sequence parameterset.
void FindAVCDimensions(
        const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height) {
        const sp<ABuffer> &seqParamSet, int32_t *width, int32_t *height, int32_t *isInterlaced) {
    ABitReader br(seqParamSet->data() + 1, seqParamSet->size() - 1);

    unsigned profile_idc = br.getBits(8);
@@ -128,6 +128,10 @@ void FindAVCDimensions(
            (frame_crop_left_offset + frame_crop_right_offset) * cropUnitX;
        *height -=
            (frame_crop_top_offset + frame_crop_bottom_offset) * cropUnitY;

        if (isInterlaced != NULL) {
            *isInterlaced = !frame_mbs_only_flag;
        }
    }
}

Loading