Browse Source

feat: 1504 warning dialog

hexleo 5 years ago
parent
commit
9cb88ecd63

+ 2 - 1
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/AnimTool.java

@@ -76,7 +76,7 @@ public class AnimTool {
      * @return
      */
     private boolean checkCommonArg(CommonArg commonArg) throws Exception {
-        return CommonArgTool.autoFillAndCheck(commonArg);
+        return CommonArgTool.autoFillAndCheck(commonArg, toolListener);
     }
 
     private boolean finalCheck(CommonArg commonArg) {
@@ -334,6 +334,7 @@ public class AnimTool {
 
     public interface IToolListener {
         void onProgress(float progress);
+        void onWarning(String msg);
         void onError();
         void onComplete();
     }

+ 17 - 8
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArgTool.java

@@ -19,20 +19,20 @@ class CommonArgTool {
      * 参数自动填充
      * @param commonArg
      */
-    static boolean autoFillAndCheck(CommonArg commonArg) throws Exception {
+    static boolean autoFillAndCheck(CommonArg commonArg, AnimTool.IToolListener toolListener) throws Exception {
 
         String os = System.getProperty("os.name");
         TLog.i(TAG, os);
 
         if (commonArg.inputPath == null && "".equals(commonArg.inputPath)) {
-            TLog.i(TAG, "error: input path invalid");
+            TLog.e(TAG, "input path invalid");
             return false;
         }
 
         //  路径检查
         File input = new File(commonArg.inputPath);
         if (!input.exists()) {
-            TLog.i(TAG, "error: input path invalid " + commonArg.inputPath);
+            TLog.e(TAG, "input path invalid " + commonArg.inputPath);
             return false;
         }
 
@@ -55,7 +55,7 @@ class CommonArgTool {
                 src.z = i;
                 File srcPath = new File(src.srcPath);
                 if (!srcPath.exists()) {
-                    TLog.i(TAG, "error: src="+ src.srcId+",path invalid " + src.srcPath);
+                    TLog.e(TAG, "src="+ src.srcId+",path invalid " + src.srcPath);
                     continue;
                 }
                 if (!File.separator.equals(src.srcPath.substring(src.srcPath.length() - 1))) {
@@ -76,7 +76,7 @@ class CommonArgTool {
         // 检查第一帧
         File firstFrame = new File(commonArg.inputPath + "000.png");
         if (!firstFrame.exists()) {
-            TLog.i(TAG, "error: first frame 000.png does not exist");
+            TLog.e(TAG, "first frame 000.png does not exist");
             return false;
         }
         // 获取视频高度
@@ -84,7 +84,7 @@ class CommonArgTool {
         commonArg.rgbPoint.w = inputBuf.getWidth();
         commonArg.rgbPoint.h = inputBuf.getHeight();
         if (commonArg.rgbPoint.w <= 0 || commonArg.rgbPoint.h <= 0) {
-            TLog.i(TAG, "error: video size " + commonArg.rgbPoint.w + "x" + commonArg.rgbPoint.h);
+            TLog.e(TAG, "video size " + commonArg.rgbPoint.w + "x" + commonArg.rgbPoint.h);
             return false;
         }
 
@@ -121,11 +121,20 @@ class CommonArgTool {
         }
 
         // 计算出 16倍数的视频
-        int[] size = calSizeFill( commonArg.outputW, commonArg.outputH, 0, 0);
+        int[] size = calSizeFill(commonArg.outputW, commonArg.outputH, 0, 0);
         // 得到最终视频宽高
         commonArg.outputW += size[0];
         commonArg.outputH += size[1];
 
+        if (true || commonArg.outputW > 1504 || commonArg.outputH > 1504) {
+
+            String msg = "[Warning] Output video width:" + commonArg.outputW + " or height:" + commonArg.outputH
+                    + " is over 1504. Some devices will display exception, like video turn to green!";
+            TLog.w(TAG, msg);
+            if (toolListener != null) {
+                toolListener.onWarning(msg);
+            }
+        }
 
         // 获取总帧数
         commonArg.totalFrame = 0;
@@ -140,7 +149,7 @@ class CommonArgTool {
 
 
         if (commonArg.totalFrame <= 0) {
-            TLog.i(TAG, "error: totalFrame=" + commonArg.totalFrame);
+            TLog.e(TAG, "totalFrame=" + commonArg.totalFrame);
             return false;
         }
 

+ 0 - 5
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/GetAlphaFrame.java

@@ -75,7 +75,6 @@ public class GetAlphaFrame {
         // alpha 区域
         fillColor(outputArgb, outW, commonArg.alphaPoint, true, alphaArgb, w);
 
-
         return new AlphaFrameOut(outputArgb);
 
     }
@@ -88,10 +87,6 @@ public class GetAlphaFrame {
             outY = point.y + y;
             for (int x = 0; x < point.w ; x++) {
                 outX = point.x + x;
-                int tmpP = x + y * inputW;
-                if (tmpP >= inputArgb.length) {
-                    TLog.i("hexleo_test", "x=" + x + ",y=" + y + ",inputW=" + inputW);
-                }
                 int color = inputArgb[x + y * inputW];
                 outputArgb[outX + outY * outputW] = isAlpha ? getAlpha(color) : getColor(color);
             }

+ 2 - 2
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java

@@ -24,13 +24,13 @@ public class Main {
 
     public static void main(String[] args) throws Exception {
         // 启动UI界面
-        // new ToolUI().run();
+        new ToolUI().run();
 
         // java工具普通动画
         // animTool();
 
         // java工具融合动画
-        animVapxTool();
+        // animVapxTool();
     }
 
 

+ 19 - 0
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/TLog.java

@@ -27,7 +27,26 @@ public class TLog {
         }
     }
 
+    public static void e(String tag, String msg) {
+        if (logger != null) {
+            logger.e(tag, msg);
+        } else {
+            System.out.println(tag + "\tError:" + msg);
+        }
+    }
+
+    public static void w(String tag, String msg) {
+        if (logger != null) {
+            logger.w(tag, msg);
+        } else {
+            System.out.println(tag + "\tWarning:" + msg);
+        }
+    }
+
+
     public interface ITLog {
         void i(String tag, String  msg);
+        void e(String tag, String  msg);
+        void w(String tag, String  msg);
     }
 }

+ 31 - 10
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/ui/ToolUI.java

@@ -26,6 +26,7 @@ import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.JScrollPane;
@@ -42,6 +43,7 @@ public class ToolUI {
     private final int WIDTH = 800;
     private final int HEIGHT = 600;
 
+    private final JFrame frame = new JFrame("VAP tool");
     private final ButtonGroup group = new ButtonGroup();
     private final JRadioButton btnH265 = new JRadioButton("h265");
     private final JRadioButton btnH264 = new JRadioButton("h264");
@@ -57,16 +59,32 @@ public class ToolUI {
 
     private final VapxUI vapxUI = new VapxUI();
 
-
-
-    public void run() {
+    public ToolUI() {
         TLog.logger = new TLog.ITLog() {
             @Override
             public void i(String tag, String msg) {
                 log(tag, msg);
             }
+
+            @Override
+            public void e(String tag, String msg) {
+                log(tag, "Error:" + msg);
+            }
+
+            @Override
+            public void w(String tag, String msg) {
+                log(tag, "Warning:" + msg);
+            }
         };
+    }
+
+
+    public void run() {
         createUI();
+        loadProperties();
+    }
+
+    private void loadProperties() {
         try {
             File file = new File(PROPERTIES_FILE);
             if (!file.exists()) {
@@ -85,11 +103,10 @@ public class ToolUI {
                 }
             }
         } catch (Exception e) {
-            TLog.i(TAG, "ERROR -> " + e.getMessage());
+            TLog.e(TAG, e.getMessage());
         }
     }
 
-
     private void runTool() {
         txtAreaLog.setText("");
         new Thread(new Runnable() {
@@ -98,7 +115,7 @@ public class ToolUI {
                 try {
                     runAnimTool();
                 } catch (Exception e) {
-                    TLog.i(TAG, "ERROR -> " + e.getMessage());
+                    TLog.e(TAG, e.getMessage());
                     btnCreate.setEnabled(true);
                 }
             }
@@ -136,6 +153,11 @@ public class ToolUI {
                 labelOutInfo.setText((Math.min(p, 99)) + "%");
             }
 
+            @Override
+            public void onWarning(String msg) {
+                JOptionPane.showMessageDialog(frame, msg, "Warning", JOptionPane.WARNING_MESSAGE);
+            }
+
             @Override
             public void onError() {
                 btnCreate.setEnabled(true);
@@ -149,7 +171,7 @@ public class ToolUI {
                     setProperties(commonArg);
                     Desktop.getDesktop().open(new File(commonArg.outputPath));
                 } catch (IOException e) {
-                    TLog.i(TAG, "ERROR -> " + e.getMessage());
+                    TLog.e(TAG, e.getMessage());
                 }
             }
         });
@@ -159,7 +181,6 @@ public class ToolUI {
     }
 
     private void createUI() {
-        JFrame frame = new JFrame("VAP tool");
         frame.setSize(WIDTH, HEIGHT);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
@@ -281,7 +302,7 @@ public class ToolUI {
                 try {
                     Desktop.getDesktop().open(new File(path));
                 } catch (IOException e) {
-                    TLog.i(TAG, "ERROR -> " + e.getMessage());
+                    TLog.e(TAG, e.getMessage());
                 }
             }
         });
@@ -361,7 +382,7 @@ public class ToolUI {
             commonArg.enableH265 = Boolean.TRUE.toString().equals(enableH265);
             commonArg.inputPath = inputPath;
         } catch (Exception e) {
-            TLog.i(TAG, "getProperties error:" + e.getMessage());
+            TLog.e(TAG, "getProperties error:" + e.getMessage());
         }
         return commonArg;
     }

+ 2 - 2
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/vapx/GetMaskFrame.java

@@ -83,12 +83,12 @@ public class GetMaskFrame {
             mFrame.x = startX;
             mFrame.y = lastMaxY;
             if (mFrame.x + mFrame.w > outW) {
-                TLog.i(TAG, "Error: frameIndex=" + frameIndex + ",src=" + src.srcId + ", no more space for(w)" + mFrame);
+                TLog.e(TAG, "frameIndex=" + frameIndex + ",src=" + src.srcId + ", no more space for(w)" + mFrame);
                 return null;
             }
         }
         if (mFrame.y + mFrame.h > outH) { // 高度不够直接错误
-            TLog.i(TAG, "Error: frameIndex=" + frameIndex + ",src=" + src.srcId + ", no more space(h)" + mFrame);
+            TLog.e(TAG, "frameIndex=" + frameIndex + ",src=" + src.srcId + ", no more space(h)" + mFrame);
             return null;
         }
         frame.mFrame = mFrame;