Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
537d6aa3
Commit
537d6aa3
authored
Aug 22, 2018
by
Mark Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vaapi_encode_mpeg2: Move common structure into context
parent
2c3ad16d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
28 deletions
+25
-28
vaapi_encode_mpeg2.c
libavcodec/vaapi_encode_mpeg2.c
+25
-28
No files found.
libavcodec/vaapi_encode_mpeg2.c
View file @
537d6aa3
...
...
@@ -28,6 +28,9 @@
#include "vaapi_encode.h"
typedef
struct
VAAPIEncodeMPEG2Context
{
VAAPIEncodeContext
common
;
// Derived settings.
int
mb_width
;
int
mb_height
;
...
...
@@ -35,15 +38,6 @@ typedef struct VAAPIEncodeMPEG2Context {
int
quant_p
;
int
quant_b
;
MPEG2RawSequenceHeader
sequence_header
;
MPEG2RawExtensionData
sequence_extension
;
MPEG2RawExtensionData
sequence_display_extension
;
MPEG2RawGroupOfPicturesHeader
gop_header
;
MPEG2RawPictureHeader
picture_header
;
MPEG2RawExtensionData
picture_coding_extension
;
int64_t
last_i_frame
;
unsigned
int
bit_rate
;
unsigned
int
vbv_buffer_size
;
...
...
@@ -52,6 +46,17 @@ typedef struct VAAPIEncodeMPEG2Context {
unsigned
int
f_code_horizontal
;
unsigned
int
f_code_vertical
;
// Stream state.
int64_t
last_i_frame
;
// Writer structures.
MPEG2RawSequenceHeader
sequence_header
;
MPEG2RawExtensionData
sequence_extension
;
MPEG2RawExtensionData
sequence_display_extension
;
MPEG2RawGroupOfPicturesHeader
gop_header
;
MPEG2RawPictureHeader
picture_header
;
MPEG2RawExtensionData
picture_coding_extension
;
CodedBitstreamContext
*
cbc
;
CodedBitstreamFragment
current_fragment
;
}
VAAPIEncodeMPEG2Context
;
...
...
@@ -61,8 +66,7 @@ static int vaapi_encode_mpeg2_write_fragment(AVCodecContext *avctx,
char
*
data
,
size_t
*
data_len
,
CodedBitstreamFragment
*
frag
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
int
err
;
err
=
ff_cbs_write_fragment_data
(
priv
->
cbc
,
frag
);
...
...
@@ -88,8 +92,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx,
CodedBitstreamFragment
*
frag
,
int
type
,
void
*
header
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
int
err
;
err
=
ff_cbs_insert_unit_content
(
priv
->
cbc
,
frag
,
-
1
,
type
,
header
,
NULL
);
...
...
@@ -105,8 +108,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx,
static
int
vaapi_encode_mpeg2_write_sequence_header
(
AVCodecContext
*
avctx
,
char
*
data
,
size_t
*
data_len
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
CodedBitstreamFragment
*
frag
=
&
priv
->
current_fragment
;
int
err
;
...
...
@@ -140,8 +142,7 @@ static int vaapi_encode_mpeg2_write_picture_header(AVCodecContext *avctx,
VAAPIEncodePicture
*
pic
,
char
*
data
,
size_t
*
data_len
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
CodedBitstreamFragment
*
frag
=
&
priv
->
current_fragment
;
int
err
;
...
...
@@ -164,7 +165,7 @@ fail:
static
int
vaapi_encode_mpeg2_init_sequence_params
(
AVCodecContext
*
avctx
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
av
ctx
->
priv_data
;
MPEG2RawSequenceHeader
*
sh
=
&
priv
->
sequence_header
;
MPEG2RawSequenceExtension
*
se
=
&
priv
->
sequence_extension
.
data
.
sequence
;
MPEG2RawSequenceDisplayExtension
*
sde
=
&
priv
->
sequence_display_extension
.
data
.
sequence_display
;
...
...
@@ -416,8 +417,7 @@ static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx)
static
int
vaapi_encode_mpeg2_init_picture_params
(
AVCodecContext
*
avctx
,
VAAPIEncodePicture
*
pic
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
MPEG2RawPictureHeader
*
ph
=
&
priv
->
picture_header
;
MPEG2RawPictureCodingExtension
*
pce
=
&
priv
->
picture_coding_extension
.
data
.
picture_coding
;
VAEncPictureParameterBufferMPEG2
*
vpic
=
pic
->
codec_picture_params
;
...
...
@@ -482,9 +482,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx,
VAAPIEncodePicture
*
pic
,
VAAPIEncodeSlice
*
slice
)
{
VAAPIEncode
Context
*
ctx
=
avctx
->
priv_data
;
VAAPIEncode
MPEG2Context
*
priv
=
avctx
->
priv_data
;
VAEncSliceParameterBufferMPEG2
*
vslice
=
slice
->
codec_slice_params
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
int
qp
;
vslice
->
macroblock_address
=
priv
->
mb_width
*
slice
->
index
;
...
...
@@ -515,7 +514,7 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx,
static
av_cold
int
vaapi_encode_mpeg2_configure
(
AVCodecContext
*
avctx
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
av
ctx
->
priv_data
;
int
err
;
err
=
ff_cbs_init
(
&
priv
->
cbc
,
AV_CODEC_ID_MPEG2VIDEO
,
avctx
);
...
...
@@ -638,11 +637,9 @@ static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx)
static
av_cold
int
vaapi_encode_mpeg2_close
(
AVCodecContext
*
avctx
)
{
VAAPIEncodeContext
*
ctx
=
avctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
ctx
->
priv_data
;
VAAPIEncodeMPEG2Context
*
priv
=
avctx
->
priv_data
;
if
(
priv
)
ff_cbs_close
(
&
priv
->
cbc
);
ff_cbs_close
(
&
priv
->
cbc
);
return
ff_vaapi_encode_close
(
avctx
);
}
...
...
@@ -665,7 +662,7 @@ AVCodec ff_mpeg2_vaapi_encoder = {
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"MPEG-2 (VAAPI)"
),
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
id
=
AV_CODEC_ID_MPEG2VIDEO
,
.
priv_data_size
=
sizeof
(
VAAPIEncodeContext
),
.
priv_data_size
=
sizeof
(
VAAPIEncode
MPEG2
Context
),
.
init
=
&
vaapi_encode_mpeg2_init
,
.
encode2
=
&
ff_vaapi_encode2
,
.
close
=
&
vaapi_encode_mpeg2_close
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment