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
fdab793a
Commit
fdab793a
authored
Nov 28, 2011
by
Alex Converse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avconv: Handle audio sync for non-S16 sample formats.
Also fix reporting of the number of samples added/dropped.
parent
39a7a5b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
avconv.c
avconv.c
+16
-15
No files found.
avconv.c
View file @
fdab793a
...
...
@@ -729,6 +729,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx
}
}
static
void
generate_silence
(
uint8_t
*
buf
,
enum
AVSampleFormat
sample_fmt
,
size_t
size
)
{
int
fill_char
=
0x00
;
if
(
sample_fmt
==
AV_SAMPLE_FMT_U8
)
fill_char
=
0x80
;
memset
(
buf
,
fill_char
,
size
);
}
static
void
do_audio_out
(
AVFormatContext
*
s
,
OutputStream
*
ost
,
InputStream
*
ist
,
...
...
@@ -829,9 +837,9 @@ need_realloc:
if
(
audio_sync_method
){
double
delta
=
get_sync_ipts
(
ost
)
*
enc
->
sample_rate
-
ost
->
sync_opts
-
av_fifo_size
(
ost
->
fifo
)
/
(
enc
->
channels
*
2
);
double
idelta
=
delta
*
dec
->
sample_rate
/
enc
->
sample_rate
;
int
byte_delta
=
((
int
)
idelta
)
*
2
*
dec
->
channels
;
-
av_fifo_size
(
ost
->
fifo
)
/
(
enc
->
channels
*
osize
);
int
idelta
=
delta
*
dec
->
sample_rate
/
enc
->
sample_rate
;
int
byte_delta
=
idelta
*
isize
*
dec
->
channels
;
//FIXME resample delay
if
(
fabs
(
delta
)
>
50
){
...
...
@@ -840,7 +848,8 @@ need_realloc:
byte_delta
=
FFMAX
(
byte_delta
,
-
size
);
size
+=
byte_delta
;
buf
-=
byte_delta
;
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"discarding %d audio samples
\n
"
,
(
int
)
-
delta
);
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"discarding %d audio samples
\n
"
,
-
byte_delta
/
(
isize
*
dec
->
channels
));
if
(
!
size
)
return
;
ist
->
is_start
=
0
;
...
...
@@ -854,11 +863,11 @@ need_realloc:
}
ist
->
is_start
=
0
;
memset
(
input_tmp
,
0
,
byte_delta
);
generate_silence
(
input_tmp
,
dec
->
sample_fmt
,
byte_delta
);
memcpy
(
input_tmp
+
byte_delta
,
buf
,
size
);
buf
=
input_tmp
;
size
+=
byte_delta
;
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"adding %d audio samples of silence
\n
"
,
(
int
)
delta
);
av_log
(
NULL
,
AV_LOG_VERBOSE
,
"adding %d audio samples of silence
\n
"
,
i
delta
);
}
}
else
if
(
audio_sync_method
>
1
){
int
comp
=
av_clip
(
delta
,
-
audio_sync_method
,
audio_sync_method
);
...
...
@@ -871,7 +880,7 @@ need_realloc:
}
}
else
ost
->
sync_opts
=
lrintf
(
get_sync_ipts
(
ost
)
*
enc
->
sample_rate
)
-
av_fifo_size
(
ost
->
fifo
)
/
(
enc
->
channels
*
2
);
//FIXME wrong
-
av_fifo_size
(
ost
->
fifo
)
/
(
enc
->
channels
*
osize
);
//FIXME wrong
if
(
ost
->
audio_resample
)
{
buftmp
=
audio_buf
;
...
...
@@ -1436,14 +1445,6 @@ static void print_report(OutputFile *output_files,
}
}
static
void
generate_silence
(
uint8_t
*
buf
,
enum
AVSampleFormat
sample_fmt
,
size_t
size
)
{
int
fill_char
=
0x00
;
if
(
sample_fmt
==
AV_SAMPLE_FMT_U8
)
fill_char
=
0x80
;
memset
(
buf
,
fill_char
,
size
);
}
static
void
flush_encoders
(
OutputStream
*
ost_table
,
int
nb_ostreams
)
{
int
i
,
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