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

Side by Side Diff: media/base/mock_ffmpeg.cc

Issue 151192: Cleanup resources allocated by FFmpeg to avoid memory and threads leaks... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/mock_ffmpeg.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/base/mock_ffmpeg.h" 5 #include "media/base/mock_ffmpeg.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/filters/ffmpeg_common.h" 8 #include "media/filters/ffmpeg_common.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 extern "C" { 50 extern "C" {
51 51
52 AVCodec* avcodec_find_decoder(enum CodecID id) { 52 AVCodec* avcodec_find_decoder(enum CodecID id) {
53 return media::MockFFmpeg::get()->AVCodecFindDecoder(id); 53 return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
54 } 54 }
55 55
56 int avcodec_open(AVCodecContext* avctx, AVCodec* codec) { 56 int avcodec_open(AVCodecContext* avctx, AVCodec* codec) {
57 return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec); 57 return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec);
58 } 58 }
59 59
60 int avcodec_close(AVCodecContext* avctx) {
61 return media::MockFFmpeg::get()->AVCodecClose(avctx);
62 }
63
60 int avcodec_thread_init(AVCodecContext* avctx, int threads) { 64 int avcodec_thread_init(AVCodecContext* avctx, int threads) {
61 return media::MockFFmpeg::get()->AVCodecThreadInit(avctx, threads); 65 return media::MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
62 } 66 }
63 67
64 void avcodec_flush_buffers(AVCodecContext* avctx) { 68 void avcodec_flush_buffers(AVCodecContext* avctx) {
65 return media::MockFFmpeg::get()->AVCodecFlushBuffers(avctx); 69 return media::MockFFmpeg::get()->AVCodecFlushBuffers(avctx);
66 } 70 }
67 71
68 AVFrame* avcodec_alloc_frame() { 72 AVFrame* avcodec_alloc_frame() {
69 return media::MockFFmpeg::get()->AVCodecAllocFrame(); 73 return media::MockFFmpeg::get()->AVCodecAllocFrame();
70 } 74 }
71 75
72 int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture, 76 int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture,
73 int* got_picture_ptr, AVPacket* avpkt) { 77 int* got_picture_ptr, AVPacket* avpkt) {
74 return media::MockFFmpeg::get()-> 78 return media::MockFFmpeg::get()->
75 AVCodecDecodeVideo2(avctx, picture, got_picture_ptr, avpkt); 79 AVCodecDecodeVideo2(avctx, picture, got_picture_ptr, avpkt);
76 } 80 }
77 81
78 int av_open_input_file(AVFormatContext** format, const char* filename, 82 int av_open_input_file(AVFormatContext** format, const char* filename,
79 AVInputFormat* input_format, int buffer_size, 83 AVInputFormat* input_format, int buffer_size,
80 AVFormatParameters* parameters) { 84 AVFormatParameters* parameters) {
81 return media::MockFFmpeg::get()->AVOpenInputFile(format, filename, 85 return media::MockFFmpeg::get()->AVOpenInputFile(format, filename,
82 input_format, buffer_size, 86 input_format, buffer_size,
83 parameters); 87 parameters);
84 } 88 }
85 89
90 void av_close_input_file(AVFormatContext* format) {
91 media::MockFFmpeg::get()->AVCloseInputFile(format);
92 }
93
86 int av_find_stream_info(AVFormatContext* format) { 94 int av_find_stream_info(AVFormatContext* format) {
87 return media::MockFFmpeg::get()->AVFindStreamInfo(format); 95 return media::MockFFmpeg::get()->AVFindStreamInfo(format);
88 } 96 }
89 97
90 int64 av_rescale_q(int64 a, AVRational bq, AVRational cq) { 98 int64 av_rescale_q(int64 a, AVRational bq, AVRational cq) {
91 // Because this is a math function there's little point in mocking it, so we 99 // Because this is a math function there's little point in mocking it, so we
92 // implement a cheap version that's capable of overflowing. 100 // implement a cheap version that's capable of overflowing.
93 int64 num = bq.num * cq.den; 101 int64 num = bq.num * cq.den;
94 int64 den = cq.num * bq.den; 102 int64 den = cq.num * bq.den;
95 return a * num / den; 103 return a * num / den;
(...skipping 25 matching lines...) Expand all
121 // Freeing NULL pointers are valid, but they aren't interesting from a mock 129 // Freeing NULL pointers are valid, but they aren't interesting from a mock
122 // perspective. 130 // perspective.
123 if (ptr) { 131 if (ptr) {
124 media::MockFFmpeg::get()->AVFree(ptr); 132 media::MockFFmpeg::get()->AVFree(ptr);
125 } 133 }
126 } 134 }
127 135
128 } // extern "C" 136 } // extern "C"
129 137
130 } // namespace media 138 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mock_ffmpeg.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698