forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base class of using a OMX component for video decoding. This class defines the specific behavior of using an OMX component for video decoding. It tries not to be hardware specific as much as possible. Review URL: http://codereview.chromium.org/372037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31770 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
hclam@chromium.org
committed
Nov 12, 2009
1 parent
2c55605
commit a5555a4
Showing
4 changed files
with
1,493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2009 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 <algorithm> | ||
|
||
#include "base/logging.h" | ||
#include "media/omx/input_buffer.h" | ||
|
||
namespace media { | ||
|
||
InputBuffer::InputBuffer() | ||
: data_(NULL), | ||
size_(0), | ||
used_(0) { | ||
} | ||
|
||
InputBuffer::InputBuffer(uint8* data, int size) | ||
: data_(data), | ||
size_(size), | ||
used_(0) { | ||
DCHECK_GE(size, 0); | ||
} | ||
|
||
InputBuffer::~InputBuffer() { | ||
delete [] data_; | ||
} | ||
|
||
int InputBuffer::Read(uint8* output_data, int output_size) { | ||
int copy = std::min(output_size, size_ - used_); | ||
memcpy(output_data, data_ + used_, copy); | ||
used_ += copy; | ||
return copy; | ||
} | ||
|
||
bool InputBuffer::Used() { | ||
return used_ == size_; | ||
} | ||
|
||
bool InputBuffer::Eos() { | ||
return data_ == NULL || size_ == 0; | ||
} | ||
|
||
} // namespace media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2009 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. | ||
|
||
// Defines the input buffer object for the video decoder. This provides | ||
// the interface needed by the video decoder to read input data. | ||
// | ||
// This object is implemened using system memory. | ||
|
||
#include "base/basictypes.h" | ||
|
||
namespace media { | ||
|
||
class InputBuffer { | ||
public: | ||
// Creates an empty input buffer. | ||
InputBuffer(); | ||
|
||
// Creates an input buffer given |data| and |size|. | ||
// After construction, this object will be given the ownership of | ||
// |data| and is responsible for deleting it. | ||
InputBuffer(uint8* data, int size); | ||
virtual ~InputBuffer(); | ||
|
||
// Read from the this buffer into |data| with the maximum |size| bytes. | ||
// Returns number of bytes read. If a read is successful, the number | ||
// of used bytes will advances accordingly. | ||
// Returns a negative number on error. | ||
virtual int Read(uint8* data, int size); | ||
|
||
// Returns true if this buffer is used. | ||
virtual bool Used(); | ||
|
||
// Returns true if this is an end-of-stream buffer. | ||
virtual bool Eos(); | ||
|
||
private: | ||
uint8* data_; | ||
int size_; | ||
int used_; | ||
}; | ||
|
||
} // namespace media |
Oops, something went wrong.