summaryrefslogtreecommitdiff
path: root/test/encode/mpeg2enc.c
diff options
context:
space:
mode:
authorXiang, Haihao <haihao.xiang@intel.com>2012-12-07 16:00:04 +0800
committerXiang, Haihao <haihao.xiang@intel.com>2013-05-28 16:46:49 +0800
commitacfb4ee6a2b3b6ae5b87d5a487fbdf478bdb4480 (patch)
tree29353128079b7dcb7a6da6fb1077e9af1fbd2f70 /test/encode/mpeg2enc.c
parent6f6b2e1ad6fb2763edd54996a046b81e3d14e9df (diff)
mpeg2enc: find the proper profile and level
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
Diffstat (limited to 'test/encode/mpeg2enc.c')
-rw-r--r--test/encode/mpeg2enc.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/test/encode/mpeg2enc.c b/test/encode/mpeg2enc.c
index 1a49795..0ec68e5 100644
--- a/test/encode/mpeg2enc.c
+++ b/test/encode/mpeg2enc.c
@@ -79,6 +79,23 @@ static VAProfile mpeg2_va_profiles[] = {
VAProfileMPEG2Main
};
+static struct _mpeg2_sampling_density
+{
+ int samplers_per_line;
+ int line_per_frame;
+ int frame_per_sec;
+} mpeg2_upper_samplings[2][3] = {
+ { { 0, 0, 0 },
+ { 720, 576, 30 },
+ { 0, 0, 0 },
+ },
+
+ { { 352, 288, 30 },
+ { 720, 576, 30 },
+ { 1920, 1152, 60 },
+ }
+};
+
struct mpeg2enc_context {
/* args */
int rate_control_mode;
@@ -531,12 +548,44 @@ usage(char *program)
fprintf(stderr, "\t--level <LEVEL> specify the level 0(Low), 1(Main, default) or 2(High)\n");
}
+void
+mpeg2_profile_level(struct mpeg2enc_context *ctx,
+ int profile,
+ int level)
+{
+ int l = 2, p;
+
+ for (p = profile; p < 2; p++) {
+ for (l = level; l < 3; l++) {
+ if (ctx->width <= mpeg2_upper_samplings[p][l].samplers_per_line &&
+ ctx->height <= mpeg2_upper_samplings[p][l].line_per_frame &&
+ ctx->fps <= mpeg2_upper_samplings[p][l].frame_per_sec) {
+
+ goto __find;
+ break;
+ }
+ }
+ }
+
+ if (p == 2) {
+ fprintf(stderr, "Warning: can't find a proper profile and level for the specified width/height/fps\n");
+ p = 1;
+ l = 2;
+ }
+
+__find:
+ ctx->profile = mpeg2_va_profiles[p];
+ ctx->level = l;
+}
+
static void
parse_args(struct mpeg2enc_context *ctx, int argc, char **argv)
{
int c, tmp;
int option_index = 0;
long file_size;
+ int profile = 1, level = 1;
+
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"cqp", required_argument, 0, 'c'},
@@ -648,7 +697,7 @@ parse_args(struct mpeg2enc_context *ctx, int argc, char **argv)
if (tmp < 0 || tmp > 1)
fprintf(stderr, "Waning: PROFILE must be 0 or 1\n");
else
- ctx->profile = mpeg2_va_profiles[tmp];
+ profile = tmp;
break;
@@ -658,7 +707,7 @@ parse_args(struct mpeg2enc_context *ctx, int argc, char **argv)
if (tmp < MPEG2_LEVEL_LOW || tmp > MPEG2_LEVEL_HIGH)
fprintf(stderr, "Waning: LEVEL must be 0, 1, or 2\n");
else
- ctx->level = tmp;
+ level = tmp;
break;
@@ -670,6 +719,8 @@ parse_args(struct mpeg2enc_context *ctx, int argc, char **argv)
}
}
+ mpeg2_profile_level(ctx, profile, level);
+
return;
print_usage:
@@ -681,7 +732,7 @@ err_exit:
/*
* init
*/
-static void
+void
mpeg2enc_init_sequence_parameter(struct mpeg2enc_context *ctx,
VAEncSequenceParameterBufferMPEG2 *seq_param)
{