Merge "Benchmark: Add CSV support"

gugelfrei
Treehugger Robot 5 years ago committed by Gerrit Code Review
commit d7fad5f8ed

@ -28,7 +28,9 @@ import com.android.media.benchmark.library.CodecUtils;
import com.android.media.benchmark.library.Decoder; import com.android.media.benchmark.library.Decoder;
import com.android.media.benchmark.library.Extractor; import com.android.media.benchmark.library.Extractor;
import com.android.media.benchmark.library.Native; import com.android.media.benchmark.library.Native;
import com.android.media.benchmark.library.Stats;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@ -54,6 +56,8 @@ public class DecoderTest {
InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().getTargetContext();
private static final String mInputFilePath = mContext.getString(R.string.input_file_path); private static final String mInputFilePath = mContext.getString(R.string.input_file_path);
private static final String mOutputFilePath = mContext.getString(R.string.output_file_path); private static final String mOutputFilePath = mContext.getString(R.string.output_file_path);
private static final String mStatsFile =
mContext.getFilesDir() + "/Decoder." + System.currentTimeMillis() + ".csv";
private static final String TAG = "DecoderTest"; private static final String TAG = "DecoderTest";
private static final long PER_TEST_TIMEOUT_MS = 60000; private static final long PER_TEST_TIMEOUT_MS = 60000;
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@ -105,6 +109,13 @@ public class DecoderTest {
{"crowd_1920x1080_25fps_4000kbps_h265.mkv", true}}); {"crowd_1920x1080_25fps_4000kbps_h265.mkv", true}});
} }
@BeforeClass
public static void writeStatsHeaderToFile() throws IOException {
Stats mStats = new Stats();
boolean status = mStats.writeStatsHeader(mStatsFile);
assertTrue("Unable to open stats file for writing!", status);
}
@Test(timeout = PER_TEST_TIMEOUT_MS) @Test(timeout = PER_TEST_TIMEOUT_MS)
public void testDecoder() throws IOException { public void testDecoder() throws IOException {
File inputFile = new File(mInputFilePath + mInputFile); File inputFile = new File(mInputFilePath + mInputFile);
@ -162,7 +173,8 @@ public class DecoderTest {
decoder.deInitCodec(); decoder.deInitCodec();
assertEquals("Decoder returned error " + status + " for file: " + mInputFile + assertEquals("Decoder returned error " + status + " for file: " + mInputFile +
" with codec: " + codecName, 0, status); " with codec: " + codecName, 0, status);
decoder.dumpStatistics(mInputFile + " " + codecName, extractor.getClipDuration()); decoder.dumpStatistics(mInputFile, codecName, (mAsyncMode ? "async" : "sync"),
extractor.getClipDuration(), mStatsFile);
Log.i(TAG, "Decoding Successful for file: " + mInputFile + " with codec: " + Log.i(TAG, "Decoding Successful for file: " + mInputFile + " with codec: " +
codecName); codecName);
decoder.resetDecoder(); decoder.resetDecoder();
@ -196,8 +208,8 @@ public class DecoderTest {
for (String codecName : mediaCodecs) { for (String codecName : mediaCodecs) {
Log.i("Test: %s\n", mInputFile); Log.i("Test: %s\n", mInputFile);
Native nativeDecoder = new Native(); Native nativeDecoder = new Native();
int status = int status = nativeDecoder.Decode(
nativeDecoder.Decode(mInputFilePath, mInputFile, codecName, mAsyncMode); mInputFilePath, mInputFile, mStatsFile, codecName, mAsyncMode);
assertEquals("Decoder returned error " + status + " for file: " + mInputFile, 0, assertEquals("Decoder returned error " + status + " for file: " + mInputFile, 0,
status); status);
} }

@ -29,7 +29,9 @@ import com.android.media.benchmark.library.Decoder;
import com.android.media.benchmark.library.Encoder; import com.android.media.benchmark.library.Encoder;
import com.android.media.benchmark.library.Extractor; import com.android.media.benchmark.library.Extractor;
import com.android.media.benchmark.library.Native; import com.android.media.benchmark.library.Native;
import com.android.media.benchmark.library.Stats;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@ -38,6 +40,7 @@ import java.io.File;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
@ -53,6 +56,8 @@ public class EncoderTest {
InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().getTargetContext();
private static final String mInputFilePath = mContext.getString(R.string.input_file_path); private static final String mInputFilePath = mContext.getString(R.string.input_file_path);
private static final String mOutputFilePath = mContext.getString(R.string.output_file_path); private static final String mOutputFilePath = mContext.getString(R.string.output_file_path);
private static final String mStatsFile =
mContext.getFilesDir() + "/Encoder." + System.currentTimeMillis() + ".csv";
private static final String TAG = "EncoderTest"; private static final String TAG = "EncoderTest";
private static final long PER_TEST_TIMEOUT_MS = 120000; private static final long PER_TEST_TIMEOUT_MS = 120000;
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
@ -60,7 +65,6 @@ public class EncoderTest {
private static final int ENCODE_DEFAULT_FRAME_RATE = 25; private static final int ENCODE_DEFAULT_FRAME_RATE = 25;
private static final int ENCODE_DEFAULT_BIT_RATE = 8000000 /* 8 Mbps */; private static final int ENCODE_DEFAULT_BIT_RATE = 8000000 /* 8 Mbps */;
private static final int ENCODE_MIN_BIT_RATE = 600000 /* 600 Kbps */; private static final int ENCODE_MIN_BIT_RATE = 600000 /* 600 Kbps */;
private String mInputFile; private String mInputFile;
@Parameterized.Parameters @Parameterized.Parameters
@ -85,6 +89,13 @@ public class EncoderTest {
this.mInputFile = inputFileName; this.mInputFile = inputFileName;
} }
@BeforeClass
public static void writeStatsHeaderToFile() throws IOException {
Stats mStats = new Stats();
boolean status = mStats.writeStatsHeader(mStatsFile);
assertTrue("Unable to open stats file for writing!", status);
}
@Test(timeout = PER_TEST_TIMEOUT_MS) @Test(timeout = PER_TEST_TIMEOUT_MS)
public void sampleEncoderTest() throws Exception { public void sampleEncoderTest() throws Exception {
int status; int status;
@ -220,9 +231,8 @@ public class EncoderTest {
assertEquals( assertEquals(
codecName + " encoder returned error " + status + " for " + "file:" + codecName + " encoder returned error " + status + " for " + "file:" +
" " + mInputFile, 0, status); " " + mInputFile, 0, status);
encoder.dumpStatistics( encoder.dumpStatistics(mInputFile, codecName, (asyncMode ? "async" : "sync"),
mInputFile + "with " + codecName + " for " + "aSyncMode = " + asyncMode, extractor.getClipDuration(), mStatsFile);
extractor.getClipDuration());
Log.i(TAG, "Encoding complete for file: " + mInputFile + " with codec: " + Log.i(TAG, "Encoding complete for file: " + mInputFile + " with codec: " +
codecName + " for aSyncMode = " + asyncMode); codecName + " for aSyncMode = " + asyncMode);
encoder.resetEncoder(); encoder.resetEncoder();
@ -264,8 +274,8 @@ public class EncoderTest {
// Encoding the decoder's output // Encoding the decoder's output
for (String codecName : mediaCodecs) { for (String codecName : mediaCodecs) {
Native nativeEncoder = new Native(); Native nativeEncoder = new Native();
int status = int status = nativeEncoder.Encode(
nativeEncoder.Encode(mInputFilePath, mInputFile, mDecodedFile, codecName); mInputFilePath, mInputFile, mDecodedFile, mStatsFile, codecName);
assertEquals( assertEquals(
codecName + " encoder returned error " + status + " for " + "file:" + " " + codecName + " encoder returned error " + status + " for " + "file:" + " " +
mInputFile, 0, status); mInputFile, 0, status);

@ -19,12 +19,15 @@ package com.android.media.benchmark.tests;
import com.android.media.benchmark.R; import com.android.media.benchmark.R;
import com.android.media.benchmark.library.Extractor; import com.android.media.benchmark.library.Extractor;
import com.android.media.benchmark.library.Native; import com.android.media.benchmark.library.Native;
import com.android.media.benchmark.library.Stats;
import android.content.Context; import android.content.Context;
import android.media.MediaFormat;
import android.util.Log; import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@ -32,6 +35,7 @@ import org.junit.runners.Parameterized;
import java.io.File; import java.io.File;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -39,11 +43,15 @@ import java.util.Collection;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class ExtractorTest { public class ExtractorTest {
private static Context mContext = private static Context mContext =
InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().getTargetContext();
private static final String mInputFilePath = mContext.getString(R.string.input_file_path); private static final String mInputFilePath = mContext.getString(R.string.input_file_path);
private static final String mStatsFile =
mContext.getFilesDir() + "/Extractor." + System.currentTimeMillis() + ".csv";
private static final String TAG = "ExtractorTest"; private static final String TAG = "ExtractorTest";
private String mInputFileName; private String mInputFileName;
private int mTrackId; private int mTrackId;
@ -71,6 +79,13 @@ public class ExtractorTest {
this.mTrackId = track; this.mTrackId = track;
} }
@BeforeClass
public static void writeStatsHeaderToFile() throws IOException {
Stats mStats = new Stats();
boolean status = mStats.writeStatsHeader(mStatsFile);
assertTrue("Unable to open stats file for writing!", status);
}
@Test @Test
public void sampleExtractTest() throws IOException { public void sampleExtractTest() throws IOException {
File inputFile = new File(mInputFilePath + mInputFileName); File inputFile = new File(mInputFilePath + mInputFileName);
@ -80,11 +95,13 @@ public class ExtractorTest {
FileDescriptor fileDescriptor = fileInput.getFD(); FileDescriptor fileDescriptor = fileInput.getFD();
Extractor extractor = new Extractor(); Extractor extractor = new Extractor();
extractor.setUpExtractor(fileDescriptor); extractor.setUpExtractor(fileDescriptor);
MediaFormat format = extractor.getFormat(mTrackId);
String mime = format.getString(MediaFormat.KEY_MIME);
int status = extractor.extractSample(mTrackId); int status = extractor.extractSample(mTrackId);
assertEquals("Extraction failed for " + mInputFileName, 0, status); assertEquals("Extraction failed for " + mInputFileName, 0, status);
Log.i(TAG, "Extracted " + mInputFileName + " successfully."); Log.i(TAG, "Extracted " + mInputFileName + " successfully.");
extractor.deinitExtractor(); extractor.deinitExtractor();
extractor.dumpStatistics(mInputFileName); extractor.dumpStatistics(mInputFileName, mime, mStatsFile);
fileInput.close(); fileInput.close();
} }
@ -95,7 +112,7 @@ public class ExtractorTest {
assertTrue("Cannot find " + mInputFileName + " in directory " + mInputFilePath, assertTrue("Cannot find " + mInputFileName + " in directory " + mInputFilePath,
inputFile.exists()); inputFile.exists());
FileInputStream fileInput = new FileInputStream(inputFile); FileInputStream fileInput = new FileInputStream(inputFile);
int status = nativeExtractor.Extract(mInputFilePath, mInputFileName); int status = nativeExtractor.Extract(mInputFilePath, mInputFileName, mStatsFile);
fileInput.close(); fileInput.close();
assertEquals("Extraction failed for " + mInputFileName, 0, status); assertEquals("Extraction failed for " + mInputFileName, 0, status);
Log.i(TAG, "Extracted " + mInputFileName + " successfully."); Log.i(TAG, "Extracted " + mInputFileName + " successfully.");

@ -19,6 +19,7 @@ import com.android.media.benchmark.R;
import com.android.media.benchmark.library.Extractor; import com.android.media.benchmark.library.Extractor;
import com.android.media.benchmark.library.Muxer; import com.android.media.benchmark.library.Muxer;
import com.android.media.benchmark.library.Native; import com.android.media.benchmark.library.Native;
import com.android.media.benchmark.library.Stats;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
@ -28,6 +29,7 @@ import android.media.MediaFormat;
import android.media.MediaMuxer; import android.media.MediaMuxer;
import android.util.Log; import android.util.Log;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import org.junit.runners.Parameterized;
@ -35,6 +37,7 @@ import org.junit.runners.Parameterized;
import java.io.File; import java.io.File;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
@ -47,11 +50,15 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class MuxerTest { public class MuxerTest {
private static Context mContext = private static Context mContext =
InstrumentationRegistry.getInstrumentation().getTargetContext(); InstrumentationRegistry.getInstrumentation().getTargetContext();
private static final String mInputFilePath = mContext.getString(R.string.input_file_path); private static final String mInputFilePath = mContext.getString(R.string.input_file_path);
private static final String mStatsFile =
mContext.getFilesDir() + "/Muxer." + System.currentTimeMillis() + ".csv";
private static final String TAG = "MuxerTest"; private static final String TAG = "MuxerTest";
private static final Map<String, Integer> mMapFormat = new Hashtable<String, Integer>() { private static final Map<String, Integer> mMapFormat = new Hashtable<String, Integer>() {
{ {
@ -94,6 +101,13 @@ public class MuxerTest {
this.mFormat = outputFormat; this.mFormat = outputFormat;
} }
@BeforeClass
public static void writeStatsHeaderToFile() throws IOException {
Stats mStats = new Stats();
boolean status = mStats.writeStatsHeader(mStatsFile);
assertTrue("Unable to open stats file for writing!", status);
}
@Test @Test
public void sampleMuxerTest() throws IOException { public void sampleMuxerTest() throws IOException {
File inputFile = new File(mInputFilePath + mInputFileName); File inputFile = new File(mInputFilePath + mInputFileName);
@ -132,7 +146,7 @@ public class MuxerTest {
assertEquals("Cannot perform write operation for " + mInputFileName, 0, status); assertEquals("Cannot perform write operation for " + mInputFileName, 0, status);
Log.i(TAG, "Muxed " + mInputFileName + " successfully."); Log.i(TAG, "Muxed " + mInputFileName + " successfully.");
muxer.deInitMuxer(); muxer.deInitMuxer();
muxer.dumpStatistics(mInputFileName, extractor.getClipDuration()); muxer.dumpStatistics(mInputFileName, mFormat, extractor.getClipDuration(), mStatsFile);
muxer.resetMuxer(); muxer.resetMuxer();
extractor.unselectExtractorTrack(currentTrack); extractor.unselectExtractorTrack(currentTrack);
inputBufferInfo.clear(); inputBufferInfo.clear();
@ -151,7 +165,8 @@ public class MuxerTest {
inputFile.exists()); inputFile.exists());
int tid = android.os.Process.myTid(); int tid = android.os.Process.myTid();
String mMuxOutputFile = (mContext.getFilesDir() + "/mux_" + tid + ".out"); String mMuxOutputFile = (mContext.getFilesDir() + "/mux_" + tid + ".out");
int status = nativeMuxer.Mux(mInputFilePath, mInputFileName, mMuxOutputFile, mFormat); int status = nativeMuxer.Mux(
mInputFilePath, mInputFileName, mMuxOutputFile, mStatsFile, mFormat);
assertEquals("Cannot perform write operation for " + mInputFileName, 0, status); assertEquals("Cannot perform write operation for " + mInputFileName, 0, status);
Log.i(TAG, "Muxed " + mInputFileName + " successfully."); Log.i(TAG, "Muxed " + mInputFileName + " successfully.");
File muxedFile = new File(mMuxOutputFile); File muxedFile = new File(mMuxOutputFile);

@ -18,6 +18,7 @@
#define LOG_TAG "NativeDecoder" #define LOG_TAG "NativeDecoder"
#include <jni.h> #include <jni.h>
#include <fstream>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -27,8 +28,8 @@
#include "Decoder.h" #include "Decoder.h"
extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native_Decode( extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native_Decode(
JNIEnv *env, jobject thiz, jstring jFilePath, jstring jFileName, jstring jCodecName, JNIEnv *env, jobject thiz, jstring jFilePath, jstring jFileName, jstring jStatsFile,
jboolean asyncMode) { jstring jCodecName, jboolean asyncMode) {
const char *filePath = env->GetStringUTFChars(jFilePath, nullptr); const char *filePath = env->GetStringUTFChars(jFilePath, nullptr);
const char *fileName = env->GetStringUTFChars(jFileName, nullptr); const char *fileName = env->GetStringUTFChars(jFileName, nullptr);
string sFilePath = string(filePath) + string(fileName); string sFilePath = string(filePath) + string(fileName);
@ -69,7 +70,7 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
return -1; return -1;
} }
uint8_t *inputBuffer = (uint8_t *)malloc(fileSize); uint8_t *inputBuffer = (uint8_t *) malloc(fileSize);
if (!inputBuffer) { if (!inputBuffer) {
ALOGE("Insufficient memory"); ALOGE("Insufficient memory");
return -1; return -1;
@ -105,18 +106,21 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
return -1; return -1;
} }
decoder->deInitCodec(); decoder->deInitCodec();
env->ReleaseStringUTFChars(jCodecName, codecName);
const char *inputReference = env->GetStringUTFChars(jFileName, nullptr); const char *inputReference = env->GetStringUTFChars(jFileName, nullptr);
const char *statsFile = env->GetStringUTFChars(jStatsFile, nullptr);
string sInputReference = string(inputReference); string sInputReference = string(inputReference);
decoder->dumpStatistics(sInputReference); decoder->dumpStatistics(sInputReference, sCodecName, (asyncMode ? "async" : "sync"),
statsFile);
env->ReleaseStringUTFChars(jCodecName, codecName);
env->ReleaseStringUTFChars(jStatsFile, statsFile);
env->ReleaseStringUTFChars(jFileName, inputReference); env->ReleaseStringUTFChars(jFileName, inputReference);
if(inputBuffer) { if (inputBuffer) {
free(inputBuffer); free(inputBuffer);
inputBuffer = nullptr; inputBuffer = nullptr;
} }
decoder->resetDecoder(); decoder->resetDecoder();
} }
if(inputFp) { if (inputFp) {
fclose(inputFp); fclose(inputFp);
inputFp = nullptr; inputFp = nullptr;
} }

@ -31,7 +31,7 @@
extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native_Encode( extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native_Encode(
JNIEnv *env, jobject thiz, jstring jFilePath, jstring jFileName, jstring jOutFilePath, JNIEnv *env, jobject thiz, jstring jFilePath, jstring jFileName, jstring jOutFilePath,
jstring jCodecName) { jstring jStatsFile, jstring jCodecName) {
const char *filePath = env->GetStringUTFChars(jFilePath, nullptr); const char *filePath = env->GetStringUTFChars(jFilePath, nullptr);
const char *fileName = env->GetStringUTFChars(jFileName, nullptr); const char *fileName = env->GetStringUTFChars(jFileName, nullptr);
string sFilePath = string(filePath) + string(fileName); string sFilePath = string(filePath) + string(fileName);
@ -72,7 +72,7 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
ALOGE("Track Format invalid"); ALOGE("Track Format invalid");
return -1; return -1;
} }
uint8_t *inputBuffer = (uint8_t *)malloc(fileSize); uint8_t *inputBuffer = (uint8_t *) malloc(fileSize);
if (!inputBuffer) { if (!inputBuffer) {
ALOGE("Insufficient memory"); ALOGE("Insufficient memory");
return -1; return -1;
@ -111,7 +111,7 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
return -1; return -1;
} }
AMediaFormat *format = extractor->getFormat(); AMediaFormat *format = extractor->getFormat();
if(inputBuffer) { if (inputBuffer) {
free(inputBuffer); free(inputBuffer);
inputBuffer = nullptr; inputBuffer = nullptr;
} }
@ -165,11 +165,14 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
Encoder *encoder = new Encoder(); Encoder *encoder = new Encoder();
encoder->setupEncoder(); encoder->setupEncoder();
status = encoder->encode(sCodecName, eleStream, eleSize, asyncMode[i], encParams, status = encoder->encode(sCodecName, eleStream, eleSize, asyncMode[i], encParams,
(char *)mime); (char *) mime);
encoder->deInitCodec(); encoder->deInitCodec();
cout << "codec : " << codecName << endl; cout << "codec : " << codecName << endl;
ALOGV(" asyncMode = %d \n", asyncMode[i]); ALOGV(" asyncMode = %d \n", asyncMode[i]);
encoder->dumpStatistics(sInputReference, extractor->getClipDuration()); const char *statsFile = env->GetStringUTFChars(jStatsFile, nullptr);
encoder->dumpStatistics(sInputReference, extractor->getClipDuration(), sCodecName,
(asyncMode[i] ? "async" : "sync"), statsFile);
env->ReleaseStringUTFChars(jStatsFile, statsFile);
encoder->resetEncoder(); encoder->resetEncoder();
delete encoder; delete encoder;
encoder = nullptr; encoder = nullptr;
@ -189,7 +192,7 @@ extern "C" JNIEXPORT int JNICALL Java_com_android_media_benchmark_library_Native
decoder->deInitCodec(); decoder->deInitCodec();
decoder->resetDecoder(); decoder->resetDecoder();
} }
if(inputFp) { if (inputFp) {
fclose(inputFp); fclose(inputFp);
inputFp = nullptr; inputFp = nullptr;
} }

@ -18,16 +18,15 @@
#define LOG_TAG "NativeExtractor" #define LOG_TAG "NativeExtractor"
#include <jni.h> #include <jni.h>
#include <fstream>
#include <string> #include <string>
#include <sys/stat.h> #include <sys/stat.h>
#include "Extractor.h" #include "Extractor.h"
extern "C" extern "C" JNIEXPORT int32_t JNICALL Java_com_android_media_benchmark_library_Native_Extract(
JNIEXPORT int32_t JNICALL JNIEnv *env, jobject thiz, jstring jInputFilePath, jstring jInputFileName,
Java_com_android_media_benchmark_library_Native_Extract(JNIEnv *env, jobject thiz, jstring jStatsFile) {
jstring jInputFilePath,
jstring jInputFileName) {
UNUSED(thiz); UNUSED(thiz);
const char *inputFilePath = env->GetStringUTFChars(jInputFilePath, nullptr); const char *inputFilePath = env->GetStringUTFChars(jInputFilePath, nullptr);
const char *inputFileName = env->GetStringUTFChars(jInputFileName, nullptr); const char *inputFileName = env->GetStringUTFChars(jInputFileName, nullptr);
@ -41,25 +40,39 @@ Java_com_android_media_benchmark_library_Native_Extract(JNIEnv *env, jobject thi
int32_t fd = fileno(inputFp); int32_t fd = fileno(inputFp);
Extractor *extractObj = new Extractor(); Extractor *extractObj = new Extractor();
int32_t trackCount = extractObj->initExtractor((long)fd, fileSize); int32_t trackCount = extractObj->initExtractor((long) fd, fileSize);
if (trackCount <= 0) { if (trackCount <= 0) {
ALOGE("initExtractor failed"); ALOGE("initExtractor failed");
return -1; return -1;
} }
int32_t trackID = 0; int32_t trackID = 0;
const char *mime = nullptr;
int32_t status = extractObj->extract(trackID); int32_t status = extractObj->extract(trackID);
if (status != AMEDIA_OK) { if (status != AMEDIA_OK) {
ALOGE("Extraction failed"); ALOGE("Extraction failed");
return -1; return -1;
} }
if (inputFp) { if (inputFp) {
fclose(inputFp); fclose(inputFp);
inputFp = nullptr; inputFp = nullptr;
} }
status = extractObj->setupTrackFormat(trackID);
AMediaFormat *format = extractObj->getFormat();
if (!format) {
ALOGE("format is null!");
return -1;
}
AMediaFormat_getString(format, AMEDIAFORMAT_KEY_MIME, &mime);
if (!mime) {
ALOGE("mime is null!");
return -1;
}
extractObj->deInitExtractor(); extractObj->deInitExtractor();
extractObj->dumpStatistics(inputFileName); const char *statsFile = env->GetStringUTFChars(jStatsFile, nullptr);
extractObj->dumpStatistics(string(inputFileName), string(mime), statsFile);
env->ReleaseStringUTFChars(jStatsFile, statsFile);
env->ReleaseStringUTFChars(jInputFilePath, inputFilePath); env->ReleaseStringUTFChars(jInputFilePath, inputFilePath);
env->ReleaseStringUTFChars(jInputFileName, inputFileName); env->ReleaseStringUTFChars(jInputFileName, inputFileName);

@ -18,6 +18,7 @@
#define LOG_TAG "NativeMuxer" #define LOG_TAG "NativeMuxer"
#include <jni.h> #include <jni.h>
#include <fstream>
#include <string> #include <string>
#include <sys/stat.h> #include <sys/stat.h>
@ -25,11 +26,9 @@
MUXER_OUTPUT_T getMuxerOutFormat(const char *fmt); MUXER_OUTPUT_T getMuxerOutFormat(const char *fmt);
extern "C" extern "C" JNIEXPORT int32_t JNICALL Java_com_android_media_benchmark_library_Native_Mux(
JNIEXPORT int32_t JNICALL JNIEnv *env, jobject thiz, jstring jInputFilePath, jstring jInputFileName,
Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz, jstring jOutputFilePath, jstring jStatsFile, jstring jFormat) {
jstring jInputFilePath, jstring jInputFileName,
jstring jOutputFilePath, jstring jFormat) {
UNUSED(thiz); UNUSED(thiz);
ALOGV("Mux the samples given by extractor"); ALOGV("Mux the samples given by extractor");
const char *inputFilePath = env->GetStringUTFChars(jInputFilePath, nullptr); const char *inputFilePath = env->GetStringUTFChars(jInputFilePath, nullptr);
@ -43,7 +42,6 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
const char *fmt = env->GetStringUTFChars(jFormat, nullptr); const char *fmt = env->GetStringUTFChars(jFormat, nullptr);
MUXER_OUTPUT_T outputFormat = getMuxerOutFormat(fmt); MUXER_OUTPUT_T outputFormat = getMuxerOutFormat(fmt);
env->ReleaseStringUTFChars(jFormat, fmt);
if (outputFormat == MUXER_OUTPUT_FORMAT_INVALID) { if (outputFormat == MUXER_OUTPUT_FORMAT_INVALID) {
ALOGE("output format is MUXER_OUTPUT_FORMAT_INVALID"); ALOGE("output format is MUXER_OUTPUT_FORMAT_INVALID");
return MUXER_OUTPUT_FORMAT_INVALID; return MUXER_OUTPUT_FORMAT_INVALID;
@ -75,7 +73,7 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
return -1; return -1;
} }
uint8_t *inputBuffer = (uint8_t *)malloc(fileSize); uint8_t *inputBuffer = (uint8_t *) malloc(fileSize);
if (!inputBuffer) { if (!inputBuffer) {
ALOGE("Allocation Failed"); ALOGE("Allocation Failed");
return -1; return -1;
@ -105,7 +103,7 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
} }
const char *outputFilePath = env->GetStringUTFChars(jOutputFilePath, nullptr); const char *outputFilePath = env->GetStringUTFChars(jOutputFilePath, nullptr);
FILE *outputFp = fopen(((string)outputFilePath).c_str(), "w+b"); FILE *outputFp = fopen(((string) outputFilePath).c_str(), "w+b");
env->ReleaseStringUTFChars(jOutputFilePath, outputFilePath); env->ReleaseStringUTFChars(jOutputFilePath, outputFilePath);
if (!outputFp) { if (!outputFp) {
@ -118,7 +116,7 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
} }
int32_t outFd = fileno(outputFp); int32_t outFd = fileno(outputFp);
status = muxerObj->initMuxer(outFd, (MUXER_OUTPUT_T)outputFormat); status = muxerObj->initMuxer(outFd, (MUXER_OUTPUT_T) outputFormat);
if (status != 0) { if (status != 0) {
ALOGE("initMuxer failed"); ALOGE("initMuxer failed");
if (inputBuffer) { if (inputBuffer) {
@ -138,7 +136,10 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
return -1; return -1;
} }
muxerObj->deInitMuxer(); muxerObj->deInitMuxer();
muxerObj->dumpStatistics(inputFileName); const char *statsFile = env->GetStringUTFChars(jStatsFile, nullptr);
string muxFormat(fmt);
muxerObj->dumpStatistics(string(inputFileName), muxFormat, statsFile);
env->ReleaseStringUTFChars(jStatsFile, statsFile);
env->ReleaseStringUTFChars(jInputFilePath, inputFilePath); env->ReleaseStringUTFChars(jInputFilePath, inputFilePath);
env->ReleaseStringUTFChars(jInputFileName, inputFileName); env->ReleaseStringUTFChars(jInputFileName, inputFileName);
@ -156,6 +157,7 @@ Java_com_android_media_benchmark_library_Native_Mux(JNIEnv *env, jobject thiz,
fclose(inputFp); fclose(inputFp);
inputFp = nullptr; inputFp = nullptr;
} }
env->ReleaseStringUTFChars(jFormat, fmt);
extractor->deInitExtractor(); extractor->deInitExtractor();
delete muxerObj; delete muxerObj;
@ -166,10 +168,10 @@ MUXER_OUTPUT_T getMuxerOutFormat(const char *fmt) {
static const struct { static const struct {
const char *name; const char *name;
int value; int value;
} kFormatMaps[] = {{"mp4", MUXER_OUTPUT_FORMAT_MPEG_4}, } kFormatMaps[] = {{"mp4", MUXER_OUTPUT_FORMAT_MPEG_4},
{"webm", MUXER_OUTPUT_FORMAT_WEBM}, {"webm", MUXER_OUTPUT_FORMAT_WEBM},
{"3gpp", MUXER_OUTPUT_FORMAT_3GPP}, {"3gpp", MUXER_OUTPUT_FORMAT_3GPP},
{"ogg", MUXER_OUTPUT_FORMAT_OGG}}; {"ogg", MUXER_OUTPUT_FORMAT_OGG}};
int32_t muxOutputFormat = MUXER_OUTPUT_FORMAT_INVALID; int32_t muxOutputFormat = MUXER_OUTPUT_FORMAT_INVALID;
for (auto kFormatMap : kFormatMaps) { for (auto kFormatMap : kFormatMaps) {
@ -178,5 +180,5 @@ MUXER_OUTPUT_T getMuxerOutFormat(const char *fmt) {
break; break;
} }
} }
return (MUXER_OUTPUT_T)muxOutputFormat; return (MUXER_OUTPUT_T) muxOutputFormat;
} }

@ -239,11 +239,16 @@ public class Decoder {
* Prints out the statistics in the information log * Prints out the statistics in the information log
* *
* @param inputReference The operation being performed, in this case decode * @param inputReference The operation being performed, in this case decode
* @param componentName Name of the component/codec
* @param mode The operating mode: Sync/Async
* @param durationUs Duration of the clip in microseconds * @param durationUs Duration of the clip in microseconds
* @param statsFile The output file where the stats data is written
*/ */
public void dumpStatistics(String inputReference, long durationUs) { public void dumpStatistics(String inputReference, String componentName, String mode,
long durationUs, String statsFile) throws IOException {
String operation = "decode"; String operation = "decode";
mStats.dumpStatistics(operation, inputReference, durationUs); mStats.dumpStatistics(
inputReference, operation, componentName, mode, durationUs, statsFile);
} }
/** /**

@ -326,12 +326,17 @@ public class Encoder {
/** /**
* Prints out the statistics in the information log * Prints out the statistics in the information log
* *
* @param inputReference The operation being performed, in this case encode * @param inputReference The operation being performed, in this case decode
* @param componentName Name of the component/codec
* @param mode The operating mode: Sync/Async
* @param durationUs Duration of the clip in microseconds * @param durationUs Duration of the clip in microseconds
* @param statsFile The output file where the stats data is written
*/ */
public void dumpStatistics(String inputReference, long durationUs) { public void dumpStatistics(String inputReference, String componentName, String mode,
long durationUs, String statsFile) throws IOException {
String operation = "encode"; String operation = "encode";
mStats.dumpStatistics(operation, inputReference, durationUs); mStats.dumpStatistics(
inputReference, operation, componentName, mode, durationUs, statsFile);
} }
/** /**

@ -167,9 +167,12 @@ public class Extractor {
* Write the benchmark logs for the given input file * Write the benchmark logs for the given input file
* *
* @param inputReference Name of the input file * @param inputReference Name of the input file
* @param mimeType Mime type of the muxed file
* @param statsFile The output file where the stats data is written
*/ */
public void dumpStatistics(String inputReference) { public void dumpStatistics(String inputReference, String mimeType, String statsFile)
throws IOException {
String operation = "extract"; String operation = "extract";
mStats.dumpStatistics(operation, inputReference, mDurationUs); mStats.dumpStatistics(inputReference, operation, mimeType, "", mDurationUs, statsFile);
} }
} }

@ -101,10 +101,13 @@ public class Muxer {
* Write the benchmark logs for the given input file * Write the benchmark logs for the given input file
* *
* @param inputReference Name of the input file * @param inputReference Name of the input file
* @param muxFormat Format of the muxed output
* @param clipDuration Duration of the given inputReference file * @param clipDuration Duration of the given inputReference file
* @param statsFile The output file where the stats data is written
*/ */
public void dumpStatistics(String inputReference, long clipDuration) { public void dumpStatistics(String inputReference, String muxFormat, long clipDuration,
String statsFile) throws IOException {
String operation = "mux"; String operation = "mux";
mStats.dumpStatistics(operation, inputReference, clipDuration); mStats.dumpStatistics(inputReference, operation, muxFormat, "", clipDuration, statsFile);
} }
} }

@ -19,14 +19,14 @@ package com.android.media.benchmark.library;
public class Native { public class Native {
static { System.loadLibrary("mediabenchmark_jni"); } static { System.loadLibrary("mediabenchmark_jni"); }
public native int Extract(String inputFilePath, String inputFileName); public native int Extract(String inputFilePath, String inputFileName, String statsFile);
public native int Mux(String inputFilePath, String inputFileName, String outputFilePath, public native int Mux(String inputFilePath, String inputFileName, String outputFilePath,
String format); String statsFile, String format);
public native int Decode(String inputFilePath, String inputFileName, String codecName, public native int Decode(String inputFilePath, String inputFileName, String statsFile,
boolean asyncMode); String codecName, boolean asyncMode);
public native int Encode(String inputFilePath, String inputFileName, String outputFilePath, public native int Encode(String inputFilePath, String inputFileName, String outputFilePath,
String codecName); String statsFile, String codecName);
} }

@ -18,6 +18,10 @@ package com.android.media.benchmark.library;
import android.util.Log; import android.util.Log;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -90,15 +94,39 @@ public class Stats {
return totalSize; return totalSize;
} }
/**
* Writes the stats header to a file
* <p>
* \param statsFile file where the stats data is to be written
**/
public boolean writeStatsHeader(String statsFile) throws IOException {
File outputFile = new File(statsFile);
FileOutputStream out = new FileOutputStream(outputFile, true);
if (!outputFile.exists())
return false;
String statsHeader =
"currentTime, fileName, operation, componentName, NDK/SDK, sync/async, setupTime, "
+ "destroyTime, minimumTime, maximumTime, "
+ "averageTime, timeToProcess1SecContent, totalBytesProcessedPerSec, "
+ "timeToFirstFrame, totalSizeInBytes, totalTime\n";
out.write(statsHeader.getBytes());
out.close();
return true;
}
/** /**
* Dumps the stats of the operation for a given input media. * Dumps the stats of the operation for a given input media.
* <p> * <p>
* \param inputReference input media
* \param operation describes the operation performed on the input media * \param operation describes the operation performed on the input media
* (i.e. extract/mux/decode/encode) * (i.e. extract/mux/decode/encode)
* \param inputReference input media * \param componentName name of the codec/muxFormat/mime
* \param durationUs is a duration of the input media in microseconds. * \param mode the operating mode: sync/async.
* \param durationUs is a duration of the input media in microseconds.
* \param statsFile the file where the stats data is to be written.
*/ */
public void dumpStatistics(String operation, String inputReference, long durationUs) { public void dumpStatistics(String inputReference, String operation, String componentName,
String mode, long durationUs, String statsFile) throws IOException {
if (mOutputTimer.size() == 0) { if (mOutputTimer.size() == 0) {
Log.e(TAG, "No output produced"); Log.e(TAG, "No output produced");
return; return;
@ -121,18 +149,30 @@ public class Stats {
maxTimeTakenNs = intervalNs; maxTimeTakenNs = intervalNs;
} }
} }
// Print the Stats
Log.i(TAG, "Input Reference : " + inputReference); // Write the stats row data to file
Log.i(TAG, "Setup Time in nano sec : " + mInitTimeNs); String rowData = "";
Log.i(TAG, "Average Time in nano sec : " + totalTimeTakenNs / mOutputTimer.size()); rowData += System.nanoTime() + ", ";
Log.i(TAG, "Time to first frame in nano sec : " + timeToFirstFrameNs); rowData += inputReference + ", ";
Log.i(TAG, "Time taken (in nano sec) to " + operation + " 1 sec of content : " + rowData += operation + ", ";
timeTakenPerSec); rowData += componentName + ", ";
Log.i(TAG, "Total bytes " + operation + "ed : " + size); rowData += "SDK, ";
Log.i(TAG, "Number of bytes " + operation + "ed per second : " + rowData += mode + ", ";
(size * 1000000000) / totalTimeTakenNs); rowData += mInitTimeNs + ", ";
Log.i(TAG, "Minimum Time in nano sec : " + minTimeTakenNs); rowData += mDeInitTimeNs + ", ";
Log.i(TAG, "Maximum Time in nano sec : " + maxTimeTakenNs); rowData += minTimeTakenNs + ", ";
Log.i(TAG, "Destroy Time in nano sec : " + mDeInitTimeNs); rowData += maxTimeTakenNs + ", ";
rowData += totalTimeTakenNs / mOutputTimer.size() + ", ";
rowData += timeTakenPerSec + ", ";
rowData += (size * 1000000000) / totalTimeTakenNs + ", ";
rowData += timeToFirstFrameNs + ", ";
rowData += size + ", ";
rowData += totalTimeTakenNs + "\n";
File outputFile = new File(statsFile);
FileOutputStream out = new FileOutputStream(outputFile, true);
assert outputFile.exists() : "Failed to open the stats file for writing!";
out.write(rowData.getBytes());
out.close();
} }
} }

@ -17,8 +17,10 @@
//#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0
#define LOG_TAG "Stats" #define LOG_TAG "Stats"
#include <ctime>
#include <iostream> #include <iostream>
#include <stdint.h> #include <stdint.h>
#include <fstream>
#include "Stats.h" #include "Stats.h"
@ -28,16 +30,20 @@
* \param operation describes the operation performed on the input media * \param operation describes the operation performed on the input media
* (i.e. extract/mux/decode/encode) * (i.e. extract/mux/decode/encode)
* \param inputReference input media * \param inputReference input media
* \param duarationUs is a duration of the input media in microseconds. * \param durationUs is a duration of the input media in microseconds.
* \param componentName describes the codecName/muxFormat/mimeType.
* \param mode the operating mode: sync/async.
* \param statsFile the file where the stats data is to be written.
*/ */
void Stats::dumpStatistics(std::string operation, std::string inputReference, int64_t duarationUs) { void Stats::dumpStatistics(string operation, string inputReference, int64_t durationUs,
string componentName, string mode, string statsFile) {
ALOGV("In %s", __func__); ALOGV("In %s", __func__);
if (!mOutputTimer.size()) { if (!mOutputTimer.size()) {
ALOGE("No output produced"); ALOGE("No output produced");
return; return;
} }
nsecs_t totalTimeTakenNs = getTotalTime(); nsecs_t totalTimeTakenNs = getTotalTime();
nsecs_t timeTakenPerSec = (totalTimeTakenNs * 1000000) / duarationUs; nsecs_t timeTakenPerSec = (totalTimeTakenNs * 1000000) / durationUs;
nsecs_t timeToFirstFrameNs = *mOutputTimer.begin() - mStartTimeNs; nsecs_t timeToFirstFrameNs = *mOutputTimer.begin() - mStartTimeNs;
int32_t size = std::accumulate(mFrameSizes.begin(), mFrameSizes.end(), 0); int32_t size = std::accumulate(mFrameSizes.begin(), mFrameSizes.end(), 0);
// get min and max output intervals. // get min and max output intervals.
@ -52,15 +58,32 @@ void Stats::dumpStatistics(std::string operation, std::string inputReference, in
else if (maxTimeTakenNs < intervalNs) maxTimeTakenNs = intervalNs; else if (maxTimeTakenNs < intervalNs) maxTimeTakenNs = intervalNs;
} }
// Print the Stats // Write the stats data to file.
ALOGI("Input Reference : %s \n", inputReference.c_str()); int64_t dataSize = size;
ALOGI("Setup Time in nano sec : %" PRId64 "\n", mInitTimeNs); int64_t bytesPerSec = ((int64_t)dataSize * 1000000000) / totalTimeTakenNs;
ALOGI("Average Time in nano sec : %" PRId64 "\n", totalTimeTakenNs / mOutputTimer.size()); string rowData = "";
ALOGI("Time to first frame in nano sec : %" PRId64 "\n", timeToFirstFrameNs); rowData.append(to_string(systemTime(CLOCK_MONOTONIC)) + ", ");
ALOGI("Time taken (in nano sec) to %s 1 sec of content : %" PRId64 "\n", operation.c_str(), rowData.append(inputReference + ", ");
timeTakenPerSec); rowData.append(operation + ", ");
ALOGI("Total bytes %sed : %d\n", operation.c_str(), size); rowData.append(componentName + ", ");
ALOGI("Minimum Time in nano sec : %" PRId64 "\n", minTimeTakenNs); rowData.append("NDK, ");
ALOGI("Maximum Time in nano sec : %" PRId64 "\n", maxTimeTakenNs); rowData.append(mode + ", ");
ALOGI("Destroy Time in nano sec : %" PRId64 "\n", mDeInitTimeNs); rowData.append(to_string(mInitTimeNs) + ", ");
rowData.append(to_string(mDeInitTimeNs) + ", ");
rowData.append(to_string(minTimeTakenNs) + ", ");
rowData.append(to_string(maxTimeTakenNs) + ", ");
rowData.append(to_string(totalTimeTakenNs / mOutputTimer.size()) + ", ");
rowData.append(to_string(timeTakenPerSec) + ", ");
rowData.append(to_string(bytesPerSec) + ", ");
rowData.append(to_string(timeToFirstFrameNs) + ", ");
rowData.append(to_string(size) + ",");
rowData.append(to_string(totalTimeTakenNs) + ",\n");
ofstream out(statsFile, ios::out | ios::app);
if(out.bad()) {
ALOGE("Failed to open stats file for writing!");
return;
}
out << rowData;
out.close();
} }

@ -102,7 +102,8 @@ class Stats {
return (*(mOutputTimer.end() - 1) - mStartTimeNs); return (*(mOutputTimer.end() - 1) - mStartTimeNs);
} }
void dumpStatistics(std::string operation, std::string inputReference, int64_t duarationUs); void dumpStatistics(string operation, string inputReference, int64_t duarationUs,
string codecName = "", string mode = "", string statsFile = "");
}; };
#endif // __STATS_H__ #endif // __STATS_H__

@ -238,10 +238,11 @@ void Decoder::deInitCodec() {
mStats->setDeInitTime(timeTaken); mStats->setDeInitTime(timeTaken);
} }
void Decoder::dumpStatistics(string inputReference) { void Decoder::dumpStatistics(string inputReference, string componentName, string mode,
string statsFile) {
int64_t durationUs = mExtractor->getClipDuration(); int64_t durationUs = mExtractor->getClipDuration();
string operation = "decode"; string operation = "decode";
mStats->dumpStatistics(operation, inputReference, durationUs); mStats->dumpStatistics(operation, inputReference, durationUs, componentName, mode, statsFile);
} }
void Decoder::resetDecoder() { void Decoder::resetDecoder() {

@ -71,7 +71,8 @@ class Decoder : public CallBackHandle {
int32_t decode(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameInfo, int32_t decode(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameInfo,
string &codecName, bool asyncMode, FILE *outFp = nullptr); string &codecName, bool asyncMode, FILE *outFp = nullptr);
void dumpStatistics(string inputReference); void dumpStatistics(string inputReference, string componentName = "", string mode = "",
string statsFile = "");
private: private:
AMediaCodec *mCodec; AMediaCodec *mCodec;

@ -174,9 +174,10 @@ void Encoder::resetEncoder() {
memset(&mParams, 0, sizeof mParams); memset(&mParams, 0, sizeof mParams);
} }
void Encoder::dumpStatistics(string inputReference, int64_t durationUs) { void Encoder::dumpStatistics(string inputReference, int64_t durationUs, string componentName,
string mode, string statsFile) {
string operation = "encode"; string operation = "encode";
mStats->dumpStatistics(operation, inputReference, durationUs); mStats->dumpStatistics(operation, inputReference, durationUs, componentName, mode, statsFile);
} }
int32_t Encoder::encode(string &codecName, ifstream &eleStream, size_t eleSize, int32_t Encoder::encode(string &codecName, ifstream &eleStream, size_t eleSize,

@ -75,7 +75,8 @@ class Encoder : public CallBackHandle {
int32_t encode(std::string &codecName, std::ifstream &eleStream, size_t eleSize, bool asyncMode, int32_t encode(std::string &codecName, std::ifstream &eleStream, size_t eleSize, bool asyncMode,
encParameter encParams, char *mime); encParameter encParams, char *mime);
void dumpStatistics(string inputReference, int64_t durationUs); void dumpStatistics(string inputReference, int64_t durationUs, string codecName = "",
string mode = "", string statsFile = "");
private: private:
AMediaCodec *mCodec; AMediaCodec *mCodec;

@ -111,9 +111,9 @@ int32_t Extractor::extract(int32_t trackId) {
return AMEDIA_OK; return AMEDIA_OK;
} }
void Extractor::dumpStatistics(string inputReference) { void Extractor::dumpStatistics(string inputReference, string componentName, string statsFile) {
string operation = "extract"; string operation = "extract";
mStats->dumpStatistics(operation, inputReference, mDurationUs); mStats->dumpStatistics(operation, inputReference, mDurationUs, componentName, "", statsFile);
} }
void Extractor::deInitExtractor() { void Extractor::deInitExtractor() {

@ -45,7 +45,7 @@ class Extractor {
int32_t extract(int32_t trackId); int32_t extract(int32_t trackId);
void dumpStatistics(std::string inputReference); void dumpStatistics(string inputReference, string componentName = "", string statsFile = "");
void deInitExtractor(); void deInitExtractor();

@ -66,9 +66,10 @@ void Muxer::resetMuxer() {
if (mStats) mStats->reset(); if (mStats) mStats->reset();
} }
void Muxer::dumpStatistics(string inputReference) { void Muxer::dumpStatistics(string inputReference, string componentName, string statsFile) {
string operation = "mux"; string operation = "mux";
mStats->dumpStatistics(operation, inputReference, mExtractor->getClipDuration()); mStats->dumpStatistics(operation, inputReference, mExtractor->getClipDuration(), componentName,
"", statsFile);
} }
int32_t Muxer::mux(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameInfos) { int32_t Muxer::mux(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameInfos) {

@ -51,7 +51,7 @@ class Muxer {
/* Process the frames and give Muxed output */ /* Process the frames and give Muxed output */
int32_t mux(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameSizes); int32_t mux(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameSizes);
void dumpStatistics(string inputReference); void dumpStatistics(string inputReference, string codecName = "", string statsFile = "");
private: private:
AMediaFormat *mFormat; AMediaFormat *mFormat;

Loading…
Cancel
Save