Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: media/filters/vpx_video_decoder.cc

Issue 773053002: media: Add tracing around VPx decoding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less tracing/add timestamps Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/vpx_video_decoder.h" 5 #include "media/filters/vpx_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/sys_byteorder.h" 20 #include "base/sys_byteorder.h"
20 #include "media/base/bind_to_current_loop.h" 21 #include "media/base/bind_to_current_loop.h"
21 #include "media/base/decoder_buffer.h" 22 #include "media/base/decoder_buffer.h"
22 #include "media/base/demuxer_stream.h" 23 #include "media/base/demuxer_stream.h"
23 #include "media/base/limits.h" 24 #include "media/base/limits.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 361 }
361 362
362 bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer, 363 bool VpxVideoDecoder::VpxDecode(const scoped_refptr<DecoderBuffer>& buffer,
363 scoped_refptr<VideoFrame>* video_frame) { 364 scoped_refptr<VideoFrame>* video_frame) {
364 DCHECK(video_frame); 365 DCHECK(video_frame);
365 DCHECK(!buffer->end_of_stream()); 366 DCHECK(!buffer->end_of_stream());
366 367
367 // Pass |buffer| to libvpx. 368 // Pass |buffer| to libvpx.
368 int64 timestamp = buffer->timestamp().InMicroseconds(); 369 int64 timestamp = buffer->timestamp().InMicroseconds();
369 void* user_priv = reinterpret_cast<void*>(&timestamp); 370 void* user_priv = reinterpret_cast<void*>(&timestamp);
371
372 TRACE_EVENT_BEGIN1("video", "vpx_codec_decode", "timestamp", timestamp);
DaleCurtis 2014/12/03 19:12:16 You can just use TRACE_EVENT_1() and scope it arou
Tom Finegan 2014/12/03 19:33:09 I thought the extra scoping was uglier. :) Done.
370 vpx_codec_err_t status = vpx_codec_decode(vpx_codec_, 373 vpx_codec_err_t status = vpx_codec_decode(vpx_codec_,
371 buffer->data(), 374 buffer->data(),
372 buffer->data_size(), 375 buffer->data_size(),
373 user_priv, 376 user_priv,
374 0); 377 0);
378 TRACE_EVENT_END1("video", "vpx_codec_decode", "timestamp", timestamp);
375 if (status != VPX_CODEC_OK) { 379 if (status != VPX_CODEC_OK) {
376 LOG(ERROR) << "vpx_codec_decode() failed, status=" << status; 380 LOG(ERROR) << "vpx_codec_decode() failed, status=" << status;
377 return false; 381 return false;
378 } 382 }
379 383
380 // Gets pointer to decoded data. 384 // Gets pointer to decoded data.
381 vpx_codec_iter_t iter = NULL; 385 vpx_codec_iter_t iter = NULL;
382 const vpx_image_t* vpx_image = vpx_codec_get_frame(vpx_codec_, &iter); 386 const vpx_image_t* vpx_image = vpx_codec_get_frame(vpx_codec_, &iter);
383 if (!vpx_image) { 387 if (!vpx_image) {
384 *video_frame = NULL; 388 *video_frame = NULL;
385 return true; 389 return true;
386 } 390 }
387 391
388 if (vpx_image->user_priv != reinterpret_cast<void*>(&timestamp)) { 392 if (vpx_image->user_priv != reinterpret_cast<void*>(&timestamp)) {
389 LOG(ERROR) << "Invalid output timestamp."; 393 LOG(ERROR) << "Invalid output timestamp.";
390 return false; 394 return false;
391 } 395 }
392 396
393 const vpx_image_t* vpx_image_alpha = NULL; 397 const vpx_image_t* vpx_image_alpha = NULL;
394 if (vpx_codec_alpha_ && buffer->side_data_size() >= 8) { 398 if (vpx_codec_alpha_ && buffer->side_data_size() >= 8) {
395 // Pass alpha data to libvpx. 399 // Pass alpha data to libvpx.
396 int64 timestamp_alpha = buffer->timestamp().InMicroseconds(); 400 int64 timestamp_alpha = buffer->timestamp().InMicroseconds();
397 void* user_priv_alpha = reinterpret_cast<void*>(&timestamp_alpha); 401 void* user_priv_alpha = reinterpret_cast<void*>(&timestamp_alpha);
398 402
399 // First 8 bytes of side data is side_data_id in big endian. 403 // First 8 bytes of side data is side_data_id in big endian.
400 const uint64 side_data_id = base::NetToHost64( 404 const uint64 side_data_id = base::NetToHost64(
401 *(reinterpret_cast<const uint64*>(buffer->side_data()))); 405 *(reinterpret_cast<const uint64*>(buffer->side_data())));
402 if (side_data_id == 1) { 406 if (side_data_id == 1) {
407 TRACE_EVENT_BEGIN1("video", "vpx_codec_decode_alpha",
DaleCurtis 2014/12/03 19:12:16 Ditto.
408 "timestamp_alpha", timestamp_alpha);
403 status = vpx_codec_decode(vpx_codec_alpha_, 409 status = vpx_codec_decode(vpx_codec_alpha_,
404 buffer->side_data() + 8, 410 buffer->side_data() + 8,
405 buffer->side_data_size() - 8, 411 buffer->side_data_size() - 8,
406 user_priv_alpha, 412 user_priv_alpha,
407 0); 413 0);
414 TRACE_EVENT_END1("video", "vpx_codec_decode_alpha",
415 "timestamp_alpha", timestamp_alpha);
408 416
409 if (status != VPX_CODEC_OK) { 417 if (status != VPX_CODEC_OK) {
410 LOG(ERROR) << "vpx_codec_decode() failed on alpha, status=" << status; 418 LOG(ERROR) << "vpx_codec_decode() failed on alpha, status=" << status;
411 return false; 419 return false;
412 } 420 }
413 421
414 // Gets pointer to decoded data. 422 // Gets pointer to decoded data.
415 vpx_codec_iter_t iter_alpha = NULL; 423 vpx_codec_iter_t iter_alpha = NULL;
416 vpx_image_alpha = vpx_codec_get_frame(vpx_codec_alpha_, &iter_alpha); 424 vpx_image_alpha = vpx_codec_get_frame(vpx_codec_alpha_, &iter_alpha);
417 if (!vpx_image_alpha) { 425 if (!vpx_image_alpha) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); 502 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get());
495 return; 503 return;
496 } 504 }
497 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], 505 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y],
498 vpx_image->stride[VPX_PLANE_Y], 506 vpx_image->stride[VPX_PLANE_Y],
499 vpx_image->d_h, 507 vpx_image->d_h,
500 video_frame->get()); 508 video_frame->get());
501 } 509 }
502 510
503 } // namespace media 511 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698