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

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: 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 355 }
355 356
356 base::ResetAndReturn(&decode_cb_).Run(kOk); 357 base::ResetAndReturn(&decode_cb_).Run(kOk);
357 358
358 if (video_frame.get()) 359 if (video_frame.get())
359 output_cb_.Run(video_frame); 360 output_cb_.Run(video_frame);
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) {
365 TRACE_EVENT0("video", "VpxDecode");
fgalligan1 2014/12/03 18:29:56 Is this needed?
Tom Finegan 2014/12/03 18:51:39 This tracked the entire VpxDecode() call. Removed.
364 DCHECK(video_frame); 366 DCHECK(video_frame);
365 DCHECK(!buffer->end_of_stream()); 367 DCHECK(!buffer->end_of_stream());
366 368
367 // Pass |buffer| to libvpx. 369 // Pass |buffer| to libvpx.
368 int64 timestamp = buffer->timestamp().InMicroseconds(); 370 int64 timestamp = buffer->timestamp().InMicroseconds();
369 void* user_priv = reinterpret_cast<void*>(&timestamp); 371 void* user_priv = reinterpret_cast<void*>(&timestamp);
372
373 TRACE_EVENT_BEGIN0("video", "vpx_codec_decode");
fgalligan1 2014/12/03 18:29:56 Maybe add the timestamp so we could distinguish th
Tom Finegan 2014/12/03 18:51:39 Done.
370 vpx_codec_err_t status = vpx_codec_decode(vpx_codec_, 374 vpx_codec_err_t status = vpx_codec_decode(vpx_codec_,
371 buffer->data(), 375 buffer->data(),
372 buffer->data_size(), 376 buffer->data_size(),
373 user_priv, 377 user_priv,
374 0); 378 0);
379 TRACE_EVENT_END0("video", "vpx_codec_decode");
375 if (status != VPX_CODEC_OK) { 380 if (status != VPX_CODEC_OK) {
376 LOG(ERROR) << "vpx_codec_decode() failed, status=" << status; 381 LOG(ERROR) << "vpx_codec_decode() failed, status=" << status;
377 return false; 382 return false;
378 } 383 }
379 384
380 // Gets pointer to decoded data. 385 // Gets pointer to decoded data.
381 vpx_codec_iter_t iter = NULL; 386 vpx_codec_iter_t iter = NULL;
387 TRACE_EVENT_BEGIN0("video", "vpx_codec_get_frame");
fgalligan1 2014/12/03 18:29:56 I think we can get rid of these. They should prett
Tom Finegan 2014/12/03 18:51:39 Done.
382 const vpx_image_t* vpx_image = vpx_codec_get_frame(vpx_codec_, &iter); 388 const vpx_image_t* vpx_image = vpx_codec_get_frame(vpx_codec_, &iter);
389 TRACE_EVENT_END0("video", "vpx_codec_get_frame");
383 if (!vpx_image) { 390 if (!vpx_image) {
384 *video_frame = NULL; 391 *video_frame = NULL;
385 return true; 392 return true;
386 } 393 }
387 394
388 if (vpx_image->user_priv != reinterpret_cast<void*>(&timestamp)) { 395 if (vpx_image->user_priv != reinterpret_cast<void*>(&timestamp)) {
389 LOG(ERROR) << "Invalid output timestamp."; 396 LOG(ERROR) << "Invalid output timestamp.";
390 return false; 397 return false;
391 } 398 }
392 399
393 const vpx_image_t* vpx_image_alpha = NULL; 400 const vpx_image_t* vpx_image_alpha = NULL;
394 if (vpx_codec_alpha_ && buffer->side_data_size() >= 8) { 401 if (vpx_codec_alpha_ && buffer->side_data_size() >= 8) {
395 // Pass alpha data to libvpx. 402 // Pass alpha data to libvpx.
396 int64 timestamp_alpha = buffer->timestamp().InMicroseconds(); 403 int64 timestamp_alpha = buffer->timestamp().InMicroseconds();
397 void* user_priv_alpha = reinterpret_cast<void*>(&timestamp_alpha); 404 void* user_priv_alpha = reinterpret_cast<void*>(&timestamp_alpha);
398 405
399 // First 8 bytes of side data is side_data_id in big endian. 406 // First 8 bytes of side data is side_data_id in big endian.
400 const uint64 side_data_id = base::NetToHost64( 407 const uint64 side_data_id = base::NetToHost64(
401 *(reinterpret_cast<const uint64*>(buffer->side_data()))); 408 *(reinterpret_cast<const uint64*>(buffer->side_data())));
402 if (side_data_id == 1) { 409 if (side_data_id == 1) {
410 TRACE_EVENT_BEGIN0("video", "vpx_codec_decode_alpha");
403 status = vpx_codec_decode(vpx_codec_alpha_, 411 status = vpx_codec_decode(vpx_codec_alpha_,
404 buffer->side_data() + 8, 412 buffer->side_data() + 8,
405 buffer->side_data_size() - 8, 413 buffer->side_data_size() - 8,
406 user_priv_alpha, 414 user_priv_alpha,
407 0); 415 0);
416 TRACE_EVENT_END0("video", "vpx_codec_decode_alpha");
408 417
409 if (status != VPX_CODEC_OK) { 418 if (status != VPX_CODEC_OK) {
410 LOG(ERROR) << "vpx_codec_decode() failed on alpha, status=" << status; 419 LOG(ERROR) << "vpx_codec_decode() failed on alpha, status=" << status;
411 return false; 420 return false;
412 } 421 }
413 422
414 // Gets pointer to decoded data. 423 // Gets pointer to decoded data.
415 vpx_codec_iter_t iter_alpha = NULL; 424 vpx_codec_iter_t iter_alpha = NULL;
425 TRACE_EVENT_BEGIN0("video", "vpx_codec_get_frame_alpha");
416 vpx_image_alpha = vpx_codec_get_frame(vpx_codec_alpha_, &iter_alpha); 426 vpx_image_alpha = vpx_codec_get_frame(vpx_codec_alpha_, &iter_alpha);
427 TRACE_EVENT_END0("video", "vpx_codec_get_frame_alpha");
417 if (!vpx_image_alpha) { 428 if (!vpx_image_alpha) {
418 *video_frame = NULL; 429 *video_frame = NULL;
419 return true; 430 return true;
420 } 431 }
421 432
422 if (vpx_image_alpha->user_priv != 433 if (vpx_image_alpha->user_priv !=
423 reinterpret_cast<void*>(&timestamp_alpha)) { 434 reinterpret_cast<void*>(&timestamp_alpha)) {
424 LOG(ERROR) << "Invalid output timestamp on alpha."; 435 LOG(ERROR) << "Invalid output timestamp on alpha.";
425 return false; 436 return false;
426 } 437 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get()); 505 vpx_image->stride[VPX_PLANE_Y], vpx_image->d_h, video_frame->get());
495 return; 506 return;
496 } 507 }
497 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y], 508 CopyAPlane(vpx_image_alpha->planes[VPX_PLANE_Y],
498 vpx_image->stride[VPX_PLANE_Y], 509 vpx_image->stride[VPX_PLANE_Y],
499 vpx_image->d_h, 510 vpx_image->d_h,
500 video_frame->get()); 511 video_frame->get());
501 } 512 }
502 513
503 } // namespace media 514 } // 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