mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-02 13:58:37 +00:00
分辨率修改:改为只支持标准480p 720p 1080p
This commit is contained in:
parent
c0015b4f63
commit
91bc8da018
3 changed files with 46 additions and 3 deletions
|
@ -74,14 +74,17 @@ VideoForm::VideoForm(QWidget *parent) :
|
||||||
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
||||||
m_frames.lock();
|
m_frames.lock();
|
||||||
const AVFrame *frame = m_frames.consumeRenderedFrame();
|
const AVFrame *frame = m_frames.consumeRenderedFrame();
|
||||||
|
qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
|
||||||
updateShowSize(QSize(frame->width, frame->height));
|
updateShowSize(QSize(frame->width, frame->height));
|
||||||
ui->videoWidget->setFrameSize(QSize(frame->width, frame->height));
|
ui->videoWidget->setFrameSize(QSize(frame->width, frame->height));
|
||||||
ui->videoWidget->updateTextures(frame->data[0], frame->data[1], frame->data[2], frame->linesize[0], frame->linesize[1], frame->linesize[2]);
|
ui->videoWidget->updateTextures(frame->data[0], frame->data[1], frame->data[2], frame->linesize[0], frame->linesize[1], frame->linesize[2]);
|
||||||
m_frames.unLock();
|
m_frames.unLock();
|
||||||
},Qt::QueuedConnection);
|
},Qt::QueuedConnection);
|
||||||
|
|
||||||
m_server->start("P7C0218510000537", 27183, 1080, 8000000, "");
|
// support 480p 720p 1080p
|
||||||
//m_server->start("P7C0218510000537", 27183, 0, 8000000, "");
|
//m_server->start("P7C0218510000537", 27183, 0, 8000000, "");
|
||||||
|
//m_server->start("P7C0218510000537", 27183, 1080, 8000000, "");
|
||||||
|
m_server->start("P7C0218510000537", 27183, 720, 8000000, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoForm::~VideoForm()
|
VideoForm::~VideoForm()
|
||||||
|
|
Binary file not shown.
|
@ -69,6 +69,7 @@ public final class Device {
|
||||||
@SuppressWarnings("checkstyle:MagicNumber")
|
@SuppressWarnings("checkstyle:MagicNumber")
|
||||||
private static Size computeVideoSize(int w, int h, int maxSize) {
|
private static Size computeVideoSize(int w, int h, int maxSize) {
|
||||||
// Compute the video size and the padding of the content inside this video.
|
// Compute the video size and the padding of the content inside this video.
|
||||||
|
/*
|
||||||
// Principle:
|
// Principle:
|
||||||
// - scale down the great side of the screen to maxSize (if necessary);
|
// - scale down the great side of the screen to maxSize (if necessary);
|
||||||
// - scale down the other side so that the aspect ratio is preserved;
|
// - scale down the other side so that the aspect ratio is preserved;
|
||||||
|
@ -91,7 +92,46 @@ public final class Device {
|
||||||
w = portrait ? minor : major;
|
w = portrait ? minor : major;
|
||||||
h = portrait ? major : minor;
|
h = portrait ? major : minor;
|
||||||
}
|
}
|
||||||
return new Size(w, h);
|
*/
|
||||||
|
|
||||||
|
// Principle:480p/720p/1080p and not larger than device size.
|
||||||
|
w &= ~7; // in case it's not a multiple of 8
|
||||||
|
h &= ~7;
|
||||||
|
boolean vertival = h > w;
|
||||||
|
boolean validSize = false;
|
||||||
|
int newWidth = w;
|
||||||
|
int newHeight = h;
|
||||||
|
// 480p/720p/1080p
|
||||||
|
switch (maxSize) {
|
||||||
|
case 480: // 480p:640x480
|
||||||
|
newWidth = 640;
|
||||||
|
newHeight = 480;
|
||||||
|
validSize = true;
|
||||||
|
break;
|
||||||
|
case 720: // 720p:1280x720
|
||||||
|
newWidth = 1280;
|
||||||
|
newHeight = 720;
|
||||||
|
validSize = true;
|
||||||
|
break;
|
||||||
|
case 1080: // 1080p:1920x1080
|
||||||
|
newWidth = 1920;
|
||||||
|
newHeight = 1080;
|
||||||
|
validSize = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// vertival convert
|
||||||
|
if (validSize && vertival) {
|
||||||
|
int temp = newWidth;
|
||||||
|
newWidth = newHeight;
|
||||||
|
newHeight = temp;
|
||||||
|
}
|
||||||
|
// not larger than device size.
|
||||||
|
if (newWidth > w || newHeight > h) {
|
||||||
|
newWidth = w;
|
||||||
|
newHeight = h;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Size(newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getPhysicalPoint(Position position) {
|
public Point getPhysicalPoint(Position position) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue