Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94314247 authored by junjiez's avatar junjiez Committed by Gerrit - the friendly Code Review server
Browse files

SnapdraongCamera:Fix HEIF exif

Exif information is not aligned in
heif images, need to check byte by
byte to avoid lossing exif.

Change-Id: I1c67d399d28494067722ea59aea61994349860c4
CRs-Fixed: 2583399
parent 22103395
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -106,6 +106,12 @@ public class CountedDataInputStream extends FilterInputStream {
        return readShort() & 0xffff;
    }

    public byte readByte() throws IOException {
        readOrThrow(mByteArray, 0 ,1);
        mByteBuffer.rewind();
        return mByteBuffer.get(0);
    }

    public int readInt() throws IOException {
        readOrThrow(mByteArray, 0 , 4);
        mByteBuffer.rewind();
+19 −14
Original line number Diff line number Diff line
@@ -140,6 +140,8 @@ class ExifParser {
    protected static final int OFFSET_SIZE = 2;

    private static final Charset US_ASCII = Charset.forName("US-ASCII");
    private static final byte APP1_UP = (byte)0xFF;
    private static final byte APP1_DOWN = (byte)0xE1;

    protected static final int DEFAULT_IFD0_OFFSET = 8;

@@ -784,15 +786,16 @@ class ExifParser {
                }
                marker = dataStream.readShort();
            }


        } else{
            dataStream.skip(6);
            if (dataStream.readInt() == HEIC_HEADER) {
                while(true){
                    try{
                        short marker = dataStream.readShort();
                        if (marker == JpegHeader.APP1) {
                        byte marker = dataStream.readByte();
                        if(marker == APP1_UP){
                            dataStream.mark(8);
                            marker = dataStream.readByte();
                            if (marker == APP1_DOWN){
                                int header = 0;
                                short headerTail = 0;
                                int length = dataStream.readUnsignedShort();
@@ -805,6 +808,8 @@ class ExifParser {
                                    return true;
                                }
                            }
                            dataStream.reset();
                        }
                    }catch (Exception e){
                        break;
                    }