Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
95f6f7b7
Commit
95f6f7b7
authored
6 years ago
by
Mark Thompson
Browse files
Options
Downloads
Patches
Plain Diff
vaapi_encode_mpeg2: Add options
Include the common options, and also named options for setting the profile and level.
parent
aa2563ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/vaapi_encode_mpeg2.c
+51
-2
51 additions, 2 deletions
libavcodec/vaapi_encode_mpeg2.c
with
51 additions
and
2 deletions
libavcodec/vaapi_encode_mpeg2.c
+
51
−
2
View file @
95f6f7b7
...
@@ -30,6 +30,10 @@
...
@@ -30,6 +30,10 @@
typedef
struct
VAAPIEncodeMPEG2Context
{
typedef
struct
VAAPIEncodeMPEG2Context
{
VAAPIEncodeContext
common
;
VAAPIEncodeContext
common
;
// User options.
int
profile
;
int
level
;
// Derived settings.
// Derived settings.
int
mb_width
;
int
mb_width
;
int
mb_height
;
int
mb_height
;
...
@@ -581,10 +585,18 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = {
...
@@ -581,10 +585,18 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = {
static
av_cold
int
vaapi_encode_mpeg2_init
(
AVCodecContext
*
avctx
)
static
av_cold
int
vaapi_encode_mpeg2_init
(
AVCodecContext
*
avctx
)
{
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
ctx
->
codec
=
&
vaapi_encode_type_mpeg2
;
ctx
->
codec
=
&
vaapi_encode_type_mpeg2
;
if
(
avctx
->
profile
==
FF_PROFILE_UNKNOWN
)
avctx
->
profile
=
priv
->
profile
;
if
(
avctx
->
level
==
FF_LEVEL_UNKNOWN
)
avctx
->
level
=
priv
->
level
;
// Reject unknown levels (these are required to set f_code for
// motion vector encoding).
switch
(
avctx
->
level
)
{
switch
(
avctx
->
level
)
{
case
4
:
// High
case
4
:
// High
case
6
:
// High 1440
case
6
:
// High 1440
...
@@ -623,8 +635,37 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
...
@@ -623,8 +635,37 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx)
return
ff_vaapi_encode_close
(
avctx
);
return
ff_vaapi_encode_close
(
avctx
);
}
}
#define OFFSET(x) offsetof(VAAPIEncodeMPEG2Context, x)
#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
static
const
AVOption
vaapi_encode_mpeg2_options
[]
=
{
VAAPI_ENCODE_COMMON_OPTIONS
,
{
"profile"
,
"Set profile (in profile_and_level_indication)"
,
OFFSET
(
profile
),
AV_OPT_TYPE_INT
,
{
.
i64
=
FF_PROFILE_UNKNOWN
},
FF_PROFILE_UNKNOWN
,
7
,
FLAGS
,
"profile"
},
#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
{ .i64 = value }, 0, 0, FLAGS, "profile"
{
PROFILE
(
"simple"
,
FF_PROFILE_MPEG2_SIMPLE
)
},
{
PROFILE
(
"main"
,
FF_PROFILE_MPEG2_MAIN
)
},
#undef PROFILE
{
"level"
,
"Set level (in profile_and_level_indication)"
,
OFFSET
(
level
),
AV_OPT_TYPE_INT
,
{
.
i64
=
4
},
0
,
15
,
FLAGS
,
"level"
},
#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
{ .i64 = value }, 0, 0, FLAGS, "level"
{
LEVEL
(
"low"
,
10
)
},
{
LEVEL
(
"main"
,
8
)
},
{
LEVEL
(
"high_1440"
,
6
)
},
{
LEVEL
(
"high"
,
4
)
},
#undef LEVEL
{
NULL
},
};
static
const
AVCodecDefault
vaapi_encode_mpeg2_defaults
[]
=
{
static
const
AVCodecDefault
vaapi_encode_mpeg2_defaults
[]
=
{
{
"level"
,
"4"
},
{
"bf"
,
"1"
},
{
"bf"
,
"1"
},
{
"g"
,
"120"
},
{
"g"
,
"120"
},
{
"i_qfactor"
,
"1"
},
{
"i_qfactor"
,
"1"
},
...
@@ -635,6 +676,13 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = {
...
@@ -635,6 +676,13 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = {
{
NULL
},
{
NULL
},
};
};
static
const
AVClass
vaapi_encode_mpeg2_class
=
{
.
class_name
=
"mpeg2_vaapi"
,
.
item_name
=
av_default_item_name
,
.
option
=
vaapi_encode_mpeg2_options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
AVCodec
ff_mpeg2_vaapi_encoder
=
{
AVCodec
ff_mpeg2_vaapi_encoder
=
{
.
name
=
"mpeg2_vaapi"
,
.
name
=
"mpeg2_vaapi"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"MPEG-2 (VAAPI)"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"MPEG-2 (VAAPI)"
),
...
@@ -644,6 +692,7 @@ AVCodec ff_mpeg2_vaapi_encoder = {
...
@@ -644,6 +692,7 @@ AVCodec ff_mpeg2_vaapi_encoder = {
.
init
=
&
vaapi_encode_mpeg2_init
,
.
init
=
&
vaapi_encode_mpeg2_init
,
.
encode2
=
&
ff_vaapi_encode2
,
.
encode2
=
&
ff_vaapi_encode2
,
.
close
=
&
vaapi_encode_mpeg2_close
,
.
close
=
&
vaapi_encode_mpeg2_close
,
.
priv_class
=
&
vaapi_encode_mpeg2_class
,
.
capabilities
=
AV_CODEC_CAP_DELAY
|
AV_CODEC_CAP_HARDWARE
,
.
capabilities
=
AV_CODEC_CAP_DELAY
|
AV_CODEC_CAP_HARDWARE
,
.
defaults
=
vaapi_encode_mpeg2_defaults
,
.
defaults
=
vaapi_encode_mpeg2_defaults
,
.
pix_fmts
=
(
const
enum
AVPixelFormat
[])
{
.
pix_fmts
=
(
const
enum
AVPixelFormat
[])
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment