aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-30 02:24:15 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-30 02:34:35 +0100
commitc40a35f8a7e3977c18d0ebff503a3add8ff58dad (patch)
tree889e78f2d463e5c5919533e818d781fb4fb744dc /ffmpeg.c
parent23b4f355bbd9b8c5338fc4e31b39657073e1f88f (diff)
parent464ccb01447b91717cf580b870e636514701ce4f (diff)
downloadffmpeg-c40a35f8a7e3977c18d0ebff503a3add8ff58dad.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: indeo3: check per-plane data buffer against input buffer bounds. avconv: Handle audio sync for non-S16 sample formats. pthread: don't increment index on zero-sized packets. Conflicts: libavcodec/indeo3.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 8903a97d10..f69d53fe1e 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -827,6 +827,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,
@@ -926,9 +934,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){
@@ -937,7 +945,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;
@@ -950,11 +959,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", idelta);
}
}else if(audio_sync_method>1){
int comp= av_clip(delta, -audio_sync_method, audio_sync_method);
@@ -967,7 +976,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;
@@ -1535,14 +1544,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;