summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVenkatarama NG. Avadhani <venkatarama.avadhani@ittiam.com>2018-07-05 13:49:04 +0530
committerHarish Mahendrakar <harish.mahendrakar@ittiam.com>2018-07-20 18:18:29 +0000
commit37dc76657040eab5c1024995480a39f3716d26c7 (patch)
treeeac769a1033a971824d2de400cb5118592b61224
parente09e99aa14f10956ea3846982c5c815a18d5863e (diff)
downloadlibvpx-37dc76657040eab5c1024995480a39f3716d26c7.tar
libvpx-37dc76657040eab5c1024995480a39f3716d26c7.tar.gz
libvpx-37dc76657040eab5c1024995480a39f3716d26c7.tar.bz2
libvpx-37dc76657040eab5c1024995480a39f3716d26c7.zip
Add Flag to Enable Row Based MultiThreading
This commit adds a command line argument "--row-mt". Passing "--row-mt=1" will set the row_mt flag in the decoder context. This flag will be used to determine whether row-wise multi-threading path is to be taken when the row-wise multi-threading functions are added. Change-Id: I35a5393a2720254437daa5e796630709049e0bc2
-rw-r--r--vp9/decoder/vp9_decoder.h2
-rw-r--r--vp9/vp9_dx_iface.c24
-rw-r--r--vp9/vp9_dx_iface.h1
-rw-r--r--vpx/vp8dx.h10
-rw-r--r--vpxdec.c25
5 files changed, 54 insertions, 8 deletions
diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h
index 4b26c314d..5f22c00cb 100644
--- a/vp9/decoder/vp9_decoder.h
+++ b/vp9/decoder/vp9_decoder.h
@@ -72,6 +72,8 @@ typedef struct VP9Decoder {
int inv_tile_order;
int need_resync; // wait for key/intra-only frame.
int hold_ref_buf; // hold the reference buffer.
+
+ int row_mt;
} VP9Decoder;
int vp9_receive_compressed_data(struct VP9Decoder *pbi, size_t size,
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 657490f4b..ea3200fa5 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -235,6 +235,19 @@ static void set_ppflags(const vpx_codec_alg_priv_t *ctx, vp9_ppflags_t *flags) {
flags->noise_level = ctx->postproc_cfg.noise_level;
}
+#undef ERROR
+#define ERROR(str) \
+ do { \
+ ctx->base.err_detail = str; \
+ return VPX_CODEC_INVALID_PARAM; \
+ } while (0)
+
+#define RANGE_CHECK(p, memb, lo, hi) \
+ do { \
+ if (!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \
+ ERROR(#memb " out of range [" #lo ".." #hi "]"); \
+ } while (0)
+
static vpx_codec_err_t init_decoder(vpx_codec_alg_priv_t *ctx) {
ctx->last_show_frame = -1;
ctx->need_resync = 1;
@@ -251,6 +264,9 @@ static vpx_codec_err_t init_decoder(vpx_codec_alg_priv_t *ctx) {
ctx->pbi->max_threads = ctx->cfg.threads;
ctx->pbi->inv_tile_order = ctx->invert_tile_order;
+ RANGE_CHECK(ctx, row_mt, 0, 1);
+ ctx->pbi->row_mt = ctx->row_mt;
+
// If postprocessing was enabled by the application and a
// configuration has not been provided, default it.
if (!ctx->postproc_cfg_set && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC))
@@ -632,6 +648,13 @@ static vpx_codec_err_t ctrl_set_spatial_layer_svc(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_OK;
}
+static vpx_codec_err_t ctrl_set_row_mt(vpx_codec_alg_priv_t *ctx,
+ va_list args) {
+ ctx->row_mt = va_arg(args, int);
+
+ return VPX_CODEC_OK;
+}
+
static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
{ VP8_COPY_REFERENCE, ctrl_copy_reference },
@@ -643,6 +666,7 @@ static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
{ VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment },
{ VP9_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
{ VP9_DECODE_SVC_SPATIAL_LAYER, ctrl_set_spatial_layer_svc },
+ { VP9D_SET_ROW_MT, ctrl_set_row_mt },
// Getters
{ VPXD_GET_LAST_QUANTIZER, ctrl_get_quantizer },
diff --git a/vp9/vp9_dx_iface.h b/vp9/vp9_dx_iface.h
index 18bc7ab0d..6a101b03d 100644
--- a/vp9/vp9_dx_iface.h
+++ b/vp9/vp9_dx_iface.h
@@ -45,6 +45,7 @@ struct vpx_codec_alg_priv {
// Allow for decoding up to a given spatial layer for SVC stream.
int svc_decoding;
int svc_spatial_layer;
+ int row_mt;
};
#endif // VP9_VP9_DX_IFACE_H_
diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h
index 398c67022..d0e39ef01 100644
--- a/vpx/vp8dx.h
+++ b/vpx/vp8dx.h
@@ -124,6 +124,14 @@ enum vp8_dec_control_id {
*/
VPXD_GET_LAST_QUANTIZER,
+ /*!\brief Codec control function to set row level multi-threading.
+ *
+ * 0 : off, 1 : on
+ *
+ * Supported in codecs: VP9
+ */
+ VP9D_SET_ROW_MT,
+
VP8_DECODER_CTRL_ID_MAX
};
@@ -181,6 +189,8 @@ VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
+#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
+VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
/*!\endcond */
/*! @} - end defgroup vp8_decoder */
diff --git a/vpxdec.c b/vpxdec.c
index 5c76e109d..26c475293 100644
--- a/vpxdec.c
+++ b/vpxdec.c
@@ -98,19 +98,20 @@ static const arg_def_t svcdecodingarg = ARG_DEF(
NULL, "svc-decode-layer", 1, "Decode SVC stream up to given spatial layer");
static const arg_def_t framestatsarg =
ARG_DEF(NULL, "framestats", 1, "Output per-frame stats (.csv format)");
+static const arg_def_t rowmtarg =
+ ARG_DEF(NULL, "row-mt", 1, "Enable multi-threading to run row-wise");
static const arg_def_t *all_args[] = {
- &help, &codecarg, &use_yv12,
- &use_i420, &flipuvarg, &rawvideo,
- &noblitarg, &progressarg, &limitarg,
- &skiparg, &postprocarg, &summaryarg,
- &outputfile, &threadsarg, &frameparallelarg,
- &verbosearg, &scalearg, &fb_arg,
- &md5arg, &error_concealment, &continuearg,
+ &help, &codecarg, &use_yv12, &use_i420,
+ &flipuvarg, &rawvideo, &noblitarg, &progressarg,
+ &limitarg, &skiparg, &postprocarg, &summaryarg,
+ &outputfile, &threadsarg, &frameparallelarg, &verbosearg,
+ &scalearg, &fb_arg, &md5arg, &error_concealment,
+ &continuearg,
#if CONFIG_VP9_HIGHBITDEPTH
&outbitdeptharg,
#endif
- &svcdecodingarg, &framestatsarg, NULL
+ &svcdecodingarg, &framestatsarg, &rowmtarg, NULL
};
#if CONFIG_VP8_DECODER
@@ -507,6 +508,7 @@ static int main_loop(int argc, const char **argv_) {
int arg_skip = 0;
int ec_enabled = 0;
int keep_going = 0;
+ int enable_row_mt = 0;
const VpxInterface *interface = NULL;
const VpxInterface *fourcc_interface = NULL;
uint64_t dx_time = 0;
@@ -629,6 +631,8 @@ static int main_loop(int argc, const char **argv_) {
die("Error: Could not open --framestats file (%s) for writing.\n",
arg.val);
}
+ } else if (arg_match(&arg, &rowmtarg, argi)) {
+ enable_row_mt = arg_parse_uint(&arg);
}
#if CONFIG_VP8_DECODER
else if (arg_match(&arg, &addnoise_level, argi)) {
@@ -754,6 +758,11 @@ static int main_loop(int argc, const char **argv_) {
goto fail;
}
}
+ if (vpx_codec_control(&decoder, VP9D_SET_ROW_MT, enable_row_mt)) {
+ fprintf(stderr, "Failed to set decoder in row multi-thread mode: %s\n",
+ vpx_codec_error(&decoder));
+ goto fail;
+ }
if (!quiet) fprintf(stderr, "%s\n", decoder.name);
#if CONFIG_VP8_DECODER