[x264-devel] mp4_lsmash: Use new I/O API instead of deprecated one.
Yusuke Nakamura
git at videolan.org
Sun Jul 20 11:58:31 CEST 2014
x264 | branch: master | Yusuke Nakamura <muken.the.vfrmaniac at gmail.com> | Thu Jun 19 05:21:29 2014 +0900| [8a85db879d57537f91a9908be3585512981c08b8] | committer: Fiona Glaser
mp4_lsmash: Use new I/O API instead of deprecated one.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=8a85db879d57537f91a9908be3585512981c08b8
---
configure | 4 ++--
output/mp4_lsmash.c | 32 ++++++++++++++++++--------------
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/configure b/configure
index f71c696..0a4cb94 100755
--- a/configure
+++ b/configure
@@ -943,10 +943,10 @@ if [ "$lsmash" = "auto" ] ; then
[ -z "$LSMASH_LIBS" ] && LSMASH_LIBS="-llsmash"
if cc_check lsmash.h "$LSMASH_CFLAGS $LSMASH_LIBS" ; then
- if cpp_check lsmash.h "$LSMASH_CFLAGS" "LSMASH_VERSION_MAJOR > 0 || (LSMASH_VERSION_MAJOR == 0 && LSMASH_VERSION_MINOR >= 1)" ; then
+ if cpp_check lsmash.h "$LSMASH_CFLAGS" "LSMASH_VERSION_MAJOR > 1 || (LSMASH_VERSION_MAJOR == 1 && LSMASH_VERSION_MINOR >= 5)" ; then
lsmash="yes"
else
- echo "Warning: lsmash is too old, update to rev.751 or later"
+ echo "Warning: lsmash is too old, update to rev.895 or later"
fi
fi
fi
diff --git a/output/mp4_lsmash.c b/output/mp4_lsmash.c
index b4ed31c..ce259d7 100644
--- a/output/mp4_lsmash.c
+++ b/output/mp4_lsmash.c
@@ -79,6 +79,7 @@ typedef struct
int i_dts_compress_multiplier;
int b_use_recovery;
int b_fragments;
+ lsmash_file_parameters_t file_param;
} mp4_hnd_t;
/*******************/
@@ -88,16 +89,10 @@ static void remove_mp4_hnd( hnd_t handle )
mp4_hnd_t *p_mp4 = handle;
if( !p_mp4 )
return;
- if( p_mp4->p_sei_buffer )
- {
- free( p_mp4->p_sei_buffer );
- p_mp4->p_sei_buffer = NULL;
- }
- if( p_mp4->p_root )
- {
- lsmash_destroy_root( p_mp4->p_root );
- p_mp4->p_root = NULL;
- }
+ lsmash_cleanup_summary( (lsmash_summary_t *)p_mp4->summary );
+ lsmash_close_file( &p_mp4->file_param );
+ lsmash_destroy_root( p_mp4->p_root );
+ free( p_mp4->p_sei_buffer );
free( p_mp4 );
}
@@ -181,9 +176,13 @@ static int open_file( char *psz_filename, hnd_t *p_handle, cli_output_opt_t *opt
p_mp4->b_fragments = !b_regular;
p_mp4->b_stdout = !strcmp( psz_filename, "-" );
- p_mp4->p_root = lsmash_open_movie( psz_filename, p_mp4->b_fragments ? LSMASH_FILE_MODE_WRITE_FRAGMENTED : LSMASH_FILE_MODE_WRITE );
+ p_mp4->p_root = lsmash_create_root();
MP4_FAIL_IF_ERR_EX( !p_mp4->p_root, "failed to create root.\n" );
+ MP4_FAIL_IF_ERR_EX( lsmash_open_file( psz_filename, 0, &p_mp4->file_param ) < 0, "failed to open an output file.\n" );
+ if( p_mp4->b_fragments )
+ p_mp4->file_param.mode |= LSMASH_FILE_MODE_FRAGMENTED;
+
p_mp4->summary = (lsmash_video_summary_t *)lsmash_create_summary( LSMASH_SUMMARY_TYPE_VIDEO );
MP4_FAIL_IF_ERR_EX( !p_mp4->summary,
"failed to allocate memory for summary information of video.\n" );
@@ -219,12 +218,17 @@ static int set_param( hnd_t handle, x264_param_t *p_param )
brands[brand_count++] = ISOM_BRAND_TYPE_ISO6; /* cslg and visual random access grouping */
}
+ /* Set file */
+ lsmash_file_parameters_t *file_param = &p_mp4->file_param;
+ file_param->major_brand = brands[0];
+ file_param->brands = brands;
+ file_param->brand_count = brand_count;
+ file_param->minor_version = 0;
+ MP4_FAIL_IF_ERR( !lsmash_set_file( p_mp4->p_root, file_param ), "failed to add an output file into a ROOT.\n" );
+
/* Set movie parameters. */
lsmash_movie_parameters_t movie_param;
lsmash_initialize_movie_parameters( &movie_param );
- movie_param.major_brand = ISOM_BRAND_TYPE_MP42;
- movie_param.brands = brands;
- movie_param.number_of_brands = brand_count;
MP4_FAIL_IF_ERR( lsmash_set_movie_parameters( p_mp4->p_root, &movie_param ),
"failed to set movie parameters.\n" );
p_mp4->i_movie_timescale = lsmash_get_movie_timescale( p_mp4->p_root );
More information about the x264-devel
mailing list