mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-09 01:28:58 +00:00
Parameterizes PNG target dimensions
This commit is contained in:
parent
e0444fdcae
commit
575e6b0a42
1 changed files with 10 additions and 9 deletions
|
@ -81,22 +81,23 @@ static void notify_complete() {
|
||||||
static bool in_frame_to_png(
|
static bool in_frame_to_png(
|
||||||
AVIOContext *output_context,
|
AVIOContext *output_context,
|
||||||
AVCodecContext *codecCtx, AVFrame *inframe) {
|
AVCodecContext *codecCtx, AVFrame *inframe) {
|
||||||
|
int targetHeight = codecCtx->height;
|
||||||
|
int targetWidth = codecCtx->width;
|
||||||
struct SwsContext * swCtx = sws_getContext(codecCtx->width,
|
struct SwsContext * swCtx = sws_getContext(codecCtx->width,
|
||||||
codecCtx->height,
|
codecCtx->height,
|
||||||
codecCtx->pix_fmt,
|
codecCtx->pix_fmt,
|
||||||
codecCtx->width,
|
targetWidth,
|
||||||
codecCtx->height,
|
targetHeight,
|
||||||
AV_PIX_FMT_RGB24,
|
AV_PIX_FMT_RGB24,
|
||||||
SWS_FAST_BILINEAR, 0, 0, 0);
|
SWS_FAST_BILINEAR, 0, 0, 0);
|
||||||
|
|
||||||
AVFrame * rgbFrame = av_frame_alloc();
|
AVFrame * rgbFrame = av_frame_alloc();
|
||||||
LOGV("Image frame width: %d height: %d", codecCtx->width, codecCtx->height);
|
LOGV("Image frame width: %d height: %d scaling to %d x %d", codecCtx->width, codecCtx->height, targetWidth, targetHeight);
|
||||||
rgbFrame->width = codecCtx->width;
|
rgbFrame->width = targetWidth;
|
||||||
rgbFrame->height = codecCtx->height;
|
rgbFrame->height = targetHeight;
|
||||||
rgbFrame->format = AV_PIX_FMT_RGB24;
|
rgbFrame->format = AV_PIX_FMT_RGB24;
|
||||||
av_image_alloc(
|
av_image_alloc(
|
||||||
rgbFrame->data, rgbFrame->linesize, codecCtx->width,
|
rgbFrame->data, rgbFrame->linesize, targetWidth, targetHeight, AV_PIX_FMT_RGB24, 1);
|
||||||
codecCtx->height, AV_PIX_FMT_RGB24, 1);
|
|
||||||
sws_scale(
|
sws_scale(
|
||||||
swCtx, inframe->data, inframe->linesize, 0,
|
swCtx, inframe->data, inframe->linesize, 0,
|
||||||
inframe->height, rgbFrame->data, rgbFrame->linesize);
|
inframe->height, rgbFrame->data, rgbFrame->linesize);
|
||||||
|
@ -112,8 +113,8 @@ static bool in_frame_to_png(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outCodecCtx->width = codecCtx->width;
|
outCodecCtx->width = targetWidth;
|
||||||
outCodecCtx->height = codecCtx->height;
|
outCodecCtx->height = targetHeight;
|
||||||
outCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
outCodecCtx->pix_fmt = AV_PIX_FMT_RGB24;
|
||||||
outCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
|
outCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
if (codecCtx->time_base.num && codecCtx->time_base.num) {
|
if (codecCtx->time_base.num && codecCtx->time_base.num) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue