Commit e71649cc authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

CrOS Media App: Tweak marker detection for splicing in Exif frames.

Rather than requiring input to start with the Jpeg DQT frames, detect
whether an APP1 frame is already present. This allows an in-between
layer to add an APP2 frame for the colorspace.

Bug: b/169717921
Change-Id: I326575b33df4d8e609c9ca4a6c810a55d8f093a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500390Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822120}
parent 3998c554
...@@ -133,8 +133,8 @@ function makeOrientationIfdFrame(value) { ...@@ -133,8 +133,8 @@ function makeOrientationIfdFrame(value) {
* @return {!Promise<!File>} * @return {!Promise<!File>}
*/ */
async function extractFromRawImageBuffer(buffer) { async function extractFromRawImageBuffer(buffer) {
/** Quantization table. */ /** Application Segment Marker. */
const DQT_MARKER = 0xffdb; const APP1_MARKER = 0xffe1;
/** SOI. Page 64. */ /** SOI. Page 64. */
const START_OF_IMAGE = 0xffd8; const START_OF_IMAGE = 0xffd8;
...@@ -171,9 +171,11 @@ async function extractFromRawImageBuffer(buffer) { ...@@ -171,9 +171,11 @@ async function extractFromRawImageBuffer(buffer) {
return original('No SOI'); return original('No SOI');
} }
// Files returned by Piex should begin immediately with JPEG headers. // Files returned by Piex should begin immediately with JPEG headers (and the
if (view.getUint16(2) !== DQT_MARKER) { // Define Quantization Table marker). If a layer between here and Piex has
return original('Unexpected marker'); // added its own APP marker segment(s), don't add a duplicate.
if (view.getUint16(2) === APP1_MARKER) {
return original('APP1 marker already present');
} }
// Ignore the Start-Of-Image already in `jpegData` (TIFF_HEADER has one). // Ignore the Start-Of-Image already in `jpegData` (TIFF_HEADER has one).
......
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