mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
decode latency patch by (Leon van Stuivenberg <l dot vanstuivenberg at chello dot nl>)
Originally committed as revision 2896 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
6cc270c2ac
commit
e15dec10d5
@ -119,6 +119,7 @@ char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
|
||||
void put_flush_packet(ByteIOContext *s);
|
||||
|
||||
int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
|
||||
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
|
||||
int get_byte(ByteIOContext *s);
|
||||
unsigned int get_le32(ByteIOContext *s);
|
||||
uint64_t get_le64(ByteIOContext *s);
|
||||
|
@ -309,6 +309,22 @@ int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
|
||||
return size1 - size;
|
||||
}
|
||||
|
||||
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = s->buf_end - s->buf_ptr;
|
||||
if (len == 0) {
|
||||
fill_buffer(s);
|
||||
len = s->buf_end - s->buf_ptr;
|
||||
}
|
||||
if (len > size)
|
||||
len = size;
|
||||
memcpy(buf, s->buf_ptr, len);
|
||||
s->buf_ptr += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
unsigned int get_le16(ByteIOContext *s)
|
||||
{
|
||||
unsigned int val;
|
||||
|
@ -102,6 +102,25 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
{
|
||||
int ret, size;
|
||||
|
||||
size = RAW_PACKET_SIZE;
|
||||
|
||||
if (av_new_packet(pkt, size) < 0)
|
||||
return -EIO;
|
||||
|
||||
pkt->stream_index = 0;
|
||||
ret = get_partial_buffer(&s->pb, pkt->data, size);
|
||||
if (ret <= 0) {
|
||||
av_free_packet(pkt);
|
||||
return -EIO;
|
||||
}
|
||||
pkt->size = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int raw_read_close(AVFormatContext *s)
|
||||
{
|
||||
return 0;
|
||||
@ -247,7 +266,7 @@ AVInputFormat ac3_iformat = {
|
||||
0,
|
||||
NULL,
|
||||
ac3_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
.extensions = "ac3",
|
||||
};
|
||||
@ -273,7 +292,7 @@ AVInputFormat h263_iformat = {
|
||||
0,
|
||||
h263_probe,
|
||||
video_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
// .extensions = "h263", //FIXME remove after writing mpeg4_probe
|
||||
.value = CODEC_ID_H263,
|
||||
@ -300,7 +319,7 @@ AVInputFormat m4v_iformat = {
|
||||
0,
|
||||
NULL /*mpegvideo_probe*/,
|
||||
video_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
.extensions = "m4v", //FIXME remove after writing mpeg4_probe
|
||||
.value = CODEC_ID_MPEG4,
|
||||
@ -327,7 +346,7 @@ AVInputFormat h264_iformat = {
|
||||
0,
|
||||
NULL /*mpegvideo_probe*/,
|
||||
video_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
.extensions = "h26l,h264", //FIXME remove after writing mpeg4_probe
|
||||
.value = CODEC_ID_H264,
|
||||
@ -354,7 +373,7 @@ AVInputFormat mpegvideo_iformat = {
|
||||
0,
|
||||
mpegvideo_probe,
|
||||
video_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
.value = CODEC_ID_MPEG1VIDEO,
|
||||
};
|
||||
@ -380,7 +399,7 @@ AVInputFormat mjpeg_iformat = {
|
||||
0,
|
||||
NULL,
|
||||
video_read_header,
|
||||
raw_read_packet,
|
||||
raw_read_partial_packet,
|
||||
raw_read_close,
|
||||
.extensions = "mjpg,mjpeg",
|
||||
.value = CODEC_ID_MJPEG,
|
||||
|
Loading…
Reference in New Issue
Block a user