コード例 #1
0
ファイル: VideoFormat.java プロジェクト: CraziFuzzy/sagetv
 public static VideoFormat buildVideoFormatForResolution(String s) {
   if (s == null || s.length() == 0) return null;
   VideoFormat rv = new VideoFormat();
   rv.setFormatName(s);
   try {
     int xidx = s.indexOf('x');
     if (xidx == -1) return rv;
     rv.width = Integer.parseInt(s.substring(0, xidx));
     int lastIdx = xidx + 1;
     while (Character.isDigit(s.charAt(lastIdx))) {
       lastIdx++;
       if (lastIdx >= s.length()) break;
     }
     rv.height = Integer.parseInt(s.substring(xidx + 1, lastIdx));
     if (lastIdx < s.length() && s.charAt(lastIdx) == 'i') rv.interlaced = true;
     int atSym = s.indexOf('@');
     if (atSym != -1) {
       lastIdx = atSym + 1;
       while (Character.isDigit(s.charAt(lastIdx)) || s.charAt(lastIdx) == '.') {
         lastIdx++;
         if (lastIdx >= s.length()) break;
       }
       rv.fps = Float.parseFloat(s.substring(atSym + 1, lastIdx));
     }
     return rv;
   } catch (Exception e) {
     System.out.println("Error parsing resolution:" + s + " of:" + e);
     return rv;
   }
 }
コード例 #2
0
ファイル: VideoFormat.java プロジェクト: CraziFuzzy/sagetv
 public static VideoFormat buildVideoFormatFromProperty(String str) {
   VideoFormat rv = new VideoFormat();
   int currNameStart = 0;
   int currValueStart = -1;
   for (int i = 0; i < str.length(); i++) {
     char c = str.charAt(i);
     if (c == '\\') {
       // Escaped character, so skip the next one
       i++;
       continue;
     } else if (c == '=') {
       // We found the name=value delimeter, set the value start position
       currValueStart = i + 1;
     } else if ((c == ';' || i == str.length() - 1) && currValueStart != -1) {
       if (c != ';' && i == str.length() - 1) i++;
       // We're at the end of the name value pair, get their values!
       String name = str.substring(currNameStart, currValueStart - 1);
       String value = str.substring(currValueStart, i);
       currNameStart = i + 1;
       currValueStart = -1;
       if (value.length() > 0) {
         try {
           if ("f".equals(name)) rv.setFormatName(unescapeString(value));
           else if ("fps".equals(name)) rv.fps = Float.parseFloat(value);
           else if ("fpsd".equals(name)) rv.fpsDen = Integer.parseInt(value);
           else if ("fpsn".equals(name)) rv.fpsNum = Integer.parseInt(value);
           else if ("ar".equals(name)) rv.aspectRatio = Float.parseFloat(value);
           else if ("ard".equals(name)) rv.arDen = Integer.parseInt(value);
           else if ("arn".equals(name)) rv.arNum = Integer.parseInt(value);
           else if ("w".equals(name)) rv.width = Integer.parseInt(value);
           else if ("h".equals(name)) rv.height = Integer.parseInt(value);
           else if ("lace".equals(name) && "1".equals(value)) rv.interlaced = true;
           else if ("cs".equals(name)) rv.colorspace = unescapeString(value).intern();
           else if ("br".equals(name)) rv.bitrate = Integer.parseInt(value);
           else if ("vbr".equals(name)) rv.vbr = "1".equals(value);
           else if ("main".equals(name)) rv.primary = "yes".equalsIgnoreCase(value);
           else if ("index".equals(name)) rv.orderIndex = Integer.parseInt(value);
           else if ("tag".equals(name)) rv.id = value.intern();
           else if ("fpa".equals(name)) rv.framePack3D = value.intern();
         } catch (Exception e) {
           System.out.println("ERROR parsing video format info " + str + " of:" + e);
         }
       }
     }
   }
   return rv;
 }