Reverting 1680: valgrind memory leak reported.
TBR=marpan Review URL: https://webrtc-codereview.appspot.com/392011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1686 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
738bcdc4ee
commit
79a99de8e4
@ -324,24 +324,11 @@ int VP8Encoder::Encode(const RawImage& input_image,
|
|||||||
if (encoded_complete_callback_ == NULL) {
|
if (encoded_complete_callback_ == NULL) {
|
||||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||||
}
|
}
|
||||||
|
// image in vpx_image_t format
|
||||||
// Check for change in frame size.
|
raw_->planes[PLANE_Y] = input_image._buffer;
|
||||||
if (input_image._width != codec_.width ||
|
raw_->planes[PLANE_U] = &input_image._buffer[codec_.height * codec_.width];
|
||||||
input_image._height != codec_.height) {
|
raw_->planes[PLANE_V] =
|
||||||
codec_.width = input_image._width;
|
&input_image._buffer[codec_.height * codec_.width * 5 >> 2];
|
||||||
codec_.height = input_image._height;
|
|
||||||
|
|
||||||
// Update encoder context for new frame size.
|
|
||||||
// Change of frame size will automatically trigger a key frame.
|
|
||||||
config_->g_w = codec_.width;
|
|
||||||
config_->g_h = codec_.height;
|
|
||||||
if (vpx_codec_enc_config_set(encoder_, config_)) {
|
|
||||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vpx_img_wrap(raw_, IMG_FMT_I420, codec_.width, codec_.height, 1,
|
|
||||||
input_image._buffer);
|
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#if WEBRTC_LIBVPX_VERSION >= 971
|
#if WEBRTC_LIBVPX_VERSION >= 971
|
||||||
|
@ -24,8 +24,6 @@ _maxBitRate(0),
|
|||||||
_sendCodecType(kVideoCodecUnknown),
|
_sendCodecType(kVideoCodecUnknown),
|
||||||
_codecWidth(0),
|
_codecWidth(0),
|
||||||
_codecHeight(0),
|
_codecHeight(0),
|
||||||
_initCodecWidth(0),
|
|
||||||
_initCodecHeight(0),
|
|
||||||
_userFrameRate(0),
|
_userFrameRate(0),
|
||||||
_packetLossEnc(0),
|
_packetLossEnc(0),
|
||||||
_fractionLost(0),
|
_fractionLost(0),
|
||||||
@ -66,7 +64,7 @@ WebRtc_Word32
|
|||||||
VCMMediaOptimization::Reset()
|
VCMMediaOptimization::Reset()
|
||||||
{
|
{
|
||||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
||||||
_incomingFrameRate = 0.0;
|
InputFrameRate(); // Resets _incomingFrameRate
|
||||||
_frameDropper->Reset();
|
_frameDropper->Reset();
|
||||||
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
_lossProtLogic->Reset(_clock->MillisecondTimestamp());
|
||||||
_frameDropper->SetRates(0, 0);
|
_frameDropper->SetRates(0, 0);
|
||||||
@ -282,8 +280,6 @@ VCMMediaOptimization::SetEncodingData(VideoCodecType sendCodecType,
|
|||||||
_frameDropper->SetRates(static_cast<float>(bitRate),
|
_frameDropper->SetRates(static_cast<float>(bitRate),
|
||||||
static_cast<float>(frameRate));
|
static_cast<float>(frameRate));
|
||||||
_userFrameRate = static_cast<float>(frameRate);
|
_userFrameRate = static_cast<float>(frameRate);
|
||||||
_initCodecWidth = width;
|
|
||||||
_initCodecHeight = height;
|
|
||||||
_codecWidth = width;
|
_codecWidth = width;
|
||||||
_codecHeight = height;
|
_codecHeight = height;
|
||||||
_numLayers = (numLayers <= 1) ? 1 : numLayers; // Can also be zero.
|
_numLayers = (numLayers <= 1) ? 1 : numLayers; // Can also be zero.
|
||||||
@ -579,51 +575,43 @@ VCMMediaOptimization::QMUpdate(VCMResolutionScale* qm)
|
|||||||
// Check for no change
|
// Check for no change
|
||||||
if (qm->spatialHeightFact == 1 &&
|
if (qm->spatialHeightFact == 1 &&
|
||||||
qm->spatialWidthFact == 1 &&
|
qm->spatialWidthFact == 1 &&
|
||||||
qm->temporalFact == 1) {
|
qm->temporalFact == 1)
|
||||||
return false;
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Content metrics hold native values
|
||||||
|
VideoContentMetrics* cm = _content->LongTermAvgData();
|
||||||
|
|
||||||
// Temporal
|
// Temporal
|
||||||
WebRtc_UWord32 frameRate = static_cast<WebRtc_UWord32>
|
WebRtc_UWord32 frameRate = static_cast<WebRtc_UWord32>
|
||||||
(_incomingFrameRate + 0.5f);
|
(_incomingFrameRate + 0.5f);
|
||||||
|
|
||||||
// Check if go back up in temporal resolution
|
// Check if go back up in temporal resolution
|
||||||
if (qm->temporalFact == 0) {
|
if (qm->temporalFact == 0)
|
||||||
// Currently only allow for 1/2 frame rate reduction per action.
|
{
|
||||||
// TODO (marpan): allow for 2/3 reduction
|
frameRate = (WebRtc_UWord32) 2 * _incomingFrameRate;
|
||||||
frameRate = (WebRtc_UWord32) 2 * _incomingFrameRate;
|
|
||||||
}
|
}
|
||||||
// go down in temporal resolution
|
// go down in temporal resolution
|
||||||
else {
|
else
|
||||||
frameRate = (WebRtc_UWord32)(_incomingFrameRate / qm->temporalFact + 1);
|
{
|
||||||
}
|
frameRate = (WebRtc_UWord32)(_incomingFrameRate / qm->temporalFact + 1);
|
||||||
// Reset _incomingFrameRate if temporal action was selected.
|
|
||||||
if (qm->temporalFact != 1) {
|
|
||||||
memset(_incomingFrameTimes, -1, sizeof(_incomingFrameTimes));
|
|
||||||
_incomingFrameRate = frameRate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spatial
|
// Spatial
|
||||||
WebRtc_UWord32 width = _codecWidth;
|
|
||||||
WebRtc_UWord32 height = _codecHeight;
|
WebRtc_UWord32 height = _codecHeight;
|
||||||
// Check if go back up in spatial resolution, and update frame sizes.
|
WebRtc_UWord32 width = _codecWidth;
|
||||||
// Currently only allow for 2x2 spatial down-sampling.
|
// Check if go back up in spatial resolution
|
||||||
// TODO (marpan): allow for 1x2, 2x1, and 4/3x4/3 (or 3/2x3/2).
|
if (qm->spatialHeightFact == 0 && qm->spatialWidthFact == 0)
|
||||||
if (qm->spatialHeightFact == 0 && qm->spatialWidthFact == 0) {
|
{
|
||||||
width = _codecWidth * 2;
|
height = cm->nativeHeight;
|
||||||
height = _codecHeight * 2;
|
width = cm->nativeWidth;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
width = _codecWidth / qm->spatialWidthFact;
|
{
|
||||||
height = _codecHeight / qm->spatialHeightFact;
|
height = _codecHeight / qm->spatialHeightFact;
|
||||||
|
width = _codecWidth / qm->spatialWidthFact;
|
||||||
}
|
}
|
||||||
_codecWidth = width;
|
|
||||||
_codecHeight = height;
|
|
||||||
|
|
||||||
// New frame sizes should never exceed the original sizes
|
|
||||||
// from SetEncodingData().
|
|
||||||
assert(_codecWidth <= _initCodecWidth);
|
|
||||||
assert(_codecHeight <= _initCodecHeight);
|
|
||||||
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, _id,
|
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideoCoding, _id,
|
||||||
"Quality Mode Update: W = %d, H = %d, FR = %f",
|
"Quality Mode Update: W = %d, H = %d, FR = %f",
|
||||||
@ -635,6 +623,8 @@ VCMMediaOptimization::QMUpdate(VCMResolutionScale* qm)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VCMMediaOptimization::UpdateIncomingFrameRate()
|
VCMMediaOptimization::UpdateIncomingFrameRate()
|
||||||
{
|
{
|
||||||
@ -681,6 +671,10 @@ VCMMediaOptimization::ProcessIncomingFrameRate(WebRtc_Word64 now)
|
|||||||
_incomingFrameRate = nrOfFrames * 1000.0f / static_cast<float>(diff);
|
_incomingFrameRate = nrOfFrames * 1000.0f / static_cast<float>(diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_incomingFrameRate = static_cast<float>(nrOfFrames);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_UWord32
|
WebRtc_UWord32
|
||||||
|
@ -168,8 +168,6 @@ private:
|
|||||||
VideoCodecType _sendCodecType;
|
VideoCodecType _sendCodecType;
|
||||||
WebRtc_UWord16 _codecWidth;
|
WebRtc_UWord16 _codecWidth;
|
||||||
WebRtc_UWord16 _codecHeight;
|
WebRtc_UWord16 _codecHeight;
|
||||||
WebRtc_UWord16 _initCodecWidth;
|
|
||||||
WebRtc_UWord16 _initCodecHeight;
|
|
||||||
float _userFrameRate;
|
float _userFrameRate;
|
||||||
|
|
||||||
VCMFrameDropper* _frameDropper;
|
VCMFrameDropper* _frameDropper;
|
||||||
|
@ -823,8 +823,26 @@ WebRtc_Word32 QMTestVideoSettingsCallback::SetVideoQMSettings(
|
|||||||
const WebRtc_UWord32 frame_rate,
|
const WebRtc_UWord32 frame_rate,
|
||||||
const WebRtc_UWord32 width,
|
const WebRtc_UWord32 width,
|
||||||
const WebRtc_UWord32 height) {
|
const WebRtc_UWord32 height) {
|
||||||
// Update VPM with encoder target resolution
|
WebRtc_Word32 ret_val = 0;
|
||||||
return vpm_->SetTargetResolution(width, height, frame_rate);
|
ret_val = vpm_->SetTargetResolution(width, height, frame_rate);
|
||||||
|
|
||||||
|
if (!ret_val) {
|
||||||
|
// Get current settings.
|
||||||
|
VideoCodec current_codec;
|
||||||
|
vcm_->SendCodec(¤t_codec);
|
||||||
|
WebRtc_UWord32 current_bit_rate = vcm_->Bitrate();
|
||||||
|
|
||||||
|
// Set the new calues.
|
||||||
|
current_codec.height = static_cast<WebRtc_UWord16>(height);
|
||||||
|
current_codec.width = static_cast<WebRtc_UWord16>(width);
|
||||||
|
current_codec.maxFramerate = static_cast<WebRtc_UWord8>(frame_rate);
|
||||||
|
current_codec.startBitrate = current_bit_rate;
|
||||||
|
|
||||||
|
// Re-register encoder with the updated settings.
|
||||||
|
ret_val = vcm_->RegisterSendCodec(¤t_codec, num_cores_,
|
||||||
|
max_payload_length_);
|
||||||
|
}
|
||||||
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMTestVideoSettingsCallback::SetMaxPayloadLength(
|
void QMTestVideoSettingsCallback::SetMaxPayloadLength(
|
||||||
|
Loading…
Reference in New Issue
Block a user