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

Side by Side Diff: media/filters/ffmpeg_glue.cc

Issue 2534193003: To M56: Roll src/third_party/ffmpeg/ 3c7a09882..cdf4accee (3188 commits). (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_glue_unittest.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_glue.h" 5 #include "media/filters/ffmpeg_glue.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 // If avformat_open_input() hasn't been called, we should simply free the 193 // If avformat_open_input() hasn't been called, we should simply free the
194 // AVFormatContext and buffer instead of using avformat_close_input(). 194 // AVFormatContext and buffer instead of using avformat_close_input().
195 if (!open_called_) { 195 if (!open_called_) {
196 avformat_free_context(format_context_); 196 avformat_free_context(format_context_);
197 av_free(avio_context_->buffer); 197 av_free(avio_context_->buffer);
198 return; 198 return;
199 } 199 }
200 200
201 // If avformat_open_input() has been called with this context, we need to
202 // close out any codecs/streams before closing the context.
203 if (format_context_->streams) {
204 for (int i = format_context_->nb_streams - 1; i >= 0; --i) {
205 AVStream* stream = format_context_->streams[i];
206
207 // The conditions for calling avcodec_close():
208 // 1. AVStream is alive.
209 // 2. AVCodecContext in AVStream is alive.
210 // 3. AVCodec in AVCodecContext is alive.
211 //
212 // Closing a codec context without prior avcodec_open2() will result in
213 // a crash in FFmpeg.
214 if (stream && stream->codec && stream->codec->codec) {
215 stream->discard = AVDISCARD_ALL;
216 avcodec_close(stream->codec);
217 }
218 }
219 }
220
221 avformat_close_input(&format_context_); 201 avformat_close_input(&format_context_);
222 av_free(avio_context_->buffer); 202 av_free(avio_context_->buffer);
223 } 203 }
224 204
225 } // namespace media 205 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_glue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698