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

Unified Diff: media/ffmpeg/ffmpeg_common.h

Issue 197793005: Convert scoped_ptr_malloc -> scoped_ptr, part 5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 9 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/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h ('k') | media/ffmpeg/ffmpeg_deleters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/ffmpeg/ffmpeg_common.h
diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h
index 9a98c85aa79b4898ed4171a9fd7e660e7c5092bb..2985e74137d65bcc73abaacf0a4229338fd50774 100644
--- a/media/ffmpeg/ffmpeg_common.h
+++ b/media/ffmpeg/ffmpeg_common.h
@@ -15,6 +15,7 @@
#include "media/base/media_export.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_frame.h"
+#include "media/ffmpeg/ffmpeg_deleters.h"
// Include FFmpeg header files.
extern "C" {
@@ -37,48 +38,31 @@ namespace media {
class AudioDecoderConfig;
class VideoDecoderConfig;
-// Wraps FFmpeg's av_free() in a class that can be passed as a template argument
-// to scoped_ptr_malloc.
-class ScopedPtrAVFree {
- public:
- inline void operator()(void* x) const {
- av_free(x);
- }
-};
-
-// This assumes that the AVPacket being captured was allocated outside of
-// FFmpeg via the new operator. Do not use this with AVPacket instances that
-// are allocated via malloc() or av_malloc().
-class ScopedPtrAVFreePacket {
- public:
- inline void operator()(void* x) const {
- AVPacket* packet = static_cast<AVPacket*>(x);
- av_free_packet(packet);
- delete packet;
- }
-};
-
-// 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);
- avcodec_free_frame(&frame);
- }
-};
+// The following implement the deleters declared in ffmpeg_deleters.h (which
+// contains the declarations needed for use with |scoped_ptr| without #include
+// "pollution").
+
+inline void ScopedPtrAVFree::operator()(void* x) const {
+ av_free(x);
+}
+
+inline void ScopedPtrAVFreePacket::operator()(void* x) const {
+ AVPacket* packet = static_cast<AVPacket*>(x);
+ av_free_packet(packet);
+ delete packet;
+}
+
+inline void ScopedPtrAVFreeContext::operator()(void* x) const {
+ AVCodecContext* codec_context = static_cast<AVCodecContext*>(x);
+ av_free(codec_context->extradata);
+ avcodec_close(codec_context);
+ av_free(codec_context);
+}
+
+inline void ScopedPtrAVFreeFrame::operator()(void* x) const {
+ AVFrame* frame = static_cast<AVFrame*>(x);
+ avcodec_free_frame(&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}
« no previous file with comments | « media/cdm/ppapi/external_clear_key/ffmpeg_cdm_video_decoder.h ('k') | media/ffmpeg/ffmpeg_deleters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698