Commit b3363561 authored by hkuang's avatar hkuang
Browse files

Revert "Revert 3 patches from Hangyu to get Chrome to build:"

This patch reverts the previous revert from Jim and also add a
variable user_priv in the FrameWorker to save the user_priv
passed from the application. In the decoder_get_frame function,
the user_priv will be binded with the img. This change is needed
or it will fail the unit test added here:
https://gerrit.chromium.org/gerrit/#/c/70610/

This reverts commit 9be46e45.

Change-Id: I376d9a12ee196faffdf3c792b59e6137c56132c1
parent 5e7242df
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <string> #include <string>
#include "third_party/googletest/src/include/gtest/gtest.h" #include "third_party/googletest/src/include/gtest/gtest.h"
#include "./vpx_config.h" #include "./vpx_config.h"
#include "test/acm_random.h"
#include "test/codec_factory.h" #include "test/codec_factory.h"
#include "test/decode_test_driver.h" #include "test/decode_test_driver.h"
#include "test/ivf_video_source.h" #include "test/ivf_video_source.h"
...@@ -22,17 +23,27 @@ ...@@ -22,17 +23,27 @@
#include "test/webm_video_source.h" #include "test/webm_video_source.h"
#endif #endif
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx/vp8.h"
namespace { namespace {
using std::string; using std::string;
using libvpx_test::ACMRandom;
#if CONFIG_WEBM_IO #if CONFIG_WEBM_IO
void CheckUserPrivateData(void *user_priv, int *target) {
// actual pointer value should be the same as expected.
EXPECT_EQ(reinterpret_cast<void *>(target), user_priv) <<
"user_priv pointer value does not match.";
}
// Decodes |filename|. Passes in user_priv data when calling DecodeFrame and // Decodes |filename|. Passes in user_priv data when calling DecodeFrame and
// compares the user_priv from return img with the original user_priv to see if // compares the user_priv from return img with the original user_priv to see if
// they match. Both the pointer values and the values inside the addresses // they match. Both the pointer values and the values inside the addresses
// should match. // should match.
string DecodeFile(const string &filename) { string DecodeFile(const string &filename) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
libvpx_test::WebMVideoSource video(filename); libvpx_test::WebMVideoSource video(filename);
video.Init(); video.Init();
...@@ -41,7 +52,8 @@ string DecodeFile(const string &filename) { ...@@ -41,7 +52,8 @@ string DecodeFile(const string &filename) {
libvpx_test::MD5 md5; libvpx_test::MD5 md5;
int frame_num = 0; int frame_num = 0;
for (video.Begin(); video.cxdata(); video.Next()) { for (video.Begin(); !::testing::Test::HasFailure() && video.cxdata();
video.Next()) {
void *user_priv = reinterpret_cast<void *>(&frame_num); void *user_priv = reinterpret_cast<void *>(&frame_num);
const vpx_codec_err_t res = const vpx_codec_err_t res =
decoder.DecodeFrame(video.cxdata(), video.frame_size(), decoder.DecodeFrame(video.cxdata(), video.frame_size(),
...@@ -56,16 +68,17 @@ string DecodeFile(const string &filename) { ...@@ -56,16 +68,17 @@ string DecodeFile(const string &filename) {
// Get decompressed data. // Get decompressed data.
while ((img = dec_iter.Next())) { while ((img = dec_iter.Next())) {
if (frame_num == 0) { if (frame_num == 0) {
// user_priv pointer value should be the same. CheckUserPrivateData(img->user_priv, NULL);
EXPECT_EQ(img->user_priv, reinterpret_cast<void *>(NULL)) <<
"user_priv pointer value does not match.";
} else { } else {
// user_priv pointer value should be the same. CheckUserPrivateData(img->user_priv, &frame_num);
EXPECT_EQ(img->user_priv, reinterpret_cast<void *>(&frame_num)) <<
"user_priv pointer value does not match."; // Also test ctrl_get_reference api.
// value in user_priv pointer should also be the same. struct vp9_ref_frame ref;
EXPECT_EQ(*reinterpret_cast<int *>(img->user_priv), frame_num) << // Randomly fetch a reference frame.
"Value in user_priv does not match."; ref.idx = rnd.Rand8() % 3;
decoder.Control(VP9_GET_REFERENCE, &ref);
CheckUserPrivateData(ref.img.user_priv, &frame_num);
} }
md5.Add(img); md5.Add(img);
} }
......
...@@ -210,7 +210,10 @@ static void swap_frame_buffers(VP9Decoder *pbi) { ...@@ -210,7 +210,10 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
} }
cm->frame_to_show = get_frame_new_buffer(cm); cm->frame_to_show = get_frame_new_buffer(cm);
cm->frame_bufs[cm->new_fb_idx].ref_count--;
if (!pbi->frame_parallel_decode || !cm->show_frame) {
--cm->frame_bufs[cm->new_fb_idx].ref_count;
}
// Invalidate these references until the next frame starts. // Invalidate these references until the next frame starts.
for (ref_index = 0; ref_index < 3; ref_index++) for (ref_index = 0; ref_index < 3; ref_index++)
...@@ -239,7 +242,9 @@ int vp9_receive_compressed_data(VP9Decoder *pbi, ...@@ -239,7 +242,9 @@ int vp9_receive_compressed_data(VP9Decoder *pbi,
} }
// Check if the previous frame was a frame without any references to it. // Check if the previous frame was a frame without any references to it.
if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0) // Release frame buffer if not decoding in frame parallel mode.
if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0
&& cm->frame_bufs[cm->new_fb_idx].ref_count == 0)
cm->release_fb_cb(cm->cb_priv, cm->release_fb_cb(cm->cb_priv,
&cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer); &cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer);
cm->new_fb_idx = get_free_fb(cm); cm->new_fb_idx = get_free_fb(cm);
......
...@@ -40,6 +40,23 @@ typedef struct VP9LfSyncData { ...@@ -40,6 +40,23 @@ typedef struct VP9LfSyncData {
int sync_range; int sync_range;
} VP9LfSync; } VP9LfSync;
// WorkerData for the FrameWorker thread. It contains all the information of
// the worker and decode structures for decoding a frame.
typedef struct FrameWorkerData {
struct VP9Decoder *pbi;
const uint8_t *data;
const uint8_t *data_end;
size_t data_size;
void *user_priv;
int result;
int worker_id;
// scratch_buffer is used in frame parallel mode only.
// It is used to make a copy of the compressed data.
uint8_t *scratch_buffer;
size_t scratch_buffer_size;
} FrameWorkerData;
// Allocate memory for loopfilter row synchronization. // Allocate memory for loopfilter row synchronization.
void vp9_loop_filter_alloc(struct VP9Common *cm, VP9LfSync *lf_sync, void vp9_loop_filter_alloc(struct VP9Common *cm, VP9LfSync *lf_sync,
int rows, int width); int rows, int width);
......
...@@ -32,15 +32,19 @@ struct vpx_codec_alg_priv { ...@@ -32,15 +32,19 @@ struct vpx_codec_alg_priv {
vpx_codec_priv_t base; vpx_codec_priv_t base;
vpx_codec_dec_cfg_t cfg; vpx_codec_dec_cfg_t cfg;
vp9_stream_info_t si; vp9_stream_info_t si;
struct VP9Decoder *pbi;
int postproc_cfg_set; int postproc_cfg_set;
vp8_postproc_cfg_t postproc_cfg; vp8_postproc_cfg_t postproc_cfg;
vpx_decrypt_cb decrypt_cb; vpx_decrypt_cb decrypt_cb;
void *decrypt_state; void *decrypt_state;
vpx_image_t img; vpx_image_t img;
int img_avail;
int invert_tile_order; int invert_tile_order;
int frame_parallel_decode; // frame-based threading. int frame_parallel_decode; // frame-based threading.
int last_show_frame; // Index of last output frame.
VP9Worker *frame_workers;
int num_frame_workers;
int next_submit_thread_id;
int next_output_thread_id;
// External frame buffer info to save for VP9 common. // External frame buffer info to save for VP9 common.
void *ext_priv; // Private data associated with the external frame buffers. void *ext_priv; // Private data associated with the external frame buffers.
...@@ -85,11 +89,17 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx, ...@@ -85,11 +89,17 @@ static vpx_codec_err_t decoder_init(vpx_codec_ctx_t *ctx,
} }
static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) { static vpx_codec_err_t decoder_destroy(vpx_codec_alg_priv_t *ctx) {
if (ctx->pbi) { if (ctx->frame_workers != NULL) {
vp9_decoder_remove(ctx->pbi); int i;
ctx->pbi = NULL; for (i = 0; i < ctx->num_frame_workers; ++i) {
VP9Worker *const worker = &ctx->frame_workers[i];
FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
vp9_decoder_remove(worker_data->pbi);
vpx_free(worker_data);
}
} }
vpx_free(ctx->frame_workers);
vpx_free(ctx); vpx_free(ctx);
return VPX_CODEC_OK; return VPX_CODEC_OK;
...@@ -188,32 +198,42 @@ static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx, ...@@ -188,32 +198,42 @@ static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_OK; return VPX_CODEC_OK;
} }
static void set_error_detail(vpx_codec_alg_priv_t *ctx,
const char *const error) {
ctx->base.err_detail = error;
}
static vpx_codec_err_t update_error_state(vpx_codec_alg_priv_t *ctx, static vpx_codec_err_t update_error_state(vpx_codec_alg_priv_t *ctx,
const struct vpx_internal_error_info *error) { const struct vpx_internal_error_info *error) {
if (error->error_code) if (error->error_code)
ctx->base.err_detail = error->has_detail ? error->detail : NULL; set_error_detail(ctx, error->has_detail ? error->detail : NULL);
return error->error_code; return error->error_code;
} }
static void init_buffer_callbacks(vpx_codec_alg_priv_t *ctx) { static void init_buffer_callbacks(vpx_codec_alg_priv_t *ctx) {
VP9_COMMON *const cm = &ctx->pbi->common; int i;
cm->new_fb_idx = -1; for (i = 0; i < ctx->num_frame_workers; ++i) {
VP9Worker *const worker = &ctx->frame_workers[i];
if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) { FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
cm->get_fb_cb = ctx->get_ext_fb_cb; VP9_COMMON *const cm = &worker_data->pbi->common;
cm->release_fb_cb = ctx->release_ext_fb_cb;
cm->cb_priv = ctx->ext_priv; cm->new_fb_idx = -1;
} else { if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) {
cm->get_fb_cb = vp9_get_frame_buffer; cm->get_fb_cb = ctx->get_ext_fb_cb;
cm->release_fb_cb = vp9_release_frame_buffer; cm->release_fb_cb = ctx->release_ext_fb_cb;
cm->cb_priv = ctx->ext_priv;
} else {
cm->get_fb_cb = vp9_get_frame_buffer;
cm->release_fb_cb = vp9_release_frame_buffer;
if (vp9_alloc_internal_frame_buffers(&cm->int_frame_buffers)) if (vp9_alloc_internal_frame_buffers(&cm->int_frame_buffers))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to initialize internal frame buffers"); "Failed to initialize internal frame buffers");
cm->cb_priv = &cm->int_frame_buffers; cm->cb_priv = &cm->int_frame_buffers;
}
} }
} }
...@@ -232,14 +252,58 @@ static void set_ppflags(const vpx_codec_alg_priv_t *ctx, ...@@ -232,14 +252,58 @@ static void set_ppflags(const vpx_codec_alg_priv_t *ctx,
flags->noise_level = ctx->postproc_cfg.noise_level; flags->noise_level = ctx->postproc_cfg.noise_level;
} }
static void init_decoder(vpx_codec_alg_priv_t *ctx) { static int frame_worker_hook(void *arg1, void *arg2) {
ctx->pbi = vp9_decoder_create(); FrameWorkerData *const worker_data = (FrameWorkerData *)arg1;
if (ctx->pbi == NULL) const uint8_t *data = worker_data->data;
return; (void)arg2;
worker_data->result = vp9_receive_compressed_data(worker_data->pbi,
worker_data->data_size,
&data);
worker_data->data_end = data;
return !worker_data->result;
}
static vpx_codec_err_t init_decoder(vpx_codec_alg_priv_t *ctx) {
int i;
ctx->last_show_frame = -1;
ctx->next_submit_thread_id = 0;
ctx->next_output_thread_id = 0;
ctx->num_frame_workers =
(ctx->frame_parallel_decode == 1) ? ctx->cfg.threads: 1;
ctx->pbi->max_threads = ctx->cfg.threads; ctx->frame_workers = (VP9Worker *)
ctx->pbi->inv_tile_order = ctx->invert_tile_order; vpx_malloc(ctx->num_frame_workers * sizeof(*ctx->frame_workers));
ctx->pbi->frame_parallel_decode = ctx->frame_parallel_decode; if (ctx->frame_workers == NULL) {
set_error_detail(ctx, "Failed to allocate frame_workers");
return VPX_CODEC_MEM_ERROR;
}
for (i = 0; i < ctx->num_frame_workers; ++i) {
VP9Worker *const worker = &ctx->frame_workers[i];
FrameWorkerData *worker_data = NULL;
vp9_worker_init(worker);
worker->data1 = vpx_memalign(32, sizeof(FrameWorkerData));
if (worker->data1 == NULL) {
set_error_detail(ctx, "Failed to allocate worker_data");
return VPX_CODEC_MEM_ERROR;
}
worker_data = (FrameWorkerData *)worker->data1;
worker_data->pbi = vp9_decoder_create();
if (worker_data->pbi == NULL) {
set_error_detail(ctx, "Failed to allocate worker_data");
return VPX_CODEC_MEM_ERROR;
}
// If decoding in serial mode, FrameWorker thread could create tile worker
// thread or loopfilter thread.
worker_data->pbi->max_threads =
(ctx->frame_parallel_decode == 0) ? ctx->cfg.threads : 0;
worker_data->pbi->inv_tile_order = ctx->invert_tile_order;
worker_data->pbi->frame_parallel_decode = ctx->frame_parallel_decode;
worker->hook = (VP9WorkerHook)frame_worker_hook;
}
// If postprocessing was enabled by the application and a // If postprocessing was enabled by the application and a
// configuration has not been provided, default it. // configuration has not been provided, default it.
...@@ -248,20 +312,16 @@ static void init_decoder(vpx_codec_alg_priv_t *ctx) { ...@@ -248,20 +312,16 @@ static void init_decoder(vpx_codec_alg_priv_t *ctx) {
set_default_ppflags(&ctx->postproc_cfg); set_default_ppflags(&ctx->postproc_cfg);
init_buffer_callbacks(ctx); init_buffer_callbacks(ctx);
return VPX_CODEC_OK;
} }
static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx, static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
const uint8_t **data, unsigned int data_sz, const uint8_t **data, unsigned int data_sz,
void *user_priv, int64_t deadline) { void *user_priv, int64_t deadline) {
YV12_BUFFER_CONFIG sd; vp9_ppflags_t flags = {0};
vp9_ppflags_t flags = {0, 0, 0};
VP9_COMMON *cm = NULL;
(void)deadline; (void)deadline;
vp9_zero(sd);
ctx->img_avail = 0;
// Determine the stream parameters. Note that we rely on peek_si to // Determine the stream parameters. Note that we rely on peek_si to
// validate that we have a buffer that does not wrap around the top // validate that we have a buffer that does not wrap around the top
// of the heap. // of the heap.
...@@ -276,33 +336,39 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx, ...@@ -276,33 +336,39 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_ERROR; return VPX_CODEC_ERROR;
} }
// Initialize the decoder instance on the first frame // Initialize the decoder workers on the first frame
if (ctx->pbi == NULL) { if (ctx->frame_workers == NULL) {
init_decoder(ctx); const vpx_codec_err_t res = init_decoder(ctx);
if (ctx->pbi == NULL) if (res != VPX_CODEC_OK)
return VPX_CODEC_ERROR; return res;
} }
// Set these even if already initialized. The caller may have changed the if (!ctx->frame_parallel_decode) {
// decrypt config between frames. VP9Worker *const worker = ctx->frame_workers;
ctx->pbi->decrypt_cb = ctx->decrypt_cb; FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
ctx->pbi->decrypt_state = ctx->decrypt_state; worker_data->data = *data;
worker_data->data_size = data_sz;
worker_data->user_priv = user_priv;
cm = &ctx->pbi->common; // Set these even if already initialized. The caller may have changed the
// decrypt config between frames.
worker_data->pbi->decrypt_cb = ctx->decrypt_cb;
worker_data->pbi->decrypt_state = ctx->decrypt_state;
if (vp9_receive_compressed_data(ctx->pbi, data_sz, data)) vp9_worker_execute(worker);
return update_error_state(ctx, &cm->error); if (worker->had_error)
return update_error_state(ctx, &worker_data->pbi->common.error);
// Update data pointer after decode.
*data = worker_data->data_end;
} else {
// TODO(hkuang): Implement frame parallel decode.
return VPX_CODEC_INCAPABLE;
}
if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC) if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)
set_ppflags(ctx, &flags); set_ppflags(ctx, &flags);
if (vp9_get_raw_frame(ctx->pbi, &sd, &flags))
return update_error_state(ctx, &cm->error);
yuvconfig2image(&ctx->img, &sd, user_priv);
ctx->img.fb_priv = cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
ctx->img_avail = 1;
return VPX_CODEC_OK; return VPX_CODEC_OK;
} }
...@@ -412,7 +478,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx, ...@@ -412,7 +478,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
vpx_codec_err_t res; vpx_codec_err_t res;
if (data_start < data if (data_start < data
|| frame_size > (uint32_t) (data_end - data_start)) { || frame_size > (uint32_t) (data_end - data_start)) {
ctx->base.err_detail = "Invalid frame size in index"; set_error_detail(ctx, "Invalid frame size in index");
return VPX_CODEC_CORRUPT_FRAME; return VPX_CODEC_CORRUPT_FRAME;
} }
...@@ -430,7 +496,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx, ...@@ -430,7 +496,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
// Extra data detected after the frame. // Extra data detected after the frame.
if (data_start < data_end - 1) { if (data_start < data_end - 1) {
ctx->base.err_detail = "Fail to decode frame in parallel mode"; set_error_detail(ctx, "Fail to decode frame in parallel mode");
return VPX_CODEC_INCAPABLE; return VPX_CODEC_INCAPABLE;
} }
} }
...@@ -445,7 +511,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx, ...@@ -445,7 +511,7 @@ static vpx_codec_err_t decoder_decode(vpx_codec_alg_priv_t *ctx,
vpx_codec_err_t res; vpx_codec_err_t res;
if (data_start < data if (data_start < data
|| frame_size > (uint32_t) (data_end - data_start)) { || frame_size > (uint32_t) (data_end - data_start)) {
ctx->base.err_detail = "Invalid frame size in index"; set_error_detail(ctx, "Invalid frame size in index");
return VPX_CODEC_CORRUPT_FRAME; return VPX_CODEC_CORRUPT_FRAME;
} }
...@@ -483,15 +549,31 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx, ...@@ -483,15 +549,31 @@ static vpx_image_t *decoder_get_frame(vpx_codec_alg_priv_t *ctx,
vpx_codec_iter_t *iter) { vpx_codec_iter_t *iter) {
vpx_image_t *img = NULL; vpx_image_t *img = NULL;
if (ctx->img_avail) { // iter acts as a flip flop, so an image is only returned on the first
// iter acts as a flip flop, so an image is only returned on the first // call to get_frame.
// call to get_frame. if (*iter == NULL && ctx->frame_workers != NULL) {
if (!(*iter)) { YV12_BUFFER_CONFIG sd;
vp9_ppflags_t flags = {0, 0, 0};
VP9Worker *const worker = &ctx->frame_workers[ctx->next_output_thread_id];
FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
if (vp9_get_raw_frame(worker_data->pbi, &sd, &flags) == 0) {
VP9_COMMON *const cm = &worker_data->pbi->common;
yuvconfig2image(&ctx->img, &sd, worker_data->user_priv);
ctx->img.fb_priv = cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
img = &ctx->img; img = &ctx->img;
*iter = img; *iter = img;
// Decrease reference count of last output frame in frame parallel mode.
if (ctx->frame_parallel_decode && ctx->last_show_frame >= 0) {
--cm->frame_bufs[ctx->last_show_frame].ref_count;
if (cm->frame_bufs[ctx->last_show_frame].ref_count == 0) {
cm->release_fb_cb(cm->cb_priv,
&cm->frame_bufs[ctx->last_show_frame].raw_frame_buffer);
}
}
ctx->last_show_frame = worker_data->pbi->common.new_fb_idx;
} }
} }
ctx->img_avail = 0;
return img; return img;
} }
...@@ -502,7 +584,7 @@ static vpx_codec_err_t decoder_set_fb_fn( ...@@ -502,7 +584,7 @@ static vpx_codec_err_t decoder_set_fb_fn(
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) { vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv) {
if (cb_get == NULL || cb_release == NULL) { if (cb_get == NULL || cb_release == NULL) {
return VPX_CODEC_INVALID_PARAM; return VPX_CODEC_INVALID_PARAM;
} else if (ctx->pbi == NULL) { } else if (ctx->frame_workers == NULL) {
// If the decoder has already been initialized, do not accept changes to // If the decoder has already been initialized, do not accept changes to
// the frame buffer functions. // the frame buffer functions.
ctx->get_ext_fb_cb = cb_get; ctx->get_ext_fb_cb = cb_get;
...@@ -518,12 +600,19 @@ static vpx_codec_err_t ctrl_set_reference(vpx_codec_alg_priv_t *ctx, ...@@ -518,12 +600,19 @@ static vpx_codec_err_t ctrl_set_reference(vpx_codec_alg_priv_t *ctx,
va_list args) { va_list args) {
vpx_ref_frame_t *const data = va_arg(args, vpx_ref_frame_t *); vpx_ref_frame_t *const data = va_arg(args, vpx_ref_frame_t *);
// Only support this function in serial decode.
if (ctx->frame_parallel_decode) {
set_error_detail(ctx, "Not supported in frame parallel decode");
return VPX_CODEC_INCAPABLE;
}
if (data) { if (data) {
vpx_ref_frame_t *const frame = (vpx_ref_frame_t *)data; vpx_ref_frame_t *const frame = (vpx_ref_frame_t *)data;
YV12_BUFFER_CONFIG sd; YV12_BUFFER_CONFIG sd;
VP9Worker *const worker = ctx->frame_workers;
FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
image2yuvconfig(&frame->img, &sd); image2yuvconfig(&frame->img, &sd);
return vp9_set_reference_dec(&ctx->pbi->common, return vp9_set_reference_dec(&worker_data->pbi->common,
(VP9_REFFRAME)frame->frame_type, &sd); (VP9_REFFRAME)frame->frame_type, &sd);
} else { } else {
return VPX_CODEC_INVALID_PARAM; return VPX_CODEC_INVALID_PARAM;
...@@ -534,13 +623,19 @@ static vpx_codec_err_t ctrl_copy_reference(vpx_codec_alg_priv_t *ctx, ...@@ -534,13 +623,19 @@ static vpx_codec_err_t ctrl_copy_reference(vpx_codec_alg_priv_t *ctx,
va_list args) { va_list args) {
vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
// Only support this function in serial decode.
if (ctx->frame_parallel_decode) {
set_error_detail(ctx, "Not supported in frame parallel decode");
return VPX_CODEC_INCAPABLE;
}
if (data) { if (data) {
vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data; vpx_ref_frame_t *frame = (vpx_ref_frame_t *) data;
YV12_BUFFER_CONFIG sd; YV12_BUFFER_CONFIG sd;
VP9Worker *const worker = ctx->frame_workers;
FrameWorkerData *const worker_data = (FrameWorkerData *)worker->data1;
image2yuvconfig(&frame->img, &sd); image2yuvconfig(&frame->img, &sd);
return vp9_copy_reference_dec(worker_data->pbi,
return vp9_copy_reference_dec(ctx->pbi,
(VP9_REFFRAME)frame->frame_type, &sd); (VP9_REFFRAME)frame->frame_type, &sd);
} else { } else {
return VPX_CODEC_INVALID_PARAM; return VPX_CODEC_INVALID_PARAM;
...@@ -551,11 +646,18 @@ static vpx_codec_err_t ctrl_get_reference(vpx_codec_alg_priv_t *ctx, ...@@ -551,11 +646,18 @@ static vpx_codec_err_t ctrl_get_reference(vpx_codec_alg_priv_t *ctx,
va_list args) { <