Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 // from the number of channels, otherwise report errors. | 208 // from the number of channels, otherwise report errors. |
| 209 if (channels == 1) | 209 if (channels == 1) |
| 210 return CHANNEL_LAYOUT_MONO; | 210 return CHANNEL_LAYOUT_MONO; |
| 211 if (channels == 2) | 211 if (channels == 2) |
| 212 return CHANNEL_LAYOUT_STEREO; | 212 return CHANNEL_LAYOUT_STEREO; |
| 213 DLOG(WARNING) << "Unsupported/unencountered channel layout values"; | 213 DLOG(WARNING) << "Unsupported/unencountered channel layout values"; |
| 214 return CHANNEL_LAYOUT_UNSUPPORTED; | 214 return CHANNEL_LAYOUT_UNSUPPORTED; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { | |
| 219 switch (pixel_format) { | |
| 220 case PIX_FMT_YUV422P: | |
| 221 return VideoFrame::YV16; | |
| 222 case PIX_FMT_YUV420P: | |
| 223 return VideoFrame::YV12; | |
| 224 default: | |
| 225 NOTREACHED() << "Unsupported PixelFormat: " << pixel_format; | |
| 226 } | |
| 227 return VideoFrame::INVALID; | |
| 228 } | |
| 229 | |
| 230 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { | |
| 231 switch (video_format) { | |
| 232 case VideoFrame::YV16: | |
|
scherkus (not reviewing)
2011/09/29 20:48:05
fix indentation
| |
| 233 return PIX_FMT_YUV422P; | |
| 234 case VideoFrame::YV12: | |
| 235 return PIX_FMT_YUV420P; | |
| 236 default: | |
| 237 NOTREACHED() << "Unsupported VideoFrame Format: " << video_format; | |
| 238 } | |
| 239 return PIX_FMT_NONE; | |
| 240 } | |
| 241 | |
| 218 base::TimeDelta GetFrameDuration(AVStream* stream) { | 242 base::TimeDelta GetFrameDuration(AVStream* stream) { |
| 219 AVRational time_base = { stream->r_frame_rate.den, stream->r_frame_rate.num }; | 243 AVRational time_base = { stream->r_frame_rate.den, stream->r_frame_rate.num }; |
| 220 return ConvertFromTimeBase(time_base, 1); | 244 return ConvertFromTimeBase(time_base, 1); |
| 221 } | 245 } |
| 222 | 246 |
| 223 bool GetSeekTimeAfter(AVStream* stream, const base::TimeDelta& timestamp, | 247 bool GetSeekTimeAfter(AVStream* stream, const base::TimeDelta& timestamp, |
| 224 base::TimeDelta* seek_time) { | 248 base::TimeDelta* seek_time) { |
| 225 DCHECK(stream); | 249 DCHECK(stream); |
| 226 DCHECK(timestamp >= base::TimeDelta::FromSeconds(0)); | 250 DCHECK(timestamp >= base::TimeDelta::FromSeconds(0)); |
| 227 DCHECK(seek_time); | 251 DCHECK(seek_time); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 avcodec_close(stream->codec); | 359 avcodec_close(stream->codec); |
| 336 } | 360 } |
| 337 } | 361 } |
| 338 } | 362 } |
| 339 | 363 |
| 340 // Then finally cleanup the format context. | 364 // Then finally cleanup the format context. |
| 341 av_close_input_file(format_context); | 365 av_close_input_file(format_context); |
| 342 } | 366 } |
| 343 | 367 |
| 344 } // namespace media | 368 } // namespace media |
| OLD | NEW |