blob: 0b968968c91b8ce9838865f24664a278a37b2aa6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
#include "media/tools/omx_test/file_writer_util.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "media/tools/omx_test/color_space_util.h"
namespace media {
bool FileWriter::Initialize() {
// Opens the output file for writing.
if (!output_filename_.empty()) {
output_file_.Set(file_util::OpenFile(output_filename_, "wb"));
if (!output_file_.get()) {
LOG(ERROR) << "can't open dump file %s" << output_filename_;
return false;
}
}
return true;
}
void FileWriter::UpdateSize(int width, int height) {
width_ = width;
height_ = height;
}
void FileWriter::Write(uint8* buffer, int size) {
if (size > copy_buf_size_) {
copy_buf_.reset(new uint8[size]);
copy_buf_size_ = size;
}
if (size > csc_buf_size_) {
csc_buf_.reset(new uint8[size]);
csc_buf_size_ = size;
}
// Copy the output of the decoder to user memory.
if (simulate_copy_ || output_file_.get()) // Implies a copy.
memcpy(copy_buf_.get(), buffer, size);
uint8* out_buffer = copy_buf_.get();
if (enable_csc_) {
// Now assume the raw output is NV21.
media::NV21toIYUV(copy_buf_.get(), csc_buf_.get(), width_, height_);
out_buffer = csc_buf_.get();
}
if (output_file_.get())
fwrite(out_buffer, sizeof(uint8), size, output_file_.get());
}
} // namespace media
|