libbpg-0.9.6

This commit is contained in:
King_DuckZ 2015-10-27 11:46:00 +01:00
parent 3035b41edf
commit 35a8402710
248 changed files with 232891 additions and 100 deletions

View file

@ -0,0 +1,46 @@
/*****************************************************************************
* Copyright (C) 2013-2015 x265 project
*
* Authors: Steve Borho <steve@borho.org>
* Xinyue Lu <i@7086.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#include "output.h"
#include "yuv.h"
#include "y4m.h"
#include "raw.h"
using namespace X265_NS;
ReconFile* ReconFile::open(const char *fname, int width, int height, uint32_t bitdepth, uint32_t fpsNum, uint32_t fpsDenom, int csp)
{
const char * s = strrchr(fname, '.');
if (s && !strcmp(s, ".y4m"))
return new Y4MOutput(fname, width, height, fpsNum, fpsDenom, csp);
else
return new YUVOutput(fname, width, height, bitdepth, csp);
}
OutputFile* OutputFile::open(const char *fname, InputFileInfo& inputInfo)
{
return new RAWOutput(fname, inputInfo);
}

View file

@ -0,0 +1,86 @@
/*****************************************************************************
* Copyright (C) 2013-2015 x265 project
*
* Authors: Steve Borho <steve@borho.org>
* Xinyue Lu <i@7086.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_OUTPUT_H
#define X265_OUTPUT_H
#include "x265.h"
#include "input/input.h"
namespace X265_NS {
// private x265 namespace
class ReconFile
{
protected:
virtual ~ReconFile() {}
public:
ReconFile() {}
static ReconFile* open(const char *fname, int width, int height, uint32_t bitdepth,
uint32_t fpsNum, uint32_t fpsDenom, int csp);
virtual bool isFail() const = 0;
virtual void release() = 0;
virtual bool writePicture(const x265_picture& pic) = 0;
virtual const char *getName() const = 0;
};
class OutputFile
{
protected:
virtual ~OutputFile() {}
public:
OutputFile() {}
static OutputFile* open(const char* fname, InputFileInfo& inputInfo);
virtual bool isFail() const = 0;
virtual bool needPTS() const = 0;
virtual void release() = 0;
virtual const char* getName() const = 0;
virtual void setParam(x265_param* param) = 0;
virtual int writeHeaders(const x265_nal* nal, uint32_t nalcount) = 0;
virtual int writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture& pic) = 0;
virtual void closeFile(int64_t largest_pts, int64_t second_largest_pts) = 0;
};
}
#endif // ifndef X265_OUTPUT_H

View file

@ -0,0 +1,80 @@
/*****************************************************************************
* Copyright (C) 2013-2015 x265 project
*
* Authors: Steve Borho <steve@borho.org>
* Xinyue Lu <i@7086.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#include "raw.h"
using namespace X265_NS;
using namespace std;
RAWOutput::RAWOutput(const char* fname, InputFileInfo&)
{
b_fail = false;
if (!strcmp(fname, "-"))
{
ofs = &cout;
return;
}
ofs = new ofstream(fname, ios::binary | ios::out);
if (ofs->fail())
b_fail = true;
}
void RAWOutput::setParam(x265_param* param)
{
param->bAnnexB = true;
}
int RAWOutput::writeHeaders(const x265_nal* nal, uint32_t nalcount)
{
uint32_t bytes = 0;
for (uint32_t i = 0; i < nalcount; i++)
{
ofs->write((const char*)nal->payload, nal->sizeBytes);
bytes += nal->sizeBytes;
nal++;
}
return bytes;
}
int RAWOutput::writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture&)
{
uint32_t bytes = 0;
for (uint32_t i = 0; i < nalcount; i++)
{
ofs->write((const char*)nal->payload, nal->sizeBytes);
bytes += nal->sizeBytes;
nal++;
}
return bytes;
}
void RAWOutput::closeFile(int64_t, int64_t)
{
if (ofs != &cout)
delete ofs;
}

64
x265/source/output/raw.h Normal file
View file

@ -0,0 +1,64 @@
/*****************************************************************************
* Copyright (C) 2013-2015 x265 project
*
* Authors: Steve Borho <steve@borho.org>
* Xinyue Lu <i@7086.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_HEVC_RAW_H
#define X265_HEVC_RAW_H
#include "output.h"
#include "common.h"
#include <fstream>
#include <iostream>
namespace X265_NS {
class RAWOutput : public OutputFile
{
protected:
std::ostream* ofs;
bool b_fail;
public:
RAWOutput(const char* fname, InputFileInfo&);
bool isFail() const { return b_fail; }
bool needPTS() const { return false; }
void release() { delete this; }
const char* getName() const { return "raw"; }
void setParam(x265_param* param);
int writeHeaders(const x265_nal* nal, uint32_t nalcount);
int writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture&);
void closeFile(int64_t largest_pts, int64_t second_largest_pts);
};
}
#endif // ifndef X265_HEVC_RAW_H

View file

@ -0,0 +1,197 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Peixuan Zhang <zhangpeixuancn@gmail.com>
* Chunli Zhang <chunli@multicorewareinc.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#include "common.h"
#include "reconplay.h"
#include <signal.h>
using namespace X265_NS;
#if _WIN32
#define popen _popen
#define pclose _pclose
#define pipemode "wb"
#else
#define pipemode "w"
#endif
bool ReconPlay::pipeValid;
#ifndef _WIN32
static void sigpipe_handler(int)
{
if (ReconPlay::pipeValid)
general_log(NULL, "exec", X265_LOG_ERROR, "pipe closed\n");
ReconPlay::pipeValid = false;
}
#endif
ReconPlay::ReconPlay(const char* commandLine, x265_param& param)
{
#ifndef _WIN32
if (signal(SIGPIPE, sigpipe_handler) == SIG_ERR)
general_log(&param, "exec", X265_LOG_ERROR, "Unable to register SIGPIPE handler: %s\n", strerror(errno));
#endif
width = param.sourceWidth;
height = param.sourceHeight;
colorSpace = param.internalCsp;
frameSize = 0;
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
frameSize += (uint32_t)((width >> x265_cli_csps[colorSpace].width[i]) * (height >> x265_cli_csps[colorSpace].height[i]));
for (int i = 0; i < RECON_BUF_SIZE; i++)
{
poc[i] = -1;
CHECKED_MALLOC(frameData[i], pixel, frameSize);
}
outputPipe = popen(commandLine, pipemode);
if (outputPipe)
{
const char* csp = (colorSpace >= X265_CSP_I444) ? "444" : (colorSpace >= X265_CSP_I422) ? "422" : "420";
const char* depth = (param.internalBitDepth == 10) ? "p10" : "";
fprintf(outputPipe, "YUV4MPEG2 W%d H%d F%d:%d Ip C%s%s\n", width, height, param.fpsNum, param.fpsDenom, csp, depth);
pipeValid = true;
threadActive = true;
start();
return;
}
else
general_log(&param, "exec", X265_LOG_ERROR, "popen(%s) failed\n", commandLine);
fail:
threadActive = false;
}
ReconPlay::~ReconPlay()
{
if (threadActive)
{
threadActive = false;
writeCount.poke();
stop();
}
if (outputPipe)
pclose(outputPipe);
for (int i = 0; i < RECON_BUF_SIZE; i++)
X265_FREE(frameData[i]);
}
bool ReconPlay::writePicture(const x265_picture& pic)
{
if (!threadActive || !pipeValid)
return false;
int written = writeCount.get();
int read = readCount.get();
int currentCursor = pic.poc % RECON_BUF_SIZE;
/* TODO: it's probably better to drop recon pictures when the ring buffer is
* backed up on the display app */
while (written - read > RECON_BUF_SIZE - 2 || poc[currentCursor] != -1)
{
read = readCount.waitForChange(read);
if (!threadActive)
return false;
}
X265_CHECK(pic.colorSpace == colorSpace, "invalid color space\n");
X265_CHECK(pic.bitDepth == X265_DEPTH, "invalid bit depth\n");
pixel* buf = frameData[currentCursor];
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
char* src = (char*)pic.planes[i];
int pwidth = width >> x265_cli_csps[colorSpace].width[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
memcpy(buf, src, pwidth * sizeof(pixel));
src += pic.stride[i];
buf += pwidth;
}
}
poc[currentCursor] = pic.poc;
writeCount.incr();
return true;
}
void ReconPlay::threadMain()
{
THREAD_NAME("ReconPlayOutput", 0);
do
{
/* extract the next output picture in display order and write to pipe */
if (!outputFrame())
break;
}
while (threadActive);
threadActive = false;
readCount.poke();
}
bool ReconPlay::outputFrame()
{
int written = writeCount.get();
int read = readCount.get();
int currentCursor = read % RECON_BUF_SIZE;
while (poc[currentCursor] != read)
{
written = writeCount.waitForChange(written);
if (!threadActive)
return false;
}
char* buf = (char*)frameData[currentCursor];
intptr_t remainSize = frameSize * sizeof(pixel);
fprintf(outputPipe, "FRAME\n");
while (remainSize > 0)
{
intptr_t retCount = (intptr_t)fwrite(buf, sizeof(char), remainSize, outputPipe);
if (retCount < 0 || !pipeValid)
/* pipe failure, stop writing and start dropping recon pictures */
return false;
buf += retCount;
remainSize -= retCount;
}
poc[currentCursor] = -1;
readCount.incr();
return true;
}

