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
e26782a9
Commit
e26782a9
authored
Aug 22, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: add ff_parse_pixel_format() internal function, and use it
Reduce code duplication.
parent
2c6348ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
15 deletions
+33
-15
formats.c
libavfilter/formats.c
+15
-0
internal.h
libavfilter/internal.h
+10
-0
vf_format.c
libavfilter/vf_format.c
+4
-6
vsrc_buffer.c
libavfilter/vsrc_buffer.c
+4
-9
No files found.
libavfilter/formats.c
View file @
e26782a9
...
...
@@ -236,6 +236,21 @@ void avfilter_formats_changeref(AVFilterFormats **oldref,
/* internal functions for parsing audio format arguments */
int
ff_parse_pixel_format
(
enum
PixelFormat
*
ret
,
const
char
*
arg
,
void
*
log_ctx
)
{
char
*
tail
;
int
pix_fmt
=
av_get_pix_fmt
(
arg
);
if
(
pix_fmt
==
PIX_FMT_NONE
)
{
pix_fmt
=
strtol
(
arg
,
&
tail
,
0
);
if
(
*
tail
||
(
unsigned
)
pix_fmt
>=
PIX_FMT_NB
)
{
av_log
(
log_ctx
,
AV_LOG_ERROR
,
"Invalid pixel format '%s'
\n
"
,
arg
);
return
AVERROR
(
EINVAL
);
}
}
*
ret
=
pix_fmt
;
return
0
;
}
int
ff_parse_sample_format
(
int
*
ret
,
const
char
*
arg
,
void
*
log_ctx
)
{
char
*
tail
;
...
...
libavfilter/internal.h
View file @
e26782a9
...
...
@@ -63,6 +63,16 @@ int ff_fmt_is_in(int fmt, const int *fmts);
/* Functions to parse audio format arguments */
/**
* Parse a pixel format.
*
* @param ret pixel format pointer to where the value should be written
* @param arg string to parse
* @param log_ctx log context
* @return 0 in case of success, a negative AVERROR code on error
*/
int
ff_parse_pixel_format
(
enum
PixelFormat
*
ret
,
const
char
*
arg
,
void
*
log_ctx
);
/**
* Parse a sample rate.
*
...
...
libavfilter/vf_format.c
View file @
e26782a9
...
...
@@ -25,6 +25,7 @@
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"
typedef
struct
{
/**
...
...
@@ -41,7 +42,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
FormatContext
*
format
=
ctx
->
priv
;
const
char
*
cur
,
*
sep
;
char
pix_fmt_name
[
PIX_FMT_NAME_MAXSIZE
];
int
pix_fmt_name_len
;
int
pix_fmt_name_len
,
ret
;
enum
PixelFormat
pix_fmt
;
/* parse the list of formats */
...
...
@@ -57,12 +58,9 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
memcpy
(
pix_fmt_name
,
cur
,
pix_fmt_name_len
);
pix_fmt_name
[
pix_fmt_name_len
]
=
0
;
pix_fmt
=
av_get_pix_fmt
(
pix_fmt_name
);
if
(
pix_fmt
==
PIX_FMT_NONE
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Unknown pixel format: %s
\n
"
,
pix_fmt_name
);
return
-
1
;
}
if
((
ret
=
ff_parse_pixel_format
(
&
pix_fmt
,
pix_fmt_name
,
ctx
))
<
0
)
return
ret
;
format
->
listed_pix_fmt_flags
[
pix_fmt
]
=
1
;
}
...
...
libavfilter/vsrc_buffer.c
View file @
e26782a9
...
...
@@ -24,6 +24,7 @@
*/
#include "avfilter.h"
#include "internal.h"
#include "avcodec.h"
#include "vsrc_buffer.h"
#include "libavutil/imgutils.h"
...
...
@@ -134,7 +135,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
{
BufferSourceContext
*
c
=
ctx
->
priv
;
char
pix_fmt_str
[
128
];
int
n
=
0
;
int
ret
,
n
=
0
;
*
c
->
sws_param
=
0
;
if
(
!
args
||
...
...
@@ -145,14 +146,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
return
AVERROR
(
EINVAL
);
}
if
((
c
->
pix_fmt
=
av_get_pix_fmt
(
pix_fmt_str
))
==
PIX_FMT_NONE
)
{
char
*
tail
;
c
->
pix_fmt
=
strtol
(
pix_fmt_str
,
&
tail
,
10
);
if
(
*
tail
||
c
->
pix_fmt
<
0
||
c
->
pix_fmt
>=
PIX_FMT_NB
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid pixel format string '%s'
\n
"
,
pix_fmt_str
);
return
AVERROR
(
EINVAL
);
}
}
if
((
ret
=
ff_parse_pixel_format
(
&
c
->
pix_fmt
,
pix_fmt_str
,
ctx
))
<
0
)
return
ret
;
av_log
(
ctx
,
AV_LOG_INFO
,
"w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s
\n
"
,
c
->
w
,
c
->
h
,
av_pix_fmt_descriptors
[
c
->
pix_fmt
].
name
,
...
...
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