Commit e9fcc967 by Dustin

Added copyright, better comments, removed dead code.

parent 0896a04d
Showing with 643 additions and 57 deletions
...@@ -55,7 +55,6 @@ public final class MimeTypes { ...@@ -55,7 +55,6 @@ public final class MimeTypes {
public static final String VIDEO_DOLBY_VISION = BASE_TYPE_VIDEO + "/dolby-vision"; public static final String VIDEO_DOLBY_VISION = BASE_TYPE_VIDEO + "/dolby-vision";
public static final String VIDEO_OGG = BASE_TYPE_VIDEO + "/ogg"; public static final String VIDEO_OGG = BASE_TYPE_VIDEO + "/ogg";
public static final String VIDEO_AVI = BASE_TYPE_VIDEO + "/x-msvideo"; public static final String VIDEO_AVI = BASE_TYPE_VIDEO + "/x-msvideo";
//This exists on Nvidia Shield
public static final String VIDEO_MJPEG = BASE_TYPE_VIDEO + "/mjpeg"; public static final String VIDEO_MJPEG = BASE_TYPE_VIDEO + "/mjpeg";
public static final String VIDEO_UNKNOWN = BASE_TYPE_VIDEO + "/x-unknown"; public static final String VIDEO_UNKNOWN = BASE_TYPE_VIDEO + "/x-unknown";
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import android.util.SparseArray; import android.util.SparseArray;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/**
* Wrapper for the WAVEFORMATEX structure
*/
public class AudioFormat { public class AudioFormat {
public static final short WAVE_FORMAT_PCM = 1; public static final short WAVE_FORMAT_PCM = 1;
static final short WAVE_FORMAT_AAC = 0xff; static final short WAVE_FORMAT_AAC = 0xff;
...@@ -19,9 +37,8 @@ public class AudioFormat { ...@@ -19,9 +37,8 @@ public class AudioFormat {
FORMAT_MAP.put(WAVE_FORMAT_DTS2, MimeTypes.AUDIO_DTS); FORMAT_MAP.put(WAVE_FORMAT_DTS2, MimeTypes.AUDIO_DTS);
} }
private ByteBuffer byteBuffer; private final ByteBuffer byteBuffer;
//WAVEFORMATEX
public AudioFormat(ByteBuffer byteBuffer) { public AudioFormat(ByteBuffer byteBuffer) {
this.byteBuffer = byteBuffer; this.byteBuffer = byteBuffer;
} }
...@@ -43,9 +60,6 @@ public class AudioFormat { ...@@ -43,9 +60,6 @@ public class AudioFormat {
return byteBuffer.getInt(8); return byteBuffer.getInt(8);
} }
// 12 - nBlockAlign // 12 - nBlockAlign
// public int getBlockAlign() {
// return byteBuffer.getShort(12);
// }
public short getBitsPerSample() { public short getBitsPerSample() {
return byteBuffer.getShort(14); return byteBuffer.getShort(14);
} }
...@@ -62,6 +76,4 @@ public class AudioFormat { ...@@ -62,6 +76,4 @@ public class AudioFormat {
temp.get(data); temp.get(data);
return data; return data;
} }
//TODO: Deal with WAVEFORMATEXTENSIBLE
} }
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -10,11 +25,11 @@ import java.io.IOException; ...@@ -10,11 +25,11 @@ import java.io.IOException;
/** /**
* Corrects the time and PAR for H264 streams * Corrects the time and PAR for H264 streams
* H264 is very rare in AVI due to the rise of mp4 * AVC is very rare in AVI due to the rise of the mp4 container
*/ */
public class AvcChunkPeeker extends NalChunkPeeker { public class AvcChunkPeeker extends NalChunkPeeker {
private static final int NAL_TYPE_MASK = 0x1f; private static final int NAL_TYPE_MASK = 0x1f;
private static final int NAL_TYPE_IRD = 5; private static final int NAL_TYPE_IDR = 5; //I Frame
private static final int NAL_TYPE_SEI = 6; private static final int NAL_TYPE_SEI = 6;
private static final int NAL_TYPE_SPS = 7; private static final int NAL_TYPE_SPS = 7;
private static final int NAL_TYPE_PPS = 8; private static final int NAL_TYPE_PPS = 8;
...@@ -108,7 +123,7 @@ public class AvcChunkPeeker extends NalChunkPeeker { ...@@ -108,7 +123,7 @@ public class AvcChunkPeeker extends NalChunkPeeker {
case 4: case 4:
updatePicCountClock(nalTypeOffset); updatePicCountClock(nalTypeOffset);
return; return;
case NAL_TYPE_IRD: case NAL_TYPE_IDR:
picCountClock.syncIndexes(); picCountClock.syncIndexes();
return; return;
case NAL_TYPE_AUD: case NAL_TYPE_AUD:
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -20,11 +35,11 @@ import java.util.Collections; ...@@ -20,11 +35,11 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
/** /**
* Based on the official MicroSoft spec * Extractor based on the official MicroSoft spec
* https://docs.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference * https://docs.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference
*/ */
public class AviExtractor implements Extractor { public class AviExtractor implements Extractor {
//Minimum time between keyframes in the SeekMap //Minimum time between keyframes in the AviSeekMap
static final long MIN_KEY_FRAME_RATE_US = 2_000_000L; static final long MIN_KEY_FRAME_RATE_US = 2_000_000L;
static final long UINT_MASK = 0xffffffffL; static final long UINT_MASK = 0xffffffffL;
...@@ -130,9 +145,7 @@ public class AviExtractor implements Extractor { ...@@ -130,9 +145,7 @@ public class AviExtractor implements Extractor {
@VisibleForTesting @VisibleForTesting
AviSeekMap aviSeekMap; AviSeekMap aviSeekMap;
// private long indexOffset; //Usually chunkStart //Set if a chunk is only partially read
//If partial read
private transient AviTrack chunkHandler; private transient AviTrack chunkHandler;
/** /**
...@@ -379,13 +392,7 @@ public class AviExtractor implements Extractor { ...@@ -379,13 +392,7 @@ public class AviExtractor implements Extractor {
w("Audio is not all key frames chunks=" + aviTrack.chunks + " keyFrames=" + w("Audio is not all key frames chunks=" + aviTrack.chunks + " keyFrames=" +
keyFrameCounts[aviTrack.id]); keyFrameCounts[aviTrack.id]);
} }
} /* else if (aviTrack.isVideo()) {
final LinearClock clock = aviTrack.getClock();
if (clock.length != aviTrack.chunks) {
w("Video #" + aviTrack.id + " chunks != length changing FPS");
clock.setLength(aviTrack.chunks);
} }
}*/
} }
} }
} }
...@@ -447,8 +454,6 @@ public class AviExtractor implements Extractor { ...@@ -447,8 +454,6 @@ public class AviExtractor implements Extractor {
} }
final int flags = indexByteBuffer.getInt(); final int flags = indexByteBuffer.getInt();
final int offset = indexByteBuffer.getInt(); final int offset = indexByteBuffer.getInt();
//Skip size
//indexByteBuffer.position(indexByteBuffer.position() + 4);
final int size = indexByteBuffer.getInt(); final int size = indexByteBuffer.getInt();
if ((flags & AVIIF_KEYFRAME) == AVIIF_KEYFRAME) { if ((flags & AVIIF_KEYFRAME) == AVIIF_KEYFRAME) {
if (aviTrack.isVideo()) { if (aviTrack.isVideo()) {
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/**
* Wrapper around the AVIMAINHEADER structure
*/
public class AviHeaderBox extends ResidentBox { public class AviHeaderBox extends ResidentBox {
static final int LEN = 0x38; static final int LEN = 0x38;
static final int AVIF_HASINDEX = 0x10; static final int AVIF_HASINDEX = 0x10;
private static final int AVIF_MUSTUSEINDEX = 0x20; private static final int AVIF_MUSTUSEINDEX = 0x20;
static final int AVIH = 'a' | ('v' << 8) | ('i' << 16) | ('h' << 24); static final int AVIH = 'a' | ('v' << 8) | ('i' << 16) | ('h' << 24);
//AVIMAINHEADER
AviHeaderBox(int type, int size, ByteBuffer byteBuffer) { AviHeaderBox(int type, int size, ByteBuffer byteBuffer) {
super(type, size, byteBuffer); super(type, size, byteBuffer);
} }
...@@ -39,9 +55,6 @@ public class AviHeaderBox extends ResidentBox { ...@@ -39,9 +55,6 @@ public class AviHeaderBox extends ResidentBox {
} }
// 20 - dwInitialFrames // 20 - dwInitialFrames
// int getInitialFrames() {
// return byteBuffer.getInt(20);
// }
int getStreams() { int getStreams() {
return byteBuffer.getInt(24); return byteBuffer.getInt(24);
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -6,6 +21,10 @@ import com.google.android.exoplayer2.extractor.SeekMap; ...@@ -6,6 +21,10 @@ import com.google.android.exoplayer2.extractor.SeekMap;
import com.google.android.exoplayer2.extractor.SeekPoint; import com.google.android.exoplayer2.extractor.SeekPoint;
import java.util.Arrays; import java.util.Arrays;
/**
* Seek map for AVI.
* Consists of Video chunk offsets and indexes for all streams
*/
public class AviSeekMap implements SeekMap { public class AviSeekMap implements SeekMap {
final int videoId; final int videoId;
final long videoUsPerChunk; final long videoUsPerChunk;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -5,12 +20,12 @@ import androidx.annotation.Nullable; ...@@ -5,12 +20,12 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.util.Log;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
/** /**
* Collection of info about a track * Collection of info about a track.
* This acts a bridge between AVI and ExoPlayer structures
*/ */
public class AviTrack { public class AviTrack {
public static final int[] ALL_KEY_FRAMES = new int[0]; public static final int[] ALL_KEY_FRAMES = new int[0];
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
/** /**
* This is referred to as a Chunk in the MS spec, but that gets confusing with AV chunks * This is referred to as a Chunk in the MS spec, but that gets confusing with AV chunks.
* Borrowed the term from mp4 as these are similar to boxes or atoms.
*/ */
public class Box { public class Box {
private final int size; private final int size;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
...@@ -5,6 +20,9 @@ import java.io.IOException; ...@@ -5,6 +20,9 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
/**
* Factory for Boxes. These usually exist inside a ListBox
*/
public class BoxFactory { public class BoxFactory {
static int[] types = {AviHeaderBox.AVIH, StreamHeaderBox.STRH, StreamFormatBox.STRF, StreamNameBox.STRN}; static int[] types = {AviHeaderBox.AVIH, StreamHeaderBox.STRH, StreamFormatBox.STRF, StreamNameBox.STRN};
static { static {
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
import java.io.IOException; import java.io.IOException;
/**
* Peeks for import data in the chunk stream.
*/
public interface ChunkPeeker { public interface ChunkPeeker {
void peek(ExtractorInput input, final int size) throws IOException; void peek(ExtractorInput input, final int size) throws IOException;
} }
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
/**
* A clock that is linearly derived from the current chunk index of a given stream
*/
public class LinearClock { public class LinearClock {
long durationUs; long durationUs;
int length; int length;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -9,7 +24,7 @@ import java.util.ArrayList; ...@@ -9,7 +24,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* An AVI LIST box, memory resident * An AVI LIST box. Similar to a Java List<Box>
*/ */
public class ListBox extends Box { public class ListBox extends Box {
public static final int LIST = 'L' | ('I' << 8) | ('S' << 16) | ('T' << 24); public static final int LIST = 'L' | ('I' << 8) | ('S' << 16) | ('T' << 24);
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -8,6 +23,9 @@ import com.google.android.exoplayer2.extractor.TrackOutput; ...@@ -8,6 +23,9 @@ import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.util.ParsableNalUnitBitArray; import com.google.android.exoplayer2.util.ParsableNalUnitBitArray;
import java.io.IOException; import java.io.IOException;
/**
* Peeks an MP4V stream looking for pixelWidthHeightRatio data
*/
public class Mp4vChunkPeeker extends NalChunkPeeker { public class Mp4vChunkPeeker extends NalChunkPeeker {
@VisibleForTesting @VisibleForTesting
static final byte SEQUENCE_START_CODE = (byte)0xb0; static final byte SEQUENCE_START_CODE = (byte)0xb0;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
/**
* Generic base class for NAL (0x00 0x00 0x01) chunk headers
* Theses are used by AVC and MP4V (XVID)
*/
public abstract class NalChunkPeeker implements ChunkPeeker { public abstract class NalChunkPeeker implements ChunkPeeker {
private static final int SEEK_PEEK_SIZE = 256; private static final int SEEK_PEEK_SIZE = 256;
private final int peekSize; private final int peekSize;
...@@ -105,9 +124,4 @@ public abstract class NalChunkPeeker implements ChunkPeeker { ...@@ -105,9 +124,4 @@ public abstract class NalChunkPeeker implements ChunkPeeker {
processChunk(input, nalTypeOffset); processChunk(input, nalTypeOffset);
input.resetPeekPosition(); input.resetPeekPosition();
} }
// @VisibleForTesting(otherwise = VisibleForTesting.NONE)
// void setBuffer(byte[] buffer) {
// this.buffer = buffer;
// }
} }
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -15,8 +30,6 @@ import java.nio.ByteOrder; ...@@ -15,8 +30,6 @@ import java.nio.ByteOrder;
* A box that is resident in memory * A box that is resident in memory
*/ */
public class ResidentBox extends Box { public class ResidentBox extends Box {
private static final String TAG = AviExtractor.TAG;
final private static int MAX_RESIDENT = 1024;
final ByteBuffer byteBuffer; final ByteBuffer byteBuffer;
ResidentBox(int type, int size, ByteBuffer byteBuffer) { ResidentBox(int type, int size, ByteBuffer byteBuffer) {
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/**
* Wrapper around the various StreamFormats
*/
public class StreamFormatBox extends ResidentBox { public class StreamFormatBox extends ResidentBox {
public static final int STRF = 's' | ('t' << 8) | ('r' << 16) | ('f' << 24); public static final int STRF = 's' | ('t' << 8) | ('r' << 16) | ('f' << 24);
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
* AVISTREAMHEADER * Wrapper around the AVISTREAMHEADER structure
*/ */
public class StreamHeaderBox extends ResidentBox { public class StreamHeaderBox extends ResidentBox {
public static final int STRH = 's' | ('t' << 8) | ('r' << 16) | ('h' << 24); public static final int STRH = 's' | ('t' << 8) | ('r' << 16) | ('h' << 24);
...@@ -51,9 +66,6 @@ public class StreamHeaderBox extends ResidentBox { ...@@ -51,9 +66,6 @@ public class StreamHeaderBox extends ResidentBox {
return byteBuffer.getInt(24); return byteBuffer.getInt(24);
} }
//28 - dwStart - doesn't seem to ever be set //28 - dwStart - doesn't seem to ever be set
// public int getStart() {
// return byteBuffer.getInt(28);
// }
public int getLength() { public int getLength() {
return byteBuffer.getInt(32); return byteBuffer.getInt(32);
} }
...@@ -63,11 +75,8 @@ public class StreamHeaderBox extends ResidentBox { ...@@ -63,11 +75,8 @@ public class StreamHeaderBox extends ResidentBox {
} }
//40 - dwQuality //40 - dwQuality
//44 - dwSampleSize //44 - dwSampleSize
// public int getSampleSize() {
// return byteBuffer.getInt(44);
// }
// public String toString() { public String toString() {
// return "scale=" + getScale() + " rate=" + getRate() + " length=" + getLength() + " us=" + getDurationUs(); return "scale=" + getScale() + " rate=" + getRate() + " length=" + getLength() + " us=" + getDurationUs();
// } }
} }
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/**
* Human readable stream name
*/
public class StreamNameBox extends ResidentBox { public class StreamNameBox extends ResidentBox {
public static final int STRN = 's' | ('t' << 8) | ('r' << 16) | ('n' << 24); public static final int STRN = 's' | ('t' << 8) | ('r' << 16) | ('n' << 24);
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import java.util.Arrays; import java.util.Arrays;
/**
* Optimized unbounded array of ints.
* Used primarily to create Index (SeekMap) data.
*/
public class UnboundedIntArray { public class UnboundedIntArray {
@NonNull @NonNull
@VisibleForTesting @VisibleForTesting
int[] array; int[] array;
//unint //uint
private int size =0; private int size = 0;
public UnboundedIntArray() { public UnboundedIntArray() {
this(8); this(8);
...@@ -58,8 +77,6 @@ public class UnboundedIntArray { ...@@ -58,8 +77,6 @@ public class UnboundedIntArray {
/** /**
* Only works if values are in sequential order * Only works if values are in sequential order
* @param v
* @return
*/ */
public int indexOf(int v) { public int indexOf(int v) {
return Arrays.binarySearch(array, v); return Arrays.binarySearch(array, v);
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -5,6 +20,9 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -5,6 +20,9 @@ import com.google.android.exoplayer2.util.MimeTypes;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.HashMap; import java.util.HashMap;
/**
* Wrapper around the BITMAPINFOHEADER structure
*/
public class VideoFormat { public class VideoFormat {
static final int XVID = 'X' | ('V' << 8) | ('I' << 16) | ('D' << 24); static final int XVID = 'X' | ('V' << 8) | ('I' << 16) | ('D' << 24);
...@@ -39,7 +57,7 @@ public class VideoFormat { ...@@ -39,7 +57,7 @@ public class VideoFormat {
this.byteBuffer = byteBuffer; this.byteBuffer = byteBuffer;
} }
//biSize - (uint) // 0 - biSize - (uint)
public int getWidth() { public int getWidth() {
return byteBuffer.getInt(4); return byteBuffer.getInt(4);
...@@ -71,5 +89,4 @@ public class VideoFormat { ...@@ -71,5 +89,4 @@ public class VideoFormat {
public void setCompression(final int compression) { public void setCompression(final int compression) {
byteBuffer.putInt(16, compression); byteBuffer.putInt(16, compression);
} }
} }
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import android.content.Context; import android.content.Context;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import java.nio.ByteBuffer;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.extractor.SeekMap; import com.google.android.exoplayer2.extractor.SeekMap;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import org.junit.Assert; import org.junit.Assert;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import android.content.Context; import android.content.Context;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import org.junit.Assert; import org.junit.Assert;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import android.content.Context; import android.content.Context;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.testutil.FakeExtractorInput; import com.google.android.exoplayer2.testutil.FakeExtractorInput;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import org.junit.Assert; import org.junit.Assert;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.testutil.FakeExtractorInput; import com.google.android.exoplayer2.testutil.FakeExtractorInput;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import org.junit.Assert; import org.junit.Assert;
......
/*
* Copyright (C) 2022 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.extractor.avi; package com.google.android.exoplayer2.extractor.avi;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment