summaryrefslogtreecommitdiffstats
path: root/media/tools
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 22:07:35 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 22:07:35 +0000
commit1c9744a811af60887347e76068b6c14a9361fba5 (patch)
treeab948f22667f0d53f9b221ce91342654e9e0faad /media/tools
parent9b4e643469f80cd6b186ebb0f03b6c135c0d5478 (diff)
downloadchromium_src-1c9744a811af60887347e76068b6c14a9361fba5.zip
chromium_src-1c9744a811af60887347e76068b6c14a9361fba5.tar.gz
chromium_src-1c9744a811af60887347e76068b6c14a9361fba5.tar.bz2
Switch to using avcodec_decode_audio4, avcodec_alloc_context3.
Allows us to remove another patch from FFmpeg relating to using deprecated features! We're now using the latest and greatest! FFmpeg side changes here, https://gerrit.chromium.org/gerrit/24823 BUG=112673 TEST=ffmpeg_regression_tests, webaudio tests. Review URL: https://chromiumcodereview.appspot.com/10540067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r--media/tools/media_bench/media_bench.cc42
1 files changed, 29 insertions, 13 deletions
diff --git a/media/tools/media_bench/media_bench.cc b/media/tools/media_bench/media_bench.cc
index 532aa7d..abba5f0 100644
--- a/media/tools/media_bench/media_bench.cc
+++ b/media/tools/media_bench/media_bench.cc
@@ -357,13 +357,18 @@ int main(int argc, const char** argv) {
}
// Buffer used for audio decoding.
- scoped_ptr_malloc<int16, media::ScopedPtrAVFree> samples(
- reinterpret_cast<int16*>(av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE)));
+ scoped_ptr_malloc<AVFrame, media::ScopedPtrAVFree> audio_frame(
+ avcodec_alloc_frame());
+ if (!audio_frame.get()) {
+ std::cerr << "Error: avcodec_alloc_frame for "
+ << in_path.value() << std::endl;
+ return 1;
+ }
// Buffer used for video decoding.
- scoped_ptr_malloc<AVFrame, media::ScopedPtrAVFree> frame(
+ scoped_ptr_malloc<AVFrame, media::ScopedPtrAVFree> video_frame(
avcodec_alloc_frame());
- if (!frame.get()) {
+ if (!video_frame.get()) {
std::cerr << "Error: avcodec_alloc_frame for "
<< in_path.value() << std::endl;
return 1;
@@ -405,20 +410,29 @@ int main(int argc, const char** argv) {
if (packet.stream_index == target_stream) {
int result = -1;
if (target_codec == AVMEDIA_TYPE_AUDIO) {
- int size_out = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ int size_out = 0;
+ int got_audio = 0;
+
+ avcodec_get_frame_defaults(audio_frame.get());
base::TimeTicks decode_start = base::TimeTicks::HighResNow();
- result = avcodec_decode_audio3(codec_context, samples.get(), &size_out,
- &packet);
+ result = avcodec_decode_audio4(codec_context, audio_frame.get(),
+ &got_audio, &packet);
base::TimeDelta delta = base::TimeTicks::HighResNow() - decode_start;
- if (size_out) {
+ if (got_audio) {
+ size_out = av_samples_get_buffer_size(
+ NULL, codec_context->channels, audio_frame->nb_samples,
+ codec_context->sample_fmt, 1);
+ }
+
+ if (got_audio && size_out) {
decode_times.push_back(delta.InMillisecondsF());
++frames;
read_result = 0; // Force continuation.
if (output) {
- if (fwrite(samples.get(), 1, size_out, output) !=
+ if (fwrite(audio_frame->data[0], 1, size_out, output) !=
static_cast<size_t>(size_out)) {
std::cerr << "Error: Could not write "
<< size_out << " bytes for " << in_path.value()
@@ -428,7 +442,7 @@ int main(int argc, const char** argv) {
}
const uint8* u8_samples =
- reinterpret_cast<const uint8*>(samples.get());
+ reinterpret_cast<const uint8*>(audio_frame->data[0]);
if (hash_djb2) {
hash_value = DJB2Hash(u8_samples, size_out, hash_value);
}
@@ -442,8 +456,10 @@ int main(int argc, const char** argv) {
} else if (target_codec == AVMEDIA_TYPE_VIDEO) {
int got_picture = 0;
+ avcodec_get_frame_defaults(video_frame.get());
+
base::TimeTicks decode_start = base::TimeTicks::HighResNow();
- result = avcodec_decode_video2(codec_context, frame.get(),
+ result = avcodec_decode_video2(codec_context, video_frame.get(),
&got_picture, &packet);
base::TimeDelta delta = base::TimeTicks::HighResNow() - decode_start;
@@ -453,8 +469,8 @@ int main(int argc, const char** argv) {
read_result = 0; // Force continuation.
for (int plane = 0; plane < 3; ++plane) {
- const uint8* source = frame->data[plane];
- const size_t source_stride = frame->linesize[plane];
+ const uint8* source = video_frame->data[plane];
+ const size_t source_stride = video_frame->linesize[plane];
size_t bytes_per_line = codec_context->width;
size_t copy_lines = codec_context->height;
if (plane != 0) {