package J;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import b0.o;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import okhttp3.HttpUrl;

/* JADX INFO: loaded from: classes.dex */
public class c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private I.a f1000a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    Bitmap f1001b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    int f1002c;

    class a extends i implements g {

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1003k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f1004l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        List f1005m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        int[] f1006n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        int[] f1007o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        int[] f1008p;

        /* JADX INFO: renamed from: J.c$a$a, reason: collision with other inner class name */
        class C0011a implements g {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            int f1010a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            int f1011b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            int f1012c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            int f1013d;

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            int f1014e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            int f1015f;

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            int f1016g;

            /* JADX INFO: renamed from: h, reason: collision with root package name */
            int f1017h;

            /* JADX INFO: renamed from: i, reason: collision with root package name */
            int f1018i;

            /* JADX INFO: renamed from: j, reason: collision with root package name */
            int f1019j;

            /* JADX INFO: renamed from: k, reason: collision with root package name */
            int f1020k;

            /* JADX INFO: renamed from: l, reason: collision with root package name */
            int f1021l;

            /* JADX INFO: renamed from: m, reason: collision with root package name */
            int f1022m;

            /* JADX INFO: renamed from: n, reason: collision with root package name */
            int f1023n;

            /* JADX INFO: renamed from: o, reason: collision with root package name */
            int f1024o;

            C0011a() {
            }

            @Override // J.c.g
            public long a(I.a aVar, long j2) throws Exception {
                long j3;
                long j4 = 1 + j2;
                try {
                    this.f1010a = aVar.a(j2);
                    long j5 = 2 + j2;
                    int iA = aVar.a(j4);
                    int i2 = (iA >> 7) & 1;
                    this.f1011b = i2;
                    int i3 = (iA >> 6) & 1;
                    this.f1012c = i3;
                    int i4 = (iA >> 5) & 1;
                    this.f1013d = i4;
                    if (i2 == 1) {
                        this.f1024o = 2;
                    } else if (i3 == 1) {
                        this.f1024o = 4;
                    } else if (i4 == 1) {
                        this.f1024o = 8;
                    }
                    int i5 = iA & 1;
                    this.f1014e = i5;
                    if (i5 == 1) {
                        this.f1015f = aVar.a(j5);
                        this.f1017h = aVar.a(3 + j2);
                        long j6 = 5 + j2;
                        this.f1016g = aVar.a(4 + j2);
                        j3 = j2 + 6;
                        int iA2 = aVar.a(j6);
                        this.f1018i = iA2;
                        this.f1023n = J.a.a(this.f1015f, this.f1017h, this.f1016g, iA2, false);
                    } else {
                        int iD = aVar.d(j5);
                        j3 = j2 + 4;
                        this.f1019j = (iD >> 10) & 63;
                        this.f1020k = (iD >> 6) & 15;
                        this.f1021l = (iD >> 2) & 15;
                        int i6 = iD & 3;
                        this.f1022m = i6;
                        this.f1023n = J.a.a(this.f1015f, this.f1017h, this.f1016g, i6, false);
                    }
                    o.d("CLUTSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                    return j3;
                } catch (Exception e2) {
                    e2.printStackTrace();
                    throw e2;
                }
            }

            public String toString() {
                return "CLUTSegment [clutEntryId=" + this.f1010a + ", fullRangeFlag=" + this.f1014e + ", rgbColor=" + this.f1023n + ", colorType=" + this.f1024o + "]";
            }
        }

        public a(i iVar) {
            super(iVar);
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            long j3 = j2 + 1;
            try {
                this.f1003k = aVar.a(j2);
                long j4 = j2 + 2;
                this.f1004l = (aVar.a(j3) >> 4) & 15;
                int i2 = 2;
                int i3 = this.f1118d - 2;
                this.f1118d = i3;
                int i4 = i3 / 4;
                o.d("CLUTDefinitionSegment", " segmentLen = " + this.f1118d + " clutMaxSize = " + i4, 16);
                if (i4 > 0) {
                    this.f1005m = new ArrayList();
                    int i5 = 0;
                    int i6 = 0;
                    while (i5 < this.f1118d && i6 < i4) {
                        C0011a c0011a = new C0011a();
                        long jA = c0011a.a(aVar, j4);
                        int i7 = c0011a.f1024o;
                        if (i7 == i2) {
                            if (this.f1006n == null) {
                                this.f1006n = new int[4];
                            }
                            this.f1006n[c0011a.f1010a] = c0011a.f1023n;
                        } else if (i7 == 4) {
                            if (this.f1007o == null) {
                                this.f1007o = new int[16];
                            }
                            this.f1007o[c0011a.f1010a] = c0011a.f1023n;
                        } else if (i7 != 8) {
                            o.d("CLUTDefinitionSegment", "colorType = " + c0011a.f1024o, 16);
                        } else {
                            if (this.f1008p == null) {
                                this.f1008p = new int[256];
                            }
                            this.f1008p[c0011a.f1010a] = c0011a.f1023n;
                        }
                        this.f1005m.add(c0011a);
                        i5 = (int) (((long) i5) + (jA - j4));
                        i6++;
                        j4 = jA;
                        i2 = 2;
                    }
                }
                o.d("CLUTDefinitionSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return j4;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public int[] d(int i2) {
            return i2 != 1 ? i2 != 2 ? i2 != 3 ? this.f1006n : this.f1008p : this.f1007o : this.f1006n;
        }

        @Override // J.c.i
        public String toString() {
            return "CLUTDefinitionSegment [clutId=" + this.f1003k + ", clutVerNum=" + this.f1004l + "]";
        }
    }

    /* JADX INFO: renamed from: J.c$c, reason: collision with other inner class name */
    class C0012c extends i implements g {
        public C0012c(i iVar) {
            super(iVar);
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) {
            o.d("EndOfDisplaySegment", "offset = " + j2, 16);
            return j2;
        }
    }

    class d extends i implements g {

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1038k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f1039l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        int f1040m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        int f1041n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        int f1042o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        int f1043p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        List f1044q;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        List f1045r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        List f1046s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        List f1047t;

        /* JADX INFO: renamed from: u, reason: collision with root package name */
        int f1048u;

        /* JADX INFO: renamed from: v, reason: collision with root package name */
        int f1049v;

        /* JADX INFO: renamed from: w, reason: collision with root package name */
        int f1050w;

        /* JADX INFO: renamed from: x, reason: collision with root package name */
        int[] f1051x;

        class a implements g {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            int f1053a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            int f1054b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            int f1055c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            int[] f1056d = new int[4];

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            e f1057e;

            /* JADX INFO: renamed from: J.c$d$a$a, reason: collision with other inner class name */
            class C0013a {

                /* JADX INFO: renamed from: c, reason: collision with root package name */
                int f1061c;

                /* JADX INFO: renamed from: e, reason: collision with root package name */
                int[] f1063e;

                /* JADX INFO: renamed from: d, reason: collision with root package name */
                int f1062d = 0;

                /* JADX INFO: renamed from: a, reason: collision with root package name */
                List f1059a = new ArrayList();

                /* JADX INFO: renamed from: b, reason: collision with root package name */
                List f1060b = new ArrayList();

                public C0013a(int i2) {
                    this.f1061c = i2;
                }

                public void a(int i2, int i3) {
                    if (i2 > 0) {
                        this.f1059a.add(Integer.valueOf(i2));
                        this.f1060b.add(Integer.valueOf(i3));
                        this.f1062d += i2;
                    }
                }

                public int[] b() {
                    int i2;
                    int[] iArr = this.f1063e;
                    if (iArr != null && ((i2 = this.f1062d) <= 0 || iArr.length == i2)) {
                        if (i2 <= 0) {
                            return null;
                        }
                        return iArr;
                    }
                    this.f1063e = new int[this.f1062d];
                    int i3 = 0;
                    for (int i4 = 0; i4 < this.f1059a.size(); i4++) {
                        int i5 = 0;
                        while (i5 < ((Integer) this.f1059a.get(i4)).intValue()) {
                            this.f1063e[i3] = ((Integer) this.f1060b.get(i4)).intValue();
                            i5++;
                            i3++;
                        }
                    }
                    return this.f1063e;
                }

                public int c() {
                    return this.f1062d;
                }

                public String toString() {
                    return "ObjDataItem [runLen=" + this.f1059a + ", pixelCode=" + this.f1060b + "]";
                }
            }

            class b extends e implements g {
                b() {
                    super();
                }

                @Override // J.c.g
                public long a(I.a aVar, long j2) throws Exception {
                    this.f1073f = j2;
                    this.f1072e = a.this.new C0013a(2);
                    boolean z2 = false;
                    while (!z2) {
                        try {
                            int iC = c(aVar, 2);
                            this.f1068a = iC;
                            if (iC != 0) {
                                this.f1072e.a(1, iC);
                            } else {
                                int iC2 = c(aVar, 1);
                                this.f1069b = iC2;
                                if (iC2 == 1) {
                                    this.f1072e.a(c(aVar, 3) + 3, c(aVar, 2));
                                } else {
                                    int iC3 = c(aVar, 1);
                                    this.f1070c = iC3;
                                    if (iC3 == 0) {
                                        int iC4 = c(aVar, 2);
                                        this.f1071d = iC4;
                                        if (iC4 == 0) {
                                            z2 = true;
                                        } else if (iC4 == 1) {
                                            this.f1072e.a(2, 0);
                                        } else if (iC4 == 2) {
                                            this.f1072e.a(c(aVar, 4) + 12, c(aVar, 2));
                                        } else if (iC4 == 3) {
                                            this.f1072e.a(c(aVar, 8) + 29, c(aVar, 2));
                                        }
                                    } else {
                                        this.f1072e.a(1, 0);
                                    }
                                }
                            }
                        } catch (Exception e2) {
                            e2.printStackTrace();
                            throw e2;
                        }
                    }
                    o.d("PixelCodeString2Bit", "bitmapData hLen = " + this.f1072e.c(), 16);
                    return this.f1073f;
                }
            }

            /* JADX INFO: renamed from: J.c$d$a$c, reason: collision with other inner class name */
            class C0014c extends e implements g {
                C0014c() {
                    super();
                }

                @Override // J.c.g
                public long a(I.a aVar, long j2) throws Exception {
                    this.f1073f = j2;
                    this.f1072e = a.this.new C0013a(4);
                    boolean z2 = false;
                    while (!z2) {
                        try {
                            int iC = c(aVar, 4);
                            this.f1068a = iC;
                            if (iC != 0) {
                                this.f1072e.a(1, iC);
                            } else {
                                int iC2 = c(aVar, 1);
                                this.f1069b = iC2;
                                if (iC2 == 0) {
                                    int iC3 = c(aVar, 3);
                                    if (iC3 != 0) {
                                        this.f1072e.a(iC3 + 2, 0);
                                    } else {
                                        o.d("PixelCodeString4Bit", "parserBuffer end ", 16);
                                        z2 = true;
                                    }
                                } else {
                                    int iC4 = c(aVar, 1);
                                    this.f1070c = iC4;
                                    if (iC4 == 0) {
                                        this.f1072e.a(c(aVar, 2) + 4, c(aVar, 4));
                                    } else {
                                        int iC5 = c(aVar, 2);
                                        this.f1071d = iC5;
                                        if (iC5 == 0) {
                                            this.f1072e.a(1, 0);
                                        } else if (iC5 == 1) {
                                            this.f1072e.a(2, 0);
                                        } else if (iC5 == 2) {
                                            this.f1072e.a(c(aVar, 4) + 9, c(aVar, 4));
                                        } else if (iC5 == 3) {
                                            this.f1072e.a(c(aVar, 8) + 25, c(aVar, 4));
                                        }
                                    }
                                }
                            }
                        } catch (Exception e2) {
                            e2.printStackTrace();
                            throw e2;
                        }
                    }
                    o.d("PixelCodeString4Bit", "bitmapData total = " + this.f1072e.c() + " data = " + this.f1072e, 16);
                    return this.f1073f;
                }
            }

            /* JADX INFO: renamed from: J.c$d$a$d, reason: collision with other inner class name */
            class C0015d extends e implements g {
                C0015d() {
                    super();
                }

                @Override // J.c.g
                public long a(I.a aVar, long j2) throws Exception {
                    this.f1073f = j2;
                    this.f1072e = a.this.new C0013a(8);
                    while (true) {
                        try {
                            int iC = c(aVar, 8);
                            this.f1068a = iC;
                            if (iC != 0) {
                                this.f1072e.a(1, iC);
                            } else {
                                int iC2 = c(aVar, 1);
                                this.f1069b = iC2;
                                if (iC2 == 0) {
                                    int iC3 = c(aVar, 7);
                                    if (iC3 == 0) {
                                        o.d("PixelCodeString8Bit", "bitmapData total = " + this.f1072e.c() + " data = " + this.f1072e, 16);
                                        return this.f1073f;
                                    }
                                    this.f1072e.a(iC3, 0);
                                } else {
                                    int iC4 = c(aVar, 7);
                                    o.d("PixelCodeString8Bit", "runLen 3-127 not less than three val = " + iC4, 16);
                                    this.f1072e.a(iC4, c(aVar, 8));
                                }
                            }
                        } catch (Exception e2) {
                            e2.printStackTrace();
                            throw e2;
                        }
                    }
                }
            }

            abstract class e implements g {

                /* JADX INFO: renamed from: a, reason: collision with root package name */
                int f1068a;

                /* JADX INFO: renamed from: b, reason: collision with root package name */
                int f1069b;

                /* JADX INFO: renamed from: c, reason: collision with root package name */
                int f1070c;

                /* JADX INFO: renamed from: d, reason: collision with root package name */
                int f1071d;

                /* JADX INFO: renamed from: e, reason: collision with root package name */
                C0013a f1072e;

                /* JADX INFO: renamed from: f, reason: collision with root package name */
                long f1073f = 0;

                /* JADX INFO: renamed from: g, reason: collision with root package name */
                int f1074g = 0;

                /* JADX INFO: renamed from: h, reason: collision with root package name */
                int f1075h;

                e() {
                }

                public int b() {
                    return this.f1072e.c();
                }

                protected int c(I.a aVar, int i2) {
                    int i3;
                    while (true) {
                        i3 = this.f1074g;
                        if (i3 >= i2) {
                            break;
                        }
                        int i4 = this.f1075h << 8;
                        long j2 = this.f1073f;
                        this.f1073f = 1 + j2;
                        this.f1075h = i4 + aVar.a(j2);
                        this.f1074g += 8;
                    }
                    int i5 = this.f1075h;
                    int i6 = i3 - i2;
                    this.f1074g = i6;
                    int i7 = i5 >> i6;
                    int i8 = i5 - (i7 << i6);
                    this.f1075h = i8;
                    if (i8 < 0 || i6 < 0) {
                        o.d("PixelDataSubBlock", "readNext error curByte = " + this.f1075h + " byteLast = " + this.f1074g + "result = " + i7, 16);
                    }
                    return i7;
                }
            }

            a() {
            }

            @Override // J.c.g
            public long a(I.a aVar, long j2) {
                long j3;
                long j4 = 1 + j2;
                try {
                    int iA = aVar.a(j2);
                    this.f1053a = iA;
                    if (iA == 240) {
                        o.d("PixelDataSubBlock", "END of Object line ~~ " + this.f1053a, 16);
                        return j4;
                    }
                    switch (iA) {
                        case 16:
                            b bVar = new b();
                            this.f1057e = bVar;
                            return bVar.a(aVar, j4);
                        case 17:
                            C0014c c0014c = new C0014c();
                            this.f1057e = c0014c;
                            return c0014c.a(aVar, j4);
                        case 18:
                            C0015d c0015d = new C0015d();
                            this.f1057e = c0015d;
                            return c0015d.a(aVar, j4);
                        default:
                            switch (iA) {
                                case 32:
                                    this.f1054b = aVar.d(j4);
                                    j3 = 3;
                                    break;
                                case 33:
                                    this.f1055c = aVar.b(j4);
                                    return j2 + 5;
                                case 34:
                                    this.f1056d[0] = aVar.b(j4);
                                    this.f1056d[1] = aVar.b(5 + j2);
                                    this.f1056d[2] = aVar.b(9 + j2);
                                    this.f1056d[3] = aVar.b(13 + j2);
                                    j3 = 17;
                                    break;
                                default:
                                    o.d("PixelDataSubBlock", "dataType = " + this.f1053a, 16);
                                    return j4;
                            }
                            return j3 + j2;
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                    return j2;
                }
            }

            public int b() {
                e eVar = this.f1057e;
                if (eVar != null) {
                    return eVar.b();
                }
                return 0;
            }

            public String toString() {
                return "PixelDataSubBlock [dataType=" + this.f1053a + ", mapTable2To4=" + this.f1054b + ", mapTable2To8=" + this.f1055c + ", mapTable4To8=" + Arrays.toString(this.f1056d) + ", pixelCodeString=" + this.f1057e + "]";
            }
        }

        public d(i iVar) {
            super(iVar);
        }

        private Bitmap e(List list, List list2, int[] iArr) {
            int iMax;
            int size;
            int size2;
            if (list == null || list.size() <= 0) {
                iMax = 0;
                size = 0;
            } else {
                iMax = ((a.C0013a) list.get(0)).c();
                size = list.size();
                o.c("ObjectDataSegment", 16, "getTopBitmap width = ", Integer.valueOf(iMax), " height = ", Integer.valueOf(size));
            }
            if (this.f1043p <= 0 || list2 == null || list2.size() <= 0) {
                size2 = size * 2;
            } else {
                o.c("ObjectDataSegment", 16, "getBottomBitmap width = ", Integer.valueOf(((a.C0013a) list2.get(0)).c()), " height = ", Integer.valueOf(list2.size()));
                size2 = size + list2.size();
                iMax = Math.max(iMax, ((a.C0013a) list2.get(0)).c());
            }
            o.c("ObjectDataSegment", 16, "getBitmap width = ", Integer.valueOf(iMax), " height = ", Integer.valueOf(size2));
            if (iMax <= 0 || size2 <= 0) {
                return null;
            }
            int i2 = iMax * size2;
            int[] iArr2 = new int[i2];
            Iterator it = list.iterator();
            int i3 = 0;
            int i4 = 0;
            while (it.hasNext()) {
                a.C0013a c0013a = (a.C0013a) it.next();
                if (c0013a.b() != null) {
                    int[] iArrB = c0013a.b();
                    int length = iArrB.length;
                    int i5 = 0;
                    while (i5 < length) {
                        int i6 = iArrB[i5];
                        if (i3 >= i2) {
                            break;
                        }
                        iArr2[i3] = iArr[i6];
                        i5++;
                        i3++;
                    }
                }
                i4 += 2;
                i3 = iMax * i4;
                if (i3 >= i2) {
                    break;
                }
            }
            Iterator it2 = list.iterator();
            int i7 = 1;
            int i8 = iMax;
            while (it2.hasNext()) {
                a.C0013a c0013a2 = (a.C0013a) it2.next();
                if (c0013a2.b() != null) {
                    int[] iArrB2 = c0013a2.b();
                    int length2 = iArrB2.length;
                    int i9 = 0;
                    while (i9 < length2) {
                        int i10 = iArrB2[i9];
                        if (i8 >= i2) {
                            break;
                        }
                        iArr2[i8] = iArr[i10];
                        i9++;
                        i8++;
                    }
                }
                i7 += 2;
                i8 = iMax * i7;
                if (i8 >= i2) {
                    break;
                }
            }
            return Bitmap.createBitmap(iArr2, iMax, size2, Bitmap.Config.ARGB_8888);
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            try {
                this.f1038k = aVar.d(j2);
                long j3 = j2 + 3;
                int iA = aVar.a(j2 + 2);
                this.f1039l = (iA >> 4) & 15;
                this.f1040m = (iA >> 2) & 3;
                this.f1041n = (iA >> 1) & 1;
                o.d("ObjectDataSegment", "objectCodingMethod = " + this.f1040m, 16);
                int i2 = this.f1040m;
                int i3 = 0;
                if (i2 == 0) {
                    this.f1042o = aVar.d(j3);
                    this.f1043p = aVar.d(j2 + 5);
                    long jA = j2 + 7;
                    this.f1044q = new ArrayList();
                    this.f1045r = new ArrayList();
                    this.f1046s = new ArrayList();
                    this.f1047t = new ArrayList();
                    o.d("ObjectDataSegment", "topFieldDataBlockLen = " + this.f1042o + "bottomFieldDataBlockLen = " + this.f1043p, 16);
                    int i4 = 0;
                    while (i4 < this.f1042o) {
                        a aVar2 = new a();
                        long jA2 = aVar2.a(aVar, jA);
                        if (aVar2.b() > 0) {
                            this.f1046s.add(aVar2.f1057e.f1072e);
                            this.f1044q.add(aVar2);
                        }
                        i4 = (int) (((long) i4) + (jA2 - jA));
                        jA = jA2;
                    }
                    o.d("ObjectDataSegment", "top processLen = " + i4, 16);
                    while (true) {
                        j3 = jA;
                        if (i3 >= this.f1043p) {
                            break;
                        }
                        a aVar3 = new a();
                        jA = aVar3.a(aVar, j3);
                        if (aVar3.b() > 0) {
                            this.f1047t.add(aVar3.f1057e.f1072e);
                            this.f1045r.add(aVar3);
                        }
                        i3 = (int) (((long) i3) + (jA - j3));
                    }
                    o.d("ObjectDataSegment", "bottom processLen = " + i3, 16);
                    o.d("ObjectDataSegment", "bottom total = " + (j3 - j2), 16);
                    if (aVar.a(j3) != 15) {
                        this.f1048u = aVar.a(j3);
                        o.d("ObjectDataSegment", " stuffBits = " + this.f1048u, 16);
                        j3 = 1 + j3;
                    }
                } else if (i2 != 1) {
                    o.d("ObjectDataSegment", "objectCodingMethod = " + this.f1040m, 16);
                } else {
                    long j4 = j2 + 4;
                    int iA2 = aVar.a(j3);
                    this.f1049v = iA2;
                    if (iA2 > 0) {
                        this.f1051x = new int[iA2];
                        j3 = j4;
                        while (i3 < this.f1049v) {
                            this.f1051x[i3] = aVar.d(j3);
                            j3 += 2;
                            i3++;
                        }
                    } else {
                        j3 = j4;
                    }
                }
                o.d("ObjectDataSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return j3;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public void d(i iVar, int[] iArr, Canvas canvas) {
            Bitmap bitmapE = e(this.f1046s, this.f1047t, iArr);
            if (bitmapE != null) {
                iVar.f1119e.f1035t = true;
                canvas.drawBitmap(bitmapE, 0.0f, 0.0f, new Paint());
            }
        }

        @Override // J.c.i
        public String toString() {
            return "ObjectDataSegment [objectId=" + this.f1038k + ", objectVerNum=" + this.f1039l + ", objectCodingMethod=" + this.f1040m + ", codeNum=" + this.f1049v + ", charCode=" + this.f1050w + ", chars=" + Arrays.toString(this.f1051x) + "]";
        }
    }

    class e implements g {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f1077a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        int f1078b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        i f1079c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        int f1080d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        d f1081e = null;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        a f1082f = null;

        e() {
        }

        @Override // J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            long j3 = j2 + 1;
            try {
                int iA = aVar.a(j2);
                this.f1077a = iA;
                c.this.b(32, iA);
                int iA2 = aVar.a(j3);
                this.f1078b = iA2;
                c.this.b(0, iA2);
                i iVar = c.this.new i();
                this.f1079c = iVar;
                long jA = iVar.a(aVar, j2 + 2);
                long j4 = 1 + jA;
                int iA3 = aVar.a(jA) & 63;
                this.f1080d = iA3;
                c.this.b(63, iA3);
                o.d("PESPacketData", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return j4;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public Bitmap b() {
            return this.f1079c.b();
        }

        public int c() {
            return this.f1079c.c();
        }

        public String toString() {
            return "PESPacketData [dataId=" + this.f1077a + ", subtileStreamId=" + this.f1078b + ", endPESDataMarker=" + this.f1080d + "]";
        }
    }

    class f extends i implements g {

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1084k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f1085l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        int f1086m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        List f1087n;

        class a implements g {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            int f1089a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            int f1090b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            int f1091c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            int f1092d;

            a() {
            }

            @Override // J.c.g
            public long a(I.a aVar, long j2) throws Exception {
                long j3 = 1 + j2;
                try {
                    this.f1089a = aVar.a(j2);
                    this.f1090b = aVar.a(j3);
                    this.f1091c = aVar.d(2 + j2);
                    this.f1092d = aVar.d(4 + j2);
                    long j4 = j2 + 6;
                    o.d("Segment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                    return j4;
                } catch (Exception e2) {
                    e2.printStackTrace();
                    throw e2;
                }
            }

            public String toString() {
                return "Segment [regionId=" + this.f1089a + ", reserved=" + this.f1090b + ", regionHorizontalAddress=" + this.f1091c + ", regionVerticalAddress=" + this.f1092d + "]";
            }
        }

        public f(i iVar) {
            super(iVar);
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            long j3 = 1 + j2;
            try {
                this.f1084k = aVar.a(j2);
                long jA = j2 + 2;
                int iA = aVar.a(j3);
                this.f1085l = (iA >> 4) & 15;
                this.f1086m = (iA >> 2) & 3;
                int i2 = this.f1118d - 2;
                this.f1118d = i2;
                int i3 = i2 / 6;
                o.d("PageCompositionSegment", "PageCompositionSegment segmentLen =" + this.f1118d + " segSize = " + i3, 16);
                if (i3 > 0) {
                    this.f1087n = new ArrayList();
                    for (int i4 = 0; i4 < i3; i4++) {
                        a aVar2 = new a();
                        jA = aVar2.a(aVar, jA);
                        this.f1087n.add(aVar2);
                    }
                }
                o.d("PageCompositionSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return jA;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public void d(i iVar, Canvas canvas) {
            List<h> list = iVar.f1121g;
            List list2 = this.f1087n;
            if (list2 == null || list2.size() <= 0) {
                return;
            }
            for (a aVar : this.f1087n) {
                if (list != null && list.size() > 0) {
                    for (h hVar : list) {
                        if (hVar.f1094k == aVar.f1089a) {
                            try {
                                canvas.save();
                                o.d("PageCompositionSegment", "getBitmap regionId = " + hVar.f1094k + " region.regionHorizontalAddress = " + aVar.f1091c + " region.regionVerticalAddress = " + aVar.f1092d, 16);
                                canvas.translate((float) aVar.f1091c, (float) aVar.f1092d);
                                hVar.d(iVar, canvas);
                                canvas.restore();
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        }
                    }
                }
            }
        }

        @Override // J.c.i
        public String toString() {
            return "PageCompositionSegment [pageTimeout=" + this.f1084k + ", pageVersionNum=" + this.f1085l + ", pageState=" + this.f1086m + "]";
        }
    }

    interface g {
        long a(I.a aVar, long j2);
    }

    class h extends i implements g {

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1094k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f1095l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        int f1096m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        int f1097n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        int f1098o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        int f1099p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        int f1100q;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        int f1101r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        int f1102s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        int f1103t;

        /* JADX INFO: renamed from: u, reason: collision with root package name */
        int f1104u;

        /* JADX INFO: renamed from: v, reason: collision with root package name */
        List f1105v;

        class a implements g {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            int f1107a;

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            int f1108b;

            /* JADX INFO: renamed from: c, reason: collision with root package name */
            int f1109c;

            /* JADX INFO: renamed from: d, reason: collision with root package name */
            int f1110d;

            /* JADX INFO: renamed from: e, reason: collision with root package name */
            int f1111e;

            /* JADX INFO: renamed from: f, reason: collision with root package name */
            int f1112f;

            /* JADX INFO: renamed from: g, reason: collision with root package name */
            int f1113g;

            a() {
            }

            @Override // J.c.g
            public long a(I.a aVar, long j2) throws Exception {
                try {
                    this.f1107a = aVar.d(j2);
                    int iD = aVar.d(2 + j2);
                    this.f1108b = (iD >> 14) & 3;
                    this.f1109c = (iD >> 12) & 3;
                    this.f1110d = iD & 4095;
                    long j3 = 6 + j2;
                    this.f1111e = aVar.d(4 + j2) & 4095;
                    int i2 = this.f1108b;
                    if ((i2 == 1) | (i2 == 2)) {
                        this.f1112f = aVar.a(j3);
                        j3 = j2 + 8;
                        this.f1113g = aVar.a(7 + j2);
                    }
                    o.d("DvbObject", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                    return j3;
                } catch (Exception e2) {
                    e2.printStackTrace();
                    throw e2;
                }
            }

            public String toString() {
                return "DvbObject [objectId=" + this.f1107a + ", objectType=" + this.f1108b + ", objectProviderFlag=" + this.f1109c + ", objectHPosition=" + this.f1110d + ", objectVPosition=" + this.f1111e + ", forePixel=" + this.f1112f + ", backPixel=" + this.f1113g + "]";
            }
        }

        public h(i iVar) {
            super(iVar);
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            long j3 = 1 + j2;
            try {
                this.f1094k = aVar.a(j2);
                int iA = aVar.a(j3);
                this.f1095l = (iA >> 4) & 15;
                this.f1096m = (iA >> 3) & 1;
                this.f1097n = aVar.d(2 + j2);
                this.f1098o = aVar.d(4 + j2);
                int iA2 = aVar.a(6 + j2);
                this.f1099p = (iA2 >> 5) & 7;
                this.f1100q = (iA2 >> 2) & 7;
                this.f1101r = aVar.a(7 + j2);
                long j4 = 9 + j2;
                this.f1102s = aVar.a(8 + j2);
                long j5 = j2 + 10;
                int iA3 = aVar.a(j4);
                this.f1103t = (iA3 >> 4) & 15;
                this.f1104u = (iA3 >> 2) & 3;
                int i2 = this.f1118d - 10;
                this.f1118d = i2;
                int i3 = i2 / 6;
                o.d("RegionCompositionSegment", " segmentLen = " + this.f1118d + " objectMaxSize = " + i3, 16);
                if (i3 > 0) {
                    this.f1105v = new ArrayList();
                    int i4 = 0;
                    int i5 = 0;
                    while (i4 < this.f1118d && i5 < i3) {
                        a aVar2 = new a();
                        long jA = aVar2.a(aVar, j5);
                        this.f1105v.add(aVar2);
                        i4 = (int) (((long) i4) + (jA - j5));
                        i5++;
                        j5 = jA;
                    }
                }
                o.d("RegionCompositionSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return j5;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public void d(i iVar, Canvas canvas) {
            List list;
            try {
                canvas.save();
                o.d("RegionCompositionSegment", "draw clipRect regionWidth = " + this.f1097n + " regionHeight = " + this.f1098o, 16);
                canvas.clipRect(new Rect(0, 0, this.f1097n, this.f1098o));
                List<d> list2 = iVar.f1123i;
                List list3 = iVar.f1122h;
                int[] iArrD = null;
                if (list3 != null && list3.size() > 0) {
                    for (a aVar : iVar.f1122h) {
                        if (aVar.f1003k == this.f1101r) {
                            iArrD = aVar.d(this.f1100q);
                        }
                    }
                }
                if (iArrD != null && (list = this.f1105v) != null && list.size() > 0) {
                    for (a aVar2 : this.f1105v) {
                        if (list2 != null && list2.size() > 0) {
                            for (d dVar : list2) {
                                if (dVar.f1038k == aVar2.f1107a) {
                                    try {
                                        canvas.save();
                                        o.d("RegionCompositionSegment", "draw obj.objectHPosition = " + aVar2.f1110d + " obj.objectVPosition = " + aVar2.f1111e, 16);
                                        canvas.translate((float) aVar2.f1110d, (float) aVar2.f1111e);
                                        dVar.d(iVar, iArrD, canvas);
                                        canvas.restore();
                                    } catch (Exception e2) {
                                        e2.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }
                canvas.restore();
            } catch (Exception e3) {
                e3.printStackTrace();
            }
        }

        @Override // J.c.i
        public String toString() {
            return "RegionCompositionSegment [regionId=" + this.f1094k + ", regionVerNum=" + this.f1095l + ", regionFillFlag=" + this.f1096m + ", regionWidth=" + this.f1097n + ", regionHeight=" + this.f1098o + ", regionLevelOfCompatibility=" + this.f1099p + ", regionDepth=" + this.f1100q + ", clutId=" + this.f1101r + ", region8bitPixel=" + this.f1102s + ", region4bitPixel=" + this.f1103t + ", region2bitPixel=" + this.f1104u + "]";
        }
    }

    public c(byte[] bArr) {
        try {
            this.f1000a = new I.a(bArr);
            c();
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void b(int i2, int i3) {
        if (i3 == i2) {
            return;
        }
        throw new RuntimeException("except = " + i2 + " but val = " + i3);
    }

    private void c() {
        long jC = this.f1000a.c();
        long jA = 0;
        while (jA < jC) {
            try {
                e eVar = new e();
                jA = eVar.a(this.f1000a, jA);
                o.d("DvbParserFactory", "PESPacketData = " + eVar, 16);
                Bitmap bitmapB = eVar.b();
                if (bitmapB != null) {
                    this.f1001b = bitmapB;
                    this.f1002c = eVar.c();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
                return;
            }
        }
    }

    class i implements g {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f1115a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        int f1116b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        int f1117c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        int f1118d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        b f1119e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        List f1120f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        List f1121g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        List f1122h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        List f1123i;

        public i() {
        }

        @Override // J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            boolean z2 = false;
            while (!z2) {
                long j3 = 1 + j2;
                try {
                    int iA = aVar.a(j2);
                    this.f1115a = iA;
                    c.this.b(15, iA);
                    this.f1116b = aVar.a(j3);
                    this.f1117c = aVar.d(2 + j2);
                    this.f1118d = aVar.d(4 + j2);
                    j2 += 6;
                    o.d("SubtitlingSegment", "segmentType = " + this.f1116b + " pageId = " + this.f1117c + " segmentLen = " + this.f1118d, 16);
                    int i2 = this.f1116b;
                    if (i2 == 128) {
                        j2 = c.this.new C0012c(this).a(aVar, j2);
                        z2 = true;
                    } else if (i2 != 255) {
                        switch (i2) {
                            case 16:
                                f fVar = c.this.new f(this);
                                j2 = fVar.a(aVar, j2);
                                if (this.f1120f == null) {
                                    this.f1120f = new ArrayList();
                                }
                                this.f1120f.add(fVar);
                                break;
                            case 17:
                                h hVar = c.this.new h(this);
                                j2 = hVar.a(aVar, j2);
                                if (this.f1121g == null) {
                                    this.f1121g = new ArrayList();
                                }
                                this.f1121g.add(hVar);
                                break;
                            case 18:
                                a aVar2 = c.this.new a(this);
                                j2 = aVar2.a(aVar, j2);
                                if (this.f1122h == null) {
                                    this.f1122h = new ArrayList();
                                }
                                this.f1122h.add(aVar2);
                                break;
                            case 19:
                                d dVar = c.this.new d(this);
                                j2 = dVar.a(aVar, j2);
                                if (this.f1123i == null) {
                                    this.f1123i = new ArrayList();
                                }
                                this.f1123i.add(dVar);
                                break;
                            case 20:
                                b bVar = c.this.new b(this);
                                this.f1119e = bVar;
                                j2 = bVar.a(aVar, j2);
                                break;
                            default:
                                if (i2 >= 129 && i2 <= 239) {
                                    o.d("SubtitlingSegment", "PRIVATE_DATA segmentType = " + this.f1116b, 16);
                                } else {
                                    o.d("SubtitlingSegment", "RESERVED FOR FUTURE USE segmentType = " + this.f1116b, 16);
                                }
                                break;
                        }
                    } else {
                        o.d("SubtitlingSegment", "STUFFING = 255", 16);
                    }
                    o.d("SubtitlingSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                } catch (Exception e2) {
                    e2.printStackTrace();
                    throw e2;
                }
            }
            return j2;
        }

        public Bitmap b() {
            if (this.f1119e == null) {
                this.f1119e = c.this.new b();
            }
            o.d("SubtitlingSegment", "getBitmap  ~~", 16);
            return this.f1119e.e(this);
        }

        public int c() {
            List list = this.f1120f;
            if (list == null || list.size() <= 0) {
                return 1;
            }
            return ((f) this.f1120f.get(0)).f1084k;
        }

        public String toString() {
            return "SubtitlingSegment [syncByte=" + this.f1115a + ", segmentType=" + this.f1116b + ", pageId=" + this.f1117c + ", segmentLen=" + this.f1118d + "]";
        }

        public i(i iVar) {
            this.f1115a = iVar.f1115a;
            this.f1116b = iVar.f1116b;
            this.f1117c = iVar.f1117c;
            this.f1118d = iVar.f1118d;
        }
    }

    class b extends i implements g {

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        int f1026k;

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        int f1027l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        int f1028m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        int f1029n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        int f1030o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        int f1031p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        int f1032q;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        int f1033r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        Bitmap f1034s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        boolean f1035t;

        public b() {
            super();
            this.f1035t = false;
            this.f1028m = 720;
            this.f1029n = 576;
            this.f1027l = 0;
            this.f1030o = 0;
            this.f1031p = 720;
            this.f1032q = 0;
            this.f1033r = 576;
        }

        @Override // J.c.i, J.c.g
        public long a(I.a aVar, long j2) throws Exception {
            long j3 = 1 + j2;
            try {
                int iA = aVar.a(j2);
                this.f1026k = (iA >> 4) & 15;
                this.f1027l = (iA >> 3) & 1;
                this.f1028m = aVar.d(j3);
                this.f1029n = aVar.d(3 + j2);
                long j4 = 5 + j2;
                if (this.f1027l == 1) {
                    this.f1030o = aVar.d(j4);
                    this.f1031p = aVar.d(7 + j2);
                    this.f1032q = aVar.d(9 + j2);
                    this.f1033r = aVar.d(11 + j2);
                    j4 = 13 + j2;
                }
                o.d("DisplayDefinitionSegment", HttpUrl.FRAGMENT_ENCODE_SET + this, 16);
                return j4;
            } catch (Exception e2) {
                e2.printStackTrace();
                throw e2;
            }
        }

        public void d(i iVar, Canvas canvas) {
            List list = iVar.f1120f;
            o.d("DisplayDefinitionSegment", "getBitmap displayWidth = " + this.f1028m + " displayHeight = " + this.f1029n, 16);
            if (this.f1027l == 1) {
                canvas.clipRect(new Rect(this.f1030o, this.f1032q, this.f1031p, this.f1033r));
            }
            if (list == null || list.size() <= 0) {
                return;
            }
            Iterator it = list.iterator();
            while (it.hasNext()) {
                ((f) it.next()).d(iVar, canvas);
            }
        }

        public Bitmap e(i iVar) {
            if (this.f1034s == null) {
                this.f1034s = Bitmap.createBitmap(this.f1028m, this.f1029n, Bitmap.Config.ARGB_8888);
                d(iVar, new Canvas(this.f1034s));
            }
            if (this.f1035t) {
                return this.f1034s;
            }
            return null;
        }

        @Override // J.c.i
        public String toString() {
            return "DisplayDefinitionSegment [ddsVersionNum=" + this.f1026k + ", displayWindowFlag=" + this.f1027l + ", displayWidth=" + this.f1028m + ", displayHeight=" + this.f1029n + ", displayWindowHPMin=" + this.f1030o + ", displayWindowHPMax=" + this.f1031p + ", displayWindowVPMin=" + this.f1032q + ", displayWindowVPMax=" + this.f1033r + "]";
        }

        public b(i iVar) {
            super(iVar);
            this.f1035t = false;
        }
    }
}
