File tree 5 files changed +19
-15
lines changed
src/main/java/net/ypresto/androidtranscoder
5 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,3 @@ Android Compatibility Test Suite
9
9
(https://android.googlesource.com/platform/cts/), which is developed by
10
10
The Android Open Source Project (https://source.android.com/) and
11
11
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".
Original file line number Diff line number Diff line change @@ -38,8 +38,3 @@ publish {
38
38
autoPublish = false
39
39
dryRun = false
40
40
}
41
-
42
- dependencies {
43
- compile ' org.jcodec:jcodec:0.1.9'
44
- compile fileTree(dir : ' libs' , include : [' *.jar' ])
45
- }
Original file line number Diff line number Diff line change 19
19
20
20
import net .ypresto .androidtranscoder .format .MediaFormatExtraConstants ;
21
21
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 ;
25
23
26
24
import java .nio .ByteBuffer ;
27
25
28
26
class MediaFormatValidator {
29
27
// 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 ;
31
29
32
30
public static void validateVideoOutputFormat (MediaFormat format ) {
33
31
String mime = format .getString (MediaFormat .KEY_MIME );
@@ -37,9 +35,9 @@ public static void validateVideoOutputFormat(MediaFormat format) {
37
35
throw new InvalidOutputFormatException ("Video codecs other than AVC is not supported, actual mime type: " + mime );
38
36
}
39
37
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 );
43
41
}
44
42
}
45
43
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ public class AvcCsdUtils {
30
30
// Refer: http://www.cardinalpeak.com/blog/the-h-264-sequence-parameter-set/
31
31
private static final byte AVC_SPS_NAL = 103 ; // 0<<7 + 3<<5 + 7<<0
32
32
33
+ /**
34
+ * @return ByteBuffer contains SPS without NAL header.
35
+ */
33
36
public static ByteBuffer getSpsBuffer (MediaFormat format ) {
34
37
ByteBuffer sourceBuffer = format .getByteBuffer (MediaFormatExtraConstants .KEY_AVC_SPS ).asReadOnlyBuffer (); // might be direct buffer
35
38
ByteBuffer prefixedSpsBuffer = ByteBuffer .allocate (sourceBuffer .limit ()).order (sourceBuffer .order ());
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments