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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 174027: Fix Issue 160529 in a nice way (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/mock_ffmpeg.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.cc
===================================================================
--- media/filters/ffmpeg_demuxer.cc (revision 23787)
+++ media/filters/ffmpeg_demuxer.cc (working copy)
@@ -11,25 +11,6 @@
#include "media/filters/ffmpeg_demuxer.h"
#include "media/filters/ffmpeg_glue.h"
-namespace {
-
-// Helper function to deep copy an AVPacket's data, size and timestamps.
-// Returns NULL if a packet could not be cloned (i.e., out of memory).
-AVPacket* ClonePacket(AVPacket* packet) {
- scoped_ptr<AVPacket> clone(new AVPacket());
- if (!clone.get() || av_new_packet(clone.get(), packet->size) < 0) {
- return NULL;
- }
- DCHECK_EQ(clone->size, packet->size);
- clone->dts = packet->dts;
- clone->pts = packet->pts;
- clone->duration = packet->duration;
- memcpy(clone->data, packet->data, clone->size);
- return clone.release();
-}
-
-} // namespace
-
namespace media {
//
@@ -298,8 +279,8 @@
}
scoped_refptr<DemuxerStream> FFmpegDemuxer::GetStream(int stream) {
- DCHECK(stream >= 0);
- DCHECK(stream < static_cast<int>(streams_.size()));
+ DCHECK_GE(stream, 0);
+ DCHECK_LT(stream, static_cast<int>(streams_.size()));
return streams_[stream].get();
}
@@ -491,21 +472,15 @@
// TODO(scherkus): should we post this back to the pipeline thread? I'm
// worried about downstream filters (i.e., decoders) executing on this
// thread.
- DCHECK(packet->stream_index >= 0);
- DCHECK(packet->stream_index < static_cast<int>(packet_streams_.size()));
+ DCHECK_GE(packet->stream_index, 0);
+ DCHECK_LT(packet->stream_index, static_cast<int>(packet_streams_.size()));
FFmpegDemuxerStream* demuxer_stream = packet_streams_[packet->stream_index];
if (demuxer_stream) {
- // Duplicate the entire packet to avoid aliasing.
- // Directly affects MP3, but do all formats to be safe.
- scoped_ptr<AVPacket> clone(ClonePacket(packet.get()));
- if (!clone.get()) {
- NOTREACHED();
- return;
- }
- // Free FFmpeg-allocated memory and swap original packet into |clone| so
- // that it gets deleted as |clone| goes out of scope.
- av_free_packet(packet.get());
- packet.swap(clone);
+ // If a packet is returned by FFmpeg's av_parser_parse2()
+ // the packet will reference an inner memory of FFmpeg.
+ // In this case, the packet's "destruct" member is NULL,
+ // and it MUST be duplicated. Fixes issue with MP3.
+ av_dup_packet(packet.get());
// Queue the packet with the appropriate stream. The stream takes
// ownership of the AVPacket.
« no previous file with comments | « media/base/mock_ffmpeg.cc ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698