History

iv8: assemble packets to return complete frames

Janne Grunau committed 15 years ago

Commit cf543c61 parent c4b97fb1 file · +47 −24Browse files

Unified · Split

libavformat/iv8.c+47−24
@@ -55,33 +55,56 @@ static int read_header(AVFormatContext *s, AVFormatParameters *ap) · 54 unmodified lines
55 55
56static int read_packet(AVFormatContext *s, AVPacket *pkt)56static int read_packet(AVFormatContext *s, AVPacket *pkt)
57{57{
58 int ret, size, pts, type;58 int ret, size, pts, type, flags;
59retry:59 int first_pkt = 0;
60 type= avio_rb16(s->pb); // 257 or 25860 int frame_complete = 0;
61 size= avio_rb16(s->pb);61
62 62 while (!frame_complete) {
63 avio_rb16(s->pb); //some flags, 0x80 indicates end of frame63
64 avio_rb16(s->pb); //packet number64 type = avio_rb16(s->pb); // 257 or 258
65 pts=avio_rb32(s->pb);65 size = avio_rb16(s->pb);
66 avio_rb32(s->pb); //6A 13 E3 8866 flags = avio_rb16(s->pb); //some flags, 0x80 indicates end of frame
67 67 avio_rb16(s->pb); //packet number
68 size -= 12;68 pts = avio_rb32(s->pb);
69 if(size<1)69 avio_rb32(s->pb); //6A 13 E3 88
70 return -1;70
71 71 frame_complete = flags & 0x80;
72 if(type==258){72
73 avio_skip(s->pb, size);73 size -= 12;
74 goto retry;74 if (size < 1)
75 return -1;
76
77 if (type == 258) {
78 avio_skip(s->pb, size);
79 frame_complete = 0;
80 continue;
81 }
82
83 if (!first_pkt) {
84 ret = av_get_packet(s->pb, pkt, size);
85 if (ret < 0)
86 return ret;
87 first_pkt = 1;
88 pkt->pts = pts;
89 pkt->pos -= 16;
90 } else {
91 ret = av_append_packet(s->pb, pkt, size);
92 if (ret < 0) {
93 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
94 av_free_packet(pkt);
95 return ret;
96 }
97 }
98 if (ret < size) {
99 av_log(s, AV_LOG_ERROR, "Truncated packet! Read %d of %d bytes\n",
100 ret, size);
101 pkt->flags |= AV_PKT_FLAG_CORRUPT;
102 break;
103 }
75 }104 }
76
77 ret= av_get_packet(s->pb, pkt, size);
78
79 pkt->pts= pts;
80 pkt->pos-=16;
81
82 pkt->stream_index = 0;105 pkt->stream_index = 0;
83 106
84 return ret;107 return 0;
85}108}
86 109
87AVInputFormat ff_iv8_demuxer = {110AVInputFormat ff_iv8_demuxer = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t