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

Unified Diff: media/filters/ivf_parser.h

Issue 1269473002: Extract IVF parser from VP8 parser unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 5 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
Index: media/filters/ivf_parser.h
diff --git a/media/filters/ivf_parser.h b/media/filters/ivf_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..94e0f9ee7acf8bcd60299d0da4de3fb6f46e9ae2
--- /dev/null
+++ b/media/filters/ivf_parser.h
@@ -0,0 +1,82 @@
+// Copyright 2015 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.
+
+#ifndef MEDIA_FILTERS_IVF_PARSER_H_
+#define MEDIA_FILTERS_IVF_PARSER_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "media/base/media_export.h"
+
+namespace media {
+
+#pragma pack(push, 1)
+struct MEDIA_EXPORT IvfFileHeader {
+ // Byte swap interger fields between native and (on disk) little endian.
+ void ByteSwap();
+
+ char signature[4]; // signature: 'DKIF'
+ uint16_t version; // version (should be 0)
+ uint16_t header_size; // size of header in bytes
+ uint32_t fourcc; // codec FourCC (e.g., 'VP80')
+ uint16_t width; // width in pixels
+ uint16_t height; // height in pixels
+ uint32_t timebase_denum; // timebase denumerator
+ uint32_t timebase_num; // timebase numerator. For example, if
+ // timebase_denum is 30 and timebase_num is 2, the
+ // unit of IvfFrameHeader.timestamp is 2/30
+ // seconds.
+ uint32_t num_frames; // number of frames in file
+ uint32_t unused; // unused
+};
+static_assert(
+ sizeof(IvfFileHeader) == 32,
+ "sizeof(IvfFileHeader) must be fixed since it will be used with file IO");
+
+struct MEDIA_EXPORT IvfFrameHeader {
+ // Byte swap interger fields between native and (on disk) little endian.
+ void ByteSwap();
+
+ uint32_t frame_size; // Size of frame in bytes (not including the header)
+ uint64_t timestamp; // 64-bit presentation timestamp in unit timebase,
+ // which is defined in IvfFileHeader.
+};
+static_assert(
+ sizeof(IvfFrameHeader) == 12,
+ "sizeof(IvfFrameHeader) must be fixed since it will be used with file IO");
+#pragma pack(pop)
+
+// IVF is a simple container format for video frame. It is used by libvpx to
+// transport VP8 and VP9 bitstream.
+class MEDIA_EXPORT IvfParser {
+ public:
+ IvfParser();
+
+ // Initializes the parser for IVF |stream| with size |size| and parses the
+ // file header. Returns true on success.
+ bool Initialize(const uint8_t* stream,
+ size_t size,
+ IvfFileHeader* file_header);
+
+ // Parses the next frame. Returns true if the next frame is parsed without
+ // error. |frame_header| will be filled with the frame header. |payload|
henryhsu 2015/08/05 06:22:55 |payload| what? seems the comment is not finished.
kcwu 2015/08/05 07:25:34 Done.
+ bool ParseNextFrame(IvfFrameHeader* frame_header, const uint8_t** payload);
+
+ private:
+ bool ParseFileHeader(IvfFileHeader* file_header);
+
+ // Current reading position of input stream.
+ const uint8_t* ptr_;
+
+ // The end position of input stream.
+ const uint8_t* end_;
+
+ DISALLOW_COPY_AND_ASSIGN(IvfParser);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_IVF_PARSER_H_

Powered by Google App Engine
This is Rietveld 408576698