test/decode_api_test.cc
// Test VP9 codec controls after a decode error to ensure the code doesn't
// misbehave.
Test VP9 codec controls after a decode error to ensure the code doesn't
misbehave.
Test VP9 codec controls after a decode error to ensure the code doesn ' t misbehave .
void TestVp9Controls(vpx_codec_ctx_t *dec) {
  static const int kControls[] = { VP8D_GET_LAST_REF_UPDATES,
                                   VP8D_GET_FRAME_CORRUPTED,
                                   VP9D_GET_DISPLAY_SIZE, VP9D_GET_FRAME_SIZE };
  int val[2];
  for (int i = 0; i < NELEMENTS(kControls); ++i) {
    const vpx_codec_err_t res = vpx_codec_control_(dec, kControls[i], val);
    switch (kControls[i]) {
      case VP8D_GET_FRAME_CORRUPTED:
        EXPECT_EQ(VPX_CODEC_ERROR, res) << kControls[i];
        break;
      default: EXPECT_EQ(VPX_CODEC_OK, res) << kControls[i]; break;
    }
    EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
              vpx_codec_control_(dec, kControls[i], nullptr));
  }
  vp9_ref_frame_t ref;
  ref.idx = 0;
  EXPECT_EQ(VPX_CODEC_ERROR, vpx_codec_control(dec, VP9_GET_REFERENCE, &ref));
  EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
            vpx_codec_control(dec, VP9_GET_REFERENCE, nullptr));
  vpx_ref_frame_t ref_copy;
  const int width = 352;
  const int height = 288;
  EXPECT_NE(vpx_img_alloc(&ref_copy.img, VPX_IMG_FMT_I420, width, height, 1),
            nullptr);
  ref_copy.frame_type = VP8_LAST_FRAME;
  EXPECT_EQ(VPX_CODEC_ERROR,
            vpx_codec_control(dec, VP8_COPY_REFERENCE, &ref_copy));
  EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
            vpx_codec_control(dec, VP8_COPY_REFERENCE, nullptr));
  vpx_img_free(&ref_copy.img);
}
void TestVp9Controls ( vpx_codec_ctx_t * dec ) { static const int kControls [ ] = { VP8D_GET_LAST_REF_UPDATES , VP8D_GET_FRAME_CORRUPTED , VP9D_GET_DISPLAY_SIZE , VP9D_GET_FRAME_SIZE } ; int val [ 2 ] ; for ( int i = 0 ; i < NELEMENTS ( kControls ) ; ++ i ) { const vpx_codec_err_t res = vpx_codec_control_ ( dec , kControls [ i ] , val ) ; switch ( kControls [ i ] ) { case VP8D_GET_FRAME_CORRUPTED : EXPECT_EQ ( VPX_CODEC_ERROR , res ) << kControls [ i ] ; break ; default : EXPECT_EQ ( VPX_CODEC_OK , res ) << kControls [ i ] ; break ; } EXPECT_EQ ( VPX_CODEC_INVALID_PARAM , vpx_codec_control_ ( dec , kControls [ i ] , nullptr ) ) ; } vp9_ref_frame_t ref ; ref . idx = 0 ; EXPECT_EQ ( VPX_CODEC_ERROR , vpx_codec_control ( dec , VP9_GET_REFERENCE , & ref ) ) ; EXPECT_EQ ( VPX_CODEC_INVALID_PARAM , vpx_codec_control ( dec , VP9_GET_REFERENCE , nullptr ) ) ; vpx_ref_frame_t ref_copy ; const int width = 352 ; const int height = 288 ; EXPECT_NE ( vpx_img_alloc ( & ref_copy . img , VPX_IMG_FMT_I420 , width , height , 1 ) , nullptr ) ; ref_copy . frame_type = VP8_LAST_FRAME ; EXPECT_EQ ( VPX_CODEC_ERROR , vpx_codec_control ( dec , VP8_COPY_REFERENCE , & ref_copy ) ) ; EXPECT_EQ ( VPX_CODEC_INVALID_PARAM , vpx_codec_control ( dec , VP8_COPY_REFERENCE , nullptr ) ) ; vpx_img_free ( & ref_copy . img ) ; }
Test VP9 codec controls after a decode error to ensure the code doesn't
misbehave.
Test VP9 codec controls after a decode error to ensure the code doesn ' t misbehave .