shithub: openh264

Download patch

ref: fcae7fd3001152a7aba94aa02c8691c5b1b3f195
parent: 58f1fef520b85d84ff0f077fd05e3115d2a69bea
author: Martin Storsjö <martin@martin.st>
date: Mon Jan 19 05:00:34 EST 2015

Compare macro block widths instead of picture widths

Since cropping is disabled (prepareParam does
memset (pParam, 0, sizeof (SEncParamExt)); which clears the
cropping flag), we need to make sure that the number of
macroblocks differ, not only the number of pixels.

--- a/test/api/encode_decode_api_test.cpp
+++ b/test/api/encode_decode_api_test.cpp
@@ -37,6 +37,7 @@
 #define MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA (6)
 #define MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN (8)
 
+#define GET_MB_WIDTH(x) (((x) + 15)/16)
 
 typedef struct SLost_Sim {
   WelsCommon::EWelsNalUnitType eNalType;
@@ -2591,7 +2592,7 @@
   sParam1.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
   //prepare param2
   memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
-  while (sParam2.iPicWidth == sParam1.iPicWidth) {
+  while (GET_MB_WIDTH (sParam2.iPicWidth) == GET_MB_WIDTH (sParam1.iPicWidth)) {
     sParam2.iPicWidth = GetRandWidth();
   }
   prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
@@ -2598,7 +2599,7 @@
   sParam2.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
   //prepare param3
   memcpy (&sParam3, &sParam1, sizeof (SEncParamExt));
-  while (sParam3.iPicHeight == sParam1.iPicHeight) {
+  while (GET_MB_WIDTH (sParam3.iPicHeight) == GET_MB_WIDTH (sParam1.iPicHeight)) {
     sParam3.iPicHeight = GetRandHeight();
   }
   prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3);
@@ -2768,7 +2769,7 @@
 
   int max_count = 65; // make it more then twice as MAX_SPS_COUNT
   std::vector<int> vWidthTable;
-  vWidthTable.push_back (sParam1.iPicWidth);
+  vWidthTable.push_back (GET_MB_WIDTH (sParam1.iPicWidth));
 
   std::vector<int>::iterator vWidthTableIt;
   for (int times = 0; times < max_count; times++) {
@@ -2776,9 +2777,9 @@
     memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
     do {
       sParam2.iPicWidth = GetRandWidth();
-      vWidthTableIt = std::find (vWidthTable.begin(), vWidthTable.end(), sParam2.iPicWidth);
+      vWidthTableIt = std::find (vWidthTable.begin(), vWidthTable.end(), GET_MB_WIDTH (sParam2.iPicWidth));
     } while (vWidthTableIt != vWidthTable.end());
-    vWidthTable.push_back (sParam2.iPicWidth);
+    vWidthTable.push_back (GET_MB_WIDTH (sParam2.iPicWidth));
     prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
     sParam2.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
 
@@ -2889,7 +2890,7 @@
   sParam1.eSpsPpsIdStrategy = SPS_PPS_LISTING;
   //prepare param2
   memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
-  while (sParam2.iPicWidth == sParam1.iPicWidth) {
+  while (GET_MB_WIDTH (sParam2.iPicWidth) == GET_MB_WIDTH (sParam1.iPicWidth)) {
     sParam2.iPicWidth = GetRandWidth();
   }
   prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
@@ -2948,7 +2949,7 @@
   sParam1.eSpsPpsIdStrategy = SPS_PPS_LISTING;
   //prepare param2
   memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
-  while (sParam2.iPicWidth == sParam1.iPicWidth) {
+  while (GET_MB_WIDTH (sParam2.iPicWidth) == GET_MB_WIDTH (sParam1.iPicWidth)) {
     sParam2.iPicWidth = GetRandWidth();
   }
   prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
@@ -2955,7 +2956,8 @@
   sParam2.eSpsPpsIdStrategy = SPS_PPS_LISTING;
   //prepare param3
   memcpy (&sParam3, &sParam1, sizeof (SEncParamExt));
-  while (sParam3.iPicWidth == sParam1.iPicWidth || sParam3.iPicWidth == sParam2.iPicWidth) {
+  while (GET_MB_WIDTH (sParam3.iPicWidth) == GET_MB_WIDTH (sParam1.iPicWidth) ||
+         GET_MB_WIDTH (sParam3.iPicWidth) == GET_MB_WIDTH (sParam2.iPicWidth)) {
     sParam3.iPicWidth = GetRandWidth();
   }
   prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3);