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

Unified Diff: media/filters/vp9_parser.h

Issue 2229353002: V4L2SVDA: Add a VP9Accelerator implementation utilizing the V4L2 VP9 frame API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/vp9_parser.cc » ('j') | media/filters/vp9_parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vp9_parser.h
diff --git a/media/filters/vp9_parser.h b/media/filters/vp9_parser.h
index acb88d7e76a443cfc12ac6ff20238ecc1699fd53..a6186ce149c4530b13c95732710e86d66e538b17 100644
--- a/media/filters/vp9_parser.h
+++ b/media/filters/vp9_parser.h
@@ -17,6 +17,7 @@
#include <sys/types.h>
#include <deque>
+#include <memory>
#include "base/callback.h"
#include "base/macros.h"
@@ -30,7 +31,8 @@ const int kVp9NumRefFramesLog2 = 3;
const size_t kVp9NumRefFrames = 1 << kVp9NumRefFramesLog2;
const uint8_t kVp9MaxProb = 255;
const size_t kVp9NumRefsPerFrame = 3;
-const size_t kVp9NumFrameContexts = 4;
+const size_t kVp9NumFrameContextsLog2 = 2;
+const size_t kVp9NumFrameContexts = 1 << kVp9NumFrameContextsLog2;
using Vp9Prob = uint8_t;
@@ -136,6 +138,8 @@ struct MEDIA_EXPORT Vp9QuantizationParams {
// Entropy context for frame parsing
struct MEDIA_EXPORT Vp9FrameContext {
+ static bool IsValid(const Vp9FrameContext& context);
kcwu 2016/08/10 09:59:18 How about make it non-static member function? Acc
Pawel Osciak 2016/08/13 01:51:30 Done.
+
Vp9Prob tx_probs_8x8[2][1];
Vp9Prob tx_probs_16x16[2][2];
Vp9Prob tx_probs_32x32[2][3];
@@ -255,44 +259,13 @@ struct MEDIA_EXPORT Vp9FrameHeader {
Vp9FrameContext frame_context;
};
-class Vp9FrameContextManager {
+// A parser for VP9 bitstream.
+class MEDIA_EXPORT Vp9Parser {
public:
// If context update is needed after decoding a frame, the client must
// execute this callback, passing the updated context state.
using ContextRefreshCallback = base::Callback<void(const Vp9FrameContext&)>;
- static bool IsValidFrameContext(const Vp9FrameContext& context);
-
- Vp9FrameContextManager();
- ~Vp9FrameContextManager();
- bool initialized() const { return initialized_; }
- bool needs_client_update() const { return needs_client_update_; }
- const Vp9FrameContext& frame_context() const;
-
- // Resets to uninitialized state.
- void Reset();
-
- // Sets this context need update from parser's client. Returns a callback for
- // update.
- ContextRefreshCallback SetNeedsClientUpdate();
-
- // Updates frame context.
- void Update(const Vp9FrameContext& frame_context);
-
- private:
- // Updates frame context from parser's client.
- void UpdateFromClient(const Vp9FrameContext& frame_context);
-
- bool initialized_ = false;
- bool needs_client_update_ = false;
- Vp9FrameContext frame_context_;
-
- base::WeakPtrFactory<Vp9FrameContextManager> weak_ptr_factory_;
-};
-
-// A parser for VP9 bitstream.
-class MEDIA_EXPORT Vp9Parser {
- public:
// ParseNextFrame() return values. See documentation for ParseNextFrame().
enum Result {
kOk,
@@ -316,9 +289,49 @@ class MEDIA_EXPORT Vp9Parser {
};
// The parsing context that persists across frames.
- struct Context {
+ class Context {
kcwu 2016/08/10 09:59:18 If it's class, member variable need to be named fo
Pawel Osciak 2016/08/13 01:51:30 Done.
+ public:
+ class Vp9FrameContextManager {
+ public:
+ Vp9FrameContextManager();
+ ~Vp9FrameContextManager();
+ bool initialized() const { return initialized_; }
+ bool needs_client_update() const { return needs_client_update_; }
+ const Vp9FrameContext& frame_context() const;
+
+ // Resets to uninitialized state.
+ void Reset();
+
+ // Marks this context as requiring an update from parser's client.
+ void SetNeedsClientUpdate();
+
+ // Updates frame context.
+ void Update(const Vp9FrameContext& frame_context);
+
+ // Return a callback to update frame context at a later time with.
+ ContextRefreshCallback GetUpdateCb();
+
+ private:
+ // Updates frame context from parser's client.
+ void UpdateFromClient(const Vp9FrameContext& frame_context);
+
+ bool initialized_ = false;
+ bool needs_client_update_ = false;
+ Vp9FrameContext frame_context_;
+
+ base::WeakPtrFactory<Vp9FrameContextManager> weak_ptr_factory_;
+ };
+
void Reset();
+ // Mark |frame_context_idx| as requiring update from the client.
+ void MarkFrameContextForUpdate(size_t frame_context_idx);
+
+ // Update frame context at |frame_context_idx| with the contents of
+ // |frame_context|.
+ void UpdateFrameContext(size_t frame_context_idx,
+ const Vp9FrameContext& frame_context);
+
// Segmentation and loop filter state.
Vp9SegmentationParams segmentation;
Vp9LoopFilterParams loop_filter;
@@ -342,16 +355,12 @@ class MEDIA_EXPORT Vp9Parser {
// Parse the next frame in the current stream buffer, filling |fhdr| with
// the parsed frame header and updating current segmentation and loop filter
- // state. If |parsing_compressed_header_|, this function also fills
- // |context_refresh_cb|, which is used to update frame context. If
- // |*context_refresh_cb| is null, no callback is necessary.
+ // state.
// Return kOk if a frame has successfully been parsed,
// kEOStream if there is no more data in the current stream buffer,
// kAwaitingRefresh if this frame awaiting frame context update, or
// kInvalidStream on error.
- Result ParseNextFrame(
- Vp9FrameHeader* fhdr,
- Vp9FrameContextManager::ContextRefreshCallback* context_refresh_cb);
+ Result ParseNextFrame(Vp9FrameHeader* fhdr);
// Return current segmentation state.
const Vp9SegmentationParams& GetSegmentation() const {
@@ -363,13 +372,15 @@ class MEDIA_EXPORT Vp9Parser {
return context_.loop_filter;
}
+ // Return a GetContextRefreshCb, which, if not null, has to be called with the
+ // new context state after the frame associated with |frame_hdr| is decoded.
+ ContextRefreshCallback GetContextRefreshCb(
+ const std::unique_ptr<Vp9FrameHeader>& frame_hdr);
+
// Clear parser state and return to an initialized state.
void Reset();
private:
- class UncompressedHeaderParser;
- class CompressedHeaderParser;
-
// Stores start pointer and size of each frame within the current superframe.
struct FrameInfo {
FrameInfo() = default;
« no previous file with comments | « no previous file | media/filters/vp9_parser.cc » ('j') | media/filters/vp9_parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698