Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: media/cast/sender/vp8_encoder.h

Issue 899583002: Revert of [Cast] Software encoder support for varying video frame sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/sender/video_sender.cc ('k') | media/cast/sender/vp8_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ 5 #ifndef MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_
6 #define MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ 6 #define MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "media/cast/cast_config.h" 11 #include "media/cast/cast_config.h"
12 #include "media/cast/sender/software_video_encoder.h" 12 #include "media/cast/sender/software_video_encoder.h"
13 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h" 13 #include "third_party/libvpx/source/libvpx/vpx/vpx_encoder.h"
14 #include "ui/gfx/geometry/size.h"
15 14
16 namespace media { 15 namespace media {
17 class VideoFrame; 16 class VideoFrame;
18 } 17 }
19 18
20 namespace media { 19 namespace media {
21 namespace cast { 20 namespace cast {
22 21
23 class Vp8Encoder : public SoftwareVideoEncoder { 22 class Vp8Encoder : public SoftwareVideoEncoder {
24 public: 23 public:
(...skipping 25 matching lines...) Expand all
50 kBufferSent, 49 kBufferSent,
51 kBufferAcked 50 kBufferAcked
52 }; 51 };
53 52
54 struct BufferState { 53 struct BufferState {
55 uint32 frame_id; 54 uint32 frame_id;
56 Vp8BufferState state; 55 Vp8BufferState state;
57 }; 56 };
58 57
59 bool is_initialized() const { 58 bool is_initialized() const {
60 // ConfigureForNewFrameSize() sets the timebase denominator value to 59 // Initialize() sets the timebase denominator value to non-zero if the
61 // non-zero if the encoder is successfully initialized, and it is zero 60 // encoder is successfully initialized, and it is zero otherwise.
62 // otherwise.
63 return config_.g_timebase.den != 0; 61 return config_.g_timebase.den != 0;
64 } 62 }
65 63
66 // If the |encoder_| is live, attempt reconfiguration to allow it to encode
67 // frames at a new |frame_size|. Otherwise, tear it down and re-create a new
68 // |encoder_| instance.
69 void ConfigureForNewFrameSize(const gfx::Size& frame_size);
70
71 // Calculate which next Vp8 buffers to update with the next frame. 64 // Calculate which next Vp8 buffers to update with the next frame.
72 Vp8Buffers GetNextBufferToUpdate(); 65 Vp8Buffers GetNextBufferToUpdate();
73 66
74 // Get encoder flags for our referenced encoder buffers. 67 // Get encoder flags for our referenced encoder buffers.
75 // Return which previous frame to reference. 68 // Return which previous frame to reference.
76 uint32 GetCodecReferenceFlags(vpx_codec_flags_t* flags); 69 uint32 GetCodecReferenceFlags(vpx_codec_flags_t* flags);
77 70
78 // Get encoder flags for our encoder buffers to update with next frame. 71 // Get encoder flags for our encoder buffers to update with next frame.
79 void GetCodecUpdateFlags(Vp8Buffers buffer_to_update, 72 void GetCodecUpdateFlags(Vp8Buffers buffer_to_update,
80 vpx_codec_flags_t* flags); 73 vpx_codec_flags_t* flags);
81 74
82 const VideoSenderConfig cast_config_; 75 const VideoSenderConfig cast_config_;
83 const bool use_multiple_video_buffers_; 76 const bool use_multiple_video_buffers_;
84 77
85 // VP8 internal objects. These are valid for use only while is_initialized() 78 // VP8 internal objects. These are valid for use only while is_initialized()
86 // returns true. 79 // returns true.
87 vpx_codec_enc_cfg_t config_; 80 vpx_codec_enc_cfg_t config_;
88 vpx_codec_ctx_t encoder_; 81 vpx_codec_ctx_t encoder_;
89 82
83 // Wrapper for access to YUV data planes in a media::VideoFrame.
84 vpx_image_t* raw_image_;
85
90 // Set to true to request the next frame emitted by Vp8Encoder be a key frame. 86 // Set to true to request the next frame emitted by Vp8Encoder be a key frame.
91 bool key_frame_requested_; 87 bool key_frame_requested_;
92 88
93 // Saves the current bitrate setting, for when the |encoder_| is reconfigured
94 // for different frame sizes.
95 int bitrate_kbit_;
96
97 // The |VideoFrame::timestamp()| of the last encoded frame. This is used to 89 // The |VideoFrame::timestamp()| of the last encoded frame. This is used to
98 // predict the duration of the next frame. 90 // predict the duration of the next frame.
99 base::TimeDelta last_frame_timestamp_; 91 base::TimeDelta last_frame_timestamp_;
100 92
101 // The last encoded frame's ID. 93 // The last encoded frame's ID.
102 uint32 last_encoded_frame_id_; 94 uint32 last_encoded_frame_id_;
103 95
104 // Used to track which buffers are old enough to be re-used. 96 // Used to track which buffers are old enough to be re-used.
105 uint32 last_acked_frame_id_; 97 uint32 last_acked_frame_id_;
106 98
107 // Used by GetNextBufferToUpdate() to track how many consecutive times the 99 // Used by GetNextBufferToUpdate() to track how many consecutive times the
108 // newest buffer had to be overwritten. 100 // newest buffer had to be overwritten.
109 int undroppable_frames_; 101 int undroppable_frames_;
110 102
111 // Tracks the lifecycle and dependency state of each of the three buffers. 103 // Tracks the lifecycle and dependency state of each of the three buffers.
112 BufferState buffer_state_[kNumberOfVp8VideoBuffers]; 104 BufferState buffer_state_[kNumberOfVp8VideoBuffers];
113 105
114 // This is bound to the thread where Initialize() is called. 106 // This is bound to the thread where Initialize() is called.
115 base::ThreadChecker thread_checker_; 107 base::ThreadChecker thread_checker_;
116 108
117 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder); 109 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder);
118 }; 110 };
119 111
120 } // namespace cast 112 } // namespace cast
121 } // namespace media 113 } // namespace media
122 114
123 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ 115 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_
OLDNEW
« no previous file with comments | « media/cast/sender/video_sender.cc ('k') | media/cast/sender/vp8_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698