OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Provides a simplified interface to manage one video decoding. | 38 // Provides a simplified interface to manage one video decoding. |
39 // | 39 // |
40 // TODO: similar to Encoder class, the exact services should be | 40 // TODO: similar to Encoder class, the exact services should be |
41 // added as more tests are added. | 41 // added as more tests are added. |
42 class Decoder { | 42 class Decoder { |
43 public: | 43 public: |
44 Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) | 44 Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline) |
45 : cfg_(cfg), deadline_(deadline) { | 45 : cfg_(cfg), deadline_(deadline) { |
46 memset(&decoder_, 0, sizeof(decoder_)); | 46 memset(&decoder_, 0, sizeof(decoder_)); |
| 47 Init(); |
47 } | 48 } |
48 | 49 |
49 ~Decoder() { | 50 ~Decoder() { |
50 vpx_codec_destroy(&decoder_); | 51 vpx_codec_destroy(&decoder_); |
51 } | 52 } |
52 | 53 |
53 void DecodeFrame(const uint8_t *cxdata, int size); | 54 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, int size); |
54 | 55 |
55 DxDataIterator GetDxData() { | 56 DxDataIterator GetDxData() { |
56 return DxDataIterator(&decoder_); | 57 return DxDataIterator(&decoder_); |
57 } | 58 } |
58 | 59 |
59 void set_deadline(unsigned long deadline) { | 60 void set_deadline(unsigned long deadline) { |
60 deadline_ = deadline; | 61 deadline_ = deadline; |
61 } | 62 } |
62 | 63 |
63 void Control(int ctrl_id, int arg) { | 64 void Control(int ctrl_id, int arg) { |
64 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); | 65 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); |
65 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); | 66 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
66 } | 67 } |
67 | 68 |
68 protected: | 69 void Control(int ctrl_id, const void *arg) { |
| 70 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); |
| 71 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
| 72 } |
| 73 |
69 const char *DecodeError() { | 74 const char *DecodeError() { |
70 const char *detail = vpx_codec_error_detail(&decoder_); | 75 const char *detail = vpx_codec_error_detail(&decoder_); |
71 return detail ? detail : vpx_codec_error(&decoder_); | 76 return detail ? detail : vpx_codec_error(&decoder_); |
72 } | 77 } |
73 | 78 |
| 79 protected: |
| 80 void Init() { |
| 81 const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_, |
| 82 &vpx_codec_vp8_dx_algo, |
| 83 &cfg_, 0); |
| 84 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
| 85 } |
| 86 |
74 vpx_codec_ctx_t decoder_; | 87 vpx_codec_ctx_t decoder_; |
75 vpx_codec_dec_cfg_t cfg_; | 88 vpx_codec_dec_cfg_t cfg_; |
76 unsigned int deadline_; | 89 unsigned int deadline_; |
77 }; | 90 }; |
78 | 91 |
79 // Common test functionality for all Decoder tests. | 92 // Common test functionality for all Decoder tests. |
80 class DecoderTest { | 93 class DecoderTest { |
81 public: | 94 public: |
82 // Main loop. | 95 // Main loop. |
83 virtual void RunLoop(CompressedVideoSource *video); | 96 virtual void RunLoop(CompressedVideoSource *video); |
84 | 97 |
85 // Hook to be called on every decompressed frame. | 98 // Hook to be called on every decompressed frame. |
86 virtual void DecompressedFrameHook(const vpx_image_t& img, | 99 virtual void DecompressedFrameHook(const vpx_image_t& img, |
87 const unsigned int frame_number) {} | 100 const unsigned int frame_number) {} |
88 | 101 |
89 protected: | 102 protected: |
90 DecoderTest() {} | 103 DecoderTest() {} |
91 | 104 |
92 virtual ~DecoderTest() {} | 105 virtual ~DecoderTest() {} |
93 }; | 106 }; |
94 | 107 |
95 } // namespace libvpx_test | 108 } // namespace libvpx_test |
96 | 109 |
97 #endif // TEST_DECODE_TEST_DRIVER_H_ | 110 #endif // TEST_DECODE_TEST_DRIVER_H_ |
OLD | NEW |