mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
atomsrecovery: also handle extra atoms after 'mdia' in a 'trak'
Take into account the atoms at the end of the 'trak' atom when recovering it. So that its size (already computed and added in the trak size) isn't making offsets wrong. https://bugzilla.gnome.org/show_bug.cgi?id=771478
This commit is contained in:
parent
7e39dec391
commit
b434ba86f1
2 changed files with 39 additions and 0 deletions
|
@ -673,6 +673,11 @@ moov_recov_parse_trak (MoovRecovFile * moovrf, TrakRecovData * trakrd)
|
||||||
if (!moov_recov_parse_mdia (moovrf, trakrd))
|
if (!moov_recov_parse_mdia (moovrf, trakrd))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
fseek (moovrf->file, (long int) trakrd->mdia_file_offset + trakrd->mdia_size,
|
||||||
|
SEEK_SET);
|
||||||
|
trakrd->extra_atoms_offset = ftell (moovrf->file);
|
||||||
|
trakrd->extra_atoms_size = size - (trakrd->extra_atoms_offset - offset);
|
||||||
|
|
||||||
trakrd->file_offset = offset;
|
trakrd->file_offset = offset;
|
||||||
/* position after the trak */
|
/* position after the trak */
|
||||||
return fseek (moovrf->file, (long int) offset + size, SEEK_SET) == 0;
|
return fseek (moovrf->file, (long int) offset + size, SEEK_SET) == 0;
|
||||||
|
@ -921,6 +926,31 @@ fail:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
copy_data_from_file_to_file (FILE * from, guint position, guint size, FILE * to,
|
||||||
|
GError ** err)
|
||||||
|
{
|
||||||
|
guint8 *data = NULL;
|
||||||
|
|
||||||
|
if (fseek (from, position, SEEK_SET) != 0)
|
||||||
|
goto fail;
|
||||||
|
data = g_malloc (size);
|
||||||
|
if (fread (data, 1, size, from) != size) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (fwrite (data, 1, size, to) != size) {
|
||||||
|
ATOMS_RECOV_OUTPUT_WRITE_ERROR (err);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (data);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
g_free (data);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
moov_recov_write_file (MoovRecovFile * moovrf, MdatRecovFile * mdatrf,
|
moov_recov_write_file (MoovRecovFile * moovrf, MdatRecovFile * mdatrf,
|
||||||
FILE * outf, GError ** err)
|
FILE * outf, GError ** err)
|
||||||
|
@ -1088,10 +1118,16 @@ moov_recov_write_file (MoovRecovFile * moovrf, MdatRecovFile * mdatrf,
|
||||||
ATOMS_RECOV_OUTPUT_WRITE_ERROR (err);
|
ATOMS_RECOV_OUTPUT_WRITE_ERROR (err);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (trak_data);
|
g_free (trak_data);
|
||||||
trak_data = NULL;
|
trak_data = NULL;
|
||||||
g_free (stbl_children);
|
g_free (stbl_children);
|
||||||
stbl_children = NULL;
|
stbl_children = NULL;
|
||||||
|
|
||||||
|
/* Copy the extra atoms after 'minf' */
|
||||||
|
if (!copy_data_from_file_to_file (moovrf->file, trak->extra_atoms_offset,
|
||||||
|
trak->extra_atoms_size, outf, err))
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write the mdat */
|
/* write the mdat */
|
||||||
|
|
|
@ -103,6 +103,9 @@ typedef struct
|
||||||
guint64 post_stsd_offset;
|
guint64 post_stsd_offset;
|
||||||
guint32 stsd_size;
|
guint32 stsd_size;
|
||||||
|
|
||||||
|
guint32 extra_atoms_size;
|
||||||
|
guint32 extra_atoms_offset;
|
||||||
|
|
||||||
/* for storing the samples info */
|
/* for storing the samples info */
|
||||||
AtomSTBL stbl;
|
AtomSTBL stbl;
|
||||||
} TrakRecovData;
|
} TrakRecovData;
|
||||||
|
|
Loading…
Reference in a new issue