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
247fbf07
Commit
247fbf07
authored
Mar 22, 2012
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ass: fix aspect ratio computation.
parent
c44417e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
16 deletions
+16
-16
filters.texi
doc/filters.texi
+4
-3
version.h
libavfilter/version.h
+1
-1
vf_ass.c
libavfilter/vf_ass.c
+11
-12
No files found.
doc/filters.texi
View file @
247fbf07
...
@@ -761,9 +761,10 @@ separated by ":".
...
@@ -761,9 +761,10 @@ separated by ":".
A description of the accepted options follows.
A description of the accepted options follows.
@table @option
@table @option
@item dar
@item original_size
Specifies the display aspect ratio adopted for rendering the
Specifies the size of the original video, the video for which the ASS file
subtitles. Default value is "1.0".
was composed. Due to a misdesign in ASS aspect ratio arithmetic, this is
necessary to correctly scale the fonts if the aspect ratio has been changed.
@end table
@end table
For example, to render the file @file{sub.ass} on top of the input
For example, to render the file @file{sub.ass} on top of the input
...
...
libavfilter/version.h
View file @
247fbf07
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 66
#define LIBAVFILTER_VERSION_MINOR 66
#define LIBAVFILTER_VERSION_MICRO 10
0
#define LIBAVFILTER_VERSION_MICRO 10
1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_ass.c
View file @
247fbf07
...
@@ -45,14 +45,14 @@ typedef struct {
...
@@ -45,14 +45,14 @@ typedef struct {
char
*
filename
;
char
*
filename
;
uint8_t
rgba_map
[
4
];
uint8_t
rgba_map
[
4
];
int
pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
pix_step
[
4
];
///< steps per pixel for each plane of the main output
char
*
dar
_str
;
char
*
original_size
_str
;
AVRational
dar
;
int
original_w
,
original_h
;
}
AssContext
;
}
AssContext
;
#define OFFSET(x) offsetof(AssContext, x)
#define OFFSET(x) offsetof(AssContext, x)
static
const
AVOption
ass_options
[]
=
{
static
const
AVOption
ass_options
[]
=
{
{
"
dar"
,
"set subtitles display aspect ratio"
,
OFFSET
(
dar_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
"1.0"
},
CHAR_MIN
,
CHAR_MAX
},
{
"
original_size"
,
"set the size of the original video (used to scale fonts)"
,
OFFSET
(
original_size_str
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
CHAR_MIN
,
CHAR_MAX
},
{
NULL
},
{
NULL
},
};
};
...
@@ -107,10 +107,11 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
...
@@ -107,10 +107,11 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
return
ret
;
return
ret
;
}
}
if
(
av_parse_ratio
(
&
ass
->
dar
,
ass
->
dar_str
,
100
,
0
,
ctx
)
<
0
||
if
(
ass
->
original_size_str
&&
ass
->
dar
.
num
<
0
||
ass
->
dar
.
den
<=
0
)
{
av_parse_video_size
(
&
ass
->
original_w
,
&
ass
->
original_h
,
ass
->
original_size_str
)
<
0
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid
string '%s' or value for display aspect ratio.
\n
"
,
ass
->
dar
_str
);
"Invalid
original size '%s'.
\n
"
,
ass
->
original_size
_str
);
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
}
}
...
@@ -136,8 +137,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
...
@@ -136,8 +137,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
}
}
ass_set_fonts
(
ass
->
renderer
,
NULL
,
NULL
,
1
,
NULL
,
1
);
ass_set_fonts
(
ass
->
renderer
,
NULL
,
NULL
,
1
,
NULL
,
1
);
av_log
(
ctx
,
AV_LOG_INFO
,
"dar:%f
\n
"
,
av_q2d
(
ass
->
dar
));
return
0
;
return
0
;
}
}
...
@@ -146,7 +145,7 @@ static av_cold void uninit(AVFilterContext *ctx)
...
@@ -146,7 +145,7 @@ static av_cold void uninit(AVFilterContext *ctx)
AssContext
*
ass
=
ctx
->
priv
;
AssContext
*
ass
=
ctx
->
priv
;
av_freep
(
&
ass
->
filename
);
av_freep
(
&
ass
->
filename
);
av_freep
(
&
ass
->
dar
_str
);
av_freep
(
&
ass
->
original_size
_str
);
if
(
ass
->
track
)
if
(
ass
->
track
)
ass_free_track
(
ass
->
track
);
ass_free_track
(
ass
->
track
);
if
(
ass
->
renderer
)
if
(
ass
->
renderer
)
...
@@ -173,8 +172,6 @@ static int config_input(AVFilterLink *inlink)
...
@@ -173,8 +172,6 @@ static int config_input(AVFilterLink *inlink)
{
{
AssContext
*
ass
=
inlink
->
dst
->
priv
;
AssContext
*
ass
=
inlink
->
dst
->
priv
;
const
AVPixFmtDescriptor
*
pix_desc
=
&
av_pix_fmt_descriptors
[
inlink
->
format
];
const
AVPixFmtDescriptor
*
pix_desc
=
&
av_pix_fmt_descriptors
[
inlink
->
format
];
double
sar
=
inlink
->
sample_aspect_ratio
.
num
?
av_q2d
(
inlink
->
sample_aspect_ratio
)
:
1
;
av_image_fill_max_pixsteps
(
ass
->
pix_step
,
NULL
,
pix_desc
);
av_image_fill_max_pixsteps
(
ass
->
pix_step
,
NULL
,
pix_desc
);
ff_fill_rgba_map
(
ass
->
rgba_map
,
inlink
->
format
);
ff_fill_rgba_map
(
ass
->
rgba_map
,
inlink
->
format
);
...
@@ -183,7 +180,9 @@ static int config_input(AVFilterLink *inlink)
...
@@ -183,7 +180,9 @@ static int config_input(AVFilterLink *inlink)
ass
->
vsub
=
pix_desc
->
log2_chroma_h
;
ass
->
vsub
=
pix_desc
->
log2_chroma_h
;
ass_set_frame_size
(
ass
->
renderer
,
inlink
->
w
,
inlink
->
h
);
ass_set_frame_size
(
ass
->
renderer
,
inlink
->
w
,
inlink
->
h
);
ass_set_aspect_ratio
(
ass
->
renderer
,
av_q2d
(
ass
->
dar
),
sar
);
if
(
ass
->
original_w
&&
ass
->
original_h
)
ass_set_aspect_ratio
(
ass
->
renderer
,
(
double
)
inlink
->
w
/
inlink
->
h
,
(
double
)
ass
->
original_w
/
ass
->
original_h
);
return
0
;
return
0
;
}
}
...
...
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