Skip to content

Commit

Permalink
Expose the HDR ColorInfo in the VpxOutputBuffer so the renderer can u…
Browse files Browse the repository at this point in the history
…se it.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157267699
  • Loading branch information
anjalibh authored and ojw28 committed May 31, 2017
1 parent 12ef97f commit 7d4eaa7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class LibvpxVideoRenderer extends BaseRenderer {
private DecoderCounters decoderCounters;
private Format format;
private VpxDecoder decoder;
private DecoderInputBuffer inputBuffer;
private VpxInputBuffer inputBuffer;
private VpxOutputBuffer outputBuffer;
private VpxOutputBuffer nextOutputBuffer;
private DrmSession<ExoMediaCrypto> drmSession;
Expand Down Expand Up @@ -394,6 +394,7 @@ private boolean feedInputBuffer() throws VpxDecoderException, ExoPlaybackExcepti
return false;
}
inputBuffer.flip();
inputBuffer.colorInfo = formatHolder.format.colorInfo;
decoder.queueInputBuffer(inputBuffer);
decoderCounters.inputBufferCount++;
inputBuffer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.decoder.CryptoInfo;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
import com.google.android.exoplayer2.drm.DecryptionException;
import com.google.android.exoplayer2.drm.ExoMediaCrypto;
Expand All @@ -27,7 +26,7 @@
* Vpx decoder.
*/
/* package */ final class VpxDecoder extends
SimpleDecoder<DecoderInputBuffer, VpxOutputBuffer, VpxDecoderException> {
SimpleDecoder<VpxInputBuffer, VpxOutputBuffer, VpxDecoderException> {

public static final int OUTPUT_MODE_NONE = -1;
public static final int OUTPUT_MODE_YUV = 0;
Expand All @@ -54,7 +53,7 @@
*/
public VpxDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
ExoMediaCrypto exoMediaCrypto) throws VpxDecoderException {
super(new DecoderInputBuffer[numInputBuffers], new VpxOutputBuffer[numOutputBuffers]);
super(new VpxInputBuffer[numInputBuffers], new VpxOutputBuffer[numOutputBuffers]);
if (!VpxLibrary.isAvailable()) {
throw new VpxDecoderException("Failed to load decoder native libraries.");
}
Expand Down Expand Up @@ -85,8 +84,8 @@ public void setOutputMode(int outputMode) {
}

@Override
protected DecoderInputBuffer createInputBuffer() {
return new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DIRECT);
protected VpxInputBuffer createInputBuffer() {
return new VpxInputBuffer();
}

@Override
Expand All @@ -100,7 +99,7 @@ protected void releaseOutputBuffer(VpxOutputBuffer buffer) {
}

@Override
protected VpxDecoderException decode(DecoderInputBuffer inputBuffer, VpxOutputBuffer outputBuffer,
protected VpxDecoderException decode(VpxInputBuffer inputBuffer, VpxOutputBuffer outputBuffer,
boolean reset) {
ByteBuffer inputData = inputBuffer.data;
int inputSize = inputData.limit();
Expand Down Expand Up @@ -128,6 +127,7 @@ protected VpxDecoderException decode(DecoderInputBuffer inputBuffer, VpxOutputBu
} else if (getFrameResult == -1) {
return new VpxDecoderException("Buffer initialization failed.");
}
outputBuffer.colorInfo = inputBuffer.colorInfo;
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.ext.vp9;

import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.video.ColorInfo;

/**
* Input buffer to a {@link VpxDecoder}.
*/
/* package */ final class VpxInputBuffer extends DecoderInputBuffer {

public ColorInfo colorInfo;

public VpxInputBuffer() {
super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DIRECT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.android.exoplayer2.ext.vp9;

import com.google.android.exoplayer2.decoder.OutputBuffer;
import com.google.android.exoplayer2.video.ColorInfo;
import java.nio.ByteBuffer;

/**
Expand All @@ -37,6 +38,8 @@
public ByteBuffer data;
public int width;
public int height;
public ColorInfo colorInfo;

/**
* YUV planes for YUV mode.
*/
Expand Down

0 comments on commit 7d4eaa7

Please sign in to comment.