Commit c40a35f8 authored by Michael Niedermayer's avatar Michael Niedermayer

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 23b4f355 464ccb01
...@@ -779,6 +779,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx ...@@ -779,6 +779,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, static void do_audio_out(AVFormatContext *s,
OutputStream *ost, OutputStream *ost,
InputStream *ist, InputStream *ist,
...@@ -879,9 +887,9 @@ need_realloc: ...@@ -879,9 +887,9 @@ need_realloc:
if(audio_sync_method){ if(audio_sync_method){
double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
- av_fifo_size(ost->fifo)/(enc->channels * 2); - av_fifo_size(ost->fifo)/(enc->channels * osize);
double idelta= delta*dec->sample_rate / enc->sample_rate; int idelta = delta * dec->sample_rate / enc->sample_rate;
int byte_delta= ((int)idelta)*2*dec->channels; int byte_delta = idelta * isize * dec->channels;
//FIXME resample delay //FIXME resample delay
if(fabs(delta) > 50){ if(fabs(delta) > 50){
...@@ -890,7 +898,8 @@ need_realloc: ...@@ -890,7 +898,8 @@ need_realloc:
byte_delta= FFMAX(byte_delta, -size); byte_delta= FFMAX(byte_delta, -size);
size += byte_delta; size += byte_delta;
buf -= 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) if(!size)
return; return;
ist->is_start=0; ist->is_start=0;
...@@ -904,11 +913,11 @@ need_realloc: ...@@ -904,11 +913,11 @@ need_realloc:
} }
ist->is_start=0; 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); memcpy(input_tmp + byte_delta, buf, size);
buf= input_tmp; buf= input_tmp;
size += byte_delta; 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){ }else if(audio_sync_method>1){
int comp= av_clip(delta, -audio_sync_method, audio_sync_method); int comp= av_clip(delta, -audio_sync_method, audio_sync_method);
...@@ -921,7 +930,7 @@ need_realloc: ...@@ -921,7 +930,7 @@ need_realloc:
} }
}else }else
ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) 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) { if (ost->audio_resample) {
buftmp = audio_buf; buftmp = audio_buf;
...@@ -1505,14 +1514,6 @@ static void print_report(OutputFile *output_files, ...@@ -1505,14 +1514,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) static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
{ {
int i, ret; int i, ret;
......
...@@ -827,6 +827,14 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx ...@@ -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, static void do_audio_out(AVFormatContext *s,
OutputStream *ost, OutputStream *ost,
InputStream *ist, InputStream *ist,
...@@ -926,9 +934,9 @@ need_realloc: ...@@ -926,9 +934,9 @@ need_realloc:
if(audio_sync_method){ if(audio_sync_method){
double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
- av_fifo_size(ost->fifo)/(enc->channels * 2); - av_fifo_size(ost->fifo)/(enc->channels * osize);
double idelta= delta*dec->sample_rate / enc->sample_rate; int idelta = delta * dec->sample_rate / enc->sample_rate;
int byte_delta= ((int)idelta)*2*dec->channels; int byte_delta = idelta * isize * dec->channels;
//FIXME resample delay //FIXME resample delay
if(fabs(delta) > 50){ if(fabs(delta) > 50){
...@@ -937,7 +945,8 @@ need_realloc: ...@@ -937,7 +945,8 @@ need_realloc:
byte_delta= FFMAX(byte_delta, -size); byte_delta= FFMAX(byte_delta, -size);
size += byte_delta; size += byte_delta;
buf -= 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) if(!size)
return; return;
ist->is_start=0; ist->is_start=0;
...@@ -950,11 +959,11 @@ need_realloc: ...@@ -950,11 +959,11 @@ need_realloc:
} }
ist->is_start=0; 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); memcpy(input_tmp + byte_delta, buf, size);
buf= input_tmp; buf= input_tmp;
size += byte_delta; 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){ }else if(audio_sync_method>1){
int comp= av_clip(delta, -audio_sync_method, audio_sync_method); int comp= av_clip(delta, -audio_sync_method, audio_sync_method);
...@@ -967,7 +976,7 @@ need_realloc: ...@@ -967,7 +976,7 @@ need_realloc:
} }
}else }else
ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) 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) { if (ost->audio_resample) {
buftmp = audio_buf; buftmp = audio_buf;
...@@ -1535,14 +1544,6 @@ static void print_report(OutputFile *output_files, ...@@ -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) static void flush_encoders(OutputStream *ost_table, int nb_ostreams)
{ {
int i, ret; int i, ret;
......
...@@ -494,6 +494,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt) ...@@ -494,6 +494,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
} }
fctx->prev_thread = p; fctx->prev_thread = p;
fctx->next_decoding++;
return 0; return 0;
} }
...@@ -516,8 +517,6 @@ int ff_thread_decode_frame(AVCodecContext *avctx, ...@@ -516,8 +517,6 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
err = submit_packet(p, avpkt); err = submit_packet(p, avpkt);
if (err) return err; if (err) return err;
fctx->next_decoding++;
/* /*
* If we're still receiving the initial packets, don't return a frame. * If we're still receiving the initial packets, don't return a frame.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment