Skip to content

Instantly share code, notes, and snippets.

@pawitp
Last active March 12, 2017 03:47
Show Gist options
  • Save pawitp/7945188 to your computer and use it in GitHub Desktop.
Save pawitp/7945188 to your computer and use it in GitHub Desktop.

Revisions

  1. pawitp revised this gist Jul 14, 2014. 1 changed file with 10 additions and 46 deletions.
    56 changes: 10 additions & 46 deletions patch.diff
    Original file line number Diff line number Diff line change
    @@ -1,43 +1,7 @@
    From b57e8dacd3ad7ca9d8ab67446dc3f9a247174725 Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Fri, 13 Dec 2013 21:37:01 +0700
    Subject: [PATCH 1/3] AudioMixer: fix artifact on 2 short sounds

    On the I9082, when 2 short sounds are played simultaneously, there will be artifact
    on the speaker due to the buffer not being cleared.

    Change-Id: I8a325175e8e326a638c7f29987ae272ae8af6b66
    ---
    services/audioflinger/AudioMixer.cpp | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
    index 95f7381..5f80165 100644
    --- a/services/audioflinger/AudioMixer.cpp
    +++ b/services/audioflinger/AudioMixer.cpp
    @@ -1128,8 +1128,13 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts)
    t.in = t.buffer.raw;
    // t.in == NULL can happen if the track was flushed just after having
    // been enabled for mixing.
    - if (t.in == NULL)
    + if (t.in == NULL) {
    enabledTracks &= ~(1<<i);
    +
    + // We need to clear buffer here or there will be strange artifact
    + // on I9082's speaker
    + memset(t.mainBuffer, 0, sizeof(int16_t) * MAX_NUM_CHANNELS * state->frameCount);
    + }
    }

    e0 = enabledTracks;
    --
    1.8.3.4 (Apple Git-47)


    From 0adf8dfc02fc982ae89e794ee9216f2149e9634e Mon Sep 17 00:00:00 2001
    From 6e415ac727a1e323ca430d82e2fb792390c05500 Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Tue, 17 Dec 2013 13:15:52 +0700
    Subject: [PATCH 2/3] OMXCodec: set default input buffer size
    Subject: [PATCH 1/2] OMXCodec: set default input buffer size

    Broadcom OMX only set the buffer size to 65536 by default which
    is not enough for higher bitrate video
    @@ -48,10 +12,10 @@ Change-Id: I74372f3d821e41feb38b9bc0cca4ef56aa019493
    1 file changed, 12 insertions(+)

    diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
    index fa4643f..02c45b5 100644
    index 984b51c..704dd2d 100644
    --- a/media/libstagefright/OMXCodec.cpp
    +++ b/media/libstagefright/OMXCodec.cpp
    @@ -801,6 +801,18 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    @@ -918,6 +918,18 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
    setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);
    }
    @@ -71,13 +35,13 @@ index fa4643f..02c45b5 100644
    initOutputFormat(meta);

    --
    1.8.3.4 (Apple Git-47)
    1.8.5.2 (Apple Git-48)


    From 3a374db88238ae39b0a38498f49f8327870edc90 Mon Sep 17 00:00:00 2001
    From 0d952058939edb62fa6a378b3246ee2fab3c14df Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Mon, 23 Dec 2013 18:41:44 +0700
    Subject: [PATCH 3/3] OMXCodec: set default input buffer size only for BCM
    Subject: [PATCH 2/2] OMXCodec: set default input buffer size only for BCM
    decoder

    Change-Id: Ic554343069b47a4b66ea9e8daee684d4923ecd98
    @@ -86,10 +50,10 @@ Change-Id: Ic554343069b47a4b66ea9e8daee684d4923ecd98
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
    index 02c45b5..5d48f39 100644
    index 704dd2d..dec925d 100644
    --- a/media/libstagefright/OMXCodec.cpp
    +++ b/media/libstagefright/OMXCodec.cpp
    @@ -803,7 +803,7 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    @@ -920,7 +920,7 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    }
    // Capri's OMX fail to set a reasonable default size from width and height
    #ifdef CAPRI_HWC
    @@ -99,5 +63,5 @@ index 02c45b5..5d48f39 100644
    int32_t height;
    if (meta->findInt32(kKeyWidth, &width) && meta->findInt32(kKeyHeight, &height)) {
    --
    1.8.3.4 (Apple Git-47)
    1.8.5.2 (Apple Git-48)

  2. pawitp revised this gist Dec 23, 2013. 1 changed file with 33 additions and 5 deletions.
    38 changes: 33 additions & 5 deletions patch.diff
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    From 916d3b4f678cbc99540f28772525b51a5003696d Mon Sep 17 00:00:00 2001
    From b57e8dacd3ad7ca9d8ab67446dc3f9a247174725 Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Fri, 13 Dec 2013 21:37:01 +0700
    Subject: [PATCH 1/2] AudioMixer: fix artifact on 2 short sounds
    Subject: [PATCH 1/3] AudioMixer: fix artifact on 2 short sounds

    On the I9082, when 2 short sounds are played simultaneously, there will be artifact
    on the speaker due to the buffer not being cleared.
    @@ -34,10 +34,10 @@ index 95f7381..5f80165 100644
    1.8.3.4 (Apple Git-47)


    From ec6dc5ebee04eb4570f91e02b851c3a223eac0ad Mon Sep 17 00:00:00 2001
    From 0adf8dfc02fc982ae89e794ee9216f2149e9634e Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Tue, 17 Dec 2013 13:15:52 +0700
    Subject: [PATCH 2/2] OMXCodec: set default input buffer size
    Subject: [PATCH 2/3] OMXCodec: set default input buffer size

    Broadcom OMX only set the buffer size to 65536 by default which
    is not enough for higher bitrate video
    @@ -48,7 +48,7 @@ Change-Id: I74372f3d821e41feb38b9bc0cca4ef56aa019493
    1 file changed, 12 insertions(+)

    diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
    index d3be3bc..66d5907 100644
    index fa4643f..02c45b5 100644
    --- a/media/libstagefright/OMXCodec.cpp
    +++ b/media/libstagefright/OMXCodec.cpp
    @@ -801,6 +801,18 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    @@ -73,3 +73,31 @@ index d3be3bc..66d5907 100644
    --
    1.8.3.4 (Apple Git-47)


    From 3a374db88238ae39b0a38498f49f8327870edc90 Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Mon, 23 Dec 2013 18:41:44 +0700
    Subject: [PATCH 3/3] OMXCodec: set default input buffer size only for BCM
    decoder

    Change-Id: Ic554343069b47a4b66ea9e8daee684d4923ecd98
    ---
    media/libstagefright/OMXCodec.cpp | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
    index 02c45b5..5d48f39 100644
    --- a/media/libstagefright/OMXCodec.cpp
    +++ b/media/libstagefright/OMXCodec.cpp
    @@ -803,7 +803,7 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    }
    // Capri's OMX fail to set a reasonable default size from width and height
    #ifdef CAPRI_HWC
    - else {
    + else if (!strncmp(mComponentName, "OMX.BRCM.vc4.decoder.", 21)) {
    int32_t width;
    int32_t height;
    if (meta->findInt32(kKeyWidth, &width) && meta->findInt32(kKeyHeight, &height)) {
    --
    1.8.3.4 (Apple Git-47)

  3. pawitp revised this gist Dec 17, 2013. 1 changed file with 42 additions and 2 deletions.
    44 changes: 42 additions & 2 deletions patch.diff
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    From bed477cb1cd4a7575ce586f33066dd419a4fc6e1 Mon Sep 17 00:00:00 2001
    From 916d3b4f678cbc99540f28772525b51a5003696d Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Fri, 13 Dec 2013 21:37:01 +0700
    Subject: [PATCH] AudioMixer: fix artifact on 2 short sounds
    Subject: [PATCH 1/2] AudioMixer: fix artifact on 2 short sounds

    On the I9082, when 2 short sounds are played simultaneously, there will be artifact
    on the speaker due to the buffer not being cleared.
    @@ -33,3 +33,43 @@ index 95f7381..5f80165 100644
    --
    1.8.3.4 (Apple Git-47)


    From ec6dc5ebee04eb4570f91e02b851c3a223eac0ad Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Tue, 17 Dec 2013 13:15:52 +0700
    Subject: [PATCH 2/2] OMXCodec: set default input buffer size

    Broadcom OMX only set the buffer size to 65536 by default which
    is not enough for higher bitrate video

    Change-Id: I74372f3d821e41feb38b9bc0cca4ef56aa019493
    ---
    media/libstagefright/OMXCodec.cpp | 12 ++++++++++++
    1 file changed, 12 insertions(+)

    diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
    index d3be3bc..66d5907 100644
    --- a/media/libstagefright/OMXCodec.cpp
    +++ b/media/libstagefright/OMXCodec.cpp
    @@ -801,6 +801,18 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
    setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);
    }
    +// Capri's OMX fail to set a reasonable default size from width and height
    +#ifdef CAPRI_HWC
    + else {
    + int32_t width;
    + int32_t height;
    + if (meta->findInt32(kKeyWidth, &width) && meta->findInt32(kKeyHeight, &height)) {
    + setMinBufferSize(kPortIndexInput, (width * height * 3) / 2);
    + } else {
    + ALOGE("Failed to set min buffer size");
    + }
    + }
    +#endif

    initOutputFormat(meta);

    --
    1.8.3.4 (Apple Git-47)

  4. pawitp revised this gist Dec 14, 2013. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions patch.diff
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    From 2f4a77028dffc2312946641be87e9d6cacdecd0a Mon Sep 17 00:00:00 2001
    From bed477cb1cd4a7575ce586f33066dd419a4fc6e1 Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Fri, 13 Dec 2013 21:37:01 +0700
    Subject: [PATCH] AudioMixer: fix artifact on 2 short sounds
    @@ -12,7 +12,7 @@ Change-Id: I8a325175e8e326a638c7f29987ae272ae8af6b66
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
    index 95f7381..bd40948 100644
    index 95f7381..5f80165 100644
    --- a/services/audioflinger/AudioMixer.cpp
    +++ b/services/audioflinger/AudioMixer.cpp
    @@ -1128,8 +1128,13 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts)
    @@ -25,10 +25,11 @@ index 95f7381..bd40948 100644
    +
    + // We need to clear buffer here or there will be strange artifact
    + // on I9082's speaker
    + memset(t.mainBuffer, 0, state->frameCount);
    + memset(t.mainBuffer, 0, sizeof(int16_t) * MAX_NUM_CHANNELS * state->frameCount);
    + }
    }

    e0 = enabledTracks;
    --
    1.8.3.4 (Apple Git-47)

  5. pawitp created this gist Dec 13, 2013.
    34 changes: 34 additions & 0 deletions patch.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    From 2f4a77028dffc2312946641be87e9d6cacdecd0a Mon Sep 17 00:00:00 2001
    From: Pawit Pornkitprasan <[email protected]>
    Date: Fri, 13 Dec 2013 21:37:01 +0700
    Subject: [PATCH] AudioMixer: fix artifact on 2 short sounds

    On the I9082, when 2 short sounds are played simultaneously, there will be artifact
    on the speaker due to the buffer not being cleared.

    Change-Id: I8a325175e8e326a638c7f29987ae272ae8af6b66
    ---
    services/audioflinger/AudioMixer.cpp | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
    index 95f7381..bd40948 100644
    --- a/services/audioflinger/AudioMixer.cpp
    +++ b/services/audioflinger/AudioMixer.cpp
    @@ -1128,8 +1128,13 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts)
    t.in = t.buffer.raw;
    // t.in == NULL can happen if the track was flushed just after having
    // been enabled for mixing.
    - if (t.in == NULL)
    + if (t.in == NULL) {
    enabledTracks &= ~(1<<i);
    +
    + // We need to clear buffer here or there will be strange artifact
    + // on I9082's speaker
    + memset(t.mainBuffer, 0, state->frameCount);
    + }
    }

    e0 = enabledTracks;
    --
    1.8.3.4 (Apple Git-47)