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

Commit d420b18c authored by Iliyan Malchev's avatar Iliyan Malchev Committed by Android (Google) Code Review
Browse files

Merge "Add support for TI H264 encoder"

parents a7b28df5 e641dc50
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -103,6 +103,10 @@ static int32_t getColorFormat(const char* colorFormat) {
       return OMX_COLOR_Format16bitRGB565;
    }

    if (!strcmp(colorFormat, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar")) {
       return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
    }

    LOGE("Uknown color format (%s), please add it to "
         "CameraSource::getColorFormat", colorFormat);

+5 −2
Original line number Diff line number Diff line
@@ -1715,7 +1715,10 @@ status_t MPEG4Writer::Track::parseAVCCodecSpecificData(
            return ERROR_MALFORMED;
        }
    }

// FIXME:
// Add chromat_format_idc, bit depth values, etc for AVC/h264 high profile and above
// and remove #if 0
#if 0
    {
        // Check on the profiles
        // These profiles requires additional parameter set extensions
@@ -1725,7 +1728,7 @@ status_t MPEG4Writer::Track::parseAVCCodecSpecificData(
            return BAD_VALUE;
        }
    }

#endif
    return OK;
}

+27 −1
Original line number Diff line number Diff line
@@ -218,18 +218,21 @@ static const CodecInfo kEncoderInfo[] = {
    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "AMRWBEncoder" },
    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.encode" },
    { MEDIA_MIMETYPE_AUDIO_AAC, "AACEncoder" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.DUCATI1.VIDEO.MPEG4E" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.7x30.video.encoder.mpeg4" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.qcom.video.encoder.mpeg4" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.encoder" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.Nvidia.mp4.encoder" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.SEC.MPEG4.Encoder" },
    { MEDIA_MIMETYPE_VIDEO_MPEG4, "M4vH263Encoder" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.DUCATI1.VIDEO.MPEG4E" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.7x30.video.encoder.h263" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.qcom.video.encoder.h263" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.Video.encoder" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.Nvidia.h263.encoder" },
    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.SEC.H263.Encoder" },
    { MEDIA_MIMETYPE_VIDEO_H263, "M4vH263Encoder" },
    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.DUCATI1.VIDEO.H264E" },
    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.7x30.video.encoder.avc" },
    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.qcom.video.encoder.avc" },
    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.encoder" },
@@ -393,7 +396,17 @@ uint32_t OMXCodec::getComponentQuirks(
    if (!strcmp(componentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
        quirks |= kRequiresAllocateBufferOnInputPorts;
        quirks |= kRequiresAllocateBufferOnOutputPorts;
    } else if (!strncmp(componentName, "OMX.TI.", 7)) {
    }

    // FIXME:
    // Remove the quirks after the work is done.
    else if (!strcmp(componentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E") ||
             !strcmp(componentName, "OMX.TI.DUCATI1.VIDEO.H264E")) {

        quirks |= kRequiresAllocateBufferOnInputPorts;
        quirks |= kRequiresAllocateBufferOnOutputPorts;
    }
    else if (!strncmp(componentName, "OMX.TI.", 7)) {
        // Apparently I must not use OMX_UseBuffer on either input or
        // output ports on any of the TI components or quote:
        // "(I) may have unexpected problem (sic) which can be timing related
@@ -887,6 +900,7 @@ static size_t getFrameSize(

        case OMX_COLOR_FormatYUV420Planar:
        case OMX_COLOR_FormatYUV420SemiPlanar:
        case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar:
            return (width * height * 3) / 2;

        default:
@@ -910,6 +924,7 @@ status_t OMXCodec::findTargetColorFormat(
        }
    }


    // Check whether the target color format is supported.
    return isColorFormatSupported(*colorFormat, kPortIndexInput);
}
@@ -1032,6 +1047,11 @@ void OMXCodec::setVideoInputFormat(
    video_def->nFrameWidth = width;
    video_def->nFrameHeight = height;
    video_def->xFramerate = 0;      // No need for output port
    // FIXME:
    // Revmoe this workaround after work is done.
    if (!strncmp(mComponentName, "OMX.TI.DUCATI1", 14)) {
        video_def->xFramerate = (frameRate << 16);
    }
    video_def->nBitrate = bitRate;  // Q16 format
    video_def->eCompressionFormat = compressionFormat;
    video_def->eColorFormat = OMX_COLOR_FormatUnused;
@@ -1304,6 +1324,12 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
    h264type.eProfile = static_cast<OMX_VIDEO_AVCPROFILETYPE>(profileLevel.mProfile);
    h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(profileLevel.mLevel);

    // FIXME:
    // Remove the workaround after the work in done.
    if (!strncmp(mComponentName, "OMX.TI.DUCATI1", 14)) {
        h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
    }

    if (h264type.eProfile == OMX_VIDEO_AVCProfileBaseline) {
        h264type.nSliceHeaderSpacing = 0;
        h264type.bUseHadamard = OMX_TRUE;