Skip to content

Commit 8dd2362

Browse files
committed
Remove jcodec dependency
Closes #11
1 parent ecb2693 commit 8dd2362

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

NOTICE

-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ Android Compatibility Test Suite
99
(https://android.googlesource.com/platform/cts/), which is developed by
1010
The Android Open Source Project (https://source.android.com/) and
1111
is available under a "Apache License 2.0".
12-
13-
This product depends on jcodec (http://jcodec.org/), which is developed
14-
by The JCodec project and available under a "FreeBSD license".

lib/build.gradle

-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,3 @@ publish {
3838
autoPublish = false
3939
dryRun = false
4040
}
41-
42-
dependencies {
43-
compile 'org.jcodec:jcodec:0.1.9'
44-
compile fileTree(dir: 'libs', include: ['*.jar'])
45-
}

lib/src/main/java/net/ypresto/androidtranscoder/engine/MediaFormatValidator.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919

2020
import net.ypresto.androidtranscoder.format.MediaFormatExtraConstants;
2121
import net.ypresto.androidtranscoder.utils.AvcCsdUtils;
22-
23-
import org.jcodec.codecs.h264.H264Utils;
24-
import org.jcodec.codecs.h264.io.model.SeqParameterSet;
22+
import net.ypresto.androidtranscoder.utils.AvcSpsUtils;
2523

2624
import java.nio.ByteBuffer;
2725

2826
class MediaFormatValidator {
2927
// Refer: http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles
30-
private static final int PROFILE_IDC_BASELINE = 66;
28+
private static final byte PROFILE_IDC_BASELINE = 66;
3129

3230
public static void validateVideoOutputFormat(MediaFormat format) {
3331
String mime = format.getString(MediaFormat.KEY_MIME);
@@ -37,9 +35,9 @@ public static void validateVideoOutputFormat(MediaFormat format) {
3735
throw new InvalidOutputFormatException("Video codecs other than AVC is not supported, actual mime type: " + mime);
3836
}
3937
ByteBuffer spsBuffer = AvcCsdUtils.getSpsBuffer(format);
40-
SeqParameterSet sps = H264Utils.readSPS(spsBuffer);
41-
if (sps.profile_idc != PROFILE_IDC_BASELINE) {
42-
throw new InvalidOutputFormatException("Non-baseline AVC video profile is not supported by Android OS, actual profile_idc: " + sps.profile_idc);
38+
byte profileIdc = AvcSpsUtils.getProfileIdc(spsBuffer);
39+
if (profileIdc != PROFILE_IDC_BASELINE) {
40+
throw new InvalidOutputFormatException("Non-baseline AVC video profile is not supported by Android OS, actual profile_idc: " + profileIdc);
4341
}
4442
}
4543

lib/src/main/java/net/ypresto/androidtranscoder/utils/AvcCsdUtils.java

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class AvcCsdUtils {
3030
// Refer: http://www.cardinalpeak.com/blog/the-h-264-sequence-parameter-set/
3131
private static final byte AVC_SPS_NAL = 103; // 0<<7 + 3<<5 + 7<<0
3232

33+
/**
34+
* @return ByteBuffer contains SPS without NAL header.
35+
*/
3336
public static ByteBuffer getSpsBuffer(MediaFormat format) {
3437
ByteBuffer sourceBuffer = format.getByteBuffer(MediaFormatExtraConstants.KEY_AVC_SPS).asReadOnlyBuffer(); // might be direct buffer
3538
ByteBuffer prefixedSpsBuffer = ByteBuffer.allocate(sourceBuffer.limit()).order(sourceBuffer.order());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.ypresto.androidtranscoder.utils;
2+
3+
import java.nio.ByteBuffer;
4+
5+
public class AvcSpsUtils {
6+
public static byte getProfileIdc(ByteBuffer spsBuffer) {
7+
// Refer: http://www.cardinalpeak.com/blog/the-h-264-sequence-parameter-set/
8+
// First byte after NAL.
9+
return spsBuffer.get(0);
10+
}
11+
}

0 commit comments

Comments
 (0)