-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
ffmpeg-999-aspect-ratio.patch
62 lines (56 loc) · 1.81 KB
/
ffmpeg-999-aspect-ratio.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From e5d21ff782977b0fe79a60796dc9d973d98e692c Mon Sep 17 00:00:00 2001
From: Maxime Jourdan <mjourdan@baylibre.com>
Date: Sun, 9 Sep 2018 17:22:35 +0200
Subject: [PATCH] avcodec: v4l2_context: set frame SAR using VIDIOC_CROPCAP
---
libavcodec/v4l2_context.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index efcb0426e4..8bff58ca5d 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -501,6 +501,24 @@ static int v4l2_get_coded_format(V4L2Context* ctx, uint32_t *p)
return 0;
}
+static AVRational v4l2_get_sar(V4L2Context* ctx)
+{
+ struct AVRational sar = { 1, 1 };
+ struct v4l2_cropcap cropcap;
+ int ret;
+
+ memset(&cropcap, 0, sizeof(cropcap));
+ cropcap.type = ctx->type;
+
+ ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_CROPCAP, &cropcap);
+ if (ret)
+ return sar;
+
+ sar.num = cropcap.pixelaspect.numerator;
+ sar.den = cropcap.pixelaspect.denominator;
+ return sar;
+}
+
/*****************************************************************************
*
* V4L2 Context Interface
@@ -574,6 +592,7 @@ int ff_v4l2_context_enqueue_packet(V4L2Context* ctx, const AVPacket* pkt)
int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame)
{
V4L2Buffer* avbuf = NULL;
+ int ret;
/*
* blocks until:
@@ -588,7 +607,12 @@ int ff_v4l2_context_dequeue_frame(V4L2Context* ctx, AVFrame* frame)
return AVERROR(EAGAIN);
}
- return ff_v4l2_buffer_buf_to_avframe(frame, avbuf);
+ ret = ff_v4l2_buffer_buf_to_avframe(frame, avbuf);
+ if (ret)
+ return ret;
+
+ frame->sample_aspect_ratio = v4l2_get_sar(ctx);
+ return 0;
}
int ff_v4l2_context_dequeue_packet(V4L2Context* ctx, AVPacket* pkt)
--
2.18.0