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 PixFmtToVideoFormat(PixelFormat pix_fmt) { | |
| 219 switch (pix_fmt) { | |
| 220 case PIX_FMT_YUV422P: | |
| 221 return VideoFrame::YV16; | |
| 222 case PIX_FMT_YUV420P: | |
| 223 return VideoFrame::YV12; | |
| 224 default: | |
| 225 // TODO(shadi): Should YV12 be the default? | |
|
scherkus (not reviewing)
2011/09/28 17:32:17
nope I'd rather return INVALID
shadi1
2011/09/29 18:31:03
Done.
| |
| 226 NOTREACHED(); | |
|
scherkus (not reviewing)
2011/09/28 17:32:17
could you add an error message to this:
NOTREACHE
shadi1
2011/09/29 18:31:03
Done.
| |
| 227 } | |
| 228 return VideoFrame::INVALID; | |
| 229 } | |
| 230 | |
| 218 base::TimeDelta GetFrameDuration(AVStream* stream) { | 231 base::TimeDelta GetFrameDuration(AVStream* stream) { |
| 219 AVRational time_base = { stream->r_frame_rate.den, stream->r_frame_rate.num }; | 232 AVRational time_base = { stream->r_frame_rate.den, stream->r_frame_rate.num }; |
| 220 return ConvertFromTimeBase(time_base, 1); | 233 return ConvertFromTimeBase(time_base, 1); |
| 221 } | 234 } |
| 222 | 235 |
| 223 bool GetSeekTimeAfter(AVStream* stream, const base::TimeDelta& timestamp, | 236 bool GetSeekTimeAfter(AVStream* stream, const base::TimeDelta& timestamp, |
| 224 base::TimeDelta* seek_time) { | 237 base::TimeDelta* seek_time) { |
| 225 DCHECK(stream); | 238 DCHECK(stream); |
| 226 DCHECK(timestamp >= base::TimeDelta::FromSeconds(0)); | 239 DCHECK(timestamp >= base::TimeDelta::FromSeconds(0)); |
| 227 DCHECK(seek_time); | 240 DCHECK(seek_time); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 avcodec_close(stream->codec); | 348 avcodec_close(stream->codec); |
| 336 } | 349 } |
| 337 } | 350 } |
| 338 } | 351 } |
| 339 | 352 |
| 340 // Then finally cleanup the format context. | 353 // Then finally cleanup the format context. |
| 341 av_close_input_file(format_context); | 354 av_close_input_file(format_context); |
| 342 } | 355 } |
| 343 | 356 |
| 344 } // namespace media | 357 } // namespace media |
| OLD | NEW |