Skip to content

Commit 50dabc5

Browse files
theandi666Android (Google) Code Review
authored andcommitted
Merge "Set crop params to ANative Window during Initialization."
2 parents ff1cd56 + db62a24 commit 50dabc5

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

include/media/stagefright/OMXCodec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ struct OMXCodec : public MediaSource,
319319
void initOutputFormat(const sp<MetaData> &inputFormat);
320320
status_t initNativeWindow();
321321

322+
void initNativeWindowCrop();
323+
322324
void dumpPortStatus(OMX_U32 portIndex);
323325

324326
status_t configureCodec(const sp<MetaData> &meta);

media/libstagefright/OMXCodec.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,22 +2351,6 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
23512351
formatHasNotablyChanged(oldOutputFormat, mOutputFormat)) {
23522352
mOutputPortSettingsHaveChanged = true;
23532353

2354-
if (mNativeWindow != NULL) {
2355-
int32_t left, top, right, bottom;
2356-
CHECK(mOutputFormat->findRect(
2357-
kKeyCropRect,
2358-
&left, &top, &right, &bottom));
2359-
2360-
android_native_rect_t crop;
2361-
crop.left = left;
2362-
crop.top = top;
2363-
crop.right = right + 1;
2364-
crop.bottom = bottom + 1;
2365-
2366-
// We'll ignore any errors here, if the surface is
2367-
// already invalid, we'll know soon enough.
2368-
native_window_set_crop(mNativeWindow.get(), &crop);
2369-
}
23702354
} else if (data2 == OMX_IndexConfigCommonScale) {
23712355
OMX_CONFIG_SCALEFACTORTYPE scale;
23722356
InitOMXParams(&scale);
@@ -4183,6 +4167,24 @@ status_t OMXCodec::initNativeWindow() {
41834167
return OK;
41844168
}
41854169

4170+
void OMXCodec::initNativeWindowCrop() {
4171+
int32_t left, top, right, bottom;
4172+
4173+
CHECK(mOutputFormat->findRect(
4174+
kKeyCropRect,
4175+
&left, &top, &right, &bottom));
4176+
4177+
android_native_rect_t crop;
4178+
crop.left = left;
4179+
crop.top = top;
4180+
crop.right = right + 1;
4181+
crop.bottom = bottom + 1;
4182+
4183+
// We'll ignore any errors here, if the surface is
4184+
// already invalid, we'll know soon enough.
4185+
native_window_set_crop(mNativeWindow.get(), &crop);
4186+
}
4187+
41864188
void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
41874189
mOutputFormat = new MetaData;
41884190
mOutputFormat->setCString(kKeyDecoderComponent, mComponentName);
@@ -4366,6 +4368,10 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
43664368
video_def->nFrameWidth - 1,
43674369
video_def->nFrameHeight - 1);
43684370
}
4371+
4372+
if (mNativeWindow != NULL) {
4373+
initNativeWindowCrop();
4374+
}
43694375
}
43704376
break;
43714377
}

0 commit comments

Comments
 (0)