2011-12-13 21:15:05 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_DECODING_STATE_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_DECODING_STATE_H_
|
2011-12-13 21:15:05 +00:00
|
|
|
|
2016-10-06 05:04:52 -07:00
|
|
|
#include <map>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2011-12-13 21:15:05 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Forward declarations
|
2016-10-06 05:04:52 -07:00
|
|
|
struct NaluInfo;
|
2011-12-13 21:15:05 +00:00
|
|
|
class VCMFrameBuffer;
|
|
|
|
|
class VCMPacket;
|
|
|
|
|
|
|
|
|
|
class VCMDecodingState {
|
|
|
|
|
public:
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
// The max number of bits used to reference back
|
|
|
|
|
// to a previous frame when using flexible mode.
|
|
|
|
|
static const uint16_t kNumRefBits = 7;
|
|
|
|
|
static const uint16_t kFrameDecodedLength = 1 << kNumRefBits;
|
|
|
|
|
|
2011-12-13 21:15:05 +00:00
|
|
|
VCMDecodingState();
|
|
|
|
|
~VCMDecodingState();
|
|
|
|
|
// Check for old frame
|
|
|
|
|
bool IsOldFrame(const VCMFrameBuffer* frame) const;
|
|
|
|
|
// Check for old packet
|
|
|
|
|
bool IsOldPacket(const VCMPacket* packet) const;
|
|
|
|
|
// Check for frame continuity based on current decoded state. Use best method
|
|
|
|
|
// possible, i.e. temporal info, picture ID or sequence number.
|
|
|
|
|
bool ContinuousFrame(const VCMFrameBuffer* frame) const;
|
|
|
|
|
void SetState(const VCMFrameBuffer* frame);
|
2013-04-25 21:45:29 +00:00
|
|
|
void CopyFrom(const VCMDecodingState& state);
|
2013-06-17 07:13:16 +00:00
|
|
|
bool UpdateEmptyFrame(const VCMFrameBuffer* frame);
|
2011-12-13 21:15:05 +00:00
|
|
|
// Update the sequence number if the timestamp matches current state and the
|
2012-01-03 20:35:25 +00:00
|
|
|
// sequence number is higher than the current one. This accounts for packets
|
|
|
|
|
// arriving late.
|
|
|
|
|
void UpdateOldPacket(const VCMPacket* packet);
|
2011-12-13 21:15:05 +00:00
|
|
|
void SetSeqNum(uint16_t new_seq_num);
|
|
|
|
|
void Reset();
|
|
|
|
|
uint32_t time_stamp() const;
|
|
|
|
|
uint16_t sequence_num() const;
|
|
|
|
|
// Return true if at initial state.
|
2013-03-04 15:24:40 +00:00
|
|
|
bool in_initial_state() const;
|
2011-12-13 21:15:05 +00:00
|
|
|
// Return true when sync is on - decode all layers.
|
|
|
|
|
bool full_sync() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void UpdateSyncState(const VCMFrameBuffer* frame);
|
|
|
|
|
// Designated continuity functions
|
|
|
|
|
bool ContinuousPictureId(int picture_id) const;
|
|
|
|
|
bool ContinuousSeqNum(uint16_t seq_num) const;
|
|
|
|
|
bool ContinuousLayer(int temporal_id, int tl0_pic_id) const;
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
bool ContinuousFrameRefs(const VCMFrameBuffer* frame) const;
|
2012-09-19 11:08:05 +00:00
|
|
|
bool UsingPictureId(const VCMFrameBuffer* frame) const;
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
bool UsingFlexibleMode(const VCMFrameBuffer* frame) const;
|
|
|
|
|
bool AheadOfFramesDecodedClearedTo(uint16_t index) const;
|
2016-10-06 05:04:52 -07:00
|
|
|
bool HaveSpsAndPps(const std::vector<NaluInfo>& nalus) const;
|
2011-12-13 21:15:05 +00:00
|
|
|
|
|
|
|
|
// Keep state of last decoded frame.
|
|
|
|
|
// TODO(mikhal/stefan): create designated classes to handle these types.
|
2015-12-21 04:12:39 -08:00
|
|
|
uint16_t sequence_num_;
|
|
|
|
|
uint32_t time_stamp_;
|
|
|
|
|
int picture_id_;
|
|
|
|
|
int temporal_id_;
|
|
|
|
|
int tl0_pic_id_;
|
|
|
|
|
bool full_sync_; // Sync flag when temporal layers are used.
|
|
|
|
|
bool in_initial_state_;
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
|
|
|
|
|
// Used to check references in flexible mode.
|
|
|
|
|
bool frame_decoded_[kFrameDecodedLength];
|
|
|
|
|
uint16_t frame_decoded_cleared_to_;
|
2016-10-06 05:04:52 -07:00
|
|
|
std::set<int> received_sps_;
|
|
|
|
|
std::map<int, int> received_pps_;
|
2011-12-13 21:15:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_DECODING_STATE_H_
|