Merges new jpgjs: fixes invalid JPEG marker.
This commit is contained in:
parent
62e6b434b9
commit
ac0ae3e5fd
31
external/jpgjs/LICENSE
vendored
31
external/jpgjs/LICENSE
vendored
@ -1,24 +1,17 @@
|
|||||||
|
|
||||||
Copyright (C) 2011 by notmasteryet
|
Copyright (C) 2011 notmasteryet
|
||||||
|
|
||||||
Contributors: Yury Delendik
|
Contributors: Yury Delendik <ydelendik@mozilla.com>
|
||||||
Brendan Dahl <bdahl@mozilla.com>
|
Brendan Dahl <bdahl@mozilla.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
a copy of this software and associated documentation files (the
|
you may not use this file except in compliance with the License.
|
||||||
"Software"), to deal in the Software without restriction, including
|
You may obtain a copy of the License at
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
Unless required by applicable law or agreed to in writing, software
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
See the License for the specific language governing permissions and
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
limitations under the License.
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
27
external/jpgjs/jpg.js
vendored
27
external/jpgjs/jpg.js
vendored
@ -1,5 +1,20 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
/*
|
||||||
|
Copyright 2011 notmasteryet
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
// - The JPEG specification can be found in the ITU CCITT Recommendation T.81
|
// - The JPEG specification can be found in the ITU CCITT Recommendation T.81
|
||||||
// (www.w3.org/Graphics/JPEG/itu-t81.pdf)
|
// (www.w3.org/Graphics/JPEG/itu-t81.pdf)
|
||||||
@ -627,8 +642,9 @@ var JpegImage = (function jpegImage() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFFDB: // DQT (Define Quantization Tables)
|
case 0xFFDB: // DQT (Define Quantization Tables)
|
||||||
var quantizationTableCount = Math.floor((readUint16() - 2) / 65);
|
var quantizationTablesLength = readUint16();
|
||||||
for (i = 0; i < quantizationTableCount; i++) {
|
var quantizationTablesEnd = quantizationTablesLength + offset - 2;
|
||||||
|
while (offset < quantizationTablesEnd) {
|
||||||
var quantizationTableSpec = data[offset++];
|
var quantizationTableSpec = data[offset++];
|
||||||
var tableData = new Int32Array(64);
|
var tableData = new Int32Array(64);
|
||||||
if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
|
if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
|
||||||
@ -721,6 +737,13 @@ var JpegImage = (function jpegImage() {
|
|||||||
offset += processed;
|
offset += processed;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
if (data[offset - 3] == 0xFF &&
|
||||||
|
data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
|
||||||
|
// could be incorrect encoding -- last 0xFF byte of the previous
|
||||||
|
// block was eaten by the encoder
|
||||||
|
offset -= 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
throw "unknown JPEG marker " + fileMarker.toString(16);
|
throw "unknown JPEG marker " + fileMarker.toString(16);
|
||||||
}
|
}
|
||||||
fileMarker = readUint16();
|
fileMarker = readUint16();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user