/
frameworks_av.patch
153 lines (135 loc) · 5.44 KB
/
frameworks_av.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
From a91219554f6b9a2f5b2d0fa3700d7b9457141a43 Mon Sep 17 00:00:00 2001
From: Pawit Pornkitprasan <p.pawit@gmail.com>
Date: Thu, 5 Dec 2013 13:26:35 +0700
Subject: [PATCH 1/2] screenrecord: allow force landscape mode
Some devices' hardware encoder do not support encoding over a
specified height, which may be smaller than the device's display
height in portrait mode. Add a mode which uses landscape encoding
and rotation hint to overcome the limitation.
Change-Id: Icdd8de05d55c2aaaacbcaba4857173c78ef76a24
Conflicts:
cmds/screenrecord/screenrecord.cpp
---
cmds/screenrecord/Android.mk | 4 ++++
cmds/screenrecord/screenrecord.cpp | 20 +++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/cmds/screenrecord/Android.mk b/cmds/screenrecord/Android.mk
index 6747e6015..d9a1e8770 100644
--- a/cmds/screenrecord/Android.mk
+++ b/cmds/screenrecord/Android.mk
@@ -16,6 +16,10 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
+ifeq ($(BOARD_SCREENRECORD_LANDSCAPE_ONLY),true)
+ LOCAL_CFLAGS += -DLANDSCAPE_ONLY
+endif
+
LOCAL_SRC_FILES := \
screenrecord.cpp \
EglWindow.cpp \
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index 59d566127..7fb656258 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -65,6 +65,13 @@ static const uint32_t kFallbackWidth = 1280; // 720p
static const uint32_t kFallbackHeight = 720;
static const char* kMimeTypeAvc = "video/avc";
+// Build-time parameters.
+#ifdef LANDSCAPE_ONLY
+static bool gLandscapeOnly = true; // Only encode in landscape
+#else
+static bool gLandscapeOnly = false;
+#endif
+
// Command-line parameters.
static bool gVerbose = false; // chatty on stdout
static bool gRotate = false; // rotate 90 degrees
@@ -560,6 +567,17 @@ static status_t recordScreen(const char* fileName) {
gVideoHeight = rotated ? mainDpyInfo.w : mainDpyInfo.h;
}
+ // Some devices cannot handle encoding tall height (> 720), so we
+ // compensate by encoding in landscape and rotating
+ bool autoRotated = false;
+ if (gLandscapeOnly && !gSizeSpecified && gVideoHeight > gVideoWidth) {
+ int newWidth = gVideoHeight;
+ gVideoHeight = gVideoWidth;
+ gVideoWidth = newWidth;
+ gRotate = !gRotate;
+ autoRotated = true;
+ }
+
// Configure and start the encoder.
sp<MediaCodec> encoder;
sp<FrameOutput> frameOutput;
@@ -650,7 +668,7 @@ static status_t recordScreen(const char* fileName) {
muxer = new MediaMuxer(fd, MediaMuxer::OUTPUT_FORMAT_MPEG_4);
close(fd);
if (gRotate) {
- muxer->setOrientationHint(90); // TODO: does this do anything?
+ muxer->setOrientationHint(autoRotated ? 270 : 90);
}
break;
}
--
2.11.0
From ba9b456162571d09684b1a7274d53e58eaaaa847 Mon Sep 17 00:00:00 2001
From: Michael Gernoth <michael@gernoth.net>
Date: Wed, 11 Mar 2015 03:19:22 -0500
Subject: [PATCH 2/2] libstagefright: Make it possible to skip OMX buffer
reallocation
Some devices don't like the call to setParameter() at this point, so
skip this call if enough buffers are already allocated. This check
was present in KitKat but got removed when code to allocate extra-
buffers was introduced.
This is activated only for omap4 for now, but also has an opt-in via BOARD_CANT_REALLOCATE_OMX_BUFFERS
Conflicts:
media/libstagefright/Android.mk
media/libstagefright/OMXCodec.cpp
---
media/libstagefright/ACodec.cpp | 9 +++++++++
media/libstagefright/Android.mk | 8 ++++++++
2 files changed, 17 insertions(+)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 37fd5a51e..2e8ddc2b8 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1052,6 +1052,12 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
// 2. try to allocate two (2) additional buffers to reduce starvation from
// the consumer
// plus an extra buffer to account for incorrect minUndequeuedBufs
+#ifdef BOARD_CANT_REALLOCATE_OMX_BUFFERS
+ // Some devices don't like to set OMX_IndexParamPortDefinition at this
+ // point (even with an unmodified def), so skip it if possible.
+ // This check was present in KitKat.
+ if (def.nBufferCountActual < def.nBufferCountMin + *minUndequeuedBuffers) {
+#endif
for (OMX_U32 extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
OMX_U32 newBufferCount =
def.nBufferCountMin + *minUndequeuedBuffers + extraBuffers;
@@ -1071,6 +1077,9 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
return err;
}
}
+#ifdef BOARD_CANT_REALLOCATE_OMX_BUFFERS
+ }
+#endif
err = native_window_set_buffer_count(
mNativeWindow.get(), def.nBufferCountActual);
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 38485021e..02b9aba61 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -131,6 +131,14 @@ ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DENABLE_STAGEFRIGHT_EXPERIMENTS
endif
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+LOCAL_CFLAGS += -DBOARD_CANT_REALLOCATE_OMX_BUFFERS
+endif
+
+ifeq ($(BOARD_CANT_REALLOCATE_OMX_BUFFERS),true)
+LOCAL_CFLAGS += -DBOARD_CANT_REALLOCATE_OMX_BUFFERS
+endif
+
LOCAL_CLANG := true
LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow
--
2.11.0