0
|
1 /*****************************************************************************
|
|
2 * Copyright (C) 2013-2015 x265 project
|
|
3 *
|
|
4 * Authors: Steve Borho <steve@borho.org>
|
|
5 * Xinyue Lu <i@7086.in>
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
|
|
20 *
|
|
21 * This program is also available under a commercial proprietary license.
|
|
22 * For more information, contact us at license @ x265.com.
|
|
23 *****************************************************************************/
|
|
24
|
|
25 #include "raw.h"
|
|
26
|
|
27 using namespace X265_NS;
|
|
28 using namespace std;
|
|
29
|
|
30 RAWOutput::RAWOutput(const char* fname, InputFileInfo&)
|
|
31 {
|
|
32 b_fail = false;
|
|
33 if (!strcmp(fname, "-"))
|
|
34 {
|
|
35 ofs = &cout;
|
|
36 return;
|
|
37 }
|
|
38 ofs = new ofstream(fname, ios::binary | ios::out);
|
|
39 if (ofs->fail())
|
|
40 b_fail = true;
|
|
41 }
|
|
42
|
|
43 void RAWOutput::setParam(x265_param* param)
|
|
44 {
|
|
45 param->bAnnexB = true;
|
|
46 }
|
|
47
|
|
48 int RAWOutput::writeHeaders(const x265_nal* nal, uint32_t nalcount)
|
|
49 {
|
|
50 uint32_t bytes = 0;
|
|
51
|
|
52 for (uint32_t i = 0; i < nalcount; i++)
|
|
53 {
|
|
54 ofs->write((const char*)nal->payload, nal->sizeBytes);
|
|
55 bytes += nal->sizeBytes;
|
|
56 nal++;
|
|
57 }
|
|
58
|
|
59 return bytes;
|
|
60 }
|
|
61
|
|
62 int RAWOutput::writeFrame(const x265_nal* nal, uint32_t nalcount, x265_picture&)
|
|
63 {
|
|
64 uint32_t bytes = 0;
|
|
65
|
|
66 for (uint32_t i = 0; i < nalcount; i++)
|
|
67 {
|
|
68 ofs->write((const char*)nal->payload, nal->sizeBytes);
|
|
69 bytes += nal->sizeBytes;
|
|
70 nal++;
|
|
71 }
|
|
72
|
|
73 return bytes;
|
|
74 }
|
|
75
|
|
76 void RAWOutput::closeFile(int64_t, int64_t)
|
|
77 {
|
|
78 if (ofs != &cout)
|
|
79 delete ofs;
|
|
80 }
|