Remove EnableMirroring and MirrorRenderStream

R=mflodman@webrtc.org, pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/35239004

Cr-Commit-Position: refs/heads/master@{#8409}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8409 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
magjed@webrtc.org 2015-02-18 12:54:48 +00:00
parent 131bea89d6
commit f68e186de3
17 changed files with 1 additions and 305 deletions

View File

@ -956,8 +956,6 @@ class FakeWebRtcVideoEngine
WEBRTC_STUB(SetExpectedRenderDelay, (int render_id, int render_delay));
WEBRTC_STUB(ConfigureRender, (int, const unsigned int, const float,
const float, const float, const float));
WEBRTC_STUB(MirrorRenderStream, (const int, const bool, const bool,
const bool));
WEBRTC_FUNC(AddRenderer, (const int render_id,
webrtc::RawVideoType video_type,
webrtc::ExternalRenderer* renderer)) {

View File

@ -177,13 +177,6 @@ class WebRtcPassthroughRender : public webrtc::VideoRender {
return -1;
}
virtual int32_t MirrorRenderStream(const int renderId,
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis) OVERRIDE {
return -1;
}
private:
typedef std::map<uint32_t, PassthroughStream*> StreamMap;

View File

@ -152,19 +152,6 @@ int ConvertNV12ToRGB565(const uint8_t* src_frame,
uint8_t* dst_frame,
int width, int height);
// Mirror functions
// The following 2 functions perform mirroring on a given image
// (LeftRight/UpDown).
// Input:
// - src_frame : Pointer to a source frame.
// - dst_frame : Pointer to a destination frame.
// Return value: 0 if OK, < 0 otherwise.
// It is assumed that src and dst frames have equal dimensions.
int MirrorI420LeftRight(const I420VideoFrame* src_frame,
I420VideoFrame* dst_frame);
int MirrorI420UpDown(const I420VideoFrame* src_frame,
I420VideoFrame* dst_frame);
// Compute PSNR for an I420 frame (all planes).
// Returns the PSNR in decibel, to a maximum of kInfinitePSNR.
double I420PSNR(const I420VideoFrame* ref_frame,

View File

@ -326,69 +326,6 @@ TEST_F(TestLibYuv, RotateTest) {
0, kRotate180, &rotated_res_i420_frame));
}
TEST_F(TestLibYuv, MirrorTest) {
// TODO(mikhal): Add an automated test to confirm output.
std::string str;
int width = 16;
int half_width = (width + 1) / 2;
int height = 8;
int half_height = (height + 1) / 2;
I420VideoFrame test_frame;
test_frame.CreateEmptyFrame(width, height, width,
half_width, half_width);
memset(test_frame.buffer(kYPlane), 255, width * height);
memset(test_frame.buffer(kUPlane), 255, half_width * half_height);
memset(test_frame.buffer(kVPlane), 255, half_width * half_height);
// Create input frame.
I420VideoFrame in_frame, test_in_frame;
in_frame.CreateEmptyFrame(width, height, width,
half_width ,half_width);
int plane_offset[kNumOfPlanes];
plane_offset[kYPlane] = 10;
plane_offset[kUPlane] = 100;
plane_offset[kVPlane] = 200;
CreateImage(&in_frame, plane_offset);
EXPECT_EQ(0, PrintFrame(&in_frame, "InputFrame"));
test_in_frame.CopyFrame(in_frame);
I420VideoFrame out_frame, test_out_frame;
out_frame.CreateEmptyFrame(width, height, width,
half_width ,half_width);
CreateImage(&out_frame, plane_offset);
test_out_frame.CopyFrame(out_frame);
// Left-Right.
std::cout << "Test Mirror function: LeftRight" << std::endl;
EXPECT_EQ(0, MirrorI420LeftRight(&in_frame, &out_frame));
EXPECT_EQ(0, PrintFrame(&out_frame, "OutputFrame"));
EXPECT_EQ(0, MirrorI420LeftRight(&out_frame, &in_frame));
EXPECT_EQ(0, memcmp(in_frame.buffer(kYPlane),
test_in_frame.buffer(kYPlane), width * height));
EXPECT_EQ(0, memcmp(in_frame.buffer(kUPlane),
test_in_frame.buffer(kUPlane), half_width * half_height));
EXPECT_EQ(0, memcmp(in_frame.buffer(kVPlane),
test_in_frame.buffer(kVPlane), half_width * half_height));
// UpDown
std::cout << "Test Mirror function: UpDown" << std::endl;
EXPECT_EQ(0, MirrorI420UpDown(&in_frame, &out_frame));
EXPECT_EQ(0, PrintFrame(&out_frame, "OutputFrame"));
EXPECT_EQ(0, MirrorI420UpDown(&out_frame, &test_frame));
EXPECT_EQ(0, memcmp(in_frame.buffer(kYPlane),
test_in_frame.buffer(kYPlane), width * height));
EXPECT_EQ(0, memcmp(in_frame.buffer(kUPlane),
test_in_frame.buffer(kUPlane), half_width * half_height));
EXPECT_EQ(0, memcmp(in_frame.buffer(kVPlane),
test_in_frame.buffer(kVPlane), half_width * half_height));
// TODO(mikhal): Write to a file, and ask to look at the file.
std::cout << "Do the mirrored frames look correct?" << std::endl;
}
TEST_F(TestLibYuv, alignment) {
int value = 0x3FF; // 1023
EXPECT_EQ(0x400, AlignInt(value, 128)); // Low 7 bits are zero.

View File

@ -288,50 +288,6 @@ int ConvertFromYV12(const I420VideoFrame& src_frame,
ConvertVideoType(dst_video_type));
}
int MirrorI420LeftRight(const I420VideoFrame* src_frame,
I420VideoFrame* dst_frame) {
// Source and destination frames should have equal resolution.
if (src_frame->width() != dst_frame->width() ||
src_frame->height() != dst_frame->height())
return -1;
return libyuv::I420Mirror(src_frame->buffer(kYPlane),
src_frame->stride(kYPlane),
src_frame->buffer(kUPlane),
src_frame->stride(kUPlane),
src_frame->buffer(kVPlane),
src_frame->stride(kVPlane),
dst_frame->buffer(kYPlane),
dst_frame->stride(kYPlane),
dst_frame->buffer(kUPlane),
dst_frame->stride(kUPlane),
dst_frame->buffer(kVPlane),
dst_frame->stride(kVPlane),
src_frame->width(), src_frame->height());
}
int MirrorI420UpDown(const I420VideoFrame* src_frame,
I420VideoFrame* dst_frame) {
// Source and destination frames should have equal resolution
if (src_frame->width() != dst_frame->width() ||
src_frame->height() != dst_frame->height())
return -1;
// Inserting negative height flips the frame.
return libyuv::I420Copy(src_frame->buffer(kYPlane),
src_frame->stride(kYPlane),
src_frame->buffer(kUPlane),
src_frame->stride(kUPlane),
src_frame->buffer(kVPlane),
src_frame->stride(kVPlane),
dst_frame->buffer(kYPlane),
dst_frame->stride(kYPlane),
dst_frame->buffer(kUPlane),
dst_frame->stride(kUPlane),
dst_frame->buffer(kVPlane),
dst_frame->stride(kVPlane),
src_frame->width(), -(src_frame->height()));
}
// Compute PSNR for an I420 frame (all planes)
double I420PSNR(const I420VideoFrame* ref_frame,
const I420VideoFrame* test_frame) {

View File

@ -271,11 +271,6 @@ public:
virtual int32_t SetTimeoutImage(const uint32_t streamId,
const I420VideoFrame& videoFrame,
const uint32_t timeout)= 0;
virtual int32_t MirrorRenderStream(const int renderId,
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis) = 0;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_INTERFACE_VIDEO_RENDER_H_

View File

@ -54,10 +54,7 @@ IncomingVideoStream::IncomingVideoStream(const int32_t module_id,
temp_frame_(),
start_image_(),
timeout_image_(),
timeout_time_(),
mirror_frames_enabled_(false),
mirroring_(),
transformed_video_frame_() {
timeout_time_() {
WEBRTC_TRACE(kTraceMemory, kTraceVideoRenderer, module_id_,
"%s created for stream %d", __FUNCTION__, stream_id);
}
@ -100,25 +97,6 @@ int32_t IncomingVideoStream::RenderFrame(const uint32_t stream_id,
return -1;
}
// Mirroring is not supported if the frame is backed by a texture.
if (true == mirror_frames_enabled_ && video_frame.native_handle() == NULL) {
transformed_video_frame_.CreateEmptyFrame(video_frame.width(),
video_frame.height(),
video_frame.stride(kYPlane),
video_frame.stride(kUPlane),
video_frame.stride(kVPlane));
if (mirroring_.mirror_x_axis) {
MirrorI420UpDown(&video_frame,
&transformed_video_frame_);
video_frame.SwapFrame(&transformed_video_frame_);
}
if (mirroring_.mirror_y_axis) {
MirrorI420LeftRight(&video_frame,
&transformed_video_frame_);
video_frame.SwapFrame(&transformed_video_frame_);
}
}
// Rate statistics.
num_frames_since_last_calculation_++;
int64_t now_ms = TickTime::MillisecondTimestamp();
@ -162,17 +140,6 @@ int32_t IncomingVideoStream::SetRenderCallback(
return 0;
}
int32_t IncomingVideoStream::EnableMirroring(const bool enable,
const bool mirror_x_axis,
const bool mirror_y_axis) {
CriticalSectionScoped cs(&stream_critsect_);
mirror_frames_enabled_ = enable;
mirroring_.mirror_x_axis = mirror_x_axis;
mirroring_.mirror_y_axis = mirror_y_axis;
return 0;
}
int32_t IncomingVideoStream::SetExpectedRenderDelay(
int32_t delay_ms) {
CriticalSectionScoped csS(&stream_critsect_);

View File

@ -20,12 +20,6 @@ class ThreadWrapper;
class VideoRenderCallback;
class VideoRenderFrames;
struct VideoMirroring {
VideoMirroring() : mirror_x_axis(false), mirror_y_axis(false) {}
bool mirror_x_axis;
bool mirror_y_axis;
};
class IncomingVideoStream : public VideoRenderCallback {
public:
IncomingVideoStream(const int32_t module_id,
@ -63,10 +57,6 @@ class IncomingVideoStream : public VideoRenderCallback {
int32_t SetTimeoutImage(const I420VideoFrame& video_frame,
const uint32_t timeout);
int32_t EnableMirroring(const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis);
int32_t SetExpectedRenderDelay(int32_t delay_ms);
protected:
@ -104,10 +94,6 @@ class IncomingVideoStream : public VideoRenderCallback {
I420VideoFrame start_image_;
I420VideoFrame timeout_image_;
uint32_t timeout_time_;
bool mirror_frames_enabled_;
VideoMirroring mirroring_;
I420VideoFrame transformed_video_frame_;
};
} // namespace webrtc

View File

@ -648,32 +648,4 @@ int32_t ModuleVideoRenderImpl::SetTimeoutImage(
return item->second->SetTimeoutImage(videoFrame, timeout);
}
int32_t ModuleVideoRenderImpl::MirrorRenderStream(const int renderId,
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis)
{
CriticalSectionScoped cs(&_moduleCrit);
if (!_ptrRenderer)
{
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
"%s: No renderer", __FUNCTION__);
return -1;
}
IncomingVideoStreamMap::const_iterator item =
_streamRenderMap.find(renderId);
if (item == _streamRenderMap.end())
{
// This stream doesn't exist
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
"%s: stream doesn't exist", __FUNCTION__);
return 0;
}
assert(item->second != NULL);
return item->second->EnableMirroring(enable, mirrorXAxis, mirrorYAxis);
}
} // namespace webrtc

View File

@ -202,11 +202,6 @@ public:
const I420VideoFrame& videoFrame,
const uint32_t timeout);
virtual int32_t MirrorRenderStream(const int renderId,
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis);
private:
int32_t _id;
CriticalSectionWrapper& _moduleCrit;

View File

@ -871,32 +871,4 @@ int32_t ModuleVideoRenderImpl::SetTimeoutImage(
return item->second->SetTimeoutImage(videoFrame, timeout);
}
int32_t ModuleVideoRenderImpl::MirrorRenderStream(const int renderId,
const bool enable,
const bool mirrorXAxis,
const bool mirrorYAxis)
{
CriticalSectionScoped cs(&_moduleCrit);
if (!_ptrRenderer)
{
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
"%s: No renderer", __FUNCTION__);
return -1;
}
IncomingVideoStreamMap::const_iterator item =
_streamRenderMap.find(renderId);
if (item == _streamRenderMap.end())
{
// This stream doesn't exist
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
"%s: stream doesn't exist", __FUNCTION__);
return 0;
}
assert(item->second != NULL);
return item->second->EnableMirroring(enable, mirrorXAxis, mirrorYAxis);
}
} // namespace webrtc

