[vlc-commits] demux: heif: handle JPEG
Francois Cartegnie
git at videolan.org
Wed Mar 14 17:46:31 CET 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 14 16:51:54 2018 +0100| [5273850e2dac53c69fecf3f98dcdd1ee9284fcd1] | committer: Francois Cartegnie
demux: heif: handle JPEG
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5273850e2dac53c69fecf3f98dcdd1ee9284fcd1
---
modules/demux/mp4/heif.c | 36 ++++++++++++++++++++++++++++++++++--
modules/demux/mp4/libmp4.c | 1 +
modules/demux/mp4/libmp4.h | 3 +++
modules/demux/mp4/mp4.c | 1 +
4 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/modules/demux/mp4/heif.c b/modules/demux/mp4/heif.c
index f2a066a5bc..4a65c2f534 100644
--- a/modules/demux/mp4/heif.c
+++ b/modules/demux/mp4/heif.c
@@ -48,6 +48,7 @@ struct heif_private_t
{
MP4_Box_t *p_infe;
es_format_t fmt;
+ const MP4_Box_t *p_shared_header;
} current;
};
@@ -227,6 +228,9 @@ static int DemuxHEIF( demux_t *p_demux )
p_sys->i_end_display_time = 0;
}
+ /* Reset prev pic params */
+ p_sys->current.p_shared_header = NULL;
+
/* First or next picture */
if( !p_sys->current.p_infe )
{
@@ -255,13 +259,22 @@ static int DemuxHEIF( demux_t *p_demux )
return VLC_DEMUXER_EOF;
es_format_t fmt;
+ const char *psz_mime = p_sys->current.BOXDATA(p_infe)->psz_content_type;
switch( p_sys->current.BOXDATA(p_infe)->item_type )
{
case VLC_FOURCC('h','v','c','1'):
es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_HEVC );
break;
- default: /* Unsupported picture, goto next */
- return VLC_DEMUXER_SUCCESS;
+ case VLC_FOURCC('j','p','e','g'):
+ es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_JPEG );
+ break;
+ default:
+ if( psz_mime && !strcasecmp( "image/jpeg", psz_mime ) )
+ {
+ es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_JPEG );
+ break;
+ }
+ return VLC_DEMUXER_SUCCESS; /* Unsupported picture, goto next */
}
/* Load properties */
@@ -292,6 +305,10 @@ static int DemuxHEIF( demux_t *p_demux )
}
}
break;
+ case ATOM_jpeC:
+ if( fmt.i_codec == VLC_CODEC_JPEG )
+ p_sys->current.p_shared_header = p_prop;
+ break;
case ATOM_ispe:
fmt.video.i_visible_width = p_prop->data.p_ispe->i_width;
fmt.video.i_visible_height = p_prop->data.p_ispe->i_height;
@@ -346,6 +363,20 @@ static int DemuxHEIF( demux_t *p_demux )
continue;
block_t **pp_append = &p_block;
+
+ /* Shared prefix data, ex: JPEG */
+ if( p_sys->current.p_shared_header )
+ {
+ *pp_append = block_Alloc( p_sys->current.p_shared_header->data.p_binary->i_blob );
+ if( *pp_append )
+ {
+ memcpy( (*pp_append)->p_buffer,
+ p_sys->current.p_shared_header->data.p_binary->p_blob,
+ p_sys->current.p_shared_header->data.p_binary->i_blob );
+ pp_append = &((*pp_append)->p_next);
+ }
+ }
+
for( uint16_t j=0; j<BOXDATA(p_iloc)->p_items[i].i_extent_count; j++ )
{
uint64_t i_offset = BOXDATA(p_iloc)->p_items[i].i_base_offset +
@@ -402,6 +433,7 @@ int OpenHEIF( vlc_object_t * p_this )
case MAJOR_mif1:
case MAJOR_heic:
case MAJOR_heix:
+ case MAJOR_jpeg:
break;
case MAJOR_msf1:
case MAJOR_hevc:
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 8198d0d561..11b0d79f09 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -4843,6 +4843,7 @@ static const struct
{ ATOM_avcC, MP4_ReadBox_avcC, ATOM_avc1 },
{ ATOM_avcC, MP4_ReadBox_avcC, ATOM_avc3 },
{ ATOM_hvcC, MP4_ReadBox_Binary, 0 },
+ { ATOM_jpeC, MP4_ReadBox_Binary, 0 }, /* heif */
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp08 },
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp09 },
{ ATOM_vpcC, MP4_ReadBox_vpcC, ATOM_vp10 },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 60fb4a4f86..be93d12019 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -48,6 +48,8 @@ typedef int64_t stime_t;
#define MAJOR_heix VLC_FOURCC( 'h', 'e', 'i', 'x' ) /* heif */
#define MAJOR_hevc VLC_FOURCC( 'h', 'e', 'v', 'c' ) /* heif */
#define MAJOR_hevx VLC_FOURCC( 'h', 'e', 'v', 'x' ) /* heif */
+#define MAJOR_jpeg VLC_FOURCC( 'j', 'p', 'e', 'g' ) /* heif */
+#define MAJOR_jpgs VLC_FOURCC( 'j', 'p', 'g', 's' ) /* heif */
#define ATOM_root VLC_FOURCC( 'r', 'o', 'o', 't' )
#define ATOM_uuid VLC_FOURCC( 'u', 'u', 'i', 'd' )
@@ -258,6 +260,7 @@ typedef int64_t stime_t;
#define ATOM_fiel VLC_FOURCC( 'f', 'i', 'e', 'l' )
#define ATOM_glbl VLC_FOURCC( 'g', 'l', 'b', 'l' )
#define ATOM_hvcC VLC_FOURCC( 'h', 'v', 'c', 'C' )
+#define ATOM_jpeC VLC_FOURCC( 'j', 'p', 'e', 'C' )
#define ATOM_dvc VLC_FOURCC( 'd', 'v', 'c', ' ' )
#define ATOM_dvp VLC_FOURCC( 'd', 'v', 'p', ' ' )
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index fabde94deb..b19050f066 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -730,6 +730,7 @@ static int Open( vlc_object_t * p_this )
case MAJOR_heic:
case MAJOR_heix:
case MAJOR_mif1:
+ case MAJOR_jpeg:
/* We don't yet support f4v, but avformat does. */
case MAJOR_f4v:
return VLC_EGENERIC;
More information about the vlc-commits
mailing list