[vlc-commits] avcodec: keep the source crop information if it's available
Steve Lhomme
git at videolan.org
Wed Sep 19 12:15:03 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Sep 17 09:52:28 2018 +0200| [3d82cde70b0e64ec552f507955fd2b53ec7a9710] | committer: Steve Lhomme
avcodec: keep the source crop information if it's available
There's no way to tell lavc where to crop the video so we copy the metadata
from the decoder source format.
Ref: #21192
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3d82cde70b0e64ec552f507955fd2b53ec7a9710
---
modules/codec/avcodec/video.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 560f8a5496..91ee22f878 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -182,8 +182,24 @@ static int lavc_GetVideoFormat(decoder_t *dec, video_format_t *restrict fmt,
fmt->i_width = width;
fmt->i_height = height;
- fmt->i_visible_width = ctx->width;
- fmt->i_visible_height = ctx->height;
+ if ( dec->fmt_in.video.i_visible_width != 0 &&
+ dec->fmt_in.video.i_visible_width <= ctx->width &&
+ dec->fmt_in.video.i_visible_height != 0 &&
+ dec->fmt_in.video.i_visible_height <= ctx->height )
+ {
+ /* the demuxer/packetizer provided crop info that are lost in lavc */
+ fmt->i_visible_width = dec->fmt_in.video.i_visible_width;
+ fmt->i_visible_height = dec->fmt_in.video.i_visible_height;
+ fmt->i_x_offset = dec->fmt_in.video.i_x_offset;
+ fmt->i_y_offset = dec->fmt_in.video.i_y_offset;
+ }
+ else
+ {
+ fmt->i_visible_width = ctx->width;
+ fmt->i_visible_height = ctx->height;
+ fmt->i_x_offset = 0;
+ fmt->i_y_offset = 0;
+ }
/* If an aspect-ratio was specified in the input format then force it */
if (dec->fmt_in.video.i_sar_num > 0 && dec->fmt_in.video.i_sar_den > 0)
More information about the vlc-commits
mailing list