Format with google-java-format
Also amended Javadoc and added assertion to grow method
This commit is contained in:
parent
adee4626d3
commit
8750ed8de6
@ -51,14 +51,16 @@ public class SimpleDecoderOutputBuffer extends DecoderOutputBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reallocates the buffer with new size
|
||||
* Existing data between beginning of the buffer and {@link ByteBuffer#limit} is copied to the new buffer,
|
||||
* and {@link ByteBuffer#position} is preserved. {@link ByteBuffer#limit} is set to the new size.
|
||||
* @param newSize New size of buffer.
|
||||
* Grows the buffer with to a new size.
|
||||
*
|
||||
* <p>Existing data is copied to the new buffer, and {@link ByteBuffer#position} is preserved.
|
||||
*
|
||||
* @param newSize New size of the buffer.
|
||||
* @return The {@link #data} buffer, for convenience.
|
||||
*/
|
||||
public ByteBuffer grow(int newSize) {
|
||||
Assertions.checkNotNull(data);
|
||||
Assertions.checkArgument(newSize >= data.limit());
|
||||
final ByteBuffer newData = ByteBuffer.allocateDirect(newSize).order(ByteOrder.nativeOrder());
|
||||
final int restorePosition = data.position();
|
||||
data.position(0);
|
||||
|
@ -63,7 +63,8 @@ import java.util.List;
|
||||
codecName = Assertions.checkNotNull(FfmpegLibrary.getCodecName(format.sampleMimeType));
|
||||
extraData = getExtraData(format.sampleMimeType, format.initializationData);
|
||||
encoding = outputFloat ? C.ENCODING_PCM_FLOAT : C.ENCODING_PCM_16BIT;
|
||||
outputBufferSize = outputFloat ? INITIAL_OUTPUT_BUFFER_SIZE_32BIT : INITIAL_OUTPUT_BUFFER_SIZE_16BIT;
|
||||
outputBufferSize =
|
||||
outputFloat ? INITIAL_OUTPUT_BUFFER_SIZE_32BIT : INITIAL_OUTPUT_BUFFER_SIZE_16BIT;
|
||||
nativeContext =
|
||||
ffmpegInitialize(codecName, extraData, outputFloat, format.sampleRate, format.channelCount);
|
||||
if (nativeContext == 0) {
|
||||
@ -106,9 +107,10 @@ import java.util.List;
|
||||
}
|
||||
ByteBuffer inputData = Util.castNonNull(inputBuffer.data);
|
||||
int inputSize = inputData.limit();
|
||||
outputBuffer.init(inputBuffer.timeUs, outputBufferSize);
|
||||
|
||||
int result = ffmpegDecode(nativeContext, inputData, inputSize, outputBuffer, outputBuffer.data, outputBufferSize);
|
||||
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, outputBufferSize);
|
||||
int result =
|
||||
ffmpegDecode(
|
||||
nativeContext, inputData, inputSize, outputBuffer, outputData, outputBufferSize);
|
||||
if (result == AUDIO_DECODER_ERROR_OTHER) {
|
||||
return new FfmpegDecoderException("Error decoding (see logcat).");
|
||||
} else if (result == AUDIO_DECODER_ERROR_INVALID_DATA) {
|
||||
@ -135,13 +137,15 @@ import java.util.List;
|
||||
}
|
||||
hasOutputFormat = true;
|
||||
}
|
||||
outputBuffer.data.position(0);
|
||||
outputBuffer.data.limit(result);
|
||||
outputData.position(0);
|
||||
outputData.limit(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Called from native code
|
||||
/** @noinspection unused*/
|
||||
/**
|
||||
* @noinspection unused
|
||||
*/
|
||||
private ByteBuffer growOutputBuffer(SimpleDecoderOutputBuffer outputBuffer, int requiredSize) {
|
||||
// Use it for new buffer so that hopefully we won't need to reallocate again
|
||||
outputBufferSize = requiredSize;
|
||||
@ -229,7 +233,12 @@ import java.util.List;
|
||||
int rawChannelCount);
|
||||
|
||||
private native int ffmpegDecode(
|
||||
long context, ByteBuffer inputData, int inputSize, SimpleDecoderOutputBuffer decoderOutputBuffer, ByteBuffer outputData, int outputSize);
|
||||
long context,
|
||||
ByteBuffer inputData,
|
||||
int inputSize,
|
||||
SimpleDecoderOutputBuffer decoderOutputBuffer,
|
||||
ByteBuffer outputData,
|
||||
int outputSize);
|
||||
|
||||
private native int ffmpegGetChannelCount(long context);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user