Skip to content

Commit 481ffa5

Browse files
Hong TengAndroid (Google) Code Review
authored andcommitted
Merge "Fix for issue 5309336 -add videoeditor maximum prefetch YUV frames in media_profiles.xml to limit the total memory usage." into ics-mr1
2 parents ce33622 + 7eb5319 commit 481ffa5

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

include/media/MediaProfiles.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,21 @@ enum camcorder_quality {
4848
};
4949

5050
/**
51-
*Set CIF as default maximum import and export resolution of video editor.
52-
*The maximum import and export resolutions are platform specific,
53-
*which should be defined in media_profiles.xml.
51+
* Set CIF as default maximum import and export resolution of video editor.
52+
* The maximum import and export resolutions are platform specific,
53+
* which should be defined in media_profiles.xml.
54+
* Set default maximum prefetch YUV frames to 6, which means video editor can
55+
* queue up to 6 YUV frames in the video encoder source.
56+
* This value is used to limit the amount of memory used by video editor
57+
* engine when the encoder consumes YUV frames at a lower speed
58+
* than video editor engine produces.
5459
*/
5560
enum videoeditor_capability {
5661
VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH = 352,
5762
VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT = 288,
5863
VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH = 352,
5964
VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT = 288,
65+
VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES = 6
6066
};
6167

6268
enum video_decoder {
@@ -138,6 +144,8 @@ class MediaProfiles
138144
* videoeditor.input.height.max - max input video frame height
139145
* videoeditor.output.width.max - max output video frame width
140146
* videoeditor.output.height.max - max output video frame height
147+
* maxPrefetchYUVFrames - max prefetch YUV frames in video editor engine. This value is used
148+
* to limit the memory consumption.
141149
*/
142150
int getVideoEditorCapParamByName(const char *name) const;
143151

@@ -357,18 +365,20 @@ class MediaProfiles
357365
};
358366
struct VideoEditorCap {
359367
VideoEditorCap(int inFrameWidth, int inFrameHeight,
360-
int outFrameWidth, int outFrameHeight)
368+
int outFrameWidth, int outFrameHeight, int frames)
361369
: mMaxInputFrameWidth(inFrameWidth),
362370
mMaxInputFrameHeight(inFrameHeight),
363371
mMaxOutputFrameWidth(outFrameWidth),
364-
mMaxOutputFrameHeight(outFrameHeight) {}
372+
mMaxOutputFrameHeight(outFrameHeight),
373+
mMaxPrefetchYUVFrames(frames) {}
365374

366375
~VideoEditorCap() {}
367376

368377
int mMaxInputFrameWidth;
369378
int mMaxInputFrameHeight;
370379
int mMaxOutputFrameWidth;
371380
int mMaxOutputFrameHeight;
381+
int mMaxPrefetchYUVFrames;
372382
};
373383

374384
int getCamcorderProfileIndex(int cameraId, camcorder_quality quality) const;

media/libmedia/MediaProfiles.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,12 @@ MediaProfiles::createVideoEditorCap(const char **atts, MediaProfiles *profiles)
404404
CHECK(!strcmp("maxInputFrameWidth", atts[0]) &&
405405
!strcmp("maxInputFrameHeight", atts[2]) &&
406406
!strcmp("maxOutputFrameWidth", atts[4]) &&
407-
!strcmp("maxOutputFrameHeight", atts[6]));
407+
!strcmp("maxOutputFrameHeight", atts[6]) &&
408+
!strcmp("maxPrefetchYUVFrames", atts[8]));
408409

409410
MediaProfiles::VideoEditorCap *pVideoEditorCap =
410411
new MediaProfiles::VideoEditorCap(atoi(atts[1]), atoi(atts[3]),
411-
atoi(atts[5]), atoi(atts[7]));
412+
atoi(atts[5]), atoi(atts[7]), atoi(atts[9]));
412413

413414
logVideoEditorCap(*pVideoEditorCap);
414415
profiles->mVideoEditorCap = pVideoEditorCap;
@@ -850,7 +851,8 @@ MediaProfiles::createDefaultVideoEditorCap(MediaProfiles *profiles)
850851
VIDEOEDITOR_DEFAULT_MAX_INPUT_FRAME_WIDTH,
851852
VIDEOEDITOR_DEFUALT_MAX_INPUT_FRAME_HEIGHT,
852853
VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH,
853-
VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT);
854+
VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT,
855+
VIDEOEDITOR_DEFAULT_MAX_PREFETCH_YUV_FRAMES);
854856
}
855857
/*static*/ void
856858
MediaProfiles::createDefaultExportVideoProfiles(MediaProfiles *profiles)
@@ -1019,6 +1021,8 @@ int MediaProfiles::getVideoEditorCapParamByName(const char *name) const
10191021
return mVideoEditorCap->mMaxOutputFrameWidth;
10201022
if (!strcmp("videoeditor.output.height.max", name))
10211023
return mVideoEditorCap->mMaxOutputFrameHeight;
1024+
if (!strcmp("maxPrefetchYUVFrames", name))
1025+
return mVideoEditorCap->mMaxPrefetchYUVFrames;
10221026

10231027
LOGE("The given video editor param name %s is not found", name);
10241028
return -1;

0 commit comments

Comments
 (0)