| OLD | NEW |
| 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/ffmpeg/ffmpeg_common.h" | 5 #include "media/ffmpeg/ffmpeg_common.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
| 10 #include "media/base/video_util.h" | 10 #include "media/base/video_util.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 case VideoFrame::YV16: | 406 case VideoFrame::YV16: |
| 407 return PIX_FMT_YUV422P; | 407 return PIX_FMT_YUV422P; |
| 408 case VideoFrame::YV12: | 408 case VideoFrame::YV12: |
| 409 return PIX_FMT_YUV420P; | 409 return PIX_FMT_YUV420P; |
| 410 default: | 410 default: |
| 411 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 411 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
| 412 } | 412 } |
| 413 return PIX_FMT_NONE; | 413 return PIX_FMT_NONE; |
| 414 } | 414 } |
| 415 | 415 |
| 416 void DestroyAVFormatContext(AVFormatContext* format_context) { | |
| 417 DCHECK(format_context); | |
| 418 | |
| 419 // Iterate each stream and destroy each one of them. | |
| 420 if (format_context->streams) { | |
| 421 int streams = format_context->nb_streams; | |
| 422 for (int i = 0; i < streams; ++i) { | |
| 423 AVStream* stream = format_context->streams[i]; | |
| 424 | |
| 425 // The conditions for calling avcodec_close(): | |
| 426 // 1. AVStream is alive. | |
| 427 // 2. AVCodecContext in AVStream is alive. | |
| 428 // 3. AVCodec in AVCodecContext is alive. | |
| 429 // Notice that closing a codec context without prior avcodec_open2() will | |
| 430 // result in a crash in FFmpeg. | |
| 431 if (stream && stream->codec && stream->codec->codec) { | |
| 432 stream->discard = AVDISCARD_ALL; | |
| 433 avcodec_close(stream->codec); | |
| 434 } | |
| 435 } | |
| 436 } | |
| 437 | |
| 438 // Then finally cleanup the format context. | |
| 439 avformat_close_input(&format_context); | |
| 440 } | |
| 441 | |
| 442 } // namespace media | 416 } // namespace media |
| OLD | NEW |