View file

@ -0,0 +1,74 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Peixuan Zhang <zhangpeixuancn@gmail.com>
* Chunli Zhang <chunli@multicorewareinc.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_RECONPLAY_H
#define X265_RECONPLAY_H
#include "x265.h"
#include "threading.h"
#include <cstdio>
namespace X265_NS {
// private x265 namespace
class ReconPlay : public Thread
{
public:
ReconPlay(const char* commandLine, x265_param& param);
virtual ~ReconPlay();
bool writePicture(const x265_picture& pic);
static bool pipeValid;
protected:
enum { RECON_BUF_SIZE = 40 };
FILE* outputPipe; /* The output pipe for player */
size_t frameSize; /* size of one frame in pixels */
bool threadActive; /* worker thread is active */
int width; /* width of frame */
int height; /* height of frame */
int colorSpace; /* color space of frame */
int poc[RECON_BUF_SIZE];
pixel* frameData[RECON_BUF_SIZE];
/* Note that the class uses read and write counters to signal that reads and
* writes have occurred in the ring buffer, but writes into the buffer
* happen in decode order and the reader must check that the POC it next
* needs to send to the pipe is in fact present. The counters are used to
* prevent the writer from getting too far ahead of the reader */
ThreadSafeInteger readCount;
ThreadSafeInteger writeCount;
void threadMain();
bool outputFrame();
};
}
#endif // ifndef X265_RECONPLAY_H

