Skip to content

Commit

Permalink
added HEIF playback for avc jpeg and png
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Oct 18, 2017
1 parent 4b4e702 commit 430bea9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
9 changes: 0 additions & 9 deletions modules/isom_in/read.c
Expand Up @@ -824,18 +824,9 @@ GF_Err ISOR_ConnectChannel(GF_InputService *plug, LPNETCHANNEL channel, const ch
ch->time_scale = gf_isom_get_media_timescale(ch->owner->mov, ch->track);
}
else {
u32 item_type;
ch->item_id = ESID;
ch->item_idx = item_idx;
ch->use_item = GF_TRUE;
gf_isom_get_meta_item_info(ch->owner->mov, GF_TRUE, 0, ch->item_idx, NULL, &item_type, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
switch (item_type) {
case GF_ISOM_SUBTYPE_HVC1:
ch->streamType = GF_STREAM_VISUAL;
break;
default:
e = GF_BAD_PARAM;
}
ch->has_edit_list = GF_FALSE;
ch->has_rap = GF_TRUE;
ch->time_scale = 1000;
Expand Down
14 changes: 10 additions & 4 deletions src/isomedia/meta.c
Expand Up @@ -553,12 +553,17 @@ GF_EXPORT
GF_Err gf_isom_get_meta_image_props(GF_ISOFile *file, Bool root_meta, u32 track_num, u32 item_id, GF_ImageItemProperties *prop) {
u32 count, i;
u32 count2, j;
GF_MetaBox *meta;
meta = gf_isom_get_meta(file, root_meta, track_num);
GF_ItemPropertyAssociationBox *ipma = NULL;
GF_ItemPropertyContainerBox *ipco = NULL;
GF_MetaBox *meta = gf_isom_get_meta(file, root_meta, track_num);
if (!meta) return GF_BAD_PARAM;

GF_ItemPropertyAssociationBox *ipma = (GF_ItemPropertyAssociationBox *)gf_list_get(meta->item_props->other_boxes, 0);
GF_ItemPropertyContainerBox *ipco = meta->item_props->property_container;
memset(prop, 0, sizeof(GF_ImageItemProperties));
if (!meta->item_props) return GF_OK;

ipma = (GF_ItemPropertyAssociationBox *)gf_list_get(meta->item_props->other_boxes, 0);
ipco = meta->item_props->property_container;

count = gf_list_count(ipma->entries);
for (i = 0; i < count; i++) {
GF_ItemPropertyAssociationEntry *entry = (GF_ItemPropertyAssociationEntry *)gf_list_get(ipma->entries, i);
Expand Down Expand Up @@ -597,6 +602,7 @@ GF_Err gf_isom_get_meta_image_props(GF_ISOFile *file, Bool root_meta, u32 track_
}
break;
case GF_ISOM_BOX_TYPE_HVCC:
case GF_ISOM_BOX_TYPE_AVCC:
prop->config = b;
break;
}
Expand Down
62 changes: 57 additions & 5 deletions src/media_tools/isom_tools.c
Expand Up @@ -979,11 +979,11 @@ GF_ESD *gf_media_map_item_esd(GF_ISOFile *mp4, u32 item_id)
u32 item_type;
u32 prot_idx;
Bool is_self_ref;
char *name;
char *mime;
char *encoding;
char *url;
char *urn;
const char *name;
const char *mime;
const char *encoding;
const char *url;
const char *urn;
GF_ESD *esd;
GF_Err e;

Expand Down Expand Up @@ -1011,7 +1011,59 @@ GF_ESD *gf_media_map_item_esd(GF_ISOFile *mp4, u32 item_id)
esd->slConfig->useTimestampsFlag = 1;
esd->slConfig->timestampResolution = 1000;
return esd;
} else if (item_type == GF_ISOM_SUBTYPE_AVC_H264) {
GF_ImageItemProperties props;
esd = gf_odf_desc_esd_new(0);
if (item_id > (1 << 16)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("Item ID greater than 16 bits, does not fit on ES ID\n"));
}
esd->ESID = (u16)item_id;
esd->OCRESID = esd->ESID;
esd->decoderConfig->streamType = GF_STREAM_VISUAL;
esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_AVC;
e = gf_isom_get_meta_image_props(mp4, GF_TRUE, 0, item_id, &props);
if (e == GF_OK && props.config) {
gf_odf_avc_cfg_write(((GF_AVCConfigurationBox *)props.config)->config, &esd->decoderConfig->decoderSpecificInfo->data, &esd->decoderConfig->decoderSpecificInfo->dataLength);
}
esd->slConfig->hasRandomAccessUnitsOnlyFlag = 1;
esd->slConfig->useTimestampsFlag = 1;
esd->slConfig->timestampResolution = 1000;
return esd;
} else if ((item_type == GF_ISOM_SUBTYPE_JPEG) || (mime && !strcmp(mime, "image/jpeg")) ){
GF_ImageItemProperties props;
esd = gf_odf_desc_esd_new(0);
if (item_id > (1 << 16)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("Item ID greater than 16 bits, does not fit on ES ID\n"));
}
esd->ESID = (u16)item_id;
esd->OCRESID = esd->ESID;
esd->decoderConfig->streamType = GF_STREAM_VISUAL;
esd->decoderConfig->objectTypeIndication = GPAC_OTI_IMAGE_JPEG;
e = gf_isom_get_meta_image_props(mp4, GF_TRUE, 0, item_id, &props);
if (e == GF_OK && props.config) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("JPEG image item decoder config not supported, patch welcome\n"));
}
esd->slConfig->hasRandomAccessUnitsOnlyFlag = 1;
esd->slConfig->useTimestampsFlag = 1;
esd->slConfig->timestampResolution = 1000;
return esd;
} else if ((item_type == GF_ISOM_SUBTYPE_PNG) || (mime && !strcmp(mime, "image/png")) ){
GF_ImageItemProperties props;
esd = gf_odf_desc_esd_new(0);
if (item_id > (1 << 16)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("Item ID greater than 16 bits, does not fit on ES ID\n"));
}
esd->ESID = (u16)item_id;
esd->OCRESID = esd->ESID;
esd->decoderConfig->streamType = GF_STREAM_VISUAL;
esd->decoderConfig->objectTypeIndication = GPAC_OTI_IMAGE_PNG;
e = gf_isom_get_meta_image_props(mp4, GF_TRUE, 0, item_id, &props);
esd->slConfig->hasRandomAccessUnitsOnlyFlag = 1;
esd->slConfig->useTimestampsFlag = 1;
esd->slConfig->timestampResolution = 1000;
return esd;
} else {

return NULL;
}
}
Expand Down

0 comments on commit 430bea9

Please sign in to comment.