diff options
author | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 07:55:02 +0000 |
---|---|---|
committer | jrummell@chromium.org <jrummell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-26 07:55:02 +0000 |
commit | 2cfa1f1f2058a73b0a1778dd562ba6ed39e40f92 (patch) | |
tree | 2a160b1ff54c0936f749791f86b5fff44f82a5e4 /media/ffmpeg | |
parent | 2ff72995b5decaf76436a053d297afdc760a2ddf (diff) | |
download | chromium_src-2cfa1f1f2058a73b0a1778dd562ba6ed39e40f92.zip chromium_src-2cfa1f1f2058a73b0a1778dd562ba6ed39e40f92.tar.gz chromium_src-2cfa1f1f2058a73b0a1778dd562ba6ed39e40f92.tar.bz2 |
Cleanup destruction of ffmpeg objects
The code to free up AVCodecContext and AVFrame objects is replicated in
several places. This cleanup is to common code into a scoped_ptr deleter,
and then use scoped_ptr_malloc for all references to these objects.
BUG=
TEST=media_unittests successful using ASAN and HeapChecker
Review URL: https://codereview.chromium.org/24286009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225382 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h index ccd2aa5..39626ac 100644 --- a/media/ffmpeg/ffmpeg_common.h +++ b/media/ffmpeg/ffmpeg_common.h @@ -58,6 +58,28 @@ class ScopedPtrAVFreePacket { } }; +// Frees an AVCodecContext object in a class that can be passed as a Deleter +// argument to scoped_ptr_malloc. +class ScopedPtrAVFreeContext { + public: + inline void operator()(void* x) const { + AVCodecContext* codec_context = static_cast<AVCodecContext*>(x); + av_free(codec_context->extradata); + avcodec_close(codec_context); + av_free(codec_context); + } +}; + +// Frees an AVFrame object in a class that can be passed as a Deleter argument +// to scoped_ptr_malloc. +class ScopedPtrAVFreeFrame { + public: + inline void operator()(void* x) const { + AVFrame* frame = static_cast<AVFrame*>(x); + av_frame_free(&frame); + } +}; + // Converts an int64 timestamp in |time_base| units to a base::TimeDelta. // For example if |timestamp| equals 11025 and |time_base| equals {1, 44100} // then the return value will be a base::TimeDelta for 0.25 seconds since that |