use custom packet allocation only for DV

Originally committed as revision 1937 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Fabrice Bellard 22 years ago
parent 01310af292
commit 2af7e61032
  1. 56
      libavformat/avidec.c

@ -296,9 +296,17 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
int n, d[8], size, i; int n, d[8], size, i;
memset(d, -1, sizeof(int)*8); memset(d, -1, sizeof(int)*8);
if (avi->type == 1 && avi->stream_index) if (avi->type == 1 && avi->stream_index) {
goto pkt_init; /* duplicate DV packet */
av_init_packet(pkt);
pkt->data = avi->buf;
pkt->size = avi->buf_size;
pkt->destruct = __destruct_pkt;
pkt->stream_index = avi->stream_index;
avi->stream_index = !avi->stream_index;
return 0;
}
for(i=url_ftell(pb); !url_feof(pb); i++) { for(i=url_ftell(pb); !url_feof(pb); i++) {
int j; int j;
@ -346,31 +354,29 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
&& n < s->nb_streams && n < s->nb_streams
&& i + size <= avi->movi_end) { && i + size <= avi->movi_end) {
uint8_t *tbuf = av_realloc(avi->buf, size + FF_INPUT_BUFFER_PADDING_SIZE); if (avi->type == 1) {
if (!tbuf) uint8_t *tbuf = av_realloc(avi->buf, size + FF_INPUT_BUFFER_PADDING_SIZE);
return -1; if (!tbuf)
avi->buf = tbuf; return -1;
avi->buf_size = size; avi->buf = tbuf;
get_buffer(pb, avi->buf, size); avi->buf_size = size;
if (size & 1) av_init_packet(pkt);
get_byte(pb); pkt->data = avi->buf;
if (avi->type != 1) pkt->size = avi->buf_size;
avi->stream_index = n; pkt->destruct = __destruct_pkt;
goto pkt_init; avi->stream_index = n;
} else {
av_new_packet(pkt, size);
}
get_buffer(pb, pkt->data, size);
if (size & 1)
get_byte(pb);
pkt->stream_index = n;
pkt->flags |= PKT_FLAG_KEY; // FIXME: We really should read index for that
return 0;
} }
} }
return -1; return -1;
pkt_init:
av_init_packet(pkt);
pkt->data = avi->buf;
pkt->size = avi->buf_size;
pkt->destruct = __destruct_pkt;
pkt->stream_index = avi->stream_index;
pkt->flags |= PKT_FLAG_KEY; // FIXME: We really should read index for that
avi->stream_index = !avi->stream_index;
return 0;
} }
static int avi_read_close(AVFormatContext *s) static int avi_read_close(AVFormatContext *s)

Loading…
Cancel
Save