cleanup rotation degree settings.

BZ: 149979

mRotationDegress is not initialized. setRotationDegress function is
cleaned up so it can be used during VA setup.

Change-Id: I0f8a62f4694f6048de131d4a170d5b1cf70878e7
Signed-off-by: Andy Qiu <junhai.qiu@intel.com>
Signed-off-by: pingshix <pingx.shi@intel.com>
diff --git a/videodecoder/VideoDecoderAVC.cpp b/videodecoder/VideoDecoderAVC.cpp
index 67ce66f..45e7e9d 100644
--- a/videodecoder/VideoDecoderAVC.cpp
+++ b/videodecoder/VideoDecoderAVC.cpp
@@ -117,7 +117,7 @@
         }
     }
 
-    VideoDecoderBase::setRotationDegrees(buffer);
+    VideoDecoderBase::setRotationDegrees(buffer->rotationDegrees);
 
     status = decodeFrame(buffer, data);
     if (status == DECODE_MULTIPLE_FRAME) {
diff --git a/videodecoder/VideoDecoderBase.cpp b/videodecoder/VideoDecoderBase.cpp
index bb3bef5..c4d961a 100644
--- a/videodecoder/VideoDecoderBase.cpp
+++ b/videodecoder/VideoDecoderBase.cpp
@@ -935,19 +935,7 @@
         CHECK_STATUS("mapSurface")
     }
 
-    VADisplayAttribute rotate;
-    rotate.type = VADisplayAttribRotation;
-    rotate.value = VA_ROTATION_NONE;
-    if (mConfigBuffer.rotationDegrees == 0)
-        rotate.value = VA_ROTATION_NONE;
-    else if (mConfigBuffer.rotationDegrees == 90)
-        rotate.value = VA_ROTATION_90;
-    else if (mConfigBuffer.rotationDegrees == 180)
-        rotate.value = VA_ROTATION_180;
-    else if (mConfigBuffer.rotationDegrees == 270)
-        rotate.value = VA_ROTATION_270;
-
-    vaStatus = vaSetDisplayAttributes(mVADisplay, &rotate, 1);
+    setRotationDegrees(mConfigBuffer.rotationDegrees);
 
     mVAStarted = true;
     return DECODE_SUCCESS;
@@ -1373,24 +1361,28 @@
     }
 }
 
-void VideoDecoderBase::setRotationDegrees(VideoDecodeBuffer *buffer) {
+void VideoDecoderBase::setRotationDegrees(int32_t rotationDegrees) {
+    if (mRotationDegrees == rotationDegrees) {
+        return;
+    }
 
-    if (mRotationDegrees != buffer->rotationDegrees) {
-        ITRACE("set new mRotationDegrees = %d", mRotationDegrees);
-        VADisplayAttribute rotate;
-        rotate.type = VADisplayAttribRotation;
+    ITRACE("set new rotation degree: %d", rotationDegrees);
+    VADisplayAttribute rotate;
+    rotate.type = VADisplayAttribRotation;
+    rotate.value = VA_ROTATION_NONE;
+    if (rotationDegrees == 0)
         rotate.value = VA_ROTATION_NONE;
-        if (buffer->rotationDegrees == 0)
-            rotate.value = VA_ROTATION_NONE;
-        else if (buffer->rotationDegrees == 90)
-            rotate.value = VA_ROTATION_90;
-        else if (buffer->rotationDegrees == 180)
-            rotate.value = VA_ROTATION_180;
-        else if (buffer->rotationDegrees == 270)
-            rotate.value = VA_ROTATION_270;
+    else if (rotationDegrees == 90)
+        rotate.value = VA_ROTATION_90;
+    else if (rotationDegrees == 180)
+        rotate.value = VA_ROTATION_180;
+    else if (rotationDegrees == 270)
+        rotate.value = VA_ROTATION_270;
 
-        vaSetDisplayAttributes(mVADisplay, &rotate, 1);
-        mRotationDegrees = buffer->rotationDegrees;
-   }
+    VAStatus ret = vaSetDisplayAttributes(mVADisplay, &rotate, 1);
+    if (ret) {
+        ETRACE("Failed to set rotation degree.");
+    }
+    mRotationDegrees = rotationDegrees;
 }
 
diff --git a/videodecoder/VideoDecoderBase.h b/videodecoder/VideoDecoderBase.h
index 6bd0d1b..b111bb3 100644
--- a/videodecoder/VideoDecoderBase.h
+++ b/videodecoder/VideoDecoderBase.h
@@ -171,7 +171,7 @@
     void setOutputWindowSize(int32_t size) {mOutputWindowSize = (size < OUTPUT_WINDOW_SIZE) ? size : OUTPUT_WINDOW_SIZE;}
     void querySurfaceRenderStatus(VideoSurfaceBuffer* surface);
     void enableLowDelayMode(bool enable) {mLowDelay = enable;}
-    void setRotationDegrees(VideoDecodeBuffer *buffer);
+    void setRotationDegrees(int32_t rotationDegrees);
 };
 
 
diff --git a/videodecoder/VideoDecoderVP8.cpp b/videodecoder/VideoDecoderVP8.cpp
index 34fd866..9bfd15b 100644
--- a/videodecoder/VideoDecoderVP8.cpp
+++ b/videodecoder/VideoDecoderVP8.cpp
@@ -145,7 +145,7 @@
         CHECK_STATUS("startVA");
     }
 
-    VideoDecoderBase::setRotationDegrees(buffer);
+    VideoDecoderBase::setRotationDegrees(buffer->rotationDegrees);
 
     status = decodeFrame(buffer, data);
 
diff --git a/videodecoder/securevideo/merrifield/VideoDecoderAVCSecure.cpp b/videodecoder/securevideo/merrifield/VideoDecoderAVCSecure.cpp
index cd8b2ca..ab7bc7e 100644
--- a/videodecoder/securevideo/merrifield/VideoDecoderAVCSecure.cpp
+++ b/videodecoder/securevideo/merrifield/VideoDecoderAVCSecure.cpp
@@ -137,7 +137,7 @@
         // |...encrypted video bitstream (16 bytes aligned)...| 4 bytes of header size |...NALU headers..|
         pByteStream = buffer->data + buffer->size + 4;
         sizeLeft = *(int32_t *)(buffer->data + buffer->size);
-        ITRACE("%s sizeLeft: %d buffer->size: %#x", __func__, sizeLeft, buffer->size);
+        VTRACE("%s sizeLeft: %d buffer->size: %#x", __func__, sizeLeft, buffer->size);
         mInputBuffer = buffer->data;
     } else {
         status = parseAnnexBStream(buffer->data, buffer->size, &mByteStream);