[vlc-commits] Added 'pasp' atom support to mp4/mov demuxer.
Laurent Aimar
git at videolan.org
Thu Oct 27 20:35:22 CEST 2011
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Oct 27 00:07:47 2011 +0200| [6b49065d2c4ba3375fd5c4962a097e592f9d859d] | committer: Laurent Aimar
Added 'pasp' atom support to mp4/mov demuxer.
This atom can store an optionnal aspect ratio.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b49065d2c4ba3375fd5c4962a097e592f9d859d
---
modules/demux/mp4/libmp4.c | 18 ++++++++++++++++++
modules/demux/mp4/libmp4.h | 8 ++++++++
modules/demux/mp4/mp4.c | 9 +++++++++
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 35ebfee..d26da3d 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -2704,6 +2704,23 @@ static int MP4_ReadBox_iods( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 );
}
+static int MP4_ReadBox_pasp( stream_t *p_stream, MP4_Box_t *p_box )
+{
+ MP4_READBOX_ENTER( MP4_Box_data_pasp_t );
+
+ MP4_GET4BYTES( p_box->data.p_pasp->i_horizontal_spacing );
+ MP4_GET4BYTES( p_box->data.p_pasp->i_vertical_spacing );
+
+#ifdef MP4_VERBOSE
+ msg_Dbg( p_stream,
+ "read box: \"paps\" %dx%d",
+ p_box->data.p_pasp->i_horizontal_spacing,
+ p_box->data.p_pasp->i_vertical_spacing);
+#endif
+
+ MP4_READBOX_EXIT( 1 );
+}
+
/* For generic */
static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box )
@@ -2818,6 +2835,7 @@ static const struct
{ ATOM_gnre, MP4_ReadBox_gnre, MP4_FreeBox_Common },
{ ATOM_trkn, MP4_ReadBox_trkn, MP4_FreeBox_Common },
{ ATOM_iods, MP4_ReadBox_iods, MP4_FreeBox_Common },
+ { ATOM_pasp, MP4_ReadBox_pasp, MP4_FreeBox_Common },
/* Nothing to do with this box */
{ ATOM_mdat, MP4_ReadBoxSkip, MP4_FreeBox_Common },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index f9e89dc..c4d2c82 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -80,6 +80,7 @@
#define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
#define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
#define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' )
+#define ATOM_pasp VLC_FOURCC( 'p', 'a', 's', 'p' )
#define ATOM_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
#define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
@@ -981,6 +982,12 @@ typedef struct
} MP4_Box_data_iods_t;
+typedef struct
+{
+ uint32_t i_horizontal_spacing;
+ uint32_t i_vertical_spacing;
+} MP4_Box_data_pasp_t;
+
/*
typedef struct MP4_Box_data__s
{
@@ -1022,6 +1029,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_gnre_t *p_gnre;
MP4_Box_data_trkn_t *p_trkn;
MP4_Box_data_iods_t *p_iods;
+ MP4_Box_data_pasp_t *p_pasp;
MP4_Box_data_stsz_t *p_stsz;
MP4_Box_data_stz2_t *p_stz2;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index c04e400..4ef7b76 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -1506,6 +1506,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
MP4_Box_t *p_esds;
MP4_Box_t *p_frma;
MP4_Box_t *p_enda;
+ MP4_Box_t *p_pasp;
if( pp_es )
*pp_es = NULL;
@@ -1541,6 +1542,8 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
if( !p_enda )
p_enda = MP4_BoxGet( p_sample, "enda" );
+ p_pasp = MP4_BoxGet( p_sample, "pasp" );
+
if( p_track->fmt.i_cat == AUDIO_ES && ( p_track->i_sample_size == 1 || p_track->i_sample_size == 2 ) )
{
MP4_Box_data_sample_soun_t *p_soun;
@@ -1640,6 +1643,12 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
p_track->fmt.video.i_sar_num = p_track->i_width * p_track->fmt.video.i_height;
p_track->fmt.video.i_sar_den = p_track->i_height * p_track->fmt.video.i_width;
}
+ if( p_pasp && p_pasp->data.p_pasp->i_horizontal_spacing > 0 &&
+ p_pasp->data.p_pasp->i_vertical_spacing > 0 )
+ {
+ p_track->fmt.video.i_sar_num = p_pasp->data.p_pasp->i_horizontal_spacing;
+ p_track->fmt.video.i_sar_den = p_pasp->data.p_pasp->i_vertical_spacing;
+ }
/* Support for cropping (eg. in H263 files) */
p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width;
More information about the vlc-commits
mailing list