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

Side by Side Diff: media/base/android/sdk_media_codec_bridge.cc

Issue 1945273002: Revert of Use actual audio channel count in Spitzer audio decoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug607024
Patch Set: Created 4 years, 7 months 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/base/android/sdk_media_codec_bridge.h" 5 #include "media/base/android/sdk_media_codec_bridge.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 env, j_media_codec_.obj(), input_buffer_index)); 307 env, j_media_codec_.obj(), input_buffer_index));
308 if (j_buffer.is_null()) 308 if (j_buffer.is_null())
309 return MEDIA_CODEC_ERROR; 309 return MEDIA_CODEC_ERROR;
310 310
311 *data = static_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj())); 311 *data = static_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj()));
312 *capacity = 312 *capacity =
313 base::checked_cast<size_t>(env->GetDirectBufferCapacity(j_buffer.obj())); 313 base::checked_cast<size_t>(env->GetDirectBufferCapacity(j_buffer.obj()));
314 return MEDIA_CODEC_OK; 314 return MEDIA_CODEC_OK;
315 } 315 }
316 316
317 MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress( 317 MediaCodecStatus SdkMediaCodecBridge::CopyFromOutputBuffer(int index,
318 int index, 318 size_t offset,
319 size_t offset, 319 void* dst,
320 const uint8_t** addr, 320 size_t num) {
321 size_t* capacity) { 321 void* src_data = nullptr;
322 size_t src_capacity = 0;
323 MediaCodecStatus status =
324 GetOutputBufferAddress(index, offset, &src_data, &src_capacity);
325 if (status == MEDIA_CODEC_OK) {
326 CHECK_GE(src_capacity, num);
327 memcpy(dst, src_data, num);
328 }
329 return status;
330 }
331
332 MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress(int index,
333 size_t offset,
334 void** addr,
335 size_t* capacity) {
322 JNIEnv* env = AttachCurrentThread(); 336 JNIEnv* env = AttachCurrentThread();
323 ScopedJavaLocalRef<jobject> j_buffer( 337 ScopedJavaLocalRef<jobject> j_buffer(
324 Java_MediaCodecBridge_getOutputBuffer(env, j_media_codec_.obj(), index)); 338 Java_MediaCodecBridge_getOutputBuffer(env, j_media_codec_.obj(), index));
325 if (j_buffer.is_null()) 339 if (j_buffer.is_null())
326 return MEDIA_CODEC_ERROR; 340 return MEDIA_CODEC_ERROR;
327 const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj()); 341 const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj());
328 CHECK_GE(total_capacity, offset); 342 CHECK_GE(total_capacity, offset);
329 *addr = reinterpret_cast<const uint8_t*>( 343 *addr =
330 env->GetDirectBufferAddress(j_buffer.obj())) + 344 reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj())) +
331 offset; 345 offset;
332 *capacity = total_capacity - offset; 346 *capacity = total_capacity - offset;
333 return MEDIA_CODEC_OK; 347 return MEDIA_CODEC_OK;
334 } 348 }
335 349
336 // static 350 // static
337 bool SdkMediaCodecBridge::RegisterSdkMediaCodecBridge(JNIEnv* env) { 351 bool SdkMediaCodecBridge::RegisterSdkMediaCodecBridge(JNIEnv* env) {
338 return RegisterNativesImpl(env); 352 return RegisterNativesImpl(env);
339 } 353 }
340 354
341 // static 355 // static
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 572 }
559 573
560 MediaCodecStatus AudioCodecBridge::PlayOutputBuffer(int index, 574 MediaCodecStatus AudioCodecBridge::PlayOutputBuffer(int index,
561 size_t size, 575 size_t size,
562 size_t offset, 576 size_t offset,
563 bool postpone, 577 bool postpone,
564 int64_t* playback_pos) { 578 int64_t* playback_pos) {
565 DCHECK_LE(0, index); 579 DCHECK_LE(0, index);
566 int numBytes = base::checked_cast<int>(size); 580 int numBytes = base::checked_cast<int>(size);
567 581
568 const uint8_t* buffer = nullptr; 582 void* buffer = nullptr;
569 size_t capacity = 0; 583 size_t capacity = 0;
570 MediaCodecStatus status = 584 MediaCodecStatus status =
571 GetOutputBufferAddress(index, offset, &buffer, &capacity); 585 GetOutputBufferAddress(index, offset, &buffer, &capacity);
572 if (status == MEDIA_CODEC_ERROR) 586 if (status == MEDIA_CODEC_ERROR)
573 return status; 587 return status;
574 588
575 numBytes = std::min(base::checked_cast<int>(capacity), numBytes); 589 numBytes = std::min(base::checked_cast<int>(capacity), numBytes);
576 CHECK_GE(numBytes, 0); 590 CHECK_GE(numBytes, 0);
577 591
578 JNIEnv* env = AttachCurrentThread(); 592 JNIEnv* env = AttachCurrentThread();
579 ScopedJavaLocalRef<jbyteArray> byte_array = 593 ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray(
580 base::android::ToJavaByteArray(env, buffer, numBytes); 594 env, static_cast<uint8_t*>(buffer), numBytes);
581 *playback_pos = Java_MediaCodecBridge_playOutputBuffer( 595 *playback_pos = Java_MediaCodecBridge_playOutputBuffer(
582 env, media_codec(), byte_array.obj(), postpone); 596 env, media_codec(), byte_array.obj(), postpone);
583 return status; 597 return status;
584 } 598 }
585 599
586 void AudioCodecBridge::SetVolume(double volume) { 600 void AudioCodecBridge::SetVolume(double volume) {
587 JNIEnv* env = AttachCurrentThread(); 601 JNIEnv* env = AttachCurrentThread();
588 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 602 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
589 } 603 }
590 604
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (adaptive_playback_supported_for_testing_ == 0) 699 if (adaptive_playback_supported_for_testing_ == 0)
686 return false; 700 return false;
687 else if (adaptive_playback_supported_for_testing_ > 0) 701 else if (adaptive_playback_supported_for_testing_ > 0)
688 return true; 702 return true;
689 JNIEnv* env = AttachCurrentThread(); 703 JNIEnv* env = AttachCurrentThread();
690 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), 704 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(),
691 width, height); 705 width, height);
692 } 706 }
693 707
694 } // namespace media 708 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/sdk_media_codec_bridge.h ('k') | media/filters/android/media_codec_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698