mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-21 22:36:59 +00:00
* and finaly avoid deadlock at the end of audio stream
Originally committed as revision 183 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
de5123dc35
commit
2d83f323d6
@ -2271,9 +2271,9 @@ static int decode_frame(AVCodecContext * avctx,
|
|||||||
if (len > buf_size)
|
if (len > buf_size)
|
||||||
len = buf_size;
|
len = buf_size;
|
||||||
else if (len > 0) {
|
else if (len > 0) {
|
||||||
memcpy(s->inbuf_ptr, buf_ptr, len);
|
memcpy(s->inbuf_ptr, buf_ptr, len);
|
||||||
buf_ptr += len;
|
buf_ptr += len;
|
||||||
buf_size -= len;
|
buf_size -= len;
|
||||||
s->inbuf_ptr += len;
|
s->inbuf_ptr += len;
|
||||||
}
|
}
|
||||||
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
|
if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) {
|
||||||
@ -2282,7 +2282,7 @@ static int decode_frame(AVCodecContext * avctx,
|
|||||||
(s->inbuf[2] << 8) | s->inbuf[3];
|
(s->inbuf[2] << 8) | s->inbuf[3];
|
||||||
if (check_header(header) < 0) {
|
if (check_header(header) < 0) {
|
||||||
/* no sync found : move by one byte (inefficient, but simple!) */
|
/* no sync found : move by one byte (inefficient, but simple!) */
|
||||||
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
|
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
|
||||||
s->inbuf_ptr--;
|
s->inbuf_ptr--;
|
||||||
dprintf("skip %x\n", header);
|
dprintf("skip %x\n", header);
|
||||||
/* reset free format frame size to give a chance
|
/* reset free format frame size to give a chance
|
||||||
@ -2291,14 +2291,14 @@ static int decode_frame(AVCodecContext * avctx,
|
|||||||
} else {
|
} else {
|
||||||
if (decode_header(s, header) == 1) {
|
if (decode_header(s, header) == 1) {
|
||||||
/* free format: compute frame size */
|
/* free format: compute frame size */
|
||||||
s->frame_size = -1;
|
s->frame_size = -1;
|
||||||
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf);
|
memcpy(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1);
|
||||||
s->inbuf_ptr--;
|
s->inbuf_ptr--;
|
||||||
} else {
|
} else {
|
||||||
/* update codec info */
|
/* update codec info */
|
||||||
avctx->sample_rate = s->sample_rate;
|
avctx->sample_rate = s->sample_rate;
|
||||||
avctx->channels = s->nb_channels;
|
avctx->channels = s->nb_channels;
|
||||||
avctx->bit_rate = s->bit_rate;
|
avctx->bit_rate = s->bit_rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2359,13 +2359,12 @@ static int decode_frame(AVCodecContext * avctx,
|
|||||||
len = s->frame_size - len;
|
len = s->frame_size - len;
|
||||||
if (len > buf_size)
|
if (len > buf_size)
|
||||||
len = buf_size;
|
len = buf_size;
|
||||||
else if (len > 0)
|
else if (len < 4)
|
||||||
{
|
len = buf_size > 4 ? 4 : buf_size;
|
||||||
memcpy(s->inbuf_ptr, buf_ptr, len);
|
memcpy(s->inbuf_ptr, buf_ptr, len);
|
||||||
buf_ptr += len;
|
buf_ptr += len;
|
||||||
s->inbuf_ptr += len;
|
s->inbuf_ptr += len;
|
||||||
buf_size -= len;
|
buf_size -= len;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
out_size = mp_decode_frame(s, out_samples);
|
out_size = mp_decode_frame(s, out_samples);
|
||||||
s->inbuf_ptr = s->inbuf;
|
s->inbuf_ptr = s->inbuf;
|
||||||
|
Loading…
Reference in New Issue
Block a user