blob: 1447fc1650fea111b3f0dc93383a505924b38ca9 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "rtc_base/bind.h"
18#include "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:
Emircan Uysalerd7ae3c32018-01-25 13:01:09 -080038 case kVideoCodecMultiplex:
hbosd6648362016-01-21 05:43:11 -080039 case kVideoCodecUnknown:
40 return 0;
41 }
42 RTC_NOTREACHED();
43 return 0;
44}
45
mflodman351424e2017-08-10 02:43:14 -070046EncodedImage::EncodedImage() : EncodedImage(nullptr, 0, 0) {}
47
48EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size)
49 : _buffer(buffer), _length(length), _size(size) {}
50
51void EncodedImage::SetEncodeTime(int64_t encode_start_ms,
Ilya Nikolaevskiy76f2a852017-11-16 14:33:53 +010052 int64_t encode_finish_ms) {
53 timing_.encode_start_ms = encode_start_ms;
54 timing_.encode_finish_ms = encode_finish_ms;
mflodman351424e2017-08-10 02:43:14 -070055}
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070056} // namespace webrtc