• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // CodecRTComponent.cpp
2 #include <string.h>
3 #include <iostream>
4 #include "typedefs.h"
5 #include "CodecRTComponent.h"
6 
7 using namespace CodecRTComponent;
8 using namespace Platform;
9 using namespace Windows::Storage;
10 
11 extern "C" int EncMain (int argc, char** argv);
12 extern int32_t DecMain (int32_t iArgC, char* pArgV[]);
13 //encoder info
14 extern float   g_fFPS;
15 extern double  g_dEncoderTime;
16 extern int     g_iEncodedFrame;
17 
18 //decoder info
19 extern double g_dDecTime;
20 extern float  g_fDecFPS;
21 extern int    g_iDecodedFrameNum;
22 
23 
CodecRunTimeComponent()24 CodecRunTimeComponent::CodecRunTimeComponent() {
25 }
26 
GetEncFPS()27 float CodecRunTimeComponent::GetEncFPS() {
28   return g_fFPS;
29 }
GetEncTime()30 double CodecRunTimeComponent::GetEncTime() {
31   return g_dEncoderTime;
32 }
GetEncodedFrameNum()33 int  CodecRunTimeComponent::GetEncodedFrameNum() {
34   return g_iEncodedFrame;
35 }
36 
Encode()37 int CodecRunTimeComponent::Encode() {
38   int iRet = 0;
39   int argc = 6;
40   char* argv[6];
41   int iSize = 0;
42 
43   //App test data files' path
44   char InputPath[256] = { 0 };
45   char InputWelsEncCfgPath[256] = { 0 };
46   char InputCfgPath[256] = { 0 };
47   char InputYUVPath[256] = { 0 };
48   char OutputPath[256] = { 0 };
49   char Output264Path[256] = { 0 };
50 
51   //App data location
52   Windows::Storage::StorageFolder^ InputLocation;
53   Platform::String^ InputLocationPath;
54   Windows::Storage::StorageFolder^ OutputLocation;
55   Platform::String^ OutputLocationPath;
56 
57   //set input file path
58   InputLocation = Windows::ApplicationModel::Package::Current->InstalledLocation;
59   InputLocationPath = Platform::String::Concat (InputLocation->Path, "\\");
60   const wchar_t* pWcharInputFile = InputLocationPath->Data();
61 
62   iSize = wcslen (pWcharInputFile);
63   InputPath[iSize] = 0;
64   for (int y = 0; y < iSize; y++) {
65     InputPath[y] = (char)pWcharInputFile[y];
66   }
67 
68   //set output file path
69   OutputLocation = ApplicationData::Current->LocalFolder;
70   OutputLocationPath = Platform::String::Concat (OutputLocation->Path, "\\");
71   const wchar_t* pWcharOutputFile = OutputLocationPath->Data();
72 
73   iSize = wcslen (pWcharOutputFile);
74   OutputPath[iSize] = 0;
75   for (int y = 0; y < iSize; y++) {
76     OutputPath[y] = (char)pWcharOutputFile[y];
77   }
78 
79   //App
80   strcpy (InputWelsEncCfgPath, InputPath);
81   strcat (InputWelsEncCfgPath, "welsenc.cfg");
82 
83   strcpy (InputYUVPath, InputPath);
84   strcat (InputYUVPath, "CiscoVT2people_160x96_6fps.yuv");
85 
86   // single layer only
87   strcpy (InputCfgPath, InputPath);
88   strcat (InputCfgPath, "layer2.cfg");
89   // for multiple layers
90   /*
91   strcpy(InputCfg0Path, InputPath);
92   strcat(InputCfg0Path, "layer0.cfg");
93   strcpy(InputCfg1Path, InputPath);
94   strcat(InputCfg1Path, "layer1.cfg");
95   ...
96   */
97 
98   strcpy (Output264Path, OutputPath);
99   strcat (Output264Path, "WP8_Test_CiscoVT2people_160x96_6fps.264");
100 
101   argv[0] = (char*) ("EncoderApp");
102   argv[1] = InputWelsEncCfgPath;
103   argv[2] = (char*) ("-org");
104   argv[3] = InputYUVPath;
105   argv[4] = (char*) ("-bf");
106   argv[5] = Output264Path;
107 
108   argc = 6;
109   iRet = EncMain (argc, argv);
110 
111   return iRet;
112 }
113 
114 
GetDecFPS()115 float CodecRunTimeComponent::GetDecFPS() {
116   return g_fDecFPS;
117 }
GetDecTime()118 double CodecRunTimeComponent::GetDecTime() {
119   return g_dDecTime;
120 }
GetDecodedFrameNum()121 int CodecRunTimeComponent::GetDecodedFrameNum() {
122   return g_iDecodedFrameNum;
123 }
124 
Decode()125 int CodecRunTimeComponent::Decode() {
126   int iRet = 0;
127   int argc = 3;
128   char* argv[3];
129   int size = 0;
130 
131   //App data files' path
132   char InputPath[256] = { 0 };
133   char OutputPath[256] = { 0 };
134   char InputBitstreamPath[256] = { 0 };
135   char OutputYUVPath[256] = { 0 };
136 
137   //App data location
138   Windows::Storage::StorageFolder^ InputLocation;
139   Platform::String^ InputLocationPath;
140 
141   Windows::Storage::StorageFolder^ OutputLocation;
142   Platform::String^ OutputLocationPath;
143 
144   //set input file path
145   InputLocation = Windows::ApplicationModel::Package::Current->InstalledLocation;
146   InputLocationPath = Platform::String::Concat (InputLocation->Path, "\\");
147   const wchar_t* pWcharInputFile = InputLocationPath->Data();
148 
149   size = wcslen (pWcharInputFile);
150   InputPath[size] = 0;
151   for (int y = 0; y < size; y++) {
152     InputPath[y] = (char)pWcharInputFile[y];
153   }
154 
155   //set output file path
156   OutputLocation = ApplicationData::Current->LocalFolder;
157   OutputLocationPath = Platform::String::Concat (OutputLocation->Path, "\\");
158   const wchar_t* pWcharOutputFile = OutputLocationPath->Data();
159 
160   size = wcslen (pWcharOutputFile);
161   OutputPath[size] = 0;
162   for (int y = 0; y < size; y++) {
163     OutputPath[y] = (char)pWcharOutputFile[y];
164   }
165 
166   //App test setting
167   strcpy_s (InputBitstreamPath, InputPath);
168   strcat_s (InputBitstreamPath, "BA_MW_D.264");
169 
170   strcpy_s (OutputYUVPath, OutputPath);
171   strcat_s (OutputYUVPath, "WP8_Dec_BA_MW_D.yuv");
172 
173   argv[0] = (char*) ("DecoderApp");
174   argv[1] = InputBitstreamPath;
175   argv[2] = OutputYUVPath;
176 
177   argc = 3;
178   iRet = DecMain (argc, argv);
179 
180   return iRet;
181 }
182