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
23426987
Commit
23426987
authored
Feb 24, 2013
by
Reimar Döffinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mpeg12: reduce hwaccel-related code duplication.
Signed-off-by:
Reimar Döffinger
<
Reimar.Doeffinger@gmx.de
>
parent
7d15cd4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
19 deletions
+18
-19
mpeg12.c
libavcodec/mpeg12.c
+18
-19
No files found.
libavcodec/mpeg12.c
View file @
23426987
...
@@ -1237,23 +1237,31 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
...
@@ -1237,23 +1237,31 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
MpegEncContext
*
s
=
&
s1
->
mpeg_enc_ctx
;
MpegEncContext
*
s
=
&
s1
->
mpeg_enc_ctx
;
if
(
s
->
chroma_format
<
2
)
{
if
(
s
->
chroma_format
<
2
)
{
enum
AVPixelFormat
res
;
return
avctx
->
get_format
(
avctx
,
res
=
avctx
->
get_format
(
avctx
,
avctx
->
codec_id
==
AV_CODEC_ID_MPEG1VIDEO
?
avctx
->
codec_id
==
AV_CODEC_ID_MPEG1VIDEO
?
mpeg1_hwaccel_pixfmt_list_420
:
mpeg1_hwaccel_pixfmt_list_420
:
mpeg2_hwaccel_pixfmt_list_420
);
mpeg2_hwaccel_pixfmt_list_420
);
if
(
res
!=
AV_PIX_FMT_XVMC_MPEG2_IDCT
&&
res
!=
AV_PIX_FMT_XVMC_MPEG2_MC
)
{
avctx
->
xvmc_acceleration
=
0
;
}
else
if
(
!
avctx
->
xvmc_acceleration
)
{
avctx
->
xvmc_acceleration
=
2
;
}
return
res
;
}
else
if
(
s
->
chroma_format
==
2
)
}
else
if
(
s
->
chroma_format
==
2
)
return
AV_PIX_FMT_YUV422P
;
return
AV_PIX_FMT_YUV422P
;
else
else
return
AV_PIX_FMT_YUV444P
;
return
AV_PIX_FMT_YUV444P
;
}
}
static
void
setup_hwaccel_for_pixfmt
(
AVCodecContext
*
avctx
)
{
if
(
avctx
->
pix_fmt
!=
AV_PIX_FMT_XVMC_MPEG2_IDCT
&&
avctx
->
pix_fmt
!=
AV_PIX_FMT_XVMC_MPEG2_MC
)
{
avctx
->
xvmc_acceleration
=
0
;
}
else
if
(
!
avctx
->
xvmc_acceleration
)
{
avctx
->
xvmc_acceleration
=
2
;
}
avctx
->
hwaccel
=
ff_find_hwaccel
(
avctx
->
codec
->
id
,
avctx
->
pix_fmt
);
// until then pix_fmt may be changed right after codec init
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_XVMC_MPEG2_IDCT
||
avctx
->
hwaccel
||
uses_vdpau
(
avctx
))
if
(
avctx
->
idct_algo
==
FF_IDCT_AUTO
)
avctx
->
idct_algo
=
FF_IDCT_SIMPLE
;
}
/* Call this function when we know all parameters.
/* Call this function when we know all parameters.
* It may be called in different places for MPEG-1 and MPEG-2. */
* It may be called in different places for MPEG-1 and MPEG-2. */
static
int
mpeg_decode_postinit
(
AVCodecContext
*
avctx
)
static
int
mpeg_decode_postinit
(
AVCodecContext
*
avctx
)
...
@@ -1348,12 +1356,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
...
@@ -1348,12 +1356,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
}
// MPEG-2
}
// MPEG-2
avctx
->
pix_fmt
=
mpeg_get_pixelformat
(
avctx
);
avctx
->
pix_fmt
=
mpeg_get_pixelformat
(
avctx
);
avctx
->
hwaccel
=
ff_find_hwaccel
(
avctx
->
codec
->
id
,
avctx
->
pix_fmt
);
setup_hwaccel_for_pixfmt
(
avctx
);
// until then pix_fmt may be changed right after codec init
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_XVMC_MPEG2_IDCT
||
avctx
->
hwaccel
||
uses_vdpau
(
avctx
))
if
(
avctx
->
idct_algo
==
FF_IDCT_AUTO
)
avctx
->
idct_algo
=
FF_IDCT_SIMPLE
;
/* Quantization matrices may need reordering
/* Quantization matrices may need reordering
* if DCT permutation is changed. */
* if DCT permutation is changed. */
...
@@ -2105,11 +2108,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
...
@@ -2105,11 +2108,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx)
s
->
low_delay
=
1
;
s
->
low_delay
=
1
;
avctx
->
pix_fmt
=
mpeg_get_pixelformat
(
avctx
);
avctx
->
pix_fmt
=
mpeg_get_pixelformat
(
avctx
);
avctx
->
hwaccel
=
ff_find_hwaccel
(
avctx
->
codec
->
id
,
avctx
->
pix_fmt
);
setup_hwaccel_for_pixfmt
(
avctx
);
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_XVMC_MPEG2_IDCT
||
avctx
->
hwaccel
||
uses_vdpau
(
avctx
))
if
(
avctx
->
idct_algo
==
FF_IDCT_AUTO
)
avctx
->
idct_algo
=
FF_IDCT_SIMPLE
;
if
(
ff_MPV_common_init
(
s
)
<
0
)
if
(
ff_MPV_common_init
(
s
)
<
0
)
return
-
1
;
return
-
1
;
...
...
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