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
a1411eec
Commit
a1411eec
authored
Jun 13, 2012
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffprobe: add writer_print_rational()
Improve overall consistency, allow some factorization.
parent
b6131ac5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
ffprobe.c
ffprobe.c
+19
-13
No files found.
ffprobe.c
View file @
a1411eec
...
@@ -165,6 +165,7 @@ typedef struct Writer {
...
@@ -165,6 +165,7 @@ typedef struct Writer {
void
(
*
print_section_header
)(
WriterContext
*
wctx
,
const
char
*
);
void
(
*
print_section_header
)(
WriterContext
*
wctx
,
const
char
*
);
void
(
*
print_section_footer
)(
WriterContext
*
wctx
,
const
char
*
);
void
(
*
print_section_footer
)(
WriterContext
*
wctx
,
const
char
*
);
void
(
*
print_integer
)
(
WriterContext
*
wctx
,
const
char
*
,
long
long
int
);
void
(
*
print_integer
)
(
WriterContext
*
wctx
,
const
char
*
,
long
long
int
);
void
(
*
print_rational
)
(
WriterContext
*
wctx
,
AVRational
*
q
,
char
*
sep
);
void
(
*
print_string
)
(
WriterContext
*
wctx
,
const
char
*
,
const
char
*
);
void
(
*
print_string
)
(
WriterContext
*
wctx
,
const
char
*
,
const
char
*
);
void
(
*
show_tags
)
(
WriterContext
*
wctx
,
AVDictionary
*
dict
);
void
(
*
show_tags
)
(
WriterContext
*
wctx
,
AVDictionary
*
dict
);
int
flags
;
///< a combination or WRITER_FLAG_*
int
flags
;
///< a combination or WRITER_FLAG_*
...
@@ -309,6 +310,16 @@ static inline void writer_print_integer(WriterContext *wctx,
...
@@ -309,6 +310,16 @@ static inline void writer_print_integer(WriterContext *wctx,
}
}
}
}
static
inline
void
writer_print_rational
(
WriterContext
*
wctx
,
const
char
*
key
,
AVRational
q
,
char
sep
)
{
AVBPrint
buf
;
av_bprint_init
(
&
buf
,
0
,
AV_BPRINT_SIZE_AUTOMATIC
);
av_bprintf
(
&
buf
,
"%d%c%d"
,
q
.
num
,
sep
,
q
.
den
);
wctx
->
writer
->
print_string
(
wctx
,
key
,
buf
.
str
);
wctx
->
nb_item
++
;
}
static
inline
void
writer_print_string
(
WriterContext
*
wctx
,
static
inline
void
writer_print_string
(
WriterContext
*
wctx
,
const
char
*
key
,
const
char
*
val
,
int
opt
)
const
char
*
key
,
const
char
*
val
,
int
opt
)
{
{
...
@@ -1508,6 +1519,7 @@ static void writer_register_all(void)
...
@@ -1508,6 +1519,7 @@ static void writer_register_all(void)
} while (0)
} while (0)
#define print_int(k, v) writer_print_integer(w, k, v)
#define print_int(k, v) writer_print_integer(w, k, v)
#define print_q(k, v, s) writer_print_rational(w, k, v, s)
#define print_str(k, v) writer_print_string(w, k, v, 0)
#define print_str(k, v) writer_print_string(w, k, v, 0)
#define print_str_opt(k, v) writer_print_string(w, k, v, 1)
#define print_str_opt(k, v) writer_print_string(w, k, v, 1)
#define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
#define print_time(k, v, tb) writer_print_time(w, k, v, tb, 0)
...
@@ -1580,9 +1592,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream)
...
@@ -1580,9 +1592,7 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream)
if
(
s
)
print_str
(
"pix_fmt"
,
s
);
if
(
s
)
print_str
(
"pix_fmt"
,
s
);
else
print_str_opt
(
"pix_fmt"
,
"unknown"
);
else
print_str_opt
(
"pix_fmt"
,
"unknown"
);
if
(
frame
->
sample_aspect_ratio
.
num
)
{
if
(
frame
->
sample_aspect_ratio
.
num
)
{
print_fmt
(
"sample_aspect_ratio"
,
"%d:%d"
,
print_q
(
"sample_aspect_ratio"
,
frame
->
sample_aspect_ratio
,
':'
);
frame
->
sample_aspect_ratio
.
num
,
frame
->
sample_aspect_ratio
.
den
);
}
else
{
}
else
{
print_str_opt
(
"sample_aspect_ratio"
,
"N/A"
);
print_str_opt
(
"sample_aspect_ratio"
,
"N/A"
);
}
}
...
@@ -1710,7 +1720,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
...
@@ -1710,7 +1720,7 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
s
=
av_get_media_type_string
(
dec_ctx
->
codec_type
);
s
=
av_get_media_type_string
(
dec_ctx
->
codec_type
);
if
(
s
)
print_str
(
"codec_type"
,
s
);
if
(
s
)
print_str
(
"codec_type"
,
s
);
else
print_str_opt
(
"codec_type"
,
"unknown"
);
else
print_str_opt
(
"codec_type"
,
"unknown"
);
print_
fmt
(
"codec_time_base"
,
"%d/%d"
,
dec_ctx
->
time_base
.
num
,
dec_ctx
->
time_base
.
den
);
print_
q
(
"codec_time_base"
,
dec_ctx
->
time_base
,
'/'
);
/* print AVI/FourCC tag */
/* print AVI/FourCC tag */
av_get_codec_tag_string
(
val_str
,
sizeof
(
val_str
),
dec_ctx
->
codec_tag
);
av_get_codec_tag_string
(
val_str
,
sizeof
(
val_str
),
dec_ctx
->
codec_tag
);
...
@@ -1723,16 +1733,12 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
...
@@ -1723,16 +1733,12 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
print_int
(
"height"
,
dec_ctx
->
height
);
print_int
(
"height"
,
dec_ctx
->
height
);
print_int
(
"has_b_frames"
,
dec_ctx
->
has_b_frames
);
print_int
(
"has_b_frames"
,
dec_ctx
->
has_b_frames
);
if
(
dec_ctx
->
sample_aspect_ratio
.
num
)
{
if
(
dec_ctx
->
sample_aspect_ratio
.
num
)
{
print_fmt
(
"sample_aspect_ratio"
,
"%d:%d"
,
print_q
(
"sample_aspect_ratio"
,
dec_ctx
->
sample_aspect_ratio
,
':'
);
dec_ctx
->
sample_aspect_ratio
.
num
,
dec_ctx
->
sample_aspect_ratio
.
den
);
av_reduce
(
&
display_aspect_ratio
.
num
,
&
display_aspect_ratio
.
den
,
av_reduce
(
&
display_aspect_ratio
.
num
,
&
display_aspect_ratio
.
den
,
dec_ctx
->
width
*
dec_ctx
->
sample_aspect_ratio
.
num
,
dec_ctx
->
width
*
dec_ctx
->
sample_aspect_ratio
.
num
,
dec_ctx
->
height
*
dec_ctx
->
sample_aspect_ratio
.
den
,
dec_ctx
->
height
*
dec_ctx
->
sample_aspect_ratio
.
den
,
1024
*
1024
);
1024
*
1024
);
print_fmt
(
"display_aspect_ratio"
,
"%d:%d"
,
print_q
(
"display_aspect_ratio"
,
display_aspect_ratio
,
':'
);
display_aspect_ratio
.
num
,
display_aspect_ratio
.
den
);
}
else
{
}
else
{
print_str_opt
(
"sample_aspect_ratio"
,
"N/A"
);
print_str_opt
(
"sample_aspect_ratio"
,
"N/A"
);
print_str_opt
(
"display_aspect_ratio"
,
"N/A"
);
print_str_opt
(
"display_aspect_ratio"
,
"N/A"
);
...
@@ -1776,9 +1782,9 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
...
@@ -1776,9 +1782,9 @@ static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_i
if
(
fmt_ctx
->
iformat
->
flags
&
AVFMT_SHOW_IDS
)
print_fmt
(
"id"
,
"0x%x"
,
stream
->
id
);
if
(
fmt_ctx
->
iformat
->
flags
&
AVFMT_SHOW_IDS
)
print_fmt
(
"id"
,
"0x%x"
,
stream
->
id
);
else
print_str_opt
(
"id"
,
"N/A"
);
else
print_str_opt
(
"id"
,
"N/A"
);
print_
fmt
(
"r_frame_rate"
,
"%d/%d"
,
stream
->
r_frame_rate
.
num
,
stream
->
r_frame_rate
.
den
);
print_
q
(
"r_frame_rate"
,
stream
->
r_frame_rate
,
'/'
);
print_
fmt
(
"avg_frame_rate"
,
"%d/%d"
,
stream
->
avg_frame_rate
.
num
,
stream
->
avg_frame_rate
.
den
);
print_
q
(
"avg_frame_rate"
,
stream
->
avg_frame_rate
,
'/'
);
print_
fmt
(
"time_base"
,
"%d/%d"
,
stream
->
time_base
.
num
,
stream
->
time_base
.
den
);
print_
q
(
"time_base"
,
stream
->
time_base
,
'/'
);
print_time
(
"start_time"
,
stream
->
start_time
,
&
stream
->
time_base
);
print_time
(
"start_time"
,
stream
->
start_time
,
&
stream
->
time_base
);
print_time
(
"duration"
,
stream
->
duration
,
&
stream
->
time_base
);
print_time
(
"duration"
,
stream
->
duration
,
&
stream
->
time_base
);
if
(
dec_ctx
->
bit_rate
>
0
)
print_val
(
"bit_rate"
,
dec_ctx
->
bit_rate
,
unit_bit_per_second_str
);
if
(
dec_ctx
->
bit_rate
>
0
)
print_val
(
"bit_rate"
,
dec_ctx
->
bit_rate
,
unit_bit_per_second_str
);
...
...
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