View File

@ -108,12 +108,6 @@ class ViERender {
const float right,
const float bottom) = 0;
// This function mirrors the rendered stream left and right or up and down.
virtual int MirrorRenderStream(const int render_id,
const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis) = 0;
// External render.
virtual int AddRenderer(const int render_id,
RawVideoType video_input_format,

View File

@ -220,29 +220,6 @@ void ViEAutoTest::ViERenderExtendedTest()
AutoTestSleep(kAutoTestSleepTimeMs);
#endif
ViETest::Log("Mirroring Local Preview (Window1) Left-Right");
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, true, false, true));
AutoTestSleep(kAutoTestSleepTimeMs);
ViETest::Log("\nMirroring Local Preview (Window1) Left-Right and Up-Down");
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, true, true, true));
AutoTestSleep(kAutoTestSleepTimeMs);
ViETest::Log("\nMirroring Remote Window(Window2) Up-Down");
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbChannel.videoChannel, true, true, false));
AutoTestSleep(kAutoTestSleepTimeMs);
ViETest::Log("Disabling Mirroing on Window1 and Window2");
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbCapture.captureId, false, false, false));
AutoTestSleep(kAutoTestSleepTimeMs);
EXPECT_EQ(0, ViE.render->MirrorRenderStream(
tbChannel.videoChannel, false, false, false));
AutoTestSleep(kAutoTestSleepTimeMs);
ViETest::Log("\nEnabling Full Screen render in 5 sec");
EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId));

