diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index 5dacab45460d74aa38643533219389ecb9c9aceb..fde73e4ab5cc5a3989ac358e154dc43dc01ab186 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -668,6 +668,25 @@ static vpx_codec_err_t get_frame_corrupted(vpx_codec_alg_priv_t *ctx, } } +static vpx_codec_err_t get_display_size(vpx_codec_alg_priv_t *ctx, + int ctrl_id, + va_list args) { + int *const display_size = va_arg(args, int *); + + if (display_size) { + const VP9D_COMP *const pbi = (VP9D_COMP *)ctx->pbi; + if (pbi) { + display_size[0] = pbi->common.display_width; + display_size[1] = pbi->common.display_height; + } else { + return VPX_CODEC_ERROR; + } + return VPX_CODEC_OK; + } else { + return VPX_CODEC_INVALID_PARAM; + } +} + static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx, int ctr_id, va_list args) { @@ -686,6 +705,7 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = { {VP8D_GET_LAST_REF_UPDATES, get_last_ref_updates}, {VP8D_GET_FRAME_CORRUPTED, get_frame_corrupted}, {VP9_GET_REFERENCE, get_reference}, + {VP9D_GET_DISPLAY_SIZE, get_display_size}, {VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order}, { -1, NULL}, }; diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h index d3093c48c5db9462f473d91fdaa6c7ddb1773e36..b457b9302b3559cc795258ccf9d0977ed6022e40 100644 --- a/vpx/vp8dx.h +++ b/vpx/vp8dx.h @@ -73,6 +73,9 @@ enum vp8_dec_control_id { */ VP8D_SET_DECRYPTOR, + /** control function to get the display dimensions for the current frame. */ + VP9D_GET_DISPLAY_SIZE, + /** For testing. */ VP9_INVERT_TILE_DECODE_ORDER, @@ -105,6 +108,7 @@ VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *) VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *) VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *) VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vp8_decrypt_init *) +VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *) VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int) /*! @} - end defgroup vp8_decoder */ diff --git a/vpxdec.c b/vpxdec.c index dc2eec826cbd793c56a5cd5d9d138c18eeb78deb..051a46106d0c6ffde0e2af1c3958e9a632e12362 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -426,7 +426,6 @@ int main_loop(int argc, const char **argv_) { int frames_corrupted = 0; int dec_flags = 0; int do_scale = 0; - int stream_w = 0, stream_h = 0; vpx_image_t *scaled_img = NULL; int frame_avail, got_data; @@ -771,9 +770,18 @@ int main_loop(int argc, const char **argv_) { } if (do_scale) { + int stream_w = 0, stream_h = 0; if (img && frame_out == 1) { - stream_w = img->d_w; - stream_h = img->d_h; + int display_size[2]; + if (vpx_codec_control(&decoder, VP9D_GET_DISPLAY_SIZE, + display_size)) { + // Fallback to use raw image size if display size not available. + stream_w = img->d_w; + stream_h = img->d_h; + } else { + stream_w = display_size[0]; + stream_h = display_size[1]; + } scaled_img = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, stream_w, stream_h, 16); } @@ -794,7 +802,6 @@ int main_loop(int argc, const char **argv_) { img = scaled_img; } } - if (img) { unsigned int y; char out_fn[PATH_MAX];