109
x265/source/output/y4m.cpp Normal file
View file

@ -0,0 +1,109 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#include "common.h"
#include "output.h"
#include "y4m.h"
using namespace X265_NS;
using namespace std;
Y4MOutput::Y4MOutput(const char *filename, int w, int h, uint32_t fpsNum, uint32_t fpsDenom, int csp)
: width(w)
, height(h)
, colorSpace(csp)
, frameSize(0)
{
ofs.open(filename, ios::binary | ios::out);
buf = new char[width];
const char *cf = (csp >= X265_CSP_I444) ? "444" : (csp >= X265_CSP_I422) ? "422" : "420";
if (ofs)
{
ofs << "YUV4MPEG2 W" << width << " H" << height << " F" << fpsNum << ":" << fpsDenom << " Ip" << " C" << cf << "\n";
header = ofs.tellp();
}
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
frameSize += (uint32_t)((width >> x265_cli_csps[colorSpace].width[i]) * (height >> x265_cli_csps[colorSpace].height[i]));
}
Y4MOutput::~Y4MOutput()
{
ofs.close();
delete [] buf;
}
bool Y4MOutput::writePicture(const x265_picture& pic)
{
std::ofstream::pos_type outPicPos = header;
outPicPos += (uint64_t)pic.poc * (6 + frameSize);
ofs.seekp(outPicPos);
ofs << "FRAME\n";
#if HIGH_BIT_DEPTH
if (pic.bitDepth > 8 && pic.poc == 0)
x265_log(NULL, X265_LOG_WARNING, "y4m: down-shifting reconstructed pixels to 8 bits\n");
#else
if (pic.bitDepth > 8 && pic.poc == 0)
x265_log(NULL, X265_LOG_WARNING, "y4m: forcing reconstructed pixels to 8 bits\n");
#endif
X265_CHECK(pic.colorSpace == colorSpace, "invalid color space\n");
#if HIGH_BIT_DEPTH
// encoder gave us short pixels, downshift, then write
X265_CHECK(pic.bitDepth > 8, "invalid bit depth\n");
int shift = pic.bitDepth - 8;
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
uint16_t *src = (uint16_t*)pic.planes[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
for (int w = 0; w < width >> x265_cli_csps[colorSpace].width[i]; w++)
buf[w] = (char)(src[w] >> shift);
ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]);
src += pic.stride[i] / sizeof(*src);
}
}
#else // if HIGH_BIT_DEPTH
X265_CHECK(pic.bitDepth == 8, "invalid bit depth\n");
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
char *src = (char*)pic.planes[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]);
src += pic.stride[i] / sizeof(*src);
}
}
#endif // if HIGH_BIT_DEPTH
return true;
}

69
x265/source/output/y4m.h Normal file
View file

@ -0,0 +1,69 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_Y4M_H
#define X265_Y4M_H
#include "output.h"
#include <fstream>
namespace X265_NS {
// private x265 namespace
class Y4MOutput : public ReconFile
{
protected:
int width;
int height;
int colorSpace;
uint32_t frameSize;
std::ofstream ofs;
std::ofstream::pos_type header;
char *buf;
void writeHeader();
public:
Y4MOutput(const char *filename, int width, int height, uint32_t fpsNum, uint32_t fpsDenom, int csp);
virtual ~Y4MOutput();
const char *getName() const { return "y4m"; }
bool isFail() const { return ofs.fail(); }
void release() { delete this; }
bool writePicture(const x265_picture& pic);
};
}
#endif // ifndef X265_Y4M_H

105
x265/source/output/yuv.cpp Normal file
View file

@ -0,0 +1,105 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#include "common.h"
#include "output.h"
#include "yuv.h"
using namespace X265_NS;
using namespace std;
YUVOutput::YUVOutput(const char *filename, int w, int h, uint32_t d, int csp)
: width(w)
, height(h)
, depth(d)
, colorSpace(csp)
, frameSize(0)
{
ofs.open(filename, ios::binary | ios::out);
buf = new char[width];
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
frameSize += (uint32_t)((width >> x265_cli_csps[colorSpace].width[i]) * (height >> x265_cli_csps[colorSpace].height[i]));
}
YUVOutput::~YUVOutput()
{
ofs.close();
delete [] buf;
}
bool YUVOutput::writePicture(const x265_picture& pic)
{
uint64_t fileOffset = pic.poc;
fileOffset *= frameSize;
X265_CHECK(pic.colorSpace == colorSpace, "invalid color space\n");
X265_CHECK(pic.bitDepth == (int)depth, "invalid bit depth\n");
#if HIGH_BIT_DEPTH
if (depth == 8)
{
int shift = pic.bitDepth - 8;
ofs.seekp((std::streamoff)fileOffset);
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
uint16_t *src = (uint16_t*)pic.planes[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
for (int w = 0; w < width >> x265_cli_csps[colorSpace].width[i]; w++)
buf[w] = (char)(src[w] >> shift);
ofs.write(buf, width >> x265_cli_csps[colorSpace].width[i]);
src += pic.stride[i] / sizeof(*src);
}
}
}
else
{
ofs.seekp((std::streamoff)(fileOffset * 2));
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
uint16_t *src = (uint16_t*)pic.planes[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
ofs.write((const char*)src, (width * 2) >> x265_cli_csps[colorSpace].width[i]);
src += pic.stride[i] / sizeof(*src);
}
}
}
#else // if HIGH_BIT_DEPTH
ofs.seekp((std::streamoff)fileOffset);
for (int i = 0; i < x265_cli_csps[colorSpace].planes; i++)
{
char *src = (char*)pic.planes[i];
for (int h = 0; h < height >> x265_cli_csps[colorSpace].height[i]; h++)
{
ofs.write(src, width >> x265_cli_csps[colorSpace].width[i]);
src += pic.stride[i] / sizeof(*src);
}
}
#endif // if HIGH_BIT_DEPTH
return true;
}

69
x265/source/output/yuv.h Normal file
View file

@ -0,0 +1,69 @@
/*****************************************************************************
* Copyright (C) 2013 x265 project
*
* Authors: Steve Borho <steve@borho.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at license @ x265.com.
*****************************************************************************/
#ifndef X265_YUV_H
#define X265_YUV_H
#include "output.h"
#include "common.h"
#include <fstream>
namespace X265_NS {
// private x265 namespace
class YUVOutput : public ReconFile
{
protected:
int width;
int height;
uint32_t depth;
int colorSpace;
uint32_t frameSize;
char *buf;
std::ofstream ofs;
public:
YUVOutput(const char *filename, int width, int height, uint32_t bitdepth, int csp);
virtual ~YUVOutput();
const char *getName() const { return "yuv"; }
bool isFail() const { return ofs.fail(); }
void release() { delete this; }
bool writePicture(const x265_picture& pic);
};
}
#endif // ifndef X265_YUV_H