| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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), deadline_(deadline), init_done_(false) { |
| 45 memset(&decoder_, 0, sizeof(decoder_)); | 45 memset(&decoder_, 0, sizeof(decoder_)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual ~Decoder() { | 48 virtual ~Decoder() { |
| 49 vpx_codec_destroy(&decoder_); | 49 vpx_codec_destroy(&decoder_); |
| 50 } | 50 } |
| 51 | 51 |
| 52 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, int size); | 52 vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size); |
| 53 | 53 |
| 54 DxDataIterator GetDxData() { | 54 DxDataIterator GetDxData() { |
| 55 return DxDataIterator(&decoder_); | 55 return DxDataIterator(&decoder_); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void set_deadline(unsigned long deadline) { | 58 void set_deadline(unsigned long deadline) { |
| 59 deadline_ = deadline; | 59 deadline_ = deadline; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Control(int ctrl_id, int arg) { | 62 void Control(int ctrl_id, int arg) { |
| 63 InitOnce(); | 63 InitOnce(); |
| 64 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); | 64 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); |
| 65 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); | 65 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void Control(int ctrl_id, const void *arg) { | 68 void Control(int ctrl_id, const void *arg) { |
| 69 InitOnce(); | 69 InitOnce(); |
| 70 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); | 70 const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg); |
| 71 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); | 71 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 const char* DecodeError() { | 74 const char* DecodeError() { |
| 75 const char *detail = vpx_codec_error_detail(&decoder_); | 75 const char *detail = vpx_codec_error_detail(&decoder_); |
| 76 return detail ? detail : vpx_codec_error(&decoder_); | 76 return detail ? detail : vpx_codec_error(&decoder_); |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Passes the external frame buffer information to libvpx. |
| 80 vpx_codec_err_t SetFrameBufferFunctions( |
| 81 vpx_get_frame_buffer_cb_fn_t cb_get, |
| 82 vpx_release_frame_buffer_cb_fn_t cb_release, void *user_priv) { |
| 83 InitOnce(); |
| 84 return vpx_codec_set_frame_buffer_functions( |
| 85 &decoder_, cb_get, cb_release, user_priv); |
| 86 } |
| 87 |
| 79 protected: | 88 protected: |
| 80 virtual const vpx_codec_iface_t* CodecInterface() const = 0; | 89 virtual vpx_codec_iface_t* CodecInterface() const = 0; |
| 81 | 90 |
| 82 void InitOnce() { | 91 void InitOnce() { |
| 83 if (!init_done_) { | 92 if (!init_done_) { |
| 84 const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_, | 93 const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_, |
| 85 CodecInterface(), | 94 CodecInterface(), |
| 86 &cfg_, 0); | 95 &cfg_, 0); |
| 87 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); | 96 ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError(); |
| 88 init_done_ = true; | 97 init_done_ = true; |
| 89 } | 98 } |
| 90 } | 99 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 113 explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {} | 122 explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {} |
| 114 | 123 |
| 115 virtual ~DecoderTest() {} | 124 virtual ~DecoderTest() {} |
| 116 | 125 |
| 117 const CodecFactory *codec_; | 126 const CodecFactory *codec_; |
| 118 }; | 127 }; |
| 119 | 128 |
| 120 } // namespace libvpx_test | 129 } // namespace libvpx_test |
| 121 | 130 |
| 122 #endif // TEST_DECODE_TEST_DRIVER_H_ | 131 #endif // TEST_DECODE_TEST_DRIVER_H_ |
| OLD | NEW |