|
|
|
@ -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) |
|
|
|
|