Commit 921d37dd authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

jpeg: handle Spatial RDF metadata coded as XML data

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent c1ae08c2
......@@ -256,11 +256,23 @@ static bool getRDFFloat(const char *psz_rdf, float *out, const char *psz_var)
return false;
size_t varlen = strlen(psz_var);
char *p_end = strchr(p_start + varlen, '"');
p_start += varlen;
char *p_end = NULL;
/* XML style */
if (p_start[0] == '>')
{
p_start += 1;
p_end = strchr(p_start, '<');
}
else if (p_start[0] == '=' && p_start[1] == '"')
{
p_start += 2;
p_end = strchr(p_start, '"');
}
if (unlikely(p_end == NULL || p_end == p_start + 1))
return false;
*out = us_strtof(p_start + varlen, NULL);
*out = us_strtof(p_start, NULL);
return true;
}
......@@ -296,31 +308,32 @@ static void jpeg_GetProjection(j_decompress_ptr cinfo, video_format_t *fmt)
/* Try to find the string "GSpherical:Spherical" because the v1
spherical video spec says the tag must be there. */
if (strcasestr(psz_rdf, "ProjectionType=\"equirectangular\""))
if (strcasestr(psz_rdf, "ProjectionType=\"equirectangular\"") ||
strcasestr(psz_rdf, "ProjectionType>equirectangular"))
fmt->projection_mode = PROJECTION_MODE_EQUIRECTANGULAR;
/* pose handling */
float value;
if (getRDFFloat(psz_rdf, &value, "PoseHeadingDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "PoseHeadingDegrees"))
fmt->pose.f_yaw_degrees = value;
if (getRDFFloat(psz_rdf, &value, "PosePitchDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "PosePitchDegrees"))
fmt->pose.f_pitch_degrees = value;
if (getRDFFloat(psz_rdf, &value, "PoseRollDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "PoseRollDegrees"))
fmt->pose.f_roll_degrees = value;
/* initial view */
if (getRDFFloat(psz_rdf, &value, "InitialViewHeadingDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "InitialViewHeadingDegrees"))
fmt->pose.f_yaw_degrees = value;
if (getRDFFloat(psz_rdf, &value, "InitialViewPitchDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "InitialViewPitchDegrees"))
fmt->pose.f_pitch_degrees = value;
if (getRDFFloat(psz_rdf, &value, "InitialViewRollDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "InitialViewRollDegrees"))
fmt->pose.f_roll_degrees = value;
if (getRDFFloat(psz_rdf, &value, "InitialHorizontalFOVDegrees=\""))
if (getRDFFloat(psz_rdf, &value, "InitialHorizontalFOVDegrees"))
fmt->pose.f_fov_degrees = value;
free(psz_rdf);
......
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