Bug fix: 368813 Transition is regenerated when overlay duration changes outside the transition

Change-Id: I8217e7fe00392455427e117dc54c3461301f95c5
This commit is contained in:
Gil Dobjanschi
2011-01-19 12:07:01 -08:00
parent fe93351cf1
commit c4edeb5a60
2 changed files with 137 additions and 91 deletions

View File

@@ -93,29 +93,28 @@ public class MediaImageItem extends MediaItem {
* *
* @throws IOException * @throws IOException
*/ */
public MediaImageItem(VideoEditor editor, String mediaItemId, public MediaImageItem(VideoEditor editor, String mediaItemId, String filename, long durationMs,
String filename, long durationMs, int renderingMode) throws IOException {
int renderingMode) throws IOException {
super(editor, mediaItemId, filename, renderingMode); super(editor, mediaItemId, filename, renderingMode);
mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext(); mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext();
mVideoEditor = ((VideoEditorImpl)editor); mVideoEditor = ((VideoEditorImpl)editor);
try { try {
final Properties properties = final Properties properties = mMANativeHelper.getMediaProperties(filename);
mMANativeHelper.getMediaProperties(filename);
switch (mMANativeHelper.getFileType(properties.fileType)) { switch (mMANativeHelper.getFileType(properties.fileType)) {
case MediaProperties.FILE_JPEG: case MediaProperties.FILE_JPEG:
case MediaProperties.FILE_PNG: {
break; break;
case MediaProperties.FILE_PNG: }
break;
default: default: {
throw new IllegalArgumentException("Unsupported Input File Type"); throw new IllegalArgumentException("Unsupported Input File Type");
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("Unsupported file or file not found"); throw new IllegalArgumentException("Unsupported file or file not found: " + filename);
} }
/** /**
@@ -130,13 +129,13 @@ public class MediaImageItem extends MediaItem {
mDurationMs = durationMs; mDurationMs = durationMs;
mDecodedFilename = String.format(mMANativeHelper.getProjectPath() + mDecodedFilename = String.format(mMANativeHelper.getProjectPath() +
"/" + "decoded" + getId()+ ".rgb"); "/" + "decoded" + getId()+ ".rgb");
final FileOutputStream fl = new FileOutputStream(mDecodedFilename);
final DataOutputStream dos = new DataOutputStream(fl);
try { try {
mAspectRatio = mMANativeHelper.getAspectRatio(mWidth, mHeight); mAspectRatio = mMANativeHelper.getAspectRatio(mWidth, mHeight);
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
throw new IllegalArgumentException ("Null width and height"); throw new IllegalArgumentException ("Null width and height");
} }
mGeneratedClipHeight = 0; mGeneratedClipHeight = 0;
mGeneratedClipWidth = 0; mGeneratedClipWidth = 0;
@@ -146,9 +145,12 @@ public class MediaImageItem extends MediaItem {
*/ */
final Pair<Integer, Integer>[] resolutions = final Pair<Integer, Integer>[] resolutions =
MediaProperties.getSupportedResolutions(mAspectRatio); MediaProperties.getSupportedResolutions(mAspectRatio);
/** /**
* Get the highest resolution * Get the highest resolution
*/ */
final FileOutputStream fl = new FileOutputStream(mDecodedFilename);
final DataOutputStream dos = new DataOutputStream(fl);
final Pair<Integer, Integer> maxResolution = resolutions[resolutions.length - 1]; final Pair<Integer, Integer> maxResolution = resolutions[resolutions.length - 1];
if (mHeight > maxResolution.second) { if (mHeight > maxResolution.second) {
/** /**
@@ -171,16 +173,16 @@ public class MediaImageItem extends MediaItem {
int mNewHeight = 0; int mNewHeight = 0;
if ((mScaledWidth % 2 ) != 0) { if ((mScaledWidth % 2 ) != 0) {
mNewWidth = mScaledWidth - 1; mNewWidth = mScaledWidth - 1;
} } else {
else {
mNewWidth = mScaledWidth; mNewWidth = mScaledWidth;
} }
if ((mScaledHeight % 2 ) != 0) { if ((mScaledHeight % 2 ) != 0) {
mNewHeight = mScaledHeight - 1; mNewHeight = mScaledHeight - 1;
} } else {
else {
mNewHeight = mScaledHeight; mNewHeight = mScaledHeight;
} }
final int [] framingBuffer = new int[mNewWidth]; final int [] framingBuffer = new int[mNewWidth];
final ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4); final ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4);
IntBuffer intBuffer; IntBuffer intBuffer;
@@ -195,6 +197,7 @@ public class MediaImageItem extends MediaItem {
dos.write(array); dos.write(array);
tmp += 1; tmp += 1;
} }
mScaledWidth = mNewWidth; mScaledWidth = mNewWidth;
mScaledHeight = mNewHeight; mScaledHeight = mNewHeight;
scaledImage.recycle(); scaledImage.recycle();
@@ -204,10 +207,11 @@ public class MediaImageItem extends MediaItem {
+ "/" + "scaled" + getId()+ ".JPG"); + "/" + "scaled" + getId()+ ".JPG");
if (!((new File(mScaledFilename)).exists())) { if (!((new File(mScaledFilename)).exists())) {
super.mRegenerateClip = true; super.mRegenerateClip = true;
FileOutputStream f1 = new FileOutputStream(mScaledFilename); final FileOutputStream f1 = new FileOutputStream(mScaledFilename);
scaledImage.compress(Bitmap.CompressFormat.JPEG, 50,f1); scaledImage.compress(Bitmap.CompressFormat.JPEG, 50,f1);
f1.close(); f1.close();
} }
mScaledWidth = scaledImage.getWidth(); mScaledWidth = scaledImage.getWidth();
mScaledHeight = scaledImage.getHeight(); mScaledHeight = scaledImage.getHeight();
@@ -215,17 +219,17 @@ public class MediaImageItem extends MediaItem {
int mNewheight = 0; int mNewheight = 0;
if ((mScaledWidth % 2 ) != 0) { if ((mScaledWidth % 2 ) != 0) {
mNewWidth = mScaledWidth - 1; mNewWidth = mScaledWidth - 1;
} } else {
else {
mNewWidth = mScaledWidth; mNewWidth = mScaledWidth;
} }
if ((mScaledHeight % 2 ) != 0) { if ((mScaledHeight % 2 ) != 0) {
mNewheight = mScaledHeight - 1; mNewheight = mScaledHeight - 1;
} } else {
else {
mNewheight = mScaledHeight; mNewheight = mScaledHeight;
} }
Bitmap imageBitmap = BitmapFactory.decodeFile(mScaledFilename);
final Bitmap imageBitmap = BitmapFactory.decodeFile(mScaledFilename);
final int [] framingBuffer = new int[mNewWidth]; final int [] framingBuffer = new int[mNewWidth];
ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4); ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4);
IntBuffer intBuffer; IntBuffer intBuffer;
@@ -240,10 +244,12 @@ public class MediaImageItem extends MediaItem {
dos.write(array); dos.write(array);
tmp += 1; tmp += 1;
} }
mScaledWidth = mNewWidth; mScaledWidth = mNewWidth;
mScaledHeight = mNewheight; mScaledHeight = mNewheight;
imageBitmap.recycle(); imageBitmap.recycle();
} }
fl.close(); fl.close();
System.gc(); System.gc();
} }
@@ -286,7 +292,7 @@ public class MediaImageItem extends MediaItem {
/** /**
* @return The file name of image which is decoded and stored * @return The file name of image which is decoded and stored
* in rgb format * in RGB format
*/ */
String getDecodedImageFileName() { String getDecodedImageFileName() {
return mDecodedFilename; return mDecodedFilename;
@@ -447,7 +453,7 @@ public class MediaImageItem extends MediaItem {
* Check if the effect overlaps with the end transition * Check if the effect overlaps with the end transition
*/ */
if (effect.getStartTime() + effect.getDuration() > if (effect.getStartTime() + effect.getDuration() >
mDurationMs - transitionDurationMs) { mDurationMs - transitionDurationMs) {
mEndTransition.invalidate(); mEndTransition.invalidate();
break; break;
} }
@@ -464,7 +470,7 @@ public class MediaImageItem extends MediaItem {
* Check if the overlay overlaps with the end transition * Check if the overlay overlaps with the end transition
*/ */
if (overlay.getStartTime() + overlay.getDuration() > if (overlay.getStartTime() + overlay.getDuration() >
mDurationMs - transitionDurationMs) { mDurationMs - transitionDurationMs) {
mEndTransition.invalidate(); mEndTransition.invalidate();
break; break;
} }
@@ -648,23 +654,24 @@ public class MediaImageItem extends MediaItem {
for (int i = 0; i < thumbnailCount; i++) { for (int i = 0; i < thumbnailCount; i++) {
thumbnailArray[i] = thumbnail; thumbnailArray[i] = thumbnail;
} }
return thumbnailArray; return thumbnailArray;
} else {
}
else {
if (startMs > endMs) { if (startMs > endMs) {
throw new IllegalArgumentException("Start time is greater than end time"); throw new IllegalArgumentException("Start time is greater than end time");
} }
if (endMs > mDurationMs) { if (endMs > mDurationMs) {
throw new IllegalArgumentException("End time is greater than file duration"); throw new IllegalArgumentException("End time is greater than file duration");
} }
if (startMs == endMs) { if (startMs == endMs) {
Bitmap[] bitmap = new Bitmap[1]; Bitmap[] bitmap = new Bitmap[1];
bitmap[0] = mMANativeHelper.getPixels(getGeneratedImageClip(), bitmap[0] = mMANativeHelper.getPixels(getGeneratedImageClip(),
width, height,startMs); width, height,startMs);
return bitmap; return bitmap;
} }
return mMANativeHelper.getPixelsList(getGeneratedImageClip(), width, return mMANativeHelper.getPixelsList(getGeneratedImageClip(), width,
height,startMs,endMs,thumbnailCount); height,startMs,endMs,thumbnailCount);
} }
@@ -704,31 +711,51 @@ public class MediaImageItem extends MediaItem {
*/ */
if (mBeginTransition != null) { if (mBeginTransition != null) {
final long transitionDurationMs = mBeginTransition.getDuration(); final long transitionDurationMs = mBeginTransition.getDuration();
final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs, 0,
transitionDurationMs);
final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs, 0,
transitionDurationMs);
/** /**
* If the start time has changed and if the old or the new item * Invalidate transition if:
* overlaps with the begin transition, invalidate the transition. *
* 1. New item overlaps the transition, the old one did not
* 2. New item does not overlap the transition, the old one did
* 3. New and old item overlap the transition if begin or end
* time changed
*/ */
if (((oldStartTimeMs != newStartTimeMs) if (newOverlap != oldOverlap) { // Overlap has changed
|| (oldDurationMs != newDurationMs) )&&
(isOverlapping(oldStartTimeMs, oldDurationMs, 0, transitionDurationMs) ||
isOverlapping(newStartTimeMs, newDurationMs, 0,
transitionDurationMs))) {
mBeginTransition.invalidate(); mBeginTransition.invalidate();
} else if (newOverlap) { // Both old and new overlap
if ((oldStartTimeMs != newStartTimeMs) ||
!(oldStartTimeMs + oldDurationMs > transitionDurationMs &&
newStartTimeMs + newDurationMs > transitionDurationMs)) {
mBeginTransition.invalidate();
}
} }
} }
if (mEndTransition != null) { if (mEndTransition != null) {
final long transitionDurationMs = mEndTransition.getDuration(); final long transitionDurationMs = mEndTransition.getDuration();
final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs,
mDurationMs - transitionDurationMs, transitionDurationMs);
final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs,
mDurationMs - transitionDurationMs, transitionDurationMs);
/** /**
* If the start time + duration has changed and if the old or the new * Invalidate transition if:
* item overlaps the end transition, invalidate the transition *
* 1. New item overlaps the transition, the old one did not
* 2. New item does not overlap the transition, the old one did
* 3. New and old item overlap the transition if begin or end
* time changed
*/ */
if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs && if (newOverlap != oldOverlap) { // Overlap has changed
(isOverlapping(oldStartTimeMs, oldDurationMs,
mDurationMs - transitionDurationMs, transitionDurationMs) ||
isOverlapping(newStartTimeMs, newDurationMs,
mDurationMs - transitionDurationMs, transitionDurationMs))) {
mEndTransition.invalidate(); mEndTransition.invalidate();
} else if (newOverlap) { // Both old and new overlap
if ((oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs) ||
((oldStartTimeMs > mDurationMs - transitionDurationMs) ||
newStartTimeMs > mDurationMs - transitionDurationMs)) {
mEndTransition.invalidate();
}
} }
} }
} }
@@ -743,10 +770,12 @@ public class MediaImageItem extends MediaItem {
setGeneratedImageClip(null); setGeneratedImageClip(null);
setRegenerateClip(true); setRegenerateClip(true);
} }
if (mScaledFilename != null) { if (mScaledFilename != null) {
new File(mScaledFilename).delete(); new File(mScaledFilename).delete();
mScaledFilename = null; mScaledFilename = null;
} }
if (mDecodedFilename != null) { if (mDecodedFilename != null) {
new File(mDecodedFilename).delete(); new File(mDecodedFilename).delete();
mDecodedFilename = null; mDecodedFilename = null;

View File

@@ -78,12 +78,9 @@ public class MediaVideoItem extends MediaItem {
* *
* @throws IOException if the file cannot be opened for reading * @throws IOException if the file cannot be opened for reading
*/ */
public MediaVideoItem(VideoEditor editor, String mediaItemId, public MediaVideoItem(VideoEditor editor, String mediaItemId, String filename,
String filename, int renderingMode) throws IOException {
int renderingMode) this(editor, mediaItemId, filename, renderingMode, 0, END_OF_FILE, 100, false, null);
throws IOException {
this(editor, mediaItemId, filename, renderingMode, 0, END_OF_FILE,
100, false, null);
} }
/** /**
@@ -105,20 +102,22 @@ public class MediaVideoItem extends MediaItem {
* @throws IOException if the file cannot be opened for reading * @throws IOException if the file cannot be opened for reading
*/ */
MediaVideoItem(VideoEditor editor, String mediaItemId, String filename, MediaVideoItem(VideoEditor editor, String mediaItemId, String filename,
int renderingMode, int renderingMode, long beginMs, long endMs, int volumePercent, boolean muted,
long beginMs, long endMs, int volumePercent, boolean muted,
String audioWaveformFilename) throws IOException { String audioWaveformFilename) throws IOException {
super(editor, mediaItemId, filename, renderingMode); super(editor, mediaItemId, filename, renderingMode);
if (editor instanceof VideoEditorImpl) { if (editor instanceof VideoEditorImpl) {
mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext(); mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext();
mVideoEditor = ((VideoEditorImpl)editor); mVideoEditor = ((VideoEditorImpl)editor);
} }
Properties properties = null;
final Properties properties;
try { try {
properties = mMANativeHelper.getMediaProperties(filename); properties = mMANativeHelper.getMediaProperties(filename);
} catch ( Exception e) { } catch ( Exception e) {
throw new IllegalArgumentException("Unsupported file or file not found"); throw new IllegalArgumentException("Unsupported file or file not found: " + filename);
} }
switch (mMANativeHelper.getFileType(properties.fileType)) { switch (mMANativeHelper.getFileType(properties.fileType)) {
case MediaProperties.FILE_3GP: case MediaProperties.FILE_3GP:
break; break;
@@ -163,8 +162,7 @@ public class MediaVideoItem extends MediaItem {
mMuted = muted; mMuted = muted;
mAudioWaveformFilename = audioWaveformFilename; mAudioWaveformFilename = audioWaveformFilename;
if (audioWaveformFilename != null) { if (audioWaveformFilename != null) {
mWaveformData = mWaveformData = new SoftReference<WaveformData>(
new SoftReference<WaveformData>(
new WaveformData(audioWaveformFilename)); new WaveformData(audioWaveformFilename));
} else { } else {
mWaveformData = null; mWaveformData = null;
@@ -190,9 +188,11 @@ public class MediaVideoItem extends MediaItem {
if (beginMs > mDurationMs) { if (beginMs > mDurationMs) {
throw new IllegalArgumentException("setExtractBoundaries: Invalid start time"); throw new IllegalArgumentException("setExtractBoundaries: Invalid start time");
} }
if (endMs > mDurationMs) { if (endMs > mDurationMs) {
throw new IllegalArgumentException("setExtractBoundaries: Invalid end time"); throw new IllegalArgumentException("setExtractBoundaries: Invalid end time");
} }
if ((endMs != -1) && (beginMs >= endMs) ) { if ((endMs != -1) && (beginMs >= endMs) ) {
throw new IllegalArgumentException("setExtractBoundaries: Start time is greater than end time"); throw new IllegalArgumentException("setExtractBoundaries: Start time is greater than end time");
} }
@@ -255,18 +255,18 @@ public class MediaVideoItem extends MediaItem {
*/ */
@Override @Override
public Bitmap getThumbnail(int width, int height, long timeMs) { public Bitmap getThumbnail(int width, int height, long timeMs) {
if (timeMs > mDurationMs) if (timeMs > mDurationMs) {
{
throw new IllegalArgumentException("Time Exceeds duration"); throw new IllegalArgumentException("Time Exceeds duration");
} }
if (timeMs < 0)
{ if (timeMs < 0) {
throw new IllegalArgumentException("Invalid Time duration"); throw new IllegalArgumentException("Invalid Time duration");
} }
if ((width <=0) || (height <= 0))
{ if ((width <=0) || (height <= 0)) {
throw new IllegalArgumentException("Invalid Dimensions"); throw new IllegalArgumentException("Invalid Dimensions");
} }
return mMANativeHelper.getPixels(super.getFilename(), return mMANativeHelper.getPixels(super.getFilename(),
width, height,timeMs); width, height,timeMs);
} }
@@ -280,18 +280,21 @@ public class MediaVideoItem extends MediaItem {
if (startMs > endMs) { if (startMs > endMs) {
throw new IllegalArgumentException("Start time is greater than end time"); throw new IllegalArgumentException("Start time is greater than end time");
} }
if (endMs > mDurationMs) { if (endMs > mDurationMs) {
throw new IllegalArgumentException("End time is greater than file duration"); throw new IllegalArgumentException("End time is greater than file duration");
} }
if ((height <= 0) || (width <= 0)) { if ((height <= 0) || (width <= 0)) {
throw new IllegalArgumentException("Invalid dimension"); throw new IllegalArgumentException("Invalid dimension");
} }
if (startMs == endMs) { if (startMs == endMs) {
Bitmap[] bitmap = new Bitmap[1]; final Bitmap[] bitmap = new Bitmap[1];
bitmap[0] = mMANativeHelper.getPixels(super.getFilename(), bitmap[0] = mMANativeHelper.getPixels(super.getFilename(), width, height,startMs);
width, height,startMs);
return bitmap; return bitmap;
} }
return mMANativeHelper.getPixelsList(super.getFilename(), width, return mMANativeHelper.getPixelsList(super.getFilename(), width,
height,startMs,endMs,thumbnailCount); height,startMs,endMs,thumbnailCount);
} }
@@ -324,40 +327,58 @@ public class MediaVideoItem extends MediaItem {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, long newStartTimeMs,
long newStartTimeMs,
long newDurationMs) { long newDurationMs) {
/** /**
* Check if the item overlaps with the beginning and end transitions * Check if the item overlaps with the beginning and end transitions
*/ */
if (mBeginTransition != null) { if (mBeginTransition != null) {
final long transitionDurationMs = mBeginTransition.getDuration(); final long transitionDurationMs = mBeginTransition.getDuration();
final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs,
mBeginBoundaryTimeMs, transitionDurationMs);
final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs,
mBeginBoundaryTimeMs, transitionDurationMs);
/** /**
* If the start time has changed and if the old or the new item * Invalidate transition if:
* overlaps with the begin transition, invalidate the transition. *
* 1. New item overlaps the transition, the old one did not
* 2. New item does not overlap the transition, the old one did
* 3. New and old item overlap the transition if begin or end
* time changed
*/ */
if (((oldStartTimeMs != newStartTimeMs) if (newOverlap != oldOverlap) { // Overlap has changed
|| (oldDurationMs != newDurationMs) )&&
(isOverlapping(oldStartTimeMs, oldDurationMs,
mBeginBoundaryTimeMs, transitionDurationMs) ||
isOverlapping(newStartTimeMs, newDurationMs,
mBeginBoundaryTimeMs, transitionDurationMs))) {
mBeginTransition.invalidate(); mBeginTransition.invalidate();
} else if (newOverlap) { // Both old and new overlap
if ((oldStartTimeMs != newStartTimeMs) ||
!(oldStartTimeMs + oldDurationMs > transitionDurationMs &&
newStartTimeMs + newDurationMs > transitionDurationMs)) {
mBeginTransition.invalidate();
}
} }
} }
if (mEndTransition != null) { if (mEndTransition != null) {
final long transitionDurationMs = mEndTransition.getDuration(); final long transitionDurationMs = mEndTransition.getDuration();
final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs,
mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs);
final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs,
mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs);
/** /**
* If the start time + duration has changed and if the old or the new * Invalidate transition if:
* item overlaps the end transition, invalidate the transition *
* 1. New item overlaps the transition, the old one did not
* 2. New item does not overlap the transition, the old one did
* 3. New and old item overlap the transition if begin or end
* time changed
*/ */
if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs && if (newOverlap != oldOverlap) { // Overlap has changed
(isOverlapping(oldStartTimeMs, oldDurationMs,
mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs) ||
isOverlapping(newStartTimeMs, newDurationMs,
mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs))) {
mEndTransition.invalidate(); mEndTransition.invalidate();
} else if (newOverlap) { // Both old and new overlap
if ((oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs) ||
((oldStartTimeMs > mEndBoundaryTimeMs - transitionDurationMs) ||
newStartTimeMs > mEndBoundaryTimeMs - transitionDurationMs)) {
mEndTransition.invalidate();
}
} }
} }
} }
@@ -434,7 +455,7 @@ public class MediaVideoItem extends MediaItem {
throw new IllegalArgumentException("requested time not correct"); throw new IllegalArgumentException("requested time not correct");
} }
Surface surface = surfaceHolder.getSurface(); final Surface surface = surfaceHolder.getSurface();
if (surface == null) { if (surface == null) {
throw new RuntimeException("Surface could not be retrieved from Surface holder"); throw new RuntimeException("Surface could not be retrieved from Surface holder");
} }
@@ -442,8 +463,7 @@ public class MediaVideoItem extends MediaItem {
if (mFilename != null) { if (mFilename != null) {
return mMANativeHelper.renderMediaItemPreviewFrame(surface, return mMANativeHelper.renderMediaItemPreviewFrame(surface,
mFilename,timeMs,mWidth,mHeight); mFilename,timeMs,mWidth,mHeight);
} } else {
else {
return 0; return 0;
} }
} }
@@ -462,7 +482,7 @@ public class MediaVideoItem extends MediaItem {
* Audio track * Audio track
*/ */
public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener) public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener)
throws IOException { throws IOException {
int frameDuration = 0; int frameDuration = 0;
int sampleCount = 0; int sampleCount = 0;
final String projectPath = mMANativeHelper.getProjectPath(); final String projectPath = mMANativeHelper.getProjectPath();
@@ -481,19 +501,17 @@ public class MediaVideoItem extends MediaItem {
* Logic to get frame duration = (no. of frames per sample * 1000)/ * Logic to get frame duration = (no. of frames per sample * 1000)/
* sampling frequency * sampling frequency
*/ */
if ( mMANativeHelper.getAudioCodecType(mAudioType) == if (mMANativeHelper.getAudioCodecType(mAudioType) ==
MediaProperties.ACODEC_AMRNB ) { MediaProperties.ACODEC_AMRNB ) {
frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRNB*1000)/ frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRNB*1000)/
MediaProperties.DEFAULT_SAMPLING_FREQUENCY; MediaProperties.DEFAULT_SAMPLING_FREQUENCY;
sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRNB; sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRNB;
} } else if (mMANativeHelper.getAudioCodecType(mAudioType) ==
else if ( mMANativeHelper.getAudioCodecType(mAudioType) ==
MediaProperties.ACODEC_AMRWB ) { MediaProperties.ACODEC_AMRWB ) {
frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRWB * 1000)/ frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRWB * 1000)/
MediaProperties.DEFAULT_SAMPLING_FREQUENCY; MediaProperties.DEFAULT_SAMPLING_FREQUENCY;
sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRWB; sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRWB;
} } else if (mMANativeHelper.getAudioCodecType(mAudioType) ==
else if ( mMANativeHelper.getAudioCodecType(mAudioType) ==
MediaProperties.ACODEC_AAC_LC ) { MediaProperties.ACODEC_AAC_LC ) {
frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AAC * 1000)/ frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AAC * 1000)/
MediaProperties.DEFAULT_SAMPLING_FREQUENCY; MediaProperties.DEFAULT_SAMPLING_FREQUENCY;
@@ -682,5 +700,4 @@ public class MediaVideoItem extends MediaItem {
return clipSettings; return clipSettings;
} }
} }