Merge branch 'master' into experimental
authorJohn Koleszar <jkoleszar@google.com>
Wed, 27 Mar 2013 17:41:29 +0000 (10:41 -0700)
committerJohn Koleszar <jkoleszar@google.com>
Wed, 27 Mar 2013 17:46:19 +0000 (10:46 -0700)
Pick up VP8 encryption, quantization changes, and some fixes to vpxenc

Conflicts:
test/decode_test_driver.cc
test/decode_test_driver.h
test/encode_test_driver.cc
vp8/vp8cx.mk
vpxdec.c
vpxenc.c

Change-Id: I9fbcc64808ead47e22f1f22501965cc7f0c4791c

1  2 
configure
test/decode_test_driver.cc
test/decode_test_driver.h
test/encode_test_driver.cc
test/test.mk
vp8/encoder/bitstream.c
vp8/encoder/onyx_if.c
vp8/encoder/x86/quantize_sse2_intrinsics.c
vp8/vp8cx.mk
vpxenc.c

diff --cc configure
Simple merge
  #include "test/video_source.h"
  
  namespace libvpx_test {
- void Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
-   if (!decoder_.priv) {
-     const vpx_codec_err_t res_init = vpx_codec_dec_init(&decoder_,
-                                                         CodecInterface(),
-                                                         &cfg_, 0);
-     ASSERT_EQ(VPX_CODEC_OK, res_init) << DecodeError();
-   }
 -#if CONFIG_VP8_DECODER
  
+ vpx_codec_err_t Decoder::DecodeFrame(const uint8_t *cxdata, int size) {
    vpx_codec_err_t res_dec;
++  InitOnce();
    REGISTER_STATE_CHECK(res_dec = vpx_codec_decode(&decoder_,
                                                    cxdata, size, NULL, 0));
-   ASSERT_EQ(VPX_CODEC_OK, res_dec) << DecodeError();
+   return res_dec;
  }
  
  void DecoderTest::RunLoop(CompressedVideoSource *video) {
  
    // Decode frames.
    for (video->Begin(); video->cxdata(); video->Next()) {
-     decoder->DecodeFrame(video->cxdata(), video->frame_size());
 -    vpx_codec_err_t res_dec = decoder.DecodeFrame(video->cxdata(),
 -                                                  video->frame_size());
 -    ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder.DecodeError();
++    vpx_codec_err_t res_dec = decoder->DecodeFrame(video->cxdata(),
++                                                   video->frame_size());
++    ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
  
 -    DxDataIterator dec_iter = decoder.GetDxData();
 +    DxDataIterator dec_iter = decoder->GetDxData();
      const vpx_image_t *img = NULL;
  
      // Get decompressed data
@@@ -42,11 -42,12 +42,11 @@@ class DxDataIterator 
  class Decoder {
   public:
    Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
--      : cfg_(cfg), deadline_(deadline) {
++      : cfg_(cfg), deadline_(deadline), init_done_(false) {
      memset(&decoder_, 0, sizeof(decoder_));
 -    Init();
    }
  
 -  ~Decoder() {
 +  virtual ~Decoder() {
      vpx_codec_destroy(&decoder_);
    }
  
    }
  
    void Control(int ctrl_id, int arg) {
++    InitOnce();
      const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
      ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
    }
  
-  protected:
-   virtual const vpx_codec_iface_t* CodecInterface() const = 0;
+   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();
+   }
  
 -  const char *DecodeError() {
 +  const charDecodeError() {
      const char *detail = vpx_codec_error_detail(&decoder_);
      return detail ? detail : vpx_codec_error(&decoder_);
    }
  
 -  void Init() {
 -    const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
 -                                                   &vpx_codec_vp8_dx_algo,
 -                                                   &cfg_, 0);
 -    ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
+  protected:
++  virtual const 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);
++      ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
++      init_done_ = true;
++    }
+   }
    vpx_codec_ctx_t     decoder_;
    vpx_codec_dec_cfg_t cfg_;
    unsigned int        deadline_;
++  bool                init_done_;
  };
  
  // Common test functionality for all Decoder tests.
@@@ -161,24 -153,24 +161,25 @@@ void EncoderTest::RunLoop(VideoSource *
        again = video->img() != NULL;
  
        PreEncodeFrameHook(video);
 -      PreEncodeFrameHook(video, &encoder);
 -      encoder.EncodeFrame(video, frame_flags_);
 +      PreEncodeFrameHook(video, encoder);
 +      encoder->EncodeFrame(video, frame_flags_);
  
 -      CxDataIterator iter = encoder.GetCxData();
 +      CxDataIterator iter = encoder->GetCxData();
  
 +      bool has_cxdata = false;
 +      bool has_dxdata = false;
        while (const vpx_codec_cx_pkt_t *pkt = iter.Next()) {
 +        pkt = MutateEncoderOutputHook(pkt);
          again = true;
 -#if CONFIG_VP8_DECODER
 -        vpx_codec_err_t res_dec;
 -#endif
          switch (pkt->kind) {
            case VPX_CODEC_CX_FRAME_PKT:
 -#if CONFIG_VP8_DECODER
              has_cxdata = true;
 -            res_dec = decoder.DecodeFrame((const uint8_t*)pkt->data.frame.buf,
 -                                          pkt->data.frame.sz);
 -            ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder.DecodeError();
 -#endif
 +            if (decoder && DoDecode()) {
-               decoder->DecodeFrame((const uint8_t*)pkt->data.frame.buf,
-                                    pkt->data.frame.sz);
++              vpx_codec_err_t res_dec = decoder->DecodeFrame(
++                  (const uint8_t*)pkt->data.frame.buf, pkt->data.frame.sz);
++              ASSERT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
 +              has_dxdata = true;
 +            }
              ASSERT_GE(pkt->data.frame.pts, last_pts_);
              last_pts_ = pkt->data.frame.pts;
              FramePktHook(pkt);
diff --cc test/test.mk
@@@ -24,13 -22,12 +24,14 @@@ LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS)    
  LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc
  LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += resize_test.cc
  
 -LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ../md5_utils.h ../md5_utils.c
 -LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.cc
 -LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += decode_test_driver.h
 -LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += ivf_video_source.h
 +LIBVPX_TEST_SRCS-$(CONFIG_DECODERS)    += ../md5_utils.h ../md5_utils.c
 +LIBVPX_TEST_SRCS-yes                   += decode_test_driver.cc
 +LIBVPX_TEST_SRCS-yes                   += decode_test_driver.h
 +LIBVPX_TEST_SRCS-$(CONFIG_DECODERS)    += ivf_video_source.h
 +
 +
  LIBVPX_TEST_SRCS-$(CONFIG_VP8_DECODER) += test_vector_test.cc
  ##
  ## WHITE BOX TESTS
  ##
Simple merge
Simple merge
diff --cc vp8/vp8cx.mk
@@@ -89,8 -89,7 +89,7 @@@ VP8_CX_SRCS-$(HAVE_MMX) += encoder/x86/
  VP8_CX_SRCS-$(HAVE_MMX) += encoder/x86/vp8_enc_stubs_mmx.c
  VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/dct_sse2.asm
  VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/fwalsh_sse2.asm
 -VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2.c
 +VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2_intrinsics.c
- VP8_CX_SRCS-$(HAVE_SSE2) += encoder/x86/quantize_sse2.asm
  
  # TODO(johann) make this generic
  ifeq ($(HAVE_SSE2),yes)
diff --cc vpxenc.c
Simple merge