]> granicus.if.org Git - libvpx/blobdiff - test/decode_test_driver.h
Merge changes from topic 'wextra'
[libvpx] / test / decode_test_driver.h
index a3cfd3f520522d69dba22fc2cc3c6b69d4dacca5..644fc9e90dc1a0de5bc41ce5f23b5ba76b6c94ce 100644 (file)
@@ -26,13 +26,11 @@ class DxDataIterator {
   explicit DxDataIterator(vpx_codec_ctx_t *decoder)
       : decoder_(decoder), iter_(NULL) {}
 
-  const vpx_image_t *Next() {
-    return vpx_codec_get_frame(decoder_, &iter_);
-  }
+  const vpx_image_t *Next() { return vpx_codec_get_frame(decoder_, &iter_); }
 
  private:
-  vpx_codec_ctx_t  *decoder_;
-  vpx_codec_iter_t  iter_;
+  vpx_codec_ctx_t *decoder_;
+  vpx_codec_iter_t iter_;
 };
 
 // Provides a simplified interface to manage one video decoding.
@@ -40,15 +38,18 @@ class DxDataIterator {
 // as more tests are added.
 class Decoder {
  public:
-  Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
-      : cfg_(cfg), deadline_(deadline), init_done_(false) {
+  explicit Decoder(vpx_codec_dec_cfg_t cfg)
+      : cfg_(cfg), flags_(0), init_done_(false) {
     memset(&decoder_, 0, sizeof(decoder_));
   }
 
-  virtual ~Decoder() {
-    vpx_codec_destroy(&decoder_);
+  Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag)
+      : cfg_(cfg), flags_(flag), init_done_(false) {
+    memset(&decoder_, 0, sizeof(decoder_));
   }
 
+  virtual ~Decoder() { vpx_codec_destroy(&decoder_); }
+
   vpx_codec_err_t PeekStream(const uint8_t *cxdata, size_t size,
                              vpx_codec_stream_info_t *stream_info);
 
@@ -57,27 +58,23 @@ class Decoder {
   vpx_codec_err_t DecodeFrame(const uint8_t *cxdata, size_t size,
                               void *user_priv);
 
-  DxDataIterator GetDxData() {
-    return DxDataIterator(&decoder_);
-  }
+  DxDataIterator GetDxData() { return DxDataIterator(&decoder_); }
 
-  void set_deadline(unsigned long deadline) {
-    deadline_ = deadline;
-  }
+  void Control(int ctrl_id, int arg) { Control(ctrl_id, arg, VPX_CODEC_OK); }
 
-  void Control(int ctrl_id, int arg) {
+  void Control(int ctrl_id, const void *arg) {
     InitOnce();
     const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
     ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
   }
 
-  void Control(int ctrl_id, const void *arg) {
+  void Control(int ctrl_id, int arg, vpx_codec_err_t expected_value) {
     InitOnce();
     const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
-    ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
+    ASSERT_EQ(expected_value, res) << DecodeError();
   }
 
-  const charDecodeError() {
+  const char *DecodeError() {
     const char *detail = vpx_codec_error_detail(&decoder_);
     return detail ? detail : vpx_codec_error(&decoder_);
   }
@@ -87,31 +84,34 @@ class Decoder {
       vpx_get_frame_buffer_cb_fn_t cb_get,
       vpx_release_frame_buffer_cb_fn_t cb_release, void *user_priv) {
     InitOnce();
-    return vpx_codec_set_frame_buffer_functions(
-        &decoder_, cb_get, cb_release, user_priv);
+    return vpx_codec_set_frame_buffer_functions(&decoder_, cb_get, cb_release,
+                                                user_priv);
   }
 
-  const char* GetDecoderName() {
+  const char *GetDecoderName() const {
     return vpx_codec_iface_name(CodecInterface());
   }
 
+  bool IsVP8() const;
+
+  vpx_codec_ctx_t *GetDecoder() { return &decoder_; }
+
  protected:
-  virtual vpx_codec_iface_tCodecInterface() const = 0;
+  virtual vpx_codec_iface_t *CodecInterface() const = 0;
 
   void InitOnce() {
     if (!init_done_) {
-      const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
-                                                     CodecInterface(),
-                                                     &cfg_, 0);
+      const vpx_codec_err_t res =
+          vpx_codec_dec_init(&decoder_, CodecInterface(), &cfg_, flags_);
       ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
       init_done_ = true;
     }
   }
 
-  vpx_codec_ctx_t     decoder_;
+  vpx_codec_ctx_t decoder_;
   vpx_codec_dec_cfg_t cfg_;
-  unsigned int        deadline_;
-  bool                init_done_;
+  vpx_codec_flags_t flags_;
+  bool init_done_;
 };
 
 // Common test functionality for all Decoder tests.
@@ -122,28 +122,39 @@ class DecoderTest {
   virtual void RunLoop(CompressedVideoSource *video,
                        const vpx_codec_dec_cfg_t &dec_cfg);
 
+  virtual void set_cfg(const vpx_codec_dec_cfg_t &dec_cfg);
+  virtual void set_flags(const vpx_codec_flags_t flags);
+
   // Hook to be called before decompressing every frame.
-  virtual void PreDecodeFrameHook(const CompressedVideoSource& video,
-                                  Decoder *decoder) {}
+  virtual void PreDecodeFrameHook(const CompressedVideoSource & /*video*/,
+                                  Decoder * /*decoder*/) {}
 
   // Hook to be called to handle decode result. Return true to continue.
   virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
-                                  const CompressedVideoSource& /* video */,
+                                  const CompressedVideoSource & /*video*/,
                                   Decoder *decoder) {
     EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
     return VPX_CODEC_OK == res_dec;
   }
 
   // Hook to be called on every decompressed frame.
-  virtual void DecompressedFrameHook(const vpx_image_t& img,
-                                     const unsigned int frame_number) {}
+  virtual void DecompressedFrameHook(const vpx_image_t & /*img*/,
+                                     const unsigned int /*frame_number*/) {}
+
+  // Hook to be called on peek result
+  virtual void HandlePeekResult(Decoder *const decoder,
+                                CompressedVideoSource *video,
+                                const vpx_codec_err_t res_peek);
 
  protected:
-  explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {}
+  explicit DecoderTest(const CodecFactory *codec)
+      : codec_(codec), cfg_(), flags_(0) {}
 
   virtual ~DecoderTest() {}
 
   const CodecFactory *codec_;
+  vpx_codec_dec_cfg_t cfg_;
+  vpx_codec_flags_t flags_;
 };
 
 }  // namespace libvpx_test