Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: media/tools/omx_test/file_sink.cc

Issue 1786001: remove omx_sink and buffer merge (Closed)
Patch Set: one more missing Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/tools/omx_test/file_sink.h ('k') | media/tools/omx_test/omx_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "media/tools/omx_test/file_sink.h" 5 #include "media/tools/omx_test/file_sink.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/tools/omx_test/color_space_util.h" 9 #include "media/tools/omx_test/color_space_util.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 bool FileSink::AllocateEGLImages(int width, int height,
14 std::vector<EGLImageKHR>* images) {
15 NOTREACHED() << "This method is never used";
16 return false;
17 }
18 13
19 void FileSink::ReleaseEGLImages(const std::vector<EGLImageKHR>& images) { 14 void FileSink::BufferReady(int size, uint8* buffer) {
20 NOTREACHED() << "This method is never used";
21 }
22
23 void FileSink::UseThisBuffer(int buffer_id, OMX_BUFFERHEADERTYPE* buffer) {
24 CHECK(omx_buffers_.find(buffer_id) == omx_buffers_.end());
25 omx_buffers_[buffer_id] = buffer;
26 }
27
28 void FileSink::StopUsingThisBuffer(int id) {
29 omx_buffers_.erase(id);
30 }
31
32 void FileSink::BufferReady(int buffer_id, BufferUsedCallback* callback) {
33 CHECK(omx_buffers_.find(buffer_id) != omx_buffers_.end());
34 CHECK(callback);
35
36 OMX_BUFFERHEADERTYPE* omx_buffer = omx_buffers_[buffer_id];
37 uint8* buffer = omx_buffer->pBuffer;
38 int size = omx_buffer->nFilledLen;
39
40 // We never receive an end-of-stream buffer here.
41 CHECK(!(omx_buffer->nFlags & OMX_BUFFERFLAG_EOS));
42
43 if (size > copy_buf_size_) { 15 if (size > copy_buf_size_) {
44 copy_buf_.reset(new uint8[size]); 16 copy_buf_.reset(new uint8[size]);
45 copy_buf_size_ = size; 17 copy_buf_size_ = size;
46 } 18 }
47 if (size > csc_buf_size_) { 19 if (size > csc_buf_size_) {
48 csc_buf_.reset(new uint8[size]); 20 csc_buf_.reset(new uint8[size]);
49 csc_buf_size_ = size; 21 csc_buf_size_ = size;
50 } 22 }
51 23
52 // Copy the output of the decoder to user memory. 24 // Copy the output of the decoder to user memory.
53 if (simulate_copy_ || output_file_.get()) // Implies a copy. 25 if (simulate_copy_ || output_file_.get()) // Implies a copy.
54 memcpy(copy_buf_.get(), buffer, size); 26 memcpy(copy_buf_.get(), buffer, size);
55 27
56 uint8* out_buffer = copy_buf_.get(); 28 uint8* out_buffer = copy_buf_.get();
57 if (enable_csc_) { 29 if (enable_csc_) {
58 // Now assume the raw output is NV21. 30 // Now assume the raw output is NV21.
59 media::NV21toIYUV(copy_buf_.get(), csc_buf_.get(), width_, height_); 31 media::NV21toIYUV(copy_buf_.get(), csc_buf_.get(), width_, height_);
60 out_buffer = csc_buf_.get(); 32 out_buffer = csc_buf_.get();
61 } 33 }
62 34
63 if (output_file_.get()) 35 if (output_file_.get())
64 fwrite(out_buffer, sizeof(uint8), size, output_file_.get()); 36 fwrite(out_buffer, sizeof(uint8), size, output_file_.get());
65
66 // Always make the callback.
67 callback->Run(buffer_id);
68 delete callback;
69 } 37 }
70 38
71 bool FileSink::Initialize() { 39 bool FileSink::Initialize() {
72 // Opens the output file for writing. 40 // Opens the output file for writing.
73 if (!output_filename_.empty()) { 41 if (!output_filename_.empty()) {
74 output_file_.Set(file_util::OpenFile(output_filename_, "wb")); 42 output_file_.Set(file_util::OpenFile(output_filename_, "wb"));
75 if (!output_file_.get()) { 43 if (!output_file_.get()) {
76 LOG(ERROR) << "can't open dump file %s" << output_filename_; 44 LOG(ERROR) << "can't open dump file %s" << output_filename_;
77 return false; 45 return false;
78 } 46 }
79 } 47 }
80 return true; 48 return true;
81 } 49 }
82 50
83 void FileSink::UpdateSize(int width, int height) { 51 void FileSink::UpdateSize(int width, int height) {
84 width_ = width; 52 width_ = width;
85 height_ = height; 53 height_ = height;
86 } 54 }
87 55
88 } // namespace media 56 } // namespace media
OLDNEW
« no previous file with comments | « media/tools/omx_test/file_sink.h ('k') | media/tools/omx_test/omx_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698