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

Commit c6161722 authored by James Dong's avatar James Dong
Browse files

Properly handle start code in H264/AVC encoder output

- Some H264/AVC encoder output start code in each output buffer, and others don't.
  This patch always strips the start code first so that the sample contains the correct size.
- Also properly initialize the interleave duration.

Change-Id: I692043ce7e38f0215e1097aad9e847a57907b6e4
parent 4979601f
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -701,6 +701,7 @@ status_t StagefrightRecorder::reset() {
    mSampleRate    = 8000;
    mSampleRate    = 8000;
    mAudioChannels = 1;
    mAudioChannels = 1;
    mAudioBitRate  = 12200;
    mAudioBitRate  = 12200;
    mInterleaveDurationUs = 0;


    mOutputFd = -1;
    mOutputFd = -1;
    mFlags = 0;
    mFlags = 0;
+2 −2
Original line number Original line Diff line number Diff line
@@ -334,8 +334,6 @@ static void StripStartcode(MediaBuffer *buffer) {
}
}


off_t MPEG4Writer::addLengthPrefixedSample_l(MediaBuffer *buffer) {
off_t MPEG4Writer::addLengthPrefixedSample_l(MediaBuffer *buffer) {
    StripStartcode(buffer);

    off_t old_offset = mOffset;
    off_t old_offset = mOffset;


    size_t length = buffer->range_length();
    size_t length = buffer->range_length();
@@ -827,6 +825,8 @@ void MPEG4Writer::Track::threadEntry() {
            continue;
            continue;
        }
        }


        if (is_avc) StripStartcode(buffer);

        SampleInfo info;
        SampleInfo info;
        info.size = is_avc
        info.size = is_avc
#if USE_NALLEN_FOUR
#if USE_NALLEN_FOUR