View File

@ -236,23 +236,6 @@ int ViERenderImpl::ConfigureRender(int render_id, const unsigned int z_order,
return 0;
}
int ViERenderImpl::MirrorRenderStream(const int render_id, const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis) {
ViERenderManagerScoped rs(*(shared_data_->render_manager()));
ViERenderer* renderer = rs.Renderer(render_id);
if (!renderer) {
shared_data_->SetLastError(kViERenderInvalidRenderId);
return -1;
}
if (renderer->EnableMirroring(render_id, enable, mirror_xaxis, mirror_yaxis)
!= 0) {
shared_data_->SetLastError(kViERenderUnknownError);
return -1;
}
return 0;
}
int ViERenderImpl::AddRenderer(const int render_id,
RawVideoType video_input_format,
ExternalRenderer* external_renderer) {

View File

@ -40,9 +40,6 @@ class ViERenderImpl
virtual int ConfigureRender(int render_id, const unsigned int z_order,
const float left, const float top,
const float right, const float bottom);
virtual int MirrorRenderStream(const int render_id, const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis);
virtual int AddRenderer(const int render_id, RawVideoType video_input_format,
ExternalRenderer* renderer);

View File

@ -71,14 +71,6 @@ VideoRender& ViERenderer::RenderModule() {
return render_module_;
}
int32_t ViERenderer::EnableMirroring(const int32_t render_id,
const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis) {
return render_module_.MirrorRenderStream(render_id, enable, mirror_xaxis,
mirror_yaxis);
}
int32_t ViERenderer::SetTimeoutImage(const I420VideoFrame& timeout_image,
const int32_t timeout_value) {
return render_module_.SetTimeoutImage(render_id_, timeout_image,

View File

@ -76,11 +76,6 @@ class ViERenderer: public ViEFrameCallback {
VideoRender& RenderModule();
int32_t EnableMirroring(const int32_t render_id,
const bool enable,
const bool mirror_xaxis,
const bool mirror_yaxis);
int32_t SetTimeoutImage(const I420VideoFrame& timeout_image,
const int32_t timeout_value);
int32_t SetRenderStartImage(const I420VideoFrame& start_image);