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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 171023: Fix issue 160529 in a nice way (Closed) Base URL: http://src.chromium.org/svn/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 | « AUTHORS ('k') | third_party/ffmpeg/avcodec-52.sigs » ('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 23515)
+++ 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) {
fbarchard 2009/08/18 22:34:16 removing this breaks the unittest C:\chrome-svn\sr
- 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 {
//
@@ -495,17 +476,10 @@
DCHECK(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 packets 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, it MUST be duplicated.
fbarchard 2009/08/18 22:34:16 nit more than 80 columns... break comment into 2 l
ffmpeg 2009/08/19 01:05:25 OK, Let's focus on issue: 174027 which is the enha
+ av_dup_packet(packet.get());
// Queue the packet with the appropriate stream. The stream takes
// ownership of the AVPacket.
« no previous file with comments | « AUTHORS ('k') | third_party/ffmpeg/avcodec-52.sigs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698