Merge changes from topic 'fix-vp9-bitstream-test'

* changes:
  vp9_encoder_parms_get_to_decoder: cosmetics
  vp9...parms_get_to_decoder: remove unneeded func
  vp9...parms_get_to_decoder: fix EXPECT param order
  vp9_encoder_parms_get_to_decoder: delete dead code
  fix BitstreamParms test
  vp9_encoder_parms_get_to_decoder: remove vp10
  yuvconfig2image(): add explicit cast to avoid conv warning
  vp9/10 decoder_init: add missing alloc cast
  vp9/10: set color_space on preview frame
  vp10: add extern "C" to headers
  vp9: add extern "C" to headers
This commit is contained in:
James Zern 2015-09-15 23:14:34 +00:00 committed by Gerrit Code Review
commit c667593e1e
17 changed files with 126 additions and 93 deletions

View File

@ -14,38 +14,12 @@
#include "test/encode_test_driver.h"
#include "test/util.h"
#include "test/y4m_video_source.h"
#include "test/yuv_video_source.h"
#include "vp9/decoder/vp9_decoder.h"
typedef vpx_codec_stream_info_t vp9_stream_info_t;
struct vpx_codec_alg_priv {
vpx_codec_priv_t base;
vpx_codec_dec_cfg_t cfg;
vp9_stream_info_t si;
struct VP9Decoder *pbi;
int postproc_cfg_set;
vp8_postproc_cfg_t postproc_cfg;
vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
vpx_image_t img;
int img_avail;
int flushed;
int invert_tile_order;
int frame_parallel_decode;
// External frame buffer info to save for VP9 common.
void *ext_priv; // Private data associated with the external frame buffers.
vpx_get_frame_buffer_cb_fn_t get_ext_fb_cb;
vpx_release_frame_buffer_cb_fn_t release_ext_fb_cb;
};
static vpx_codec_alg_priv_t *get_alg_priv(vpx_codec_ctx_t *ctx) {
return (vpx_codec_alg_priv_t *)ctx->priv;
}
#include "vp9/vp9_dx_iface.c"
namespace {
const unsigned int kFramerate = 50;
const int kCpuUsed = 2;
struct EncodePerfTestVideo {
@ -71,30 +45,20 @@ struct EncodeParameters {
};
const EncodeParameters kVP9EncodeParameterSet[] = {
{0, 0, 0, 1, 0, VPX_CS_BT_601},
{0, 0, 0, 0, 0, VPX_CS_BT_709},
{0, 0, 1, 0, 0, VPX_CS_BT_2020},
{0, 2, 0, 0, 1, VPX_CS_UNKNOWN},
// TODO(JBB): Test profiles (requires more work).
{0, 0, 0, 1, 0, VPX_CS_BT_601},
{0, 0, 0, 0, 0, VPX_CS_BT_709},
{0, 0, 1, 0, 0, VPX_CS_BT_2020},
{0, 2, 0, 0, 1, VPX_CS_UNKNOWN},
// TODO(JBB): Test profiles (requires more work).
};
int is_extension_y4m(const char *filename) {
const char *dot = strrchr(filename, '.');
if (!dot || dot == filename)
return 0;
else
return !strcmp(dot, ".y4m");
}
class VpxEncoderParmsGetToDecoder
: public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<EncodeParameters, \
public ::libvpx_test::CodecTestWith2Params<EncodeParameters,
EncodePerfTestVideo> {
protected:
VpxEncoderParmsGetToDecoder()
: EncoderTest(GET_PARAM(0)),
encode_parms(GET_PARAM(1)) {
}
: EncoderTest(GET_PARAM(0)), encode_parms(GET_PARAM(1)) {}
virtual ~VpxEncoderParmsGetToDecoder() {}
@ -126,33 +90,33 @@ class VpxEncoderParmsGetToDecoder
}
virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
const libvpx_test::VideoSource& video,
const libvpx_test::VideoSource &video,
libvpx_test::Decoder *decoder) {
vpx_codec_ctx_t* vp9_decoder = decoder->GetDecoder();
vpx_codec_alg_priv_t* priv =
(vpx_codec_alg_priv_t*) get_alg_priv(vp9_decoder);
VP9Decoder* pbi = priv->pbi;
VP9_COMMON* common = &pbi->common;
vpx_codec_ctx_t *const vp9_decoder = decoder->GetDecoder();
vpx_codec_alg_priv_t *const priv =
reinterpret_cast<vpx_codec_alg_priv_t *>(vp9_decoder->priv);
FrameWorkerData *const worker_data =
reinterpret_cast<FrameWorkerData *>(priv->frame_workers[0].data1);
VP9_COMMON *const common = &worker_data->pbi->common;
if (encode_parms.lossless) {
EXPECT_EQ(common->base_qindex, 0);
EXPECT_EQ(common->y_dc_delta_q, 0);
EXPECT_EQ(common->uv_dc_delta_q, 0);
EXPECT_EQ(common->uv_ac_delta_q, 0);
EXPECT_EQ(common->tx_mode, ONLY_4X4);
EXPECT_EQ(0, common->base_qindex);
EXPECT_EQ(0, common->y_dc_delta_q);
EXPECT_EQ(0, common->uv_dc_delta_q);
EXPECT_EQ(0, common->uv_ac_delta_q);
EXPECT_EQ(ONLY_4X4, common->tx_mode);
}
EXPECT_EQ(common->error_resilient_mode, encode_parms.error_resilient);
EXPECT_EQ(encode_parms.error_resilient, common->error_resilient_mode);
if (encode_parms.error_resilient) {
EXPECT_EQ(common->frame_parallel_decoding_mode, 1);
EXPECT_EQ(common->use_prev_frame_mvs, 0);
EXPECT_EQ(1, common->frame_parallel_decoding_mode);
EXPECT_EQ(0, common->use_prev_frame_mvs);
} else {
EXPECT_EQ(common->frame_parallel_decoding_mode,
encode_parms.frame_parallel);
EXPECT_EQ(encode_parms.frame_parallel,
common->frame_parallel_decoding_mode);
}
EXPECT_EQ(common->color_space, encode_parms.cs);
EXPECT_EQ(common->log2_tile_cols, encode_parms.tile_cols);
EXPECT_EQ(common->log2_tile_rows, encode_parms.tile_rows);
EXPECT_EQ(encode_parms.cs, common->color_space);
EXPECT_EQ(encode_parms.tile_cols, common->log2_tile_cols);
EXPECT_EQ(encode_parms.tile_rows, common->log2_tile_rows);
EXPECT_EQ(VPX_CODEC_OK, res_dec) << decoder->DecodeError();
return VPX_CODEC_OK == res_dec;
@ -164,35 +128,18 @@ class VpxEncoderParmsGetToDecoder
EncodeParameters encode_parms;
};
// TODO(hkuang): This test conflicts with frame parallel decode. So disable it
// for now until fix.
TEST_P(VpxEncoderParmsGetToDecoder, DISABLED_BitstreamParms) {
TEST_P(VpxEncoderParmsGetToDecoder, BitstreamParms) {
init_flags_ = VPX_CODEC_USE_PSNR;
libvpx_test::VideoSource *video;
if (is_extension_y4m(test_video_.name)) {
video = new libvpx_test::Y4mVideoSource(test_video_.name,
0, test_video_.frames);
} else {
video = new libvpx_test::YUVVideoSource(test_video_.name,
VPX_IMG_FMT_I420,
test_video_.width,
test_video_.height,
kFramerate, 1, 0,
test_video_.frames);
}
libvpx_test::VideoSource *const video =
new libvpx_test::Y4mVideoSource(test_video_.name, 0, test_video_.frames);
ASSERT_TRUE(video != NULL);
ASSERT_NO_FATAL_FAILURE(RunLoop(video));
delete(video);
delete video;
}
VP9_INSTANTIATE_TEST_CASE(
VpxEncoderParmsGetToDecoder,
::testing::ValuesIn(kVP9EncodeParameterSet),
::testing::ValuesIn(kVP9EncodePerfTestVectors));
VP10_INSTANTIATE_TEST_CASE(
VpxEncoderParmsGetToDecoder,
::testing::ValuesIn(kVP9EncodeParameterSet),
::testing::ValuesIn(kVP9EncodePerfTestVectors));
VP9_INSTANTIATE_TEST_CASE(VpxEncoderParmsGetToDecoder,
::testing::ValuesIn(kVP9EncodeParameterSet),
::testing::ValuesIn(kVP9EncodePerfTestVectors));
} // namespace

View File

@ -14,6 +14,10 @@
#include "vp10/common/loopfilter.h"
#include "vpx_util/vpx_thread.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP10Common;
struct FRAME_COUNTS;
@ -54,4 +58,8 @@ void vp10_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
void vp10_accumulate_frame_counts(struct VP10Common *cm,
struct FRAME_COUNTS *counts, int is_dec);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP10_COMMON_LOOPFILTER_THREAD_H_

View File

@ -15,6 +15,10 @@
#include "vpx_util/vpx_thread.h"
#include "vpx/internal/vpx_codec_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP10Common;
struct VP10Decoder;
@ -63,4 +67,8 @@ void vp10_frameworker_broadcast(RefCntBuffer *const buf, int row);
void vp10_frameworker_copy_context(VPxWorker *const dst_worker,
VPxWorker *const src_worker);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP10_DECODER_DTHREAD_H_

View File

@ -14,6 +14,10 @@
#include "vp10/common/blockd.h"
#include "vp10/encoder/block.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP10_COMP;
struct VP10Common;
struct ThreadData;
@ -84,4 +88,8 @@ typedef struct PC_TREE {
void vp10_setup_pc_tree(struct VP10Common *cm, struct ThreadData *td);
void vp10_free_pc_tree(struct ThreadData *td);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* VP10_ENCODER_CONTEXT_TREE_H_ */

View File

@ -3623,6 +3623,7 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi,
cpi->refresh_last_frame = 1;
cm->frame_to_show = get_frame_new_buffer(cm);
cm->frame_to_show->color_space = cm->color_space;
// Pick the loop filter level for the frame.
loopfilter_frame(cpi, cm);

View File

@ -11,6 +11,10 @@
#ifndef VP10_ENCODER_ETHREAD_H_
#define VP10_ENCODER_ETHREAD_H_
#ifdef __cplusplus
extern "C" {
#endif
struct VP10_COMP;
struct ThreadData;
@ -22,4 +26,8 @@ typedef struct EncWorkerData {
void vp10_encode_tiles_mt(struct VP10_COMP *cpi);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP10_ENCODER_ETHREAD_H_

View File

@ -14,6 +14,10 @@
#include <stdio.h>
#include "vpx/vpx_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
void vp10_resize_plane(const uint8_t *const input,
int height,
int width,
@ -121,4 +125,9 @@ void vp10_highbd_resize_frame444(const uint8_t *const y,
int owidth,
int bd);
#endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP10_ENCODER_RESIZE_H_

View File

@ -88,7 +88,8 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
(void)data;
if (!ctx->priv) {
vpx_codec_alg_priv_t *const priv = vpx_calloc(1, sizeof(*priv));
vpx_codec_alg_priv_t *const priv =
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
if (priv == NULL)
return VPX_CODEC_MEM_ERROR;

View File

@ -56,7 +56,7 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) {
// vpx_image_t uses byte strides and a pointer to the first byte
// of the image.
img->fmt |= VPX_IMG_FMT_HIGHBITDEPTH;
img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
img->bit_depth = yv12->bit_depth;
img->planes[VPX_PLANE_Y] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->y_buffer);
img->planes[VPX_PLANE_U] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->u_buffer);

View File

@ -14,6 +14,10 @@
#include "vp9/common/vp9_loopfilter.h"
#include "vpx_util/vpx_thread.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP9Common;
struct FRAME_COUNTS;
@ -54,4 +58,8 @@ void vp9_loop_filter_frame_mt(YV12_BUFFER_CONFIG *frame,
void vp9_accumulate_frame_counts(struct VP9Common *cm,
struct FRAME_COUNTS *counts, int is_dec);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP9_COMMON_VP9_LOOPFILTER_THREAD_H_

View File

@ -15,6 +15,10 @@
#include "vpx_util/vpx_thread.h"
#include "vpx/internal/vpx_codec_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP9Common;
struct VP9Decoder;
@ -63,4 +67,8 @@ void vp9_frameworker_broadcast(RefCntBuffer *const buf, int row);
void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
VPxWorker *const src_worker);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP9_DECODER_VP9_DTHREAD_H_

View File

@ -14,6 +14,10 @@
#include "vp9/common/vp9_blockd.h"
#include "vp9/encoder/vp9_block.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP9_COMP;
struct VP9Common;
struct ThreadData;
@ -84,4 +88,8 @@ typedef struct PC_TREE {
void vp9_setup_pc_tree(struct VP9Common *cm, struct ThreadData *td);
void vp9_free_pc_tree(struct ThreadData *td);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* VP9_ENCODER_VP9_CONTEXT_TREE_H_ */

View File

@ -3816,6 +3816,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->refresh_last_frame = 1;
cm->frame_to_show = get_frame_new_buffer(cm);
cm->frame_to_show->color_space = cm->color_space;
// Pick the loop filter level for the frame.
loopfilter_frame(cpi, cm);

View File

@ -11,6 +11,10 @@
#ifndef VP9_ENCODER_VP9_ETHREAD_H_
#define VP9_ENCODER_VP9_ETHREAD_H_
#ifdef __cplusplus
extern "C" {
#endif
struct VP9_COMP;
struct ThreadData;
@ -22,4 +26,8 @@ typedef struct EncWorkerData {
void vp9_encode_tiles_mt(struct VP9_COMP *cpi);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP9_ENCODER_VP9_ETHREAD_H_

View File

@ -14,6 +14,10 @@
#include <stdio.h>
#include "vpx/vpx_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
void vp9_resize_plane(const uint8_t *const input,
int height,
int width,
@ -121,4 +125,9 @@ void vp9_highbd_resize_frame444(const uint8_t *const y,
int owidth,
int bd);
#endif // CONFIG_VP9_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP9_ENCODER_VP9_RESIZE_H_

View File

@ -88,7 +88,8 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
(void)data;
if (!ctx->priv) {
vpx_codec_alg_priv_t *const priv = vpx_calloc(1, sizeof(*priv));
vpx_codec_alg_priv_t *const priv =
(vpx_codec_alg_priv_t *)vpx_calloc(1, sizeof(*priv));
if (priv == NULL)
return VPX_CODEC_MEM_ERROR;

View File

@ -56,7 +56,7 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) {
// vpx_image_t uses byte strides and a pointer to the first byte
// of the image.
img->fmt |= VPX_IMG_FMT_HIGHBITDEPTH;
img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
img->bit_depth = yv12->bit_depth;
img->planes[VPX_PLANE_Y] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->y_buffer);
img->planes[VPX_PLANE_U] = (uint8_t*)CONVERT_TO_SHORTPTR(yv12->u_buffer);