shithub: openh264

Download patch

ref: 8af6e5cf690763eff24b7eb002c1589694996663
parent: 4033940ba7921041239f78f82710d5acb7a11766
parent: 70d2ae8334b7a184f45d2e27158c830807b95b65
author: Ethan Hugg <[email protected]>
date: Tue Jan 7 08:38:04 EST 2014

Merge pull request #77 from varunbpatil/enc_testapp_arbitrary_res

Non-multiple of 16 width/height support for enc testapp

--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -953,6 +953,11 @@
   sSvcParam.iActualPicHeight =
     sSvcParam.SUsedPicRect.iHeight = sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameHeight;
 
+  sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameWidth =
+    WELS_ALIGN(sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iActualWidth, MB_WIDTH_LUMA);
+  sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iFrameHeight =
+    WELS_ALIGN(sSvcParam.sDependencyLayers[sSvcParam.iNumDependencyLayer - 1].iActualHeight, MB_HEIGHT_LUMA);
+
   if (cmResultSuccess != pPtrEnc->Initialize ((void*)&sSvcParam, INIT_TYPE_CONFIG_BASED)) {	// SVC encoder initialization
     fprintf (stderr, "SVC encoder Initialize failed\n");
     iRet = 1;
@@ -982,7 +987,7 @@
   pSrcPicList = new SSourcePicture * [sSvcParam.iNumDependencyLayer];
   while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
     SDLayerParam* pDLayer = &sSvcParam.sDependencyLayers[iDlayerIdx];
-    const int kiPicResSize = pDLayer->iFrameWidth * pDLayer->iFrameHeight;
+    const int kiPicResSize = pDLayer->iActualWidth * pDLayer->iActualHeight;
     SSourcePicture* pSrcPic = new SSourcePicture;
     if (pSrcPic == NULL) {
       iRet = 1;
@@ -997,10 +1002,10 @@
     }
 
     pSrcPic->iColorFormat = videoFormatI420;
-    pSrcPic->iPicWidth = pDLayer->iFrameWidth;
-    pSrcPic->iPicHeight = pDLayer->iFrameHeight;
-    pSrcPic->iStride[0] = pDLayer->iFrameWidth;
-    pSrcPic->iStride[1] = pSrcPic->iStride[2] = pDLayer->iFrameWidth >> 1;
+    pSrcPic->iPicWidth = pDLayer->iActualWidth;
+    pSrcPic->iPicHeight = pDLayer->iActualHeight;
+    pSrcPic->iStride[0] = pDLayer->iActualWidth;
+    pSrcPic->iStride[1] = pSrcPic->iStride[2] = pDLayer->iActualWidth >> 1;
 
     pSrcPicList[iDlayerIdx] = pSrcPic;
 
@@ -1038,7 +1043,7 @@
     int  nSpatialLayerNum = 0;
     while (iDlayerIdx < sSvcParam.iNumDependencyLayer) {
       SDLayerParam* pDLayer = &sSvcParam.sDependencyLayers[iDlayerIdx];
-      const int kiPicResSize = ((pDLayer->iFrameWidth * pDLayer->iFrameHeight) * 3) >> 1;
+      const int kiPicResSize = ((pDLayer->iActualWidth * pDLayer->iActualHeight) * 3) >> 1;
       uint32_t uiSkipIdx = (1 << pDLayer->iTemporalResolution);
 
       bool_t bCanBeRead = false;
@@ -1051,15 +1056,15 @@
 
           pSrcPicList[nSpatialLayerNum]->pData[0] = pYUV[iDlayerIdx];
           pSrcPicList[nSpatialLayerNum]->pData[1] = pSrcPicList[nSpatialLayerNum]->pData[0] +
-              (pDLayer->iFrameWidth * pDLayer->iFrameHeight);
+              (pDLayer->iActualWidth * pDLayer->iActualHeight);
           pSrcPicList[nSpatialLayerNum]->pData[2] = pSrcPicList[nSpatialLayerNum]->pData[1] +
-              ((pDLayer->iFrameWidth * pDLayer->iFrameHeight) >> 2);
+              ((pDLayer->iActualWidth * pDLayer->iActualHeight) >> 2);
 
-          pSrcPicList[nSpatialLayerNum]->iPicWidth = pDLayer->iFrameWidth;
-          pSrcPicList[nSpatialLayerNum]->iPicHeight = pDLayer->iFrameHeight;
-          pSrcPicList[nSpatialLayerNum]->iStride[0] = pDLayer->iFrameWidth;
+          pSrcPicList[nSpatialLayerNum]->iPicWidth = pDLayer->iActualWidth;
+          pSrcPicList[nSpatialLayerNum]->iPicHeight = pDLayer->iActualHeight;
+          pSrcPicList[nSpatialLayerNum]->iStride[0] = pDLayer->iActualWidth;
           pSrcPicList[nSpatialLayerNum]->iStride[1] = pSrcPicList[nSpatialLayerNum]->iStride[2]
-              = pDLayer->iFrameWidth >> 1;
+              = pDLayer->iActualWidth >> 1;
 
           ++ nSpatialLayerNum;
         } else {	// file end while reading
--- /dev/null
+++ b/testbin/Static_152_100.yuv
@@ -1,0 +1,1 @@
+������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ))))))))))))))))))))))������������������������������������������Ҫ������������������������������������������jjjjjjjjjjjjjjjjjjjjjjQQQQQQQQQQQQQQQQQQQQQQ)))))))))))))
\ No newline at end of file
--- /dev/null
+++ b/testbin/layer2_arbitrary_res.cfg
@@ -1,0 +1,39 @@
+# Layer Configuration File
+
+
+#============================== INPUT / OUTPUT ==============================
+SourceWidth     152                     # Input  frame width
+SourceHeight    100                    # Input  frame height
+FrameRateIn     12                      # Input  frame rate [Hz]
+FrameRateOut    12                     # Output frame rate [Hz]
+InputFile       Static_152_100.yuv # Input  file
+ReconFile       rec_layer2.yuv          # Reconstructed file
+
+#============================== CODING ==============================
+ProfileIdc      66          # value of profile_idc (or 0 for auto detection)
+
+InitialQP       24			# Quantization parameters for base quality layer
+#================================ RATE CONTROL ===============================
+SpatialBitrate		600		# Unit: kbps, controled by DisableRC also
+#============================== MultiSlice Slice Argument ==============================
+# for S/M Slice(s) mode settings
+SliceMode			0		# 0: sigle slice mode; >0: multiple slices mode, see below;
+SliceSize			1500
+SliceNum			1		# multiple slices number specified
+
+SlicesAssign0		960		# count number of MBs in slice #0
+SlicesAssign1		0		# count number of MBs in slice #1
+SlicesAssign2		0		# count number of MBs in slice #2
+SlicesAssign3		0		# count number of MBs in slice #3 -- seting here is for better testing
+SlicesAssign4		0		# count number of MBs in slice #4
+SlicesAssign5		0		# count number of MBs in slice #5
+SlicesAssign6		0		# count number of MBs in slice #6
+SlicesAssign7		0		# count number of MBs in slice #7
+
+### DESIGN OF SLICE MODE ####
+# 0 SM_SINGLE_SLICE			| SliceNum==1
+# 1 SM_FIXEDSLCNUM_SLICE	| according to SliceNum			| Enabled dynamic slicing for multi-thread
+# 2 SM_RASTER_SLICE			| according to SlicesAssign		| Need input of MB numbers each slice. In addition, if other constraint in slice_argument is presented, need to follow the constraints. Typically if MB num and slice size are both constrained, re-encoding may be involved.
+# 3 SM_ROWMB_SLICE			| according to PictureMBHeight	| Typical of single row of mbs each slice?+ slice size constraint which including re-encoding
+# 4 SM_DYN_SLICE			| according to SliceSize		| Dynamic slicing (have no idea about slice_nums until encoding current frame)
+
--- /dev/null
+++ b/testbin/welsenc_arbitrary_res.cfg
@@ -1,0 +1,63 @@
+# Cisco Scalable H.264/AVC Extension Encoder Configuration File
+
+#============================== GENERAL ==============================
+OutputFile              test.264               # Bitstream file
+MaxFrameRate            30                     # Maximum frame rate [Hz]
+FramesToBeEncoded       -1                    # Number of frames (at input frame rate)
+
+GOPSize                 4                     # GOP Size (at maximum frame rate), 16
+IntraPeriod            0                    # Intra Period ( multiple of GoP size or -1)
+EnableSpsPpsIDAddition  1
+
+EnableFrameCropping 	1 		       # enable frame cropping flag
+
+#============================== LOOP FILTER ==============================
+LoopFilterDisableIDC       0                   # Loop filter idc (0: on, 1: off,
+                                               # 2: on except for slice boundaries,
+                                               # 3: two stage. slice boundries on in second stage
+                                               # 4: Luma on but Chroma off (w.r.t. idc=0)
+                                               # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2)
+                                               # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3)
+LoopFilterAlphaC0Offset	0                      # AlphaOffset(-6..+6): valid range
+LoopFilterBetaOffset	0                      # BetaOffset (-6..+6): valid range
+
+InterLayerLoopFilterDisableIDC       0         # filter idc for inter-layer deblocking (0: on, 1: off,
+                                               # 2: on except for slice boundaries,
+                                               # 3: two stage. slice boundries on in second stage
+                                               # 4: Luma on but Chroma off in enh. layer (w.r.t. idc=0)
+                                               # 5: Luma on except on slice boundaries, but Chroma off in enh. layer (w.r.t. idc=2)
+                                               # 6: Luma on in two stage. slice boundries on in second stage, but Chroma off (w.r.t. idc=3)
+InterLayerLoopFilterAlphaC0Offset 0            # AlphaOffset for inter-layer deblocking
+InterLayerLoopFilterBetaOffset    0            # BetaOffset for inter-layer deblocking
+
+#============================== SOFTWARE IMPLEMENTATION ==============================
+MultipleThreadIdc			    1	# 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
+
+#============================== RATE CONTROL ==============================
+EnableRC				1						# ENABLE RC
+TargetBitrate			5000				    # Unit: kbps, controled by EnableRC also
+
+#============================== DENOISE CONTROL ==============================
+EnableDenoise                   0              # Enable Denoise (1: enable, 0: disable)
+
+#============================== SCENE CHANGE DETECTION CONTROL =======================
+EnableSceneChangeDetection			1			# Enable Scene Change Detection (1: enable, 0: disable)
+
+#============================== BACKGROUND DETECTION CONTROL ==============================
+EnableBackgroundDetection		 1     # BGD control(1: enable, 0: disable)
+
+#============================== ADAPTIVE QUANTIZATION CONTROL =======================
+EnableAdaptiveQuantization			1			# Enable Adaptive Quantization (1: enable, 0: disable)
+
+#============================== LONG TERM REFERENCE CONTROL ==============================
+EnableLongTermReference             0              # Enable Long Term Reference (1: enable, 0: disable)
+LtrMarkPeriod                       30             # Long Term Reference Marking Period
+
+#============================== LAYER DEFINITION ==============================
+PrefixNALAddingCtrl		0						# Control flag of adding prefix unit (0: off, 1: on)
+												# It shall always be on in SVC contexts (i.e. when there are CGS/MGS/spatial enhancement layers)
+												# Can be disabled when no inter spatial layer prediction in case of its value as 0
+NumLayers              1                      # Number of layers
+//LayerCfg                layer0.cfg		# Layer 0 configuration file
+//LayerCfg                layer1.cfg		# Layer 1 configuration file
+LayerCfg                layer2_arbitrary_res.cfg		# Layer 2 configuration file