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
a079eaba
Commit
a079eaba
authored
Feb 19, 2018
by
Matthieu Bouron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avcodec/mediacodecdec_common: refactor mediacodec_dec_parse_format()
parent
e45d5575
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
52 deletions
+30
-52
mediacodecdec_common.c
libavcodec/mediacodecdec_common.c
+30
-52
No files found.
libavcodec/mediacodecdec_common.c
View file @
a079eaba
...
...
@@ -339,11 +339,22 @@ done:
return
ret
;
}
#define AMEDIAFORMAT_GET_INT32(name, key, mandatory) do { \
int32_t value = 0; \
if (ff_AMediaFormat_getInt32(s->format, key, &value)) { \
(name) = value; \
} else if (mandatory) { \
av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", key, format); \
ret = AVERROR_EXTERNAL; \
goto fail; \
} \
} while (0) \
static
int
mediacodec_dec_parse_format
(
AVCodecContext
*
avctx
,
MediaCodecDecContext
*
s
)
{
int
ret
=
0
;
int
width
=
0
;
int
height
=
0
;
int32_t
value
=
0
;
char
*
format
=
NULL
;
if
(
!
s
->
format
)
{
...
...
@@ -356,40 +367,16 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
return
AVERROR_EXTERNAL
;
}
av_log
(
avctx
,
AV_LOG_DEBUG
,
"Parsing MediaFormat %s
\n
"
,
format
);
av_freep
(
&
format
);
/* Mandatory fields */
if
(
!
ff_AMediaFormat_getInt32
(
s
->
format
,
"width"
,
&
value
))
{
format
=
ff_AMediaFormat_toString
(
s
->
format
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not get %s from format %s
\n
"
,
"width"
,
format
);
av_freep
(
&
format
);
return
AVERROR_EXTERNAL
;
}
s
->
width
=
value
;
AMEDIAFORMAT_GET_INT32
(
s
->
width
,
"width"
,
1
);
AMEDIAFORMAT_GET_INT32
(
s
->
height
,
"height"
,
1
);
if
(
!
ff_AMediaFormat_getInt32
(
s
->
format
,
"height"
,
&
value
))
{
format
=
ff_AMediaFormat_toString
(
s
->
format
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not get %s from format %s
\n
"
,
"height"
,
format
);
av_freep
(
&
format
);
return
AVERROR_EXTERNAL
;
}
s
->
height
=
value
;
AMEDIAFORMAT_GET_INT32
(
s
->
stride
,
"stride"
,
1
);
s
->
stride
=
s
->
stride
>
0
?
s
->
stride
:
s
->
width
;
if
(
!
ff_AMediaFormat_getInt32
(
s
->
format
,
"stride"
,
&
value
))
{
format
=
ff_AMediaFormat_toString
(
s
->
format
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not get %s from format %s
\n
"
,
"stride"
,
format
);
av_freep
(
&
format
);
return
AVERROR_EXTERNAL
;
}
s
->
stride
=
value
>
0
?
value
:
s
->
width
;
if
(
!
ff_AMediaFormat_getInt32
(
s
->
format
,
"slice-height"
,
&
value
))
{
format
=
ff_AMediaFormat_toString
(
s
->
format
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not get %s from format %s
\n
"
,
"slice-height"
,
format
);
av_freep
(
&
format
);
return
AVERROR_EXTERNAL
;
}
s
->
slice_height
=
value
>
0
?
value
:
s
->
height
;
AMEDIAFORMAT_GET_INT32
(
s
->
slice_height
,
"slice-height"
,
1
);
s
->
slice_height
=
s
->
slice_height
>
0
?
s
->
slice_height
:
s
->
height
;
if
(
strstr
(
s
->
codec_name
,
"OMX.Nvidia."
))
{
s
->
slice_height
=
FFALIGN
(
s
->
height
,
16
);
...
...
@@ -398,32 +385,19 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
s
->
stride
=
avctx
->
width
;
}
if
(
!
ff_AMediaFormat_getInt32
(
s
->
format
,
"color-format"
,
&
value
))
{
format
=
ff_AMediaFormat_toString
(
s
->
format
);
av_log
(
avctx
,
AV_LOG_ERROR
,
"Could not get %s from format %s
\n
"
,
"color-format"
,
format
);
av_freep
(
&
format
);
return
AVERROR_EXTERNAL
;
}
s
->
color_format
=
value
;
s
->
pix_fmt
=
avctx
->
pix_fmt
=
mcdec_map_color_format
(
avctx
,
s
,
value
);
AMEDIAFORMAT_GET_INT32
(
s
->
color_format
,
"color-format"
,
1
);
s
->
pix_fmt
=
avctx
->
pix_fmt
=
mcdec_map_color_format
(
avctx
,
s
,
s
->
color_format
);
if
(
avctx
->
pix_fmt
==
AV_PIX_FMT_NONE
)
{
av_log
(
avctx
,
AV_LOG_ERROR
,
"Output color format is not supported
\n
"
);
return
AVERROR
(
EINVAL
);
ret
=
AVERROR
(
EINVAL
);
goto
fail
;
}
/* Optional fields */
if
(
ff_AMediaFormat_getInt32
(
s
->
format
,
"crop-top"
,
&
value
))
s
->
crop_top
=
value
;
if
(
ff_AMediaFormat_getInt32
(
s
->
format
,
"crop-bottom"
,
&
value
))
s
->
crop_bottom
=
value
;
if
(
ff_AMediaFormat_getInt32
(
s
->
format
,
"crop-left"
,
&
value
))
s
->
crop_left
=
value
;
if
(
ff_AMediaFormat_getInt32
(
s
->
format
,
"crop-right"
,
&
value
))
s
->
crop_right
=
value
;
AMEDIAFORMAT_GET_INT32
(
s
->
crop_top
,
"crop-top"
,
0
);
AMEDIAFORMAT_GET_INT32
(
s
->
crop_bottom
,
"crop-bottom"
,
0
);
AMEDIAFORMAT_GET_INT32
(
s
->
crop_left
,
"crop-left"
,
0
);
AMEDIAFORMAT_GET_INT32
(
s
->
crop_right
,
"crop-right"
,
0
);
width
=
s
->
crop_right
+
1
-
s
->
crop_left
;
height
=
s
->
crop_bottom
+
1
-
s
->
crop_top
;
...
...
@@ -434,7 +408,11 @@ static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecConte
s
->
crop_top
,
s
->
crop_bottom
,
s
->
crop_left
,
s
->
crop_right
,
width
,
height
);
av_freep
(
&
format
);
return
ff_set_dimensions
(
avctx
,
width
,
height
);
fail:
av_freep
(
&
format
);
return
ret
;
}
...
...
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