Commit 0a1b4d45 authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

demux: libmp4: add atoms/structures for flip4mac

parent e3dad6ab
......@@ -1459,6 +1459,83 @@ error:
MP4_READBOX_EXIT( 0 );
}
static int MP4_ReadBox_WMA2( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_WMA2_t );
MP4_Box_data_WMA2_t *p_WMA2 = p_box->data.p_WMA2;
MP4_GET2BYTESLE( p_WMA2->Format.wFormatTag );
MP4_GET2BYTESLE( p_WMA2->Format.nChannels );
MP4_GET4BYTESLE( p_WMA2->Format.nSamplesPerSec );
MP4_GET4BYTESLE( p_WMA2->Format.nAvgBytesPerSec );
MP4_GET2BYTESLE( p_WMA2->Format.nBlockAlign );
MP4_GET2BYTESLE( p_WMA2->Format.wBitsPerSample );
if ( i_read < 0 )
goto error;
p_WMA2->i_extra = i_read;
if ( p_WMA2->i_extra )
{
p_WMA2->p_extra = malloc( i_read );
if ( ! p_WMA2->p_extra )
goto error;
memcpy( p_WMA2->p_extra, p_peek, i_read );
}
MP4_READBOX_EXIT( 1 );
error:
MP4_READBOX_EXIT( 0 );
}
static void MP4_FreeBox_WMA2( MP4_Box_t *p_box )
{
FREENULL( p_box->data.p_WMA2->p_extra );
}
static int MP4_ReadBox_strf( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_strf_t );
MP4_Box_data_strf_t *p_strf = p_box->data.p_strf;
MP4_GET4BYTESLE( p_strf->bmiHeader.biSize );
MP4_GET4BYTESLE( p_strf->bmiHeader.biWidth );
MP4_GET4BYTESLE( p_strf->bmiHeader.biHeight );
MP4_GET2BYTESLE( p_strf->bmiHeader.biPlanes );
MP4_GET2BYTESLE( p_strf->bmiHeader.biBitCount );
MP4_GETFOURCC( p_strf->bmiHeader.biCompression );
MP4_GET4BYTESLE( p_strf->bmiHeader.biSizeImage );
MP4_GET4BYTESLE( p_strf->bmiHeader.biXPelsPerMeter );
MP4_GET4BYTESLE( p_strf->bmiHeader.biYPelsPerMeter );
MP4_GET4BYTESLE( p_strf->bmiHeader.biClrUsed );
MP4_GET4BYTESLE( p_strf->bmiHeader.biClrImportant );
if ( i_read < 0 )
goto error;
p_strf->i_extra = i_read;
if ( p_strf->i_extra )
{
p_strf->p_extra = malloc( p_strf->i_extra );
if ( ! p_strf->p_extra )
goto error;
memcpy( p_strf->p_extra, p_peek, i_read );
}
MP4_READBOX_EXIT( 1 );
error:
MP4_READBOX_EXIT( 0 );
}
static void MP4_FreeBox_strf( MP4_Box_t *p_box )
{
FREENULL( p_box->data.p_strf->p_extra );
}
static int MP4_ReadBox_stsdext_chan( stream_t *p_stream, MP4_Box_t *p_box )
{
MP4_READBOX_ENTER( MP4_Box_data_chan_t );
......@@ -3391,6 +3468,7 @@ static const struct
{ ATOM_tref, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_trak },
{ ATOM_gmhd, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_minf },
{ ATOM_wave, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_stsd },
{ ATOM_wave, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_WMA2 }, /* flip4mac */
{ ATOM_ilst, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_meta },
{ ATOM_mvex, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_moov },
{ ATOM_mvex, MP4_ReadBoxContainer, MP4_FreeBox_Common, ATOM_ftyp },
......@@ -3477,8 +3555,10 @@ static const struct
{ ATOM_sawb, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_OggS, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_alac, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd },
{ ATOM_WMA2, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun, ATOM_stsd }, /* flip4mac */
/* Sound extensions */
{ ATOM_chan, MP4_ReadBox_stsdext_chan, MP4_FreeBox_stsdext_chan, 0 },
{ ATOM_WMA2, MP4_ReadBox_WMA2, MP4_FreeBox_WMA2, ATOM_wave }, /* flip4mac */
{ ATOM_drmi, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
{ ATOM_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
......@@ -3504,6 +3584,7 @@ static const struct
{ ATOM_qdrw, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
{ ATOM_mp2v, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
{ ATOM_hdv2, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
{ ATOM_WMV3, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, ATOM_stsd },
{ ATOM_mjqt, MP4_ReadBox_default, NULL, 0 }, /* found in mjpa/b */
{ ATOM_mjht, MP4_ReadBox_default, NULL, 0 },
......@@ -3522,6 +3603,8 @@ static const struct
{ ATOM_yv12, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, 0 },
{ ATOM_yuv2, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide, 0 },
{ ATOM_strf, MP4_ReadBox_strf, MP4_FreeBox_strf, ATOM_WMV3 }, /* flip4mac */
{ ATOM_mp4s, MP4_ReadBox_sample_mp4s, MP4_FreeBox_Common, 0 },
/* XXX there is 2 box where we could find this entry stbl and tref*/
......@@ -3550,6 +3633,7 @@ static const struct
{ ATOM_iviv, MP4_ReadBox_drms, MP4_FreeBox_Common, 0 },
{ ATOM_priv, MP4_ReadBox_drms, MP4_FreeBox_Common, 0 },
{ ATOM_frma, MP4_ReadBox_frma, MP4_FreeBox_Common, ATOM_sinf }, /* and rinf */
{ ATOM_frma, MP4_ReadBox_frma, MP4_FreeBox_Common, ATOM_wave }, /* flip4mac */
{ ATOM_skcr, MP4_ReadBox_skcr, MP4_FreeBox_Common, 0 },
/* found in udta */
......
......@@ -24,6 +24,7 @@
#define _VLC_LIBMP4_H 1
#include <vlc_es.h>
#include <vlc_codecs.h>
#define BLOCK16x16 (1<<16)
......@@ -139,6 +140,7 @@
#define ATOM_dac3 VLC_FOURCC( 'd', 'a', 'c', '3' )
#define ATOM_dec3 VLC_FOURCC( 'd', 'e', 'c', '3' )
#define ATOM_dvc1 VLC_FOURCC( 'd', 'v', 'c', '1' )
#define ATOM_WMA2 VLC_FOURCC( 'W', 'M', 'A', '2' )
#define ATOM_enda VLC_FOURCC( 'e', 'n', 'd', 'a' )
#define ATOM_gnre VLC_FOURCC( 'g', 'n', 'r', 'e' )
#define ATOM_trkn VLC_FOURCC( 't', 'r', 'k', 'n' )
......@@ -169,6 +171,7 @@
#define ATOM_vp31 VLC_FOURCC( 'v', 'p', '3', '1' )
#define ATOM_h264 VLC_FOURCC( 'h', '2', '6', '4' )
#define ATOM_qdrw VLC_FOURCC( 'q', 'd', 'r', 'w' )
#define ATOM_WMV3 VLC_FOURCC( 'W', 'M', 'V', '3' )
#define ATOM_avc1 VLC_FOURCC( 'a', 'v', 'c', '1' )
#define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
......@@ -198,6 +201,7 @@
#define ATOM_gmhd VLC_FOURCC( 'g', 'm', 'h', 'd' )
#define ATOM_wave VLC_FOURCC( 'w', 'a', 'v', 'e' )
#define ATOM_strf VLC_FOURCC( 's', 't', 'r', 'f' )
#define ATOM_drms VLC_FOURCC( 'd', 'r', 'm', 's' )
#define ATOM_sinf VLC_FOURCC( 's', 'i', 'n', 'f' )
......@@ -1043,6 +1047,20 @@ typedef struct
} MP4_Box_data_avcC_t;
typedef struct
{
WAVEFORMATEX Format;
uint32_t i_extra;
char *p_extra;
} MP4_Box_data_WMA2_t;
typedef struct
{
VLC_BITMAPINFOHEADER bmiHeader;
uint32_t i_extra;
char *p_extra;
} MP4_Box_data_strf_t;
/* According to Apple's CoreAudio/CoreAudioTypes.h */
#define MP4_CHAN_USE_CHANNELS_DESC 0
#define MP4_CHAN_USE_CHANNELS_BITMAP (1<<16)
......@@ -1360,6 +1378,8 @@ typedef union MP4_Box_data_s
MP4_Box_data_tfrf_t *p_tfrf;
MP4_Box_data_tfxd_t *p_tfxd;
MP4_Box_data_hvcC_t *p_hvcC;
MP4_Box_data_WMA2_t *p_WMA2; /* flip4mac Little endian audio config */
MP4_Box_data_strf_t *p_strf; /* flip4mac Little endian video config */
MP4_Box_data_data_t *p_data;
......@@ -1420,6 +1440,10 @@ static inline size_t mp4_box_headersize( MP4_Box_t *p_box )
#define MP4_GETFOURCC( dst ) MP4_GETX_PRIVATE( dst, \
VLC_FOURCC(p_peek[0],p_peek[1],p_peek[2],p_peek[3]), 4)
#define MP4_GET2BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetWLE(p_peek), 2 )
#define MP4_GET4BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetDWLE(p_peek), 4 )
#define MP4_GET8BYTESLE( dst ) MP4_GETX_PRIVATE( dst, GetQWLE(p_peek), 8 )
#define MP4_GETVERSIONFLAGS( p_void ) \
MP4_GET1BYTE( p_void->i_version ); \
MP4_GET3BYTES( p_void->i_flags )
......
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