blob: 8678700e9ab122f1ba48e7520e282564fb74aadf [file] [log] [blame]
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -07001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
nisseea3a7982017-05-15 02:42:11 -070011#include "webrtc/common_video/include/video_frame.h"
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070012
13#include <string.h>
14
15#include <algorithm> // swap
16
Edward Lemurc20978e2017-07-06 19:44:34 +020017#include "webrtc/rtc_base/bind.h"
18#include "webrtc/rtc_base/checks.h"
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070019
20namespace webrtc {
21
hbosbab934b2016-01-27 01:36:03 -080022// FFmpeg's decoder, used by H264DecoderImpl, requires up to 8 bytes padding due
23// to optimized bitstream readers. See avcodec_decode_video2.
24const size_t EncodedImage::kBufferPaddingBytesH264 = 8;
hbosd6648362016-01-21 05:43:11 -080025
hbosd6648362016-01-21 05:43:11 -080026size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) {
27 switch (codec_type) {
28 case kVideoCodecVP8:
29 case kVideoCodecVP9:
30 return 0;
31 case kVideoCodecH264:
32 return kBufferPaddingBytesH264;
33 case kVideoCodecI420:
34 case kVideoCodecRED:
35 case kVideoCodecULPFEC:
brandtr87d7d772016-11-07 03:03:41 -080036 case kVideoCodecFlexfec:
hbosd6648362016-01-21 05:43:11 -080037 case kVideoCodecGeneric:
38 case kVideoCodecUnknown:
39 return 0;
40 }
41 RTC_NOTREACHED();
42 return 0;
43}
44
mflodman351424e2017-08-10 02:43:14 -070045EncodedImage::EncodedImage() : EncodedImage(nullptr, 0, 0) {}
46
47EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size)
48 : _buffer(buffer), _length(length), _size(size) {}
49
50void EncodedImage::SetEncodeTime(int64_t encode_start_ms,
51 int64_t encode_finish_ms) const {
mflodman351424e2017-08-10 02:43:14 -070052 timing_.encode_start_ms = encode_start_ms;
53 timing_.encode_finish_ms = encode_finish_ms;
54}
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070055} // namespace webrtc