From: Dafna Hirschfeld <dafna3@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, helen.koike@collabora.com,
Dafna Hirschfeld <dafna3@gmail.com>
Subject: [v4l-utils PATCH v2 2/5] v4l2-ctl: Add function get_codec_type
Date: Mon, 21 Jan 2019 10:56:48 -0800 [thread overview]
Message-ID: <20190121185651.6229-3-dafna3@gmail.com> (raw)
In-Reply-To: <20190121185651.6229-1-dafna3@gmail.com>
Add function get_codec_type that returns the type
of codec NOT_CODEC/ENCODER/DEOCDER.
Move the functions get_cap_compose/crop_rect
to the start of the file.
Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
---
utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 123 ++++++++++++++++++--------
1 file changed, 85 insertions(+), 38 deletions(-)
diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
index 8a98b6bd..1383c5f2 100644
--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp
@@ -82,6 +82,12 @@ static bool support_out_crop;
#define TS_WINDOW 241
#define FILE_HDR_ID v4l2_fourcc('V', 'h', 'd', 'r')
+enum codec_type {
+ NOT_CODEC,
+ ENCODER,
+ DECODER
+};
+
class fps_timestamps {
private:
unsigned idx;
@@ -334,6 +340,85 @@ void streaming_usage(void)
V4L_STREAM_PORT);
}
+static enum codec_type get_codec_type(cv4l_fd &fd)
+{
+ struct v4l2_fmtdesc fmt_desc;
+ int num_cap_fmts = 0;
+ int num_compressed_cap_fmts = 0;
+ int num_out_fmts = 0;
+ int num_compressed_out_fmts = 0;
+
+ if (!fd.has_vid_m2m())
+ return NOT_CODEC;
+
+ if (fd.enum_fmt(fmt_desc, true, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE))
+ return NOT_CODEC;
+
+ do {
+ if (fmt_desc.flags & V4L2_FMT_FLAG_COMPRESSED)
+ num_compressed_cap_fmts++;
+ num_cap_fmts++;
+ } while (!fd.enum_fmt(fmt_desc));
+
+
+ if (fd.enum_fmt(fmt_desc, true, 0, V4L2_BUF_TYPE_VIDEO_OUTPUT))
+ return NOT_CODEC;
+
+ do {
+ if (fmt_desc.flags & V4L2_FMT_FLAG_COMPRESSED)
+ num_compressed_out_fmts++;
+ num_out_fmts++;
+ } while (!fd.enum_fmt(fmt_desc));
+
+ if (num_compressed_out_fmts == 0 && num_compressed_cap_fmts == num_cap_fmts) {
+ return ENCODER;
+ }
+
+ if (num_compressed_cap_fmts == 0 && num_compressed_out_fmts == num_out_fmts) {
+ return DECODER;
+ }
+
+ return NOT_CODEC;
+}
+
+static int get_cap_compose_rect(cv4l_fd &fd)
+{
+ v4l2_selection sel;
+
+ memset(&sel, 0, sizeof(sel));
+ sel.type = vidcap_buftype;
+ sel.target = V4L2_SEL_TGT_COMPOSE;
+
+ if (fd.g_selection(sel) == 0) {
+ support_cap_compose = true;
+ composed_width = sel.r.width;
+ composed_height = sel.r.height;
+ return 0;
+ }
+
+ support_cap_compose = false;
+ return 0;
+}
+
+static int get_out_crop_rect(cv4l_fd &fd)
+{
+ v4l2_selection sel;
+
+ memset(&sel, 0, sizeof(sel));
+ sel.type = vidout_buftype;
+ sel.target = V4L2_SEL_TGT_CROP;
+
+ if (fd.g_selection(sel) == 0) {
+ support_out_crop = true;
+ cropped_width = sel.r.width;
+ cropped_height = sel.r.height;
+ return 0;
+ }
+
+ support_out_crop = false;
+ return 0;
+}
+
static void set_time_stamp(cv4l_buffer &buf)
{
if ((buf.g_flags() & V4L2_BUF_FLAG_TIMESTAMP_MASK) != V4L2_BUF_FLAG_TIMESTAMP_COPY)
@@ -2109,44 +2194,6 @@ done:
fclose(file[OUT]);
}
-static int get_cap_compose_rect(cv4l_fd &fd)
-{
- v4l2_selection sel;
-
- memset(&sel, 0, sizeof(sel));
- sel.type = vidcap_buftype;
- sel.target = V4L2_SEL_TGT_COMPOSE;
-
- if (fd.g_selection(sel) == 0) {
- support_cap_compose = true;
- composed_width = sel.r.width;
- composed_height = sel.r.height;
- return 0;
- }
-
- support_cap_compose = false;
- return 0;
-}
-
-static int get_out_crop_rect(cv4l_fd &fd)
-{
- v4l2_selection sel;
-
- memset(&sel, 0, sizeof(sel));
- sel.type = vidout_buftype;
- sel.target = V4L2_SEL_TGT_CROP;
-
- if (fd.g_selection(sel) == 0) {
- support_out_crop = true;
- cropped_width = sel.r.width;
- cropped_height = sel.r.height;
- return 0;
- }
-
- support_out_crop = false;
- return 0;
-}
-
void streaming_set(cv4l_fd &fd, cv4l_fd &out_fd)
{
cv4l_disable_trace dt(fd);
--
2.17.1
next prev parent reply other threads:[~2019-01-21 18:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 18:56 [v4l-utils PATCH v2 0/5] source change support in v4l2-ctl Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 1/5] v4l2-ctl: Add support for crop and compose selection in streaming Dafna Hirschfeld
2019-01-21 18:56 ` Dafna Hirschfeld [this message]
2019-01-21 18:56 ` [v4l-utils PATCH v2 3/5] v4l2-ctl: Introduce capture_setup Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 4/5] v4l2-ctl: Add support for source change event for m2m decoder Dafna Hirschfeld
2019-01-21 18:56 ` [v4l-utils PATCH v2 5/5] v4l2-ctl: Add --stream-pixformat option Dafna Hirschfeld
2019-01-28 9:17 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190121185651.6229-3-dafna3@gmail.com \
--to=dafna3@gmail.com \
--cc=helen.koike@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).