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

Side by Side Diff: source/libvpx/test/decode_test_driver.h

Issue 812033011: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/test/decode_perf_test.cc ('k') | source/libvpx/test/decode_test_driver.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 /* 1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 23 matching lines...) Expand all
34 vpx_codec_ctx_t *decoder_; 34 vpx_codec_ctx_t *decoder_;
35 vpx_codec_iter_t iter_; 35 vpx_codec_iter_t iter_;
36 }; 36 };
37 37
38 // Provides a simplified interface to manage one video decoding. 38 // Provides a simplified interface to manage one video decoding.
39 // Similar to Encoder class, the exact services should be added 39 // Similar to Encoder class, the exact services should be added
40 // as more tests are added. 40 // as more tests are added.
41 class Decoder { 41 class Decoder {
42 public: 42 public:
43 Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) 43 Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
44 : cfg_(cfg), deadline_(deadline), init_done_(false) { 44 : cfg_(cfg), flags_(0), deadline_(deadline), init_done_(false) {
45 memset(&decoder_, 0, sizeof(decoder_));
46 }
47
48 Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
49 unsigned long deadline) // NOLINT
50 : cfg_(cfg), flags_(flag), deadline_(deadline), init_done_(false) {
45 memset(&decoder_, 0, sizeof(decoder_)); 51 memset(&decoder_, 0, sizeof(decoder_));
46 } 52 }
47 53
48 virtual ~Decoder() { 54 virtual ~Decoder() {
49 vpx_codec_destroy(&decoder_); 55 vpx_codec_destroy(&decoder_);
50 } 56 }
51 57
52 vpx_codec_err_t PeekStream(const uint8_t *cxdata, size_t size, 58 vpx_codec_err_t PeekStream(const uint8_t *cxdata, size_t size,
53 vpx_codec_stream_info_t *stream_info); 59 vpx_codec_stream_info_t *stream_info);
54 60
55 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size); 61 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size);
56 62
57 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size, 63 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size,
58 void *user_priv); 64 void *user_priv);
59 65
60 DxDataIterator GetDxData() { 66 DxDataIterator GetDxData() {
61 return DxDataIterator(&decoder_); 67 return DxDataIterator(&decoder_);
62 } 68 }
63 69
64 void set_deadline(unsigned long deadline) { 70 void set_deadline(unsigned long deadline) {
65 deadline_ = deadline; 71 deadline_ = deadline;
66 } 72 }
67 73
68 void Control(int ctrl_id, int arg) { 74 void Control(int ctrl_id, int arg) {
69 InitOnce(); 75 Control(ctrl_id, arg, VPX_CODEC_OK);
70 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
71 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
72 } 76 }
73 77
74 void Control(int ctrl_id, const void *arg) { 78 void Control(int ctrl_id, const void *arg) {
75 InitOnce(); 79 InitOnce();
76 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); 80 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
77 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); 81 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
78 } 82 }
79 83
84 void Control(int ctrl_id, int arg, vpx_codec_err_t expected_value) {
85 InitOnce();
86 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
87 ASSERT_EQ(expected_value, res) << DecodeError();
88 }
89
80 const char* DecodeError() { 90 const char* DecodeError() {
81 const char *detail = vpx_codec_error_detail(&decoder_); 91 const char *detail = vpx_codec_error_detail(&decoder_);
82 return detail ? detail : vpx_codec_error(&decoder_); 92 return detail ? detail : vpx_codec_error(&decoder_);
83 } 93 }
84 94
85 // Passes the external frame buffer information to libvpx. 95 // Passes the external frame buffer information to libvpx.
86 vpx_codec_err_t SetFrameBufferFunctions( 96 vpx_codec_err_t SetFrameBufferFunctions(
87 vpx_get_frame_buffer_cb_fn_t cb_get, 97 vpx_get_frame_buffer_cb_fn_t cb_get,
88 vpx_release_frame_buffer_cb_fn_t cb_release, void *user_priv) { 98 vpx_release_frame_buffer_cb_fn_t cb_release, void *user_priv) {
89 InitOnce(); 99 InitOnce();
90 return vpx_codec_set_frame_buffer_functions( 100 return vpx_codec_set_frame_buffer_functions(
91 &decoder_, cb_get, cb_release, user_priv); 101 &decoder_, cb_get, cb_release, user_priv);
92 } 102 }
93 103
94 const char* GetDecoderName() const { 104 const char* GetDecoderName() const {
95 return vpx_codec_iface_name(CodecInterface()); 105 return vpx_codec_iface_name(CodecInterface());
96 } 106 }
97 107
98 bool IsVP8() const; 108 bool IsVP8() const;
99 109
110 vpx_codec_ctx_t * GetDecoder() {
111 return &decoder_;
112 }
113
100 protected: 114 protected:
101 virtual vpx_codec_iface_t* CodecInterface() const = 0; 115 virtual vpx_codec_iface_t* CodecInterface() const = 0;
102 116
103 void InitOnce() { 117 void InitOnce() {
104 if (!init_done_) { 118 if (!init_done_) {
105 const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_, 119 const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
106 CodecInterface(), 120 CodecInterface(),
107 &cfg_, 0); 121 &cfg_, flags_);
108 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); 122 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
109 init_done_ = true; 123 init_done_ = true;
110 } 124 }
111 } 125 }
112 126
113 vpx_codec_ctx_t decoder_; 127 vpx_codec_ctx_t decoder_;
114 vpx_codec_dec_cfg_t cfg_; 128 vpx_codec_dec_cfg_t cfg_;
129 vpx_codec_flags_t flags_;
115 unsigned int deadline_; 130 unsigned int deadline_;
116 bool init_done_; 131 bool init_done_;
117 }; 132 };
118 133
119 // Common test functionality for all Decoder tests. 134 // Common test functionality for all Decoder tests.
120 class DecoderTest { 135 class DecoderTest {
121 public: 136 public:
122 // Main decoding loop 137 // Main decoding loop
123 virtual void RunLoop(CompressedVideoSource *video); 138 virtual void RunLoop(CompressedVideoSource *video);
124 virtual void RunLoop(CompressedVideoSource *video, 139 virtual void RunLoop(CompressedVideoSource *video,
125 const vpx_codec_dec_cfg_t &dec_cfg); 140 const vpx_codec_dec_cfg_t &dec_cfg);
126 141
142 virtual void set_cfg(const vpx_codec_dec_cfg_t &dec_cfg);
143 virtual void set_flags(const vpx_codec_flags_t flags);
144
127 // Hook to be called before decompressing every frame. 145 // Hook to be called before decompressing every frame.
128 virtual void PreDecodeFrameHook(const CompressedVideoSource& /*video*/, 146 virtual void PreDecodeFrameHook(const CompressedVideoSource& /*video*/,
129 Decoder* /*decoder*/) {} 147 Decoder* /*decoder*/) {}
130 148
131 // Hook to be called to handle decode result. Return true to continue. 149 // Hook to be called to handle decode result. Return true to continue.
132 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec, 150 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
133 const CompressedVideoSource& /*video*/, 151 const CompressedVideoSource& /*video*/,
134 Decoder *decoder) { 152 Decoder *decoder) {
135 EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError(); 153 EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
136 return VPX_CODEC_OK == res_dec; 154 return VPX_CODEC_OK == res_dec;
137 } 155 }
138 156
139 // Hook to be called on every decompressed frame. 157 // Hook to be called on every decompressed frame.
140 virtual void DecompressedFrameHook(const vpx_image_t& /*img*/, 158 virtual void DecompressedFrameHook(const vpx_image_t& /*img*/,
141 const unsigned int /*frame_number*/) {} 159 const unsigned int /*frame_number*/) {}
142 160
143 // Hook to be called on peek result 161 // Hook to be called on peek result
144 virtual void HandlePeekResult(Decoder* const decoder, 162 virtual void HandlePeekResult(Decoder* const decoder,
145 CompressedVideoSource *video, 163 CompressedVideoSource *video,
146 const vpx_codec_err_t res_peek); 164 const vpx_codec_err_t res_peek);
147 165
148 protected: 166 protected:
149 explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {} 167 explicit DecoderTest(const CodecFactory *codec)
168 : codec_(codec),
169 cfg_(),
170 flags_(0) {}
150 171
151 virtual ~DecoderTest() {} 172 virtual ~DecoderTest() {}
152 173
153 const CodecFactory *codec_; 174 const CodecFactory *codec_;
175 vpx_codec_dec_cfg_t cfg_;
176 vpx_codec_flags_t flags_;
154 }; 177 };
155 178
156 } // namespace libvpx_test 179 } // namespace libvpx_test
157 180
158 #endif // TEST_DECODE_TEST_DRIVER_H_ 181 #endif // TEST_DECODE_TEST_DRIVER_H_
OLDNEW
« no previous file with comments | « source/libvpx/test/decode_perf_test.cc ('k') | source/libvpx/test/decode_test_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698