Commit 6b49065d authored by Laurent Aimar's avatar Laurent Aimar

Added 'pasp' atom support to mp4/mov demuxer.

This atom can store an optionnal aspect ratio.
parent a2e00626
...@@ -2704,6 +2704,23 @@ static int MP4_ReadBox_iods( stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -2704,6 +2704,23 @@ static int MP4_ReadBox_iods( stream_t *p_stream, MP4_Box_t *p_box )
MP4_READBOX_EXIT( 1 ); 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 */ /* For generic */
static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box )
...@@ -2818,6 +2835,7 @@ static const struct ...@@ -2818,6 +2835,7 @@ static const struct
{ ATOM_gnre, MP4_ReadBox_gnre, MP4_FreeBox_Common }, { ATOM_gnre, MP4_ReadBox_gnre, MP4_FreeBox_Common },
{ ATOM_trkn, MP4_ReadBox_trkn, MP4_FreeBox_Common }, { ATOM_trkn, MP4_ReadBox_trkn, MP4_FreeBox_Common },
{ ATOM_iods, MP4_ReadBox_iods, 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 */ /* Nothing to do with this box */
{ ATOM_mdat, MP4_ReadBoxSkip, MP4_FreeBox_Common }, { ATOM_mdat, MP4_ReadBoxSkip, MP4_FreeBox_Common },
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' ) #define ATOM_trun VLC_FOURCC( 't', 'r', 'u', 'n' )
#define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' ) #define ATOM_cprt VLC_FOURCC( 'c', 'p', 'r', 't' )
#define ATOM_iods VLC_FOURCC( 'i', 'o', 'd', 's' ) #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_nmhd VLC_FOURCC( 'n', 'm', 'h', 'd' )
#define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' ) #define ATOM_mp2v VLC_FOURCC( 'm', 'p', '2', 'v' )
...@@ -981,6 +982,12 @@ typedef struct ...@@ -981,6 +982,12 @@ typedef struct
} MP4_Box_data_iods_t; } 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 typedef struct MP4_Box_data__s
{ {
...@@ -1022,6 +1029,7 @@ typedef union MP4_Box_data_s ...@@ -1022,6 +1029,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_gnre_t *p_gnre; MP4_Box_data_gnre_t *p_gnre;
MP4_Box_data_trkn_t *p_trkn; MP4_Box_data_trkn_t *p_trkn;
MP4_Box_data_iods_t *p_iods; MP4_Box_data_iods_t *p_iods;
MP4_Box_data_pasp_t *p_pasp;
MP4_Box_data_stsz_t *p_stsz; MP4_Box_data_stsz_t *p_stsz;
MP4_Box_data_stz2_t *p_stz2; MP4_Box_data_stz2_t *p_stz2;
......
...@@ -1506,6 +1506,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -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_esds;
MP4_Box_t *p_frma; MP4_Box_t *p_frma;
MP4_Box_t *p_enda; MP4_Box_t *p_enda;
MP4_Box_t *p_pasp;
if( pp_es ) if( pp_es )
*pp_es = NULL; *pp_es = NULL;
...@@ -1541,6 +1542,8 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -1541,6 +1542,8 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
if( !p_enda ) if( !p_enda )
p_enda = MP4_BoxGet( p_sample, "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 ) ) 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; MP4_Box_data_sample_soun_t *p_soun;
...@@ -1640,6 +1643,12 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track, ...@@ -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_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; 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) */ /* Support for cropping (eg. in H263 files) */
p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width; p_track->fmt.video.i_visible_width = p_track->fmt.video.i_width;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment