summaryrefslogtreecommitdiff
path: root/libavcodec/mediacodecdec_common.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-03-19 16:29:45 -0700
committerAman Gupta <aman@tmm1.net>2018-03-20 15:52:23 -0700
commit2ddc6b439226a7dffb740d6e50bdd835a27d10ea (patch)
treed34278b7ef833feb08b35f3e2816f3e69fb2b663 /libavcodec/mediacodecdec_common.c
parent9e67447a4ffacf28af8bace33faf3ea432ddc43e (diff)
avcodec/mediacodecdec: propagate SAR to h/w frames
Allows consumers who are converting hardware buffers to OpenGL textures to render the frames at the intended display resolution. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec/mediacodecdec_common.c')
-rw-r--r--libavcodec/mediacodecdec_common.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 635ee73486..e31adb487c 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -205,6 +205,7 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
frame->width = avctx->width;
frame->height = avctx->height;
frame->format = avctx->pix_fmt;
+ frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
frame->pts = av_rescale_q(info->presentationTimeUs,
@@ -414,6 +415,16 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
width = s->crop_right + 1 - s->crop_left;
height = s->crop_bottom + 1 - s->crop_top;
+ AMEDIAFORMAT_GET_INT32(s->display_width, "display-width", 0);
+ AMEDIAFORMAT_GET_INT32(s->display_height, "display-height", 0);
+
+ if (s->display_width && s->display_height) {
+ AVRational sar = av_div_q(
+ (AVRational){ s->display_width, s->display_height },
+ (AVRational){ width, height });
+ ff_set_sar(avctx, sar);
+ }
+
av_log(avctx, AV_LOG_INFO,
"Output crop parameters top=%d bottom=%d left=%d right=%d, "
"resulting dimensions width=%d height=%d\n",