[vlc-commits] Add HEVC support in MP4
Denis Charmet
git at videolan.org
Tue Oct 22 23:17:58 CEST 2013
vlc | branch: master | Denis Charmet <typx at dinauz.org> | Tue Oct 22 23:15:44 2013 +0200| [afd070360514d4572a3bbde02656fbca3feae735] | committer: Denis Charmet
Add HEVC support in MP4
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=afd070360514d4572a3bbde02656fbca3feae735
---
modules/demux/mp4/libmp4.c | 24 ++++++++++++++++++++++++
modules/demux/mp4/libmp4.h | 9 +++++++++
modules/demux/mp4/mp4.c | 22 ++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index d2276d6..3abb940 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1303,6 +1303,29 @@ static int MP4_ReadBox_esds( stream_t *p_stream, MP4_Box_t *p_box )
#undef es_descriptor
}
+static void MP4_FreeBox_hvcC(MP4_Box_t *p_box )
+{
+ MP4_Box_data_hvcC_t *p_hvcC = p_box->data.p_hvcC;
+ if( p_hvcC->i_hvcC > 0 ) FREENULL( p_hvcC->p_hvcC) ;
+}
+
+static int MP4_ReadBox_hvcC( stream_t *p_stream, MP4_Box_t *p_box )
+{
+ MP4_Box_data_hvcC_t *p_hvcC;
+
+ MP4_READBOX_ENTER( MP4_Box_data_hvcC_t );
+ p_hvcC = p_box->data.p_hvcC;
+
+ p_hvcC->i_hvcC = i_read;
+ if( p_hvcC->i_hvcC > 0 )
+ {
+ uint8_t * p = p_hvcC->p_hvcC = malloc( p_hvcC->i_hvcC );
+ if( p )
+ memcpy( p, p_peek, i_read );
+ }
+ MP4_READBOX_EXIT( 1 );
+}
+
static void MP4_FreeBox_avcC( MP4_Box_t *p_box )
{
MP4_Box_data_avcC_t *p_avcC = p_box->data.p_avcC;
@@ -3180,6 +3203,7 @@ static const struct
{ ATOM_dcom, MP4_ReadBox_dcom, MP4_FreeBox_Common },
{ ATOM_cmvd, MP4_ReadBox_cmvd, MP4_FreeBox_cmvd },
{ ATOM_avcC, MP4_ReadBox_avcC, MP4_FreeBox_avcC },
+ { ATOM_hvcC, MP4_ReadBox_hvcC, MP4_FreeBox_hvcC },
{ ATOM_dac3, MP4_ReadBox_dac3, MP4_FreeBox_Common },
{ ATOM_dvc1, MP4_ReadBox_dvc1, MP4_FreeBox_Common },
{ ATOM_enda, MP4_ReadBox_enda, MP4_FreeBox_Common },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 88de85a..c430f22 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -167,6 +167,8 @@
#define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
#define ATOM_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
+#define ATOM_hvcC VLC_FOURCC( 'h', 'v', 'c', 'C' )
+
#define ATOM_dvc VLC_FOURCC( 'd', 'v', 'c', ' ' )
#define ATOM_dvp VLC_FOURCC( 'd', 'v', 'p', ' ' )
#define ATOM_dv5n VLC_FOURCC( 'd', 'v', '5', 'n' )
@@ -1149,6 +1151,12 @@ typedef struct
uint8_t *CodecPrivateData;
} MP4_Box_data_stra_t;
+typedef struct
+{
+ uint32_t i_hvcC;
+ uint8_t *p_hvcC;
+} MP4_Box_data_hvcC_t;
+
/*
typedef struct MP4_Box_data__s
{
@@ -1233,6 +1241,7 @@ 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;
void *p_data; /* for unknow type */
} MP4_Box_data_t;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 1ccd510..c30dc77 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -2217,6 +2217,28 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
}
break;
}
+ case VLC_FOURCC( 'h', 'v', 'c', '1' ):
+ {
+ MP4_Box_t *p_hvcC = MP4_BoxGet( p_sample, "hvcC" );
+
+ if( p_hvcC )
+ {
+ p_track->fmt.i_extra = p_hvcC->data.p_hvcC->i_hvcC;
+ if( p_track->fmt.i_extra > 0 )
+ {
+ p_track->fmt.p_extra = malloc( p_hvcC->data.p_hvcC->i_hvcC );
+ memcpy( p_track->fmt.p_extra, p_hvcC->data.p_hvcC->p_hvcC,
+ p_track->fmt.i_extra );
+ }
+ p_track->fmt.i_codec = VLC_CODEC_HEVC;
+ }
+ else
+ {
+ msg_Err( p_demux, "missing hvcC" );
+ }
+ break;
+ }
+
case VLC_CODEC_ADPCM_MS:
case VLC_CODEC_ADPCM_IMA_WAV:
More information about the vlc-commits
mailing list