Commit d299e1bb authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Pass nullptr as user_priv to vpx_codec_decode.

Passing the address of a timestamp local variable as the user_priv
argument to vpx_codec_decode() merely verifies that
vpx_codec_get_frame() copies that value to the user_priv field of
vpx_image_t correctly. No other clients of libvpx that I've inspected do
this, including vpxdec.c, the sample decoder program.

BUG=chromium:899916

Change-Id: I65dfd479fa3634429c4b76285c257aa54d860d81
Reviewed-on: https://chromium-review.googlesource.com/c/1306413
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604104}
parent 9fa30d92
...@@ -295,14 +295,12 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer, ...@@ -295,14 +295,12 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer,
DCHECK(video_frame); DCHECK(video_frame);
DCHECK(!buffer->end_of_stream()); DCHECK(!buffer->end_of_stream());
int64_t timestamp = buffer->timestamp().InMicroseconds();
void* user_priv = reinterpret_cast<void*>(&timestamp);
{ {
TRACE_EVENT2("media", "vpx_codec_decode", "timestamp", timestamp, TRACE_EVENT1("media", "vpx_codec_decode", "buffer",
"buffer size (B)", buffer->data_size()); buffer->AsHumanReadableString());
vpx_codec_err_t status = vpx_codec_err_t status =
vpx_codec_decode(vpx_codec_.get(), buffer->data(), buffer->data_size(), vpx_codec_decode(vpx_codec_.get(), buffer->data(), buffer->data_size(),
user_priv, 0 /* deadline */); nullptr /* user_priv */, 0 /* deadline */);
if (status != VPX_CODEC_OK) { if (status != VPX_CODEC_OK) {
DLOG(ERROR) << "vpx_codec_decode() error: " DLOG(ERROR) << "vpx_codec_decode() error: "
<< vpx_codec_err_to_string(status); << vpx_codec_err_to_string(status);
...@@ -318,11 +316,6 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer, ...@@ -318,11 +316,6 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer,
return true; return true;
} }
if (vpx_image->user_priv != user_priv) {
DLOG(ERROR) << "Invalid output timestamp.";
return false;
}
const vpx_image_t* vpx_image_alpha = nullptr; const vpx_image_t* vpx_image_alpha = nullptr;
AlphaDecodeStatus alpha_decode_status = AlphaDecodeStatus alpha_decode_status =
DecodeAlphaPlane(vpx_image, &vpx_image_alpha, buffer); DecodeAlphaPlane(vpx_image, &vpx_image_alpha, buffer);
...@@ -344,7 +337,7 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer, ...@@ -344,7 +337,7 @@ bool VpxVideoDecoder::VpxDecode(const DecoderBuffer* buffer,
(*video_frame)->visible_rect().height()); (*video_frame)->visible_rect().height());
} }
(*video_frame)->set_timestamp(base::TimeDelta::FromMicroseconds(timestamp)); (*video_frame)->set_timestamp(buffer->timestamp());
// Default to the color space from the config, but if the bistream specifies // Default to the color space from the config, but if the bistream specifies
// one, prefer that instead. // one, prefer that instead.
...@@ -434,14 +427,13 @@ VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane( ...@@ -434,14 +427,13 @@ VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane(
// Try and decode buffer->side_data() minus the first 8 bytes as a full // Try and decode buffer->side_data() minus the first 8 bytes as a full
// frame. // frame.
int64_t timestamp_alpha = buffer->timestamp().InMicroseconds();
void* user_priv_alpha = reinterpret_cast<void*>(&timestamp_alpha);
{ {
TRACE_EVENT1("media", "vpx_codec_decode_alpha", "timestamp_alpha", TRACE_EVENT1("media", "vpx_codec_decode_alpha", "buffer",
timestamp_alpha); buffer->AsHumanReadableString());
vpx_codec_err_t status = vpx_codec_decode( vpx_codec_err_t status =
vpx_codec_alpha_.get(), buffer->side_data() + 8, vpx_codec_decode(vpx_codec_alpha_.get(), buffer->side_data() + 8,
buffer->side_data_size() - 8, user_priv_alpha, 0 /* deadline */); buffer->side_data_size() - 8, nullptr /* user_priv */,
0 /* deadline */);
if (status != VPX_CODEC_OK) { if (status != VPX_CODEC_OK) {
DLOG(ERROR) << "vpx_codec_decode() failed for the alpha: " DLOG(ERROR) << "vpx_codec_decode() failed for the alpha: "
<< vpx_codec_error(vpx_codec_.get()); << vpx_codec_error(vpx_codec_.get());
...@@ -455,11 +447,6 @@ VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane( ...@@ -455,11 +447,6 @@ VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane(
return kNoAlphaPlaneData; return kNoAlphaPlaneData;
} }
if ((*vpx_image_alpha)->user_priv != user_priv_alpha) {
DLOG(ERROR) << "Invalid output timestamp on alpha.";
return kAlphaPlaneError;
}
if ((*vpx_image_alpha)->d_h != vpx_image->d_h || if ((*vpx_image_alpha)->d_h != vpx_image->d_h ||
(*vpx_image_alpha)->d_w != vpx_image->d_w) { (*vpx_image_alpha)->d_w != vpx_image->d_w) {
DLOG(ERROR) << "The alpha plane dimensions are not the same as the " DLOG(ERROR) << "The alpha plane dimensions are not the same as the "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment