File tree Expand file tree Collapse file tree 5 files changed +19
-15
lines changed
src/main/java/net/ypresto/androidtranscoder Expand file tree Collapse file tree 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
99(https://android.googlesource.com/platform/cts/), which is developed by
1010The Android Open Source Project (https://source.android.com/) and
1111is 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 {
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- }
Original file line number Diff line number Diff line change 1919
2020import net .ypresto .androidtranscoder .format .MediaFormatExtraConstants ;
2121import 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
2624import java .nio .ByteBuffer ;
2725
2826class 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
Original file line number Diff line number Diff 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 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