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

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

Issue 100503006: Cleanup OPUS decoder. Remove extraneous transforms and copies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DEPS for OPUS fixes. Created 7 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 | Annotate | Revision Log
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/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 new_packet->dts = packet->dts; 838 new_packet->dts = packet->dts;
839 new_packet->pos = packet->pos; 839 new_packet->pos = packet->pos;
840 new_packet->duration = packet->duration; 840 new_packet->duration = packet->duration;
841 new_packet->convergence_duration = packet->convergence_duration; 841 new_packet->convergence_duration = packet->convergence_duration;
842 new_packet->flags = packet->flags; 842 new_packet->flags = packet->flags;
843 new_packet->stream_index = packet->stream_index; 843 new_packet->stream_index = packet->stream_index;
844 844
845 packet.swap(new_packet); 845 packet.swap(new_packet);
846 } 846 }
847 847
848 // Special case for opus in ogg. FFmpeg is pre-trimming the codec delay
849 // from the packet timestamp. Chrome expects to handle this itself inside
850 // the decoder, so shift timestamps by the delay in this case.
851 if (strcmp(glue_->format_context()->iformat->name, "ogg") == 0) {
852 const AVCodecContext* codec_context =
853 glue_->format_context()->streams[packet->stream_index]->codec;
854 if (codec_context->codec_id == AV_CODEC_ID_OPUS &&
855 codec_context->delay > 0) {
856 packet->pts += codec_context->delay;
857 }
858 }
859
848 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; 860 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index];
849 demuxer_stream->EnqueuePacket(packet.Pass()); 861 demuxer_stream->EnqueuePacket(packet.Pass());
850 } 862 }
851 863
852 // Keep reading until we've reached capacity. 864 // Keep reading until we've reached capacity.
853 ReadFrameIfNeeded(); 865 ReadFrameIfNeeded();
854 } 866 }
855 867
856 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) { 868 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) {
857 // This will block until all tasks complete. Note that after this returns it's 869 // This will block until all tasks complete. Note that after this returns it's
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 933 }
922 for (size_t i = 0; i < buffered.size(); ++i) 934 for (size_t i = 0; i < buffered.size(); ++i)
923 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 935 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
924 } 936 }
925 937
926 void FFmpegDemuxer::OnDataSourceError() { 938 void FFmpegDemuxer::OnDataSourceError() {
927 host_->OnDemuxerError(PIPELINE_ERROR_READ); 939 host_->OnDemuxerError(PIPELINE_ERROR_READ);
928 } 940 }
929 941
930 } // namespace media 942 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698