translate note into Englilsh

translate note into Englilsh
pull/166/head
xufulong 5 years ago
parent 08a7bc7464
commit d920f7974f
  1. 38
      app/src/main/cpp/fast_start.c
  2. 8
      app/src/main/cpp/ffmpeg_cmd.c
  3. 2
      app/src/main/cpp/ffmpeg_jni_define.h

@ -22,7 +22,7 @@
#define ftello(x) _ftelli64(x)
#endif
#define MIN(a,b) ((a) > (b) ? (b) : (a))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define BE_32(x) (((uint32_t)(((uint8_t*)(x))[0]) << 24) | \
(((uint8_t*)(x))[1] << 16) | \
@ -108,8 +108,7 @@ static int parse_atoms(
unsigned char *buf,
uint64_t size,
parse_atoms_callback_t callback,
void *context)
{
void *context) {
unsigned char *pos = buf;
unsigned char *end = pos + size;
atom_t atom;
@ -164,8 +163,7 @@ static int parse_atoms(
return 0;
}
static int update_stco_offsets(update_chunk_offsets_context_t *context, atom_t *atom)
{
static int update_stco_offsets(update_chunk_offsets_context_t *context, atom_t *atom) {
uint32_t current_offset;
uint32_t offset_count;
unsigned char *pos;
@ -200,8 +198,7 @@ static int update_stco_offsets(update_chunk_offsets_context_t *context, atom_t *
return 0;
}
static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t *atom)
{
static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t *atom) {
uint64_t current_offset;
uint32_t offset_count;
unsigned char *pos;
@ -230,8 +227,7 @@ static int update_co64_offsets(update_chunk_offsets_context_t *context, atom_t *
return 0;
}
static int update_chunk_offsets_callback(void *ctx, atom_t *atom)
{
static int update_chunk_offsets_callback(void *ctx, atom_t *atom) {
update_chunk_offsets_context_t *context = ctx;
int ret;
@ -267,23 +263,19 @@ static int update_chunk_offsets_callback(void *ctx, atom_t *atom)
return 0;
}
static void set_atom_size(unsigned char *header, uint32_t header_size, uint64_t size)
{
static void set_atom_size(unsigned char *header, uint32_t header_size, uint64_t size) {
switch (header_size) {
case 8:
AV_WB32(header, size);
case 8: AV_WB32(header, size);
break;
case 16:
AV_WB64(header + 8, size);
case 16: AV_WB64(header + 8, size);
break;
default:
break;
}
}
static void upgrade_stco_atom(upgrade_stco_context_t *context, atom_t *atom)
{
static void upgrade_stco_atom(upgrade_stco_context_t *context, atom_t *atom) {
unsigned char *pos;
unsigned char *end;
uint64_t new_offset;
@ -305,14 +297,13 @@ static void upgrade_stco_atom(upgrade_stco_context_t *context, atom_t *atom)
pos < end;
pos += 4) {
original_offset = BE_32(pos) - context->original_moov_size;
new_offset = (uint64_t)original_offset + context->new_moov_size;
new_offset = (uint64_t) original_offset + context->new_moov_size;
AV_WB64(context->dest, new_offset);
context->dest += 8;
}
}
static int upgrade_stco_callback(void *ctx, atom_t *atom)
{
static int upgrade_stco_callback(void *ctx, atom_t *atom) {
upgrade_stco_context_t *context = ctx;
unsigned char *start_pos;
uint64_t copy_size;
@ -357,9 +348,8 @@ static int upgrade_stco_callback(void *ctx, atom_t *atom)
static int update_moov_atom(
unsigned char **moov_atom,
uint64_t *moov_atom_size)
{
update_chunk_offsets_context_t update_context = { 0 };
uint64_t *moov_atom_size) {
update_chunk_offsets_context_t update_context = {0};
upgrade_stco_context_t upgrade_context;
unsigned char *new_moov_atom;
@ -648,7 +638,7 @@ FFMPEG_FUNC(jint, fastStart, jstring inputFile, jstring outputFile) {
return 0;
error_out:
error_out:
if (infile)
fclose(infile);
if (outfile)

@ -4,19 +4,19 @@
FFMPEG_FUNC(jint, handle, jobjectArray commands) {
int argc = (*env)->GetArrayLength(env, commands);
char **argv = (char**)malloc(argc * sizeof(char*));
char **argv = (char **) malloc(argc * sizeof(char *));
int i;
int result;
for (i = 0; i < argc; i++) {
jstring jstr = (jstring) (*env)->GetObjectArrayElement(env, commands, i);
char* temp = (char*) (*env)->GetStringUTFChars(env, jstr, 0);
char *temp = (char *) (*env)->GetStringUTFChars(env, jstr, 0);
argv[i] = malloc(1024);
strcpy(argv[i], temp);
(*env)->ReleaseStringUTFChars(env, jstr, temp);
}
//执行ffmpeg命令
//execute ffmpeg cmd
result = run(argc, argv);
//释放内存
//release memory
for (i = 0; i < argc; i++) {
free(argv[i]);
}

@ -8,7 +8,7 @@
#include <android/log.h>
#define LOGI(TAG, FORMAT, ...) __android_log_print(ANDROID_LOG_INFO, TAG, FORMAT, ##__VA_ARGS__);
#define LOGE(TAG, FORMAT,...) __android_log_print(ANDROID_LOG_ERROR, TAG, FORMAT, ##__VA_ARGS__);
#define LOGE(TAG, FORMAT, ...) __android_log_print(ANDROID_LOG_ERROR, TAG, FORMAT, ##__VA_ARGS__);
#define AUDIO_PLAYER_FUNC(RETURN_TYPE, FUNC_NAME, ...) \
JNIEXPORT RETURN_TYPE JNICALL Java_com_frank_ffmpeg_AudioPlayer_ ## FUNC_NAME \

Loading…
Cancel
Save