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

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

Issue 339743002: Cast: Make vp8 3-buffer mode work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merged, comment updated Created 6 years, 3 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
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE; 48 virtual void LatestFrameIdToReference(uint32 frame_id) OVERRIDE;
49 49
50 private: 50 private:
51 enum Vp8Buffers { 51 enum Vp8Buffers {
52 kAltRefBuffer = 0, 52 kAltRefBuffer = 0,
53 kGoldenBuffer = 1, 53 kGoldenBuffer = 1,
54 kLastBuffer = 2, 54 kLastBuffer = 2,
55 kNoBuffer = 3 // Note: must be last. 55 kNoBuffer = 3 // Note: must be last.
56 }; 56 };
57 57
58 enum Vp8BufferState {
59 kBufferStartState,
60 kBufferSent,
61 kBufferAcked
62 };
63 struct BufferState {
64 uint32 frame_id;
65 Vp8BufferState state;
66 };
67
58 void InitEncode(int number_of_cores); 68 void InitEncode(int number_of_cores);
59 69
60 // Calculate the max target in % for a keyframe. 70 // Calculate the max target in % for a keyframe.
61 uint32 MaxIntraTarget(uint32 optimal_buffer_size) const; 71 uint32 MaxIntraTarget(uint32 optimal_buffer_size) const;
62 72
63 // Calculate which next Vp8 buffers to update with the next frame. 73 // Calculate which next Vp8 buffers to update with the next frame.
64 Vp8Buffers GetNextBufferToUpdate(); 74 Vp8Buffers GetNextBufferToUpdate();
65 75
66 // Calculate which previous frame to reference.
67 uint32 GetLatestFrameIdToReference();
68
69 // Get encoder flags for our referenced encoder buffers. 76 // Get encoder flags for our referenced encoder buffers.
70 void GetCodecReferenceFlags(vpx_codec_flags_t* flags); 77 // Return which previous frame to reference.
78 uint32 GetCodecReferenceFlags(vpx_codec_flags_t* flags);
71 79
72 // Get encoder flags for our encoder buffers to update with next frame. 80 // Get encoder flags for our encoder buffers to update with next frame.
73 void GetCodecUpdateFlags(Vp8Buffers buffer_to_update, 81 void GetCodecUpdateFlags(Vp8Buffers buffer_to_update,
74 vpx_codec_flags_t* flags); 82 vpx_codec_flags_t* flags);
75 83
76 const VideoSenderConfig cast_config_; 84 const VideoSenderConfig cast_config_;
77 const bool use_multiple_video_buffers_; 85 const bool use_multiple_video_buffers_;
78 const int max_number_of_repeated_buffers_in_a_row_;
79 86
80 // VP8 internal objects. 87 // VP8 internal objects.
81 scoped_ptr<vpx_codec_enc_cfg_t> config_; 88 scoped_ptr<vpx_codec_enc_cfg_t> config_;
82 scoped_ptr<vpx_enc_ctx_t> encoder_; 89 scoped_ptr<vpx_enc_ctx_t> encoder_;
83 vpx_image_t* raw_image_; 90 vpx_image_t* raw_image_;
84 91
85 bool key_frame_requested_; 92 bool key_frame_requested_;
86 bool first_frame_received_; 93 bool first_frame_received_;
87 base::TimeDelta first_frame_timestamp_; 94 base::TimeDelta first_frame_timestamp_;
88 uint32 last_encoded_frame_id_; 95 uint32 last_encoded_frame_id_;
89 uint32 used_buffers_frame_id_[kNumberOfVp8VideoBuffers]; 96 uint32 last_acked_frame_id_;
90 bool acked_frame_buffers_[kNumberOfVp8VideoBuffers]; 97 uint32 frame_id_to_reference_;
91 Vp8Buffers last_used_vp8_buffer_; 98 uint32 undroppable_frames_;
92 int number_of_repeated_buffers_; 99 BufferState buffer_state_[kNumberOfVp8VideoBuffers];
93 100
94 // This is bound to the thread where Initialize() is called. 101 // This is bound to the thread where Initialize() is called.
95 base::ThreadChecker thread_checker_; 102 base::ThreadChecker thread_checker_;
96 103
97 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder); 104 DISALLOW_COPY_AND_ASSIGN(Vp8Encoder);
98 }; 105 };
99 106
100 } // namespace cast 107 } // namespace cast
101 } // namespace media 108 } // namespace media
102 109
103 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ 110 #endif // MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698