package com.opos.exoplayer.core.f.f; import android.text.Layout; import com.baidu.mobads.sdk.api.IAdInterListener; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.text.ttml.TtmlNode; import com.opos.exoplayer.core.f.c; import com.opos.exoplayer.core.f.f; import com.opos.exoplayer.core.i.d; import com.opos.exoplayer.core.i.v; import com.opos.exoplayer.core.i.w; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; public final class a extends c { private static final Pattern a = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$"); private static final Pattern b = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$"); private static final Pattern c = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$"); private static final Pattern d = Pattern.compile("^(\\d+\\.?\\d*?)% (\\d+\\.?\\d*?)%$"); /* renamed from: e reason: collision with root package name */ private static final C0276a f13437e = new C0276a(30.0f, 1, 1); /* renamed from: f reason: collision with root package name */ private final XmlPullParserFactory f13438f; /* access modifiers changed from: private */ /* renamed from: com.opos.exoplayer.core.f.f.a$a reason: collision with other inner class name */ public static final class C0276a { final float a; final int b; final int c; C0276a(float f2, int i2, int i3) { this.a = f2; this.b = i2; this.c = i3; } } public a() { super("TtmlDecoder"); try { XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance(); this.f13438f = newInstance; newInstance.setNamespaceAware(true); } catch (XmlPullParserException e2) { throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e2); } } /* JADX WARNING: Code restructure failed: missing block: B:33:0x00bc, code lost: if (r14.equals(com.kuaishou.weapon.p0.t.f11681g) != false) goto L_0x00e8; */ /* JADX WARNING: Removed duplicated region for block: B:48:0x00ea */ /* JADX WARNING: Removed duplicated region for block: B:57:0x0105 */ private static long a(String str, C0276a aVar) { double d2; double d3; Matcher matcher = a.matcher(str); char c2 = 2; if (matcher.matches()) { double parseLong = ((double) (Long.parseLong(matcher.group(1)) * 3600)) + ((double) (Long.parseLong(matcher.group(2)) * 60)) + ((double) Long.parseLong(matcher.group(3))); String group = matcher.group(4); double d4 = 0.0d; double parseDouble = parseLong + (group != null ? Double.parseDouble(group) : 0.0d); String group2 = matcher.group(5); double parseLong2 = parseDouble + (group2 != null ? (double) (((float) Long.parseLong(group2)) / aVar.a) : 0.0d); String group3 = matcher.group(6); if (group3 != null) { d4 = (((double) Long.parseLong(group3)) / ((double) aVar.b)) / ((double) aVar.a); } return (long) ((parseLong2 + d4) * 1000000.0d); } Matcher matcher2 = b.matcher(str); if (matcher2.matches()) { double parseDouble2 = Double.parseDouble(matcher2.group(1)); String group4 = matcher2.group(2); int hashCode = group4.hashCode(); if (hashCode != 102) { if (hashCode != 104) { if (hashCode != 109) { if (hashCode != 3494) { if (hashCode != 115) { if (hashCode == 116 && group4.equals("t")) { c2 = 5; if (c2 != 0) { d2 = 3600.0d; } else if (c2 != 1) { if (c2 == 3) { d3 = 1000.0d; } else if (c2 != 4) { if (c2 == 5) { d3 = (double) aVar.c; } return (long) (parseDouble2 * 1000000.0d); } else { d3 = (double) aVar.a; } parseDouble2 /= d3; return (long) (parseDouble2 * 1000000.0d); } else { d2 = 60.0d; } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } } } else if (group4.equals("ms")) { c2 = 3; if (c2 != 0) { } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } } else if (group4.equals("m")) { c2 = 1; if (c2 != 0) { } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } } else if (group4.equals(IAdInterListener.AdReqParam.HEIGHT)) { c2 = 0; if (c2 != 0) { } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } } else if (group4.equals("f")) { c2 = 4; if (c2 != 0) { } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } c2 = 65535; if (c2 != 0) { } parseDouble2 *= d2; return (long) (parseDouble2 * 1000000.0d); } throw new f("Malformed time expression: " + str); } private C0276a a(XmlPullParser xmlPullParser) { String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRate"); int parseInt = attributeValue != null ? Integer.parseInt(attributeValue) : 30; float f2 = 1.0f; String attributeValue2 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRateMultiplier"); if (attributeValue2 != null) { String[] split = attributeValue2.split(" "); if (split.length == 2) { f2 = ((float) Integer.parseInt(split[0])) / ((float) Integer.parseInt(split[1])); } else { throw new f("frameRateMultiplier doesn't have 2 parts"); } } int i2 = f13437e.b; String attributeValue3 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "subFrameRate"); if (attributeValue3 != null) { i2 = Integer.parseInt(attributeValue3); } int i3 = f13437e.c; String attributeValue4 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "tickRate"); if (attributeValue4 != null) { i3 = Integer.parseInt(attributeValue4); } return new C0276a(((float) parseInt) * f2, i2, i3); } private b a(b bVar) { return bVar == null ? new b() : bVar; } /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */ private b a(XmlPullParser xmlPullParser, b bVar) { char c2; StringBuilder sb; String str; b bVar2; Layout.Alignment alignment; int attributeCount = xmlPullParser.getAttributeCount(); for (int i2 = 0; i2 < attributeCount; i2++) { String attributeValue = xmlPullParser.getAttributeValue(i2); String attributeName = xmlPullParser.getAttributeName(i2); char c3 = 65535; switch (attributeName.hashCode()) { case -1550943582: if (attributeName.equals(TtmlNode.ATTR_TTS_FONT_STYLE)) { c2 = 6; break; } c2 = 65535; break; case -1224696685: if (attributeName.equals(TtmlNode.ATTR_TTS_FONT_FAMILY)) { c2 = 3; break; } c2 = 65535; break; case -1065511464: if (attributeName.equals(TtmlNode.ATTR_TTS_TEXT_ALIGN)) { c2 = 7; break; } c2 = 65535; break; case -879295043: if (attributeName.equals(TtmlNode.ATTR_TTS_TEXT_DECORATION)) { c2 = '\b'; break; } c2 = 65535; break; case -734428249: if (attributeName.equals(TtmlNode.ATTR_TTS_FONT_WEIGHT)) { c2 = 5; break; } c2 = 65535; break; case 3355: if (attributeName.equals("id")) { c2 = 0; break; } c2 = 65535; break; case 94842723: if (attributeName.equals("color")) { c2 = 2; break; } c2 = 65535; break; case 365601008: if (attributeName.equals(TtmlNode.ATTR_TTS_FONT_SIZE)) { c2 = 4; break; } c2 = 65535; break; case 1287124693: if (attributeName.equals(TtmlNode.ATTR_TTS_BACKGROUND_COLOR)) { c2 = 1; break; } c2 = 65535; break; default: c2 = 65535; break; } switch (c2) { case 0: if ("style".equals(xmlPullParser.getName())) { bVar = a(bVar).b(attributeValue); continue; } case 1: bVar = a(bVar); try { bVar.b(d.a(attributeValue)); continue; } catch (IllegalArgumentException unused) { sb = new StringBuilder(); str = "Failed parsing background value: "; break; } case 2: bVar = a(bVar); try { bVar.a(d.a(attributeValue)); continue; } catch (IllegalArgumentException unused2) { sb = new StringBuilder(); str = "Failed parsing color value: "; break; } case 3: bVar = a(bVar).a(attributeValue); continue; case 4: try { bVar = a(bVar); a(attributeValue, bVar); continue; } catch (f unused3) { sb = new StringBuilder(); str = "Failed parsing fontSize value: "; break; } case 5: bVar = a(bVar).c(TtmlNode.BOLD.equalsIgnoreCase(attributeValue)); continue; case 6: bVar = a(bVar).d(TtmlNode.ITALIC.equalsIgnoreCase(attributeValue)); continue; case 7: String d2 = v.d(attributeValue); switch (d2.hashCode()) { case -1364013995: if (d2.equals(TtmlNode.CENTER)) { c3 = 4; break; } break; case 100571: if (d2.equals(TtmlNode.END)) { c3 = 3; break; } break; case 3317767: if (d2.equals(TtmlNode.LEFT)) { c3 = 0; break; } break; case 108511772: if (d2.equals(TtmlNode.RIGHT)) { c3 = 2; break; } break; case 109757538: if (d2.equals("start")) { c3 = 1; break; } break; } if (c3 == 0 || c3 == 1) { bVar2 = a(bVar); alignment = Layout.Alignment.ALIGN_NORMAL; } else if (c3 == 2 || c3 == 3) { bVar2 = a(bVar); alignment = Layout.Alignment.ALIGN_OPPOSITE; } else if (c3 == 4) { bVar2 = a(bVar); alignment = Layout.Alignment.ALIGN_CENTER; } bVar = bVar2.a(alignment); continue; case '\b': String d3 = v.d(attributeValue); int hashCode = d3.hashCode(); if (hashCode != -1461280213) { if (hashCode != -1026963764) { if (hashCode != 913457136) { if (hashCode == 1679736913 && d3.equals(TtmlNode.LINETHROUGH)) { c3 = 0; } } else if (d3.equals(TtmlNode.NO_LINETHROUGH)) { c3 = 1; } } else if (d3.equals(TtmlNode.UNDERLINE)) { c3 = 2; } } else if (d3.equals(TtmlNode.NO_UNDERLINE)) { c3 = 3; } if (c3 == 0) { bVar = a(bVar).a(true); } else if (c3 == 1) { bVar = a(bVar).a(false); } else if (c3 == 2) { bVar = a(bVar).b(true); } else if (c3 == 3) { bVar = a(bVar).b(false); continue; } default: } sb.append(str); sb.append(attributeValue); com.opos.cmn.an.f.a.c("TtmlDecoder", sb.toString()); } return bVar; } /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */ private c a(XmlPullParser xmlPullParser, c cVar, Map<String, d> map, C0276a aVar) { long j; long j2; char c2; int attributeCount = xmlPullParser.getAttributeCount(); b a2 = a(xmlPullParser, (b) null); String[] strArr = null; String str = ""; long j3 = C.TIME_UNSET; long j4 = C.TIME_UNSET; long j5 = C.TIME_UNSET; for (int i2 = 0; i2 < attributeCount; i2++) { String attributeName = xmlPullParser.getAttributeName(i2); String attributeValue = xmlPullParser.getAttributeValue(i2); switch (attributeName.hashCode()) { case -934795532: if (attributeName.equals(TtmlNode.TAG_REGION)) { c2 = 4; break; } c2 = 65535; break; case 99841: if (attributeName.equals("dur")) { c2 = 2; break; } c2 = 65535; break; case 100571: if (attributeName.equals(TtmlNode.END)) { c2 = 1; break; } c2 = 65535; break; case 93616297: if (attributeName.equals("begin")) { c2 = 0; break; } c2 = 65535; break; case 109780401: if (attributeName.equals("style")) { c2 = 3; break; } c2 = 65535; break; default: c2 = 65535; break; } if (c2 == 0) { j3 = a(attributeValue, aVar); } else if (c2 == 1) { j4 = a(attributeValue, aVar); } else if (c2 == 2) { j5 = a(attributeValue, aVar); } else if (c2 == 3) { String[] a3 = a(attributeValue); if (a3.length > 0) { strArr = a3; } } else if (c2 == 4) { if (map.containsKey(attributeValue)) { str = attributeValue; } } } if (cVar != null) { long j6 = cVar.d; j = C.TIME_UNSET; if (j6 != C.TIME_UNSET) { if (j3 != C.TIME_UNSET) { j3 += j6; } if (j4 != C.TIME_UNSET) { j4 += cVar.d; } } } else { j = C.TIME_UNSET; } if (j4 == j) { if (j5 != j) { j2 = j3 + j5; } else if (cVar != null) { long j7 = cVar.f13444e; if (j7 != j) { j2 = j7; } } return c.a(xmlPullParser.getName(), j3, j2, a2, strArr, str); } j2 = j4; return c.a(xmlPullParser.getName(), j3, j2, a2, strArr, str); } private Map<String, b> a(XmlPullParser xmlPullParser, Map<String, b> map, Map<String, d> map2) { d b2; do { xmlPullParser.next(); if (w.b(xmlPullParser, "style")) { String c2 = w.c(xmlPullParser, "style"); b a2 = a(xmlPullParser, new b()); if (c2 != null) { for (String str : a(c2)) { a2.a(map.get(str)); } } if (a2.i() != null) { map.put(a2.i(), a2); } } else if (w.b(xmlPullParser, TtmlNode.TAG_REGION) && (b2 = b(xmlPullParser)) != null) { map2.put(b2.a, b2); } } while (!w.a(xmlPullParser, TtmlNode.TAG_HEAD)); return map; } private static void a(String str, b bVar) { Matcher matcher; String[] split = str.split("\\s+"); if (split.length == 1) { matcher = c.matcher(str); } else if (split.length == 2) { matcher = c.matcher(split[1]); com.opos.cmn.an.f.a.c("TtmlDecoder", "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first."); } else { throw new f("Invalid number of entries for fontSize: " + split.length + "."); } if (matcher.matches()) { String group = matcher.group(3); char c2 = 65535; int hashCode = group.hashCode(); if (hashCode != 37) { if (hashCode != 3240) { if (hashCode == 3592 && group.equals("px")) { c2 = 0; } } else if (group.equals("em")) { c2 = 1; } } else if (group.equals("%")) { c2 = 2; } if (c2 == 0) { bVar.c(1); } else if (c2 == 1) { bVar.c(2); } else if (c2 == 2) { bVar.c(3); } else { throw new f("Invalid unit for fontSize: '" + group + "'."); } bVar.a(Float.valueOf(matcher.group(1)).floatValue()); return; } throw new f("Invalid expression for fontSize: '" + str + "'."); } private String[] a(String str) { return str.split("\\s+"); } private d b(XmlPullParser xmlPullParser) { String str; StringBuilder sb; String str2; String c2 = w.c(xmlPullParser, "id"); if (c2 == null) { return null; } String c3 = w.c(xmlPullParser, TtmlNode.ATTR_TTS_ORIGIN); if (c3 != null) { Matcher matcher = d.matcher(c3); if (matcher.matches()) { try { float parseFloat = Float.parseFloat(matcher.group(1)) / 100.0f; int i2 = 2; float parseFloat2 = Float.parseFloat(matcher.group(2)) / 100.0f; String c4 = w.c(xmlPullParser, TtmlNode.ATTR_TTS_EXTENT); if (c4 != null) { Matcher matcher2 = d.matcher(c4); if (matcher2.matches()) { try { float parseFloat3 = Float.parseFloat(matcher2.group(1)) / 100.0f; float parseFloat4 = Float.parseFloat(matcher2.group(2)) / 100.0f; String c5 = w.c(xmlPullParser, TtmlNode.ATTR_TTS_DISPLAY_ALIGN); if (c5 != null) { String d2 = v.d(c5); char c6 = 65535; int hashCode = d2.hashCode(); if (hashCode != -1364013995) { if (hashCode == 92734940 && d2.equals("after")) { c6 = 1; } } else if (d2.equals(TtmlNode.CENTER)) { c6 = 0; } if (c6 == 0) { parseFloat2 += parseFloat4 / 2.0f; i2 = 1; } else if (c6 == 1) { parseFloat2 += parseFloat4; } return new d(c2, parseFloat, parseFloat2, 0, i2, parseFloat3); } i2 = 0; return new d(c2, parseFloat, parseFloat2, 0, i2, parseFloat3); } catch (NumberFormatException unused) { sb = new StringBuilder(); str2 = "Ignoring region with malformed extent: "; } } else { sb = new StringBuilder(); str2 = "Ignoring region with unsupported extent: "; } } else { str = "Ignoring region without an extent"; } } catch (NumberFormatException unused2) { sb = new StringBuilder(); str2 = "Ignoring region with malformed origin: "; } } else { sb = new StringBuilder(); str2 = "Ignoring region with unsupported origin: "; } sb.append(str2); sb.append(c3); str = sb.toString(); } else { str = "Ignoring region without an origin"; } com.opos.cmn.an.f.a.c("TtmlDecoder", str); return null; } private static boolean b(String str) { return str.equals("tt") || str.equals(TtmlNode.TAG_HEAD) || str.equals(TtmlNode.TAG_BODY) || str.equals(TtmlNode.TAG_DIV) || str.equals("p") || str.equals(TtmlNode.TAG_SPAN) || str.equals(TtmlNode.TAG_BR) || str.equals("style") || str.equals(TtmlNode.TAG_STYLING) || str.equals(TtmlNode.TAG_LAYOUT) || str.equals(TtmlNode.TAG_REGION) || str.equals(TtmlNode.TAG_METADATA) || str.equals(TtmlNode.TAG_SMPTE_IMAGE) || str.equals(TtmlNode.TAG_SMPTE_DATA) || str.equals(TtmlNode.TAG_SMPTE_INFORMATION); } /* access modifiers changed from: protected */ /* renamed from: b */ public f a(byte[] bArr, int i2, boolean z) { try { XmlPullParser newPullParser = this.f13438f.newPullParser(); HashMap hashMap = new HashMap(); HashMap hashMap2 = new HashMap(); f fVar = null; hashMap2.put("", new d(null)); int i3 = 0; newPullParser.setInput(new ByteArrayInputStream(bArr, 0, i2), null); LinkedList linkedList = new LinkedList(); C0276a aVar = f13437e; for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.getEventType()) { c cVar = (c) linkedList.peekLast(); if (i3 == 0) { String name = newPullParser.getName(); if (eventType == 2) { if ("tt".equals(name)) { aVar = a(newPullParser); } if (!b(name)) { com.opos.cmn.an.f.a.a("TtmlDecoder", "Ignoring unsupported tag: " + newPullParser.getName()); } else if (TtmlNode.TAG_HEAD.equals(name)) { a(newPullParser, hashMap, hashMap2); } else { try { c a2 = a(newPullParser, cVar, hashMap2, aVar); linkedList.addLast(a2); if (cVar != null) { cVar.a(a2); } } catch (f e2) { com.opos.cmn.an.f.a.c("TtmlDecoder", "Suppressing parser error", e2); } } } else if (eventType == 4) { cVar.a(c.a(newPullParser.getText())); } else if (eventType == 3) { if (newPullParser.getName().equals("tt")) { fVar = new f((c) linkedList.getLast(), hashMap, hashMap2); } linkedList.removeLast(); } newPullParser.next(); } else if (eventType != 2) { if (eventType == 3) { i3--; } newPullParser.next(); } i3++; newPullParser.next(); } return fVar; } catch (XmlPullParserException e3) { throw new f("Unable to decode source", e3); } catch (IOException e4) { throw new IllegalStateException("Unexpected error when reading input.", e4); } } }