2013-12-09 13:51:09 +01:00
|
|
|
/*!
|
|
|
|
* \copy
|
|
|
|
* Copyright (c) 2004-2013, Cisco Systems
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* h264dec.cpp: Wels Decoder Console Implementation file
|
|
|
|
*/
|
|
|
|
|
2013-12-15 08:18:19 +01:00
|
|
|
#if defined (_WIN32)
|
2013-12-09 13:51:09 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#else
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2013-12-11 18:52:02 +01:00
|
|
|
#include <stdarg.h>
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
#include "codec_def.h"
|
|
|
|
#include "codec_app_def.h"
|
|
|
|
#include "codec_api.h"
|
|
|
|
#include "read_config.h"
|
2014-01-09 02:03:00 +01:00
|
|
|
#include "typedefs.h"
|
2014-01-27 11:50:16 +01:00
|
|
|
#include "measure_time.h"
|
2013-12-09 13:51:09 +01:00
|
|
|
#include "d3d9_utils.h"
|
2013-12-11 15:51:26 +01:00
|
|
|
#include "logging.h"
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
//using namespace WelsDec;
|
|
|
|
|
|
|
|
//#define STICK_STREAM_SIZE // For Demo interfaces test with track file of integrated frames
|
|
|
|
|
2014-02-08 22:26:33 +01:00
|
|
|
void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName,
|
2014-02-08 23:33:25 +01:00
|
|
|
int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName) {
|
2013-12-12 23:21:12 +01:00
|
|
|
FILE* pH264File = NULL;
|
|
|
|
FILE* pYuvFile = NULL;
|
|
|
|
FILE* pOptionFile = NULL;
|
|
|
|
int64_t iStart = 0, iEnd = 0, iTotal = 0;
|
|
|
|
int32_t iSliceSize;
|
|
|
|
int32_t iSliceIndex = 0;
|
|
|
|
uint8_t* pBuf = NULL;
|
|
|
|
uint8_t uiStartCode[4] = {0, 0, 0, 1};
|
|
|
|
|
2014-02-08 22:26:33 +01:00
|
|
|
void* pData[3] = {NULL};
|
2013-12-12 23:21:12 +01:00
|
|
|
uint8_t* pDst[3] = {NULL};
|
|
|
|
SBufferInfo sDstBufInfo;
|
|
|
|
|
|
|
|
int32_t iBufPos = 0;
|
|
|
|
int32_t iFileSize;
|
|
|
|
int32_t i = 0;
|
|
|
|
int32_t iLastWidth = 0, iLastHeight = 0;
|
|
|
|
int32_t iFrameCount = 0;
|
|
|
|
int32_t iEndOfStreamFlag = 0;
|
|
|
|
int32_t iColorFormat = videoFormatInternal;
|
|
|
|
|
|
|
|
CUtils cOutputModule;
|
|
|
|
double dElapsed = 0;
|
|
|
|
|
|
|
|
if (pDecoder == NULL) return;
|
|
|
|
if (kpH264FileName) {
|
|
|
|
pH264File = fopen (kpH264FileName, "rb");
|
|
|
|
if (pH264File == NULL) {
|
|
|
|
fprintf (stderr, "Can not open h264 source file, check its legal path related please..\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fprintf (stderr, "H264 source file name: %s..\n", kpH264FileName);
|
|
|
|
} else {
|
|
|
|
fprintf (stderr, "Can not find any h264 bitstream file to read..\n");
|
|
|
|
fprintf (stderr, "----------------decoder return------------------------\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kpOuputFileName) {
|
|
|
|
pYuvFile = fopen (kpOuputFileName, "wb");
|
|
|
|
if (pYuvFile == NULL) {
|
|
|
|
fprintf (stderr, "Can not open yuv file to output result of decoding..\n");
|
|
|
|
// any options
|
|
|
|
//return; // can let decoder work in quiet mode, no writing any output
|
|
|
|
} else
|
|
|
|
fprintf (stderr, "Sequence output file name: %s..\n", kpOuputFileName);
|
|
|
|
} else {
|
|
|
|
fprintf (stderr, "Can not find any output file to write..\n");
|
|
|
|
// any options
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pOptionFileName) {
|
2014-02-08 23:33:25 +01:00
|
|
|
pOptionFile = fopen (pOptionFileName, "wb");
|
2013-12-12 23:21:12 +01:00
|
|
|
if (pOptionFile == NULL) {
|
|
|
|
fprintf (stderr, "Can not open optional file for write..\n");
|
|
|
|
} else
|
2014-02-08 23:33:25 +01:00
|
|
|
fprintf (stderr, "Extra optional file: %s..\n", pOptionFileName);
|
2013-12-12 23:21:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
printf ("------------------------------------------------------\n");
|
|
|
|
|
|
|
|
fseek (pH264File, 0L, SEEK_END);
|
|
|
|
iFileSize = ftell (pH264File);
|
|
|
|
if (iFileSize <= 0) {
|
|
|
|
fprintf (stderr, "Current Bit Stream File is too small, read error!!!!\n");
|
|
|
|
goto label_exit;
|
|
|
|
}
|
|
|
|
fseek (pH264File, 0L, SEEK_SET);
|
|
|
|
|
|
|
|
pBuf = new uint8_t[iFileSize + 4];
|
|
|
|
if (pBuf == NULL) {
|
|
|
|
fprintf (stderr, "new buffer failed!\n");
|
|
|
|
goto label_exit;
|
|
|
|
}
|
|
|
|
|
2014-01-05 07:42:57 +01:00
|
|
|
if (fread (pBuf, 1, iFileSize, pH264File) != iFileSize) {
|
|
|
|
fprintf (stderr, "Unable to read whole file\n");
|
|
|
|
goto label_exit;
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
memcpy (pBuf + iFileSize, &uiStartCode[0], 4); //confirmed_safe_unsafe_usage
|
|
|
|
|
|
|
|
if (pDecoder->SetOption (DECODER_OPTION_DATAFORMAT, &iColorFormat)) {
|
|
|
|
fprintf (stderr, "SetOption() failed, opt_id : %d ..\n", DECODER_OPTION_DATAFORMAT);
|
|
|
|
goto label_exit;
|
|
|
|
}
|
|
|
|
|
2013-12-09 13:51:09 +01:00
|
|
|
#if defined ( STICK_STREAM_SIZE )
|
2013-12-12 23:21:12 +01:00
|
|
|
FILE* fpTrack = fopen ("3.len", "rb");
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
#endif// STICK_STREAM_SIZE
|
|
|
|
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
while (true) {
|
|
|
|
|
|
|
|
if (iBufPos >= iFileSize) {
|
|
|
|
iEndOfStreamFlag = true;
|
|
|
|
if (iEndOfStreamFlag)
|
2014-02-08 22:26:33 +01:00
|
|
|
pDecoder->SetOption (DECODER_OPTION_END_OF_STREAM, (void*)&iEndOfStreamFlag);
|
2013-12-12 23:21:12 +01:00
|
|
|
break;
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
#if defined ( STICK_STREAM_SIZE )
|
2013-12-12 23:21:12 +01:00
|
|
|
if (fpTrack)
|
|
|
|
fread (&iSliceSize, 1, sizeof (int32_t), fpTrack);
|
2013-12-09 13:51:09 +01:00
|
|
|
#else
|
2013-12-12 23:21:12 +01:00
|
|
|
for (i = 0; i < iFileSize; i++) {
|
|
|
|
if (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 &&
|
|
|
|
pBuf[iBufPos + i + 3] == 1 && i > 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iSliceSize = i;
|
2013-12-09 13:51:09 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//for coverage test purpose
|
2013-12-12 23:21:12 +01:00
|
|
|
int32_t iOutputColorFormat;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_DATAFORMAT, &iOutputColorFormat);
|
|
|
|
int32_t iEndOfStreamFlag;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
|
|
|
|
int32_t iCurIdrPicId;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_IDR_PIC_ID, &iCurIdrPicId);
|
|
|
|
int32_t iFrameNum;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_FRAME_NUM, &iFrameNum);
|
|
|
|
int32_t bCurAuContainLtrMarkSeFlag;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_LTR_MARKING_FLAG, &bCurAuContainLtrMarkSeFlag);
|
|
|
|
int32_t iFrameNumOfAuMarkedLtr;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_LTR_MARKED_FRAME_NUM, &iFrameNumOfAuMarkedLtr);
|
|
|
|
int32_t iFeedbackVclNalInAu;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_VCL_NAL, &iFeedbackVclNalInAu);
|
|
|
|
int32_t iFeedbackTidInAu;
|
|
|
|
pDecoder->GetOption (DECODER_OPTION_TEMPORAL_ID, &iFeedbackTidInAu);
|
2013-12-09 13:51:09 +01:00
|
|
|
//~end for
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
iStart = WelsTime();
|
|
|
|
pData[0] = NULL;
|
|
|
|
pData[1] = NULL;
|
|
|
|
pData[2] = NULL;
|
|
|
|
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
|
|
|
|
|
2014-01-21 19:37:03 +01:00
|
|
|
pDecoder->DecodeFrame2 (pBuf + iBufPos, iSliceSize, pData, &sDstBufInfo);
|
2013-12-12 23:21:12 +01:00
|
|
|
|
|
|
|
if (sDstBufInfo.iBufferStatus == 1) {
|
|
|
|
pDst[0] = (uint8_t*)pData[0];
|
|
|
|
pDst[1] = (uint8_t*)pData[1];
|
|
|
|
pDst[2] = (uint8_t*)pData[2];
|
|
|
|
}
|
|
|
|
iEnd = WelsTime();
|
|
|
|
iTotal += iEnd - iStart;
|
2013-12-13 21:03:38 +01:00
|
|
|
if (sDstBufInfo.iBufferStatus == 1) {
|
2014-02-08 22:26:33 +01:00
|
|
|
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
|
2014-02-09 00:43:19 +01:00
|
|
|
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
|
|
|
|
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
|
2013-12-12 23:21:12 +01:00
|
|
|
|
|
|
|
if (pOptionFile != NULL) {
|
|
|
|
if (iWidth != iLastWidth && iHeight != iLastHeight) {
|
|
|
|
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
|
|
|
|
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
|
|
|
|
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
|
|
|
|
iLastWidth = iWidth;
|
|
|
|
iLastHeight = iHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++ iFrameCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
iBufPos += iSliceSize;
|
|
|
|
++ iSliceIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get pending last frame
|
|
|
|
pData[0] = NULL;
|
|
|
|
pData[1] = NULL;
|
|
|
|
pData[2] = NULL;
|
|
|
|
memset (&sDstBufInfo, 0, sizeof (SBufferInfo));
|
|
|
|
|
2014-01-21 19:37:03 +01:00
|
|
|
pDecoder->DecodeFrame2 (NULL, 0, pData, &sDstBufInfo);
|
2013-12-12 23:21:12 +01:00
|
|
|
if (sDstBufInfo.iBufferStatus == 1) {
|
|
|
|
pDst[0] = (uint8_t*)pData[0];
|
|
|
|
pDst[1] = (uint8_t*)pData[1];
|
|
|
|
pDst[2] = (uint8_t*)pData[2];
|
|
|
|
}
|
|
|
|
|
2013-12-13 21:03:38 +01:00
|
|
|
if (sDstBufInfo.iBufferStatus == 1) {
|
2014-02-08 22:26:33 +01:00
|
|
|
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
|
2014-02-09 00:43:19 +01:00
|
|
|
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
|
|
|
|
iHeight = sDstBufInfo.UsrData.sSystemBuffer.iHeight;
|
2013-12-12 23:21:12 +01:00
|
|
|
|
|
|
|
if (pOptionFile != NULL) {
|
|
|
|
/* Anyway, we need write in case of final frame decoding */
|
|
|
|
fwrite (&iFrameCount, sizeof (iFrameCount), 1, pOptionFile);
|
|
|
|
fwrite (&iWidth , sizeof (iWidth) , 1, pOptionFile);
|
|
|
|
fwrite (&iHeight, sizeof (iHeight), 1, pOptionFile);
|
|
|
|
iLastWidth = iWidth;
|
|
|
|
iLastHeight = iHeight;
|
|
|
|
}
|
|
|
|
++ iFrameCount;
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
#if defined ( STICK_STREAM_SIZE )
|
2013-12-12 23:21:12 +01:00
|
|
|
if (fpTrack) {
|
|
|
|
fclose (fpTrack);
|
|
|
|
fpTrack = NULL;
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
#endif// STICK_STREAM_SIZE
|
2013-12-12 23:21:12 +01:00
|
|
|
|
|
|
|
dElapsed = iTotal / 1e6;
|
|
|
|
fprintf (stderr, "-------------------------------------------------------\n");
|
|
|
|
fprintf (stderr, "iWidth: %d\nheight: %d\nFrames: %d\ndecode time: %f sec\nFPS: %f fps\n",
|
|
|
|
iWidth, iHeight, iFrameCount, dElapsed, (iFrameCount * 1.0) / dElapsed);
|
|
|
|
fprintf (stderr, "-------------------------------------------------------\n");
|
|
|
|
|
|
|
|
// coverity scan uninitial
|
2013-12-09 13:51:09 +01:00
|
|
|
label_exit:
|
2013-12-12 23:21:12 +01:00
|
|
|
if (pBuf) {
|
|
|
|
delete[] pBuf;
|
|
|
|
pBuf = NULL;
|
|
|
|
}
|
|
|
|
if (pH264File) {
|
|
|
|
fclose (pH264File);
|
|
|
|
pH264File = NULL;
|
|
|
|
}
|
|
|
|
if (pYuvFile) {
|
|
|
|
fclose (pYuvFile);
|
|
|
|
pYuvFile = NULL;
|
|
|
|
}
|
|
|
|
if (pOptionFile) {
|
|
|
|
fclose (pOptionFile);
|
|
|
|
pOptionFile = NULL;
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
int32_t main (int32_t iArgC, char* pArgV[]) {
|
|
|
|
ISVCDecoder* pDecoder = NULL;
|
|
|
|
|
|
|
|
SDecodingParam sDecParam = {0};
|
|
|
|
string strInputFile (""), strOutputFile (""), strOptionFile ("");
|
|
|
|
|
|
|
|
sDecParam.sVideoProperty.size = sizeof (sDecParam.sVideoProperty);
|
|
|
|
|
|
|
|
if (iArgC < 2) {
|
|
|
|
printf ("usage 1: h264dec.exe welsdec.cfg\n");
|
|
|
|
printf ("usage 2: h264dec.exe welsdec.264 out.yuv\n");
|
|
|
|
printf ("usage 3: h264dec.exe welsdec.264\n");
|
|
|
|
return 1;
|
|
|
|
} else if (iArgC == 2) {
|
|
|
|
if (strstr (pArgV[1], ".cfg")) { // read config file //confirmed_safe_unsafe_usage
|
|
|
|
CReadConfig cReadCfg (pArgV[1]);
|
|
|
|
string strTag[4];
|
|
|
|
string strReconFile ("");
|
|
|
|
|
|
|
|
if (!cReadCfg.ExistFile()) {
|
|
|
|
printf ("Specified file: %s not exist, maybe invalid path or parameter settting.\n", cReadCfg.GetFileName().c_str());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!cReadCfg.EndOfFile()) {
|
|
|
|
long nRd = cReadCfg.ReadLine (&strTag[0]);
|
|
|
|
if (nRd > 0) {
|
|
|
|
if (strTag[0].compare ("InputFile") == 0) {
|
|
|
|
strInputFile = strTag[1];
|
|
|
|
} else if (strTag[0].compare ("OutputFile") == 0) {
|
|
|
|
strOutputFile = strTag[1];
|
|
|
|
} else if (strTag[0].compare ("RestructionFile") == 0) {
|
|
|
|
strReconFile = strTag[1];
|
|
|
|
int32_t iLen = strReconFile.length();
|
|
|
|
sDecParam.pFileNameRestructed = new char[iLen + 1];
|
|
|
|
if (sDecParam.pFileNameRestructed != NULL) {
|
|
|
|
sDecParam.pFileNameRestructed[iLen] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy (sDecParam.pFileNameRestructed, strReconFile.c_str(), iLen); //confirmed_safe_unsafe_usage
|
|
|
|
} else if (strTag[0].compare ("TargetDQID") == 0) {
|
|
|
|
sDecParam.uiTargetDqLayer = (uint8_t)atol (strTag[1].c_str());
|
|
|
|
} else if (strTag[0].compare ("OutColorFormat") == 0) {
|
|
|
|
sDecParam.iOutputColorFormat = atol (strTag[1].c_str());
|
|
|
|
} else if (strTag[0].compare ("ErrorConcealmentFlag") == 0) {
|
|
|
|
sDecParam.uiEcActiveFlag = (uint8_t)atol (strTag[1].c_str());
|
|
|
|
} else if (strTag[0].compare ("CPULoad") == 0) {
|
|
|
|
sDecParam.uiCpuLoad = (uint32_t)atol (strTag[1].c_str());
|
|
|
|
} else if (strTag[0].compare ("VideoBitstreamType") == 0) {
|
|
|
|
sDecParam.sVideoProperty.eVideoBsType = (VIDEO_BITSTREAM_TYPE)atol (strTag[1].c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strOutputFile.empty()) {
|
|
|
|
printf ("No output file specified in configuration file.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} else if (strstr (pArgV[1],
|
|
|
|
".264")) { // no output dump yuv file, just try to render the decoded pictures //confirmed_safe_unsafe_usage
|
|
|
|
strInputFile = pArgV[1];
|
|
|
|
sDecParam.iOutputColorFormat = videoFormatI420;
|
|
|
|
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
|
|
|
sDecParam.uiEcActiveFlag = 1;
|
|
|
|
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
|
|
|
}
|
|
|
|
} else { //iArgC > 2
|
|
|
|
strInputFile = pArgV[1];
|
|
|
|
strOutputFile = pArgV[2];
|
|
|
|
sDecParam.iOutputColorFormat = videoFormatI420;
|
|
|
|
sDecParam.uiTargetDqLayer = (uint8_t) - 1;
|
|
|
|
sDecParam.uiEcActiveFlag = 1;
|
|
|
|
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
|
|
|
|
if (iArgC > 3) {
|
|
|
|
for (int i = 3; i < iArgC; i++) {
|
|
|
|
char* cmd = pArgV[i];
|
|
|
|
|
|
|
|
if (!strcmp (cmd, "-options")) {
|
2013-12-18 13:56:10 +01:00
|
|
|
if (i + 1 < iArgC)
|
|
|
|
strOptionFile = pArgV[i++];
|
|
|
|
else {
|
|
|
|
printf ("options file not specified.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2013-12-12 23:21:12 +01:00
|
|
|
} else if (!strcmp (cmd, "-trace")) {
|
2013-12-18 13:56:10 +01:00
|
|
|
if (i + 1 < iArgC)
|
|
|
|
WelsStderrSetTraceLevel (atoi (pArgV[i++]));
|
|
|
|
else {
|
|
|
|
printf ("trace level not specified.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2013-12-12 23:21:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strOutputFile.empty()) {
|
|
|
|
printf ("No output file specified in configuration file.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strInputFile.empty()) {
|
|
|
|
printf ("No input file specified in configuration file.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-12-09 13:51:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
if (CreateDecoder (&pDecoder) || (NULL == pDecoder)) {
|
|
|
|
printf ("Create Decoder failed.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:32:57 +01:00
|
|
|
if (pDecoder->Initialize (&sDecParam)) {
|
2013-12-12 23:21:12 +01:00
|
|
|
printf ("Decoder initialization failed.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t iWidth = 0;
|
|
|
|
int32_t iHeight = 0;
|
|
|
|
|
|
|
|
|
2014-02-08 23:35:18 +01:00
|
|
|
H264DecodeInstance (pDecoder, strInputFile.c_str(), !strOutputFile.empty() ? strOutputFile.c_str() : NULL, iWidth, iHeight,
|
2014-02-08 23:33:25 +01:00
|
|
|
(!strOptionFile.empty() ? strOptionFile.c_str() : NULL));
|
2013-12-12 23:21:12 +01:00
|
|
|
|
|
|
|
if (sDecParam.pFileNameRestructed != NULL) {
|
|
|
|
delete []sDecParam.pFileNameRestructed;
|
|
|
|
sDecParam.pFileNameRestructed = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDecoder) {
|
|
|
|
pDecoder->Uninitialize();
|
|
|
|
|
|
|
|
DestroyDecoder (pDecoder);
|
|
|
|
}
|
2013-12-09 13:51:09 +01:00
|
|
|
|
2013-12-12 23:21:12 +01:00
|
|
|
return 0;
|
2013-12-09 13:51:09 +01:00
|
|
|
}
|