Mercurial > libavformat.hg
comparison assdec.c @ 6303:af30d878f7d7 libavformat
use return value of ff_get_line()
author | aurel |
---|---|
date | Wed, 21 Jul 2010 21:41:46 +0000 |
parents | e62d23b0547d |
children | 8788871cbc99 |
comparison
equal
deleted
inserted
replaced
6302:869753e625c4 | 6303:af30d878f7d7 |
---|---|
72 return get_pts(*a) - get_pts(*b); | 72 return get_pts(*a) - get_pts(*b); |
73 } | 73 } |
74 | 74 |
75 static int read_header(AVFormatContext *s, AVFormatParameters *ap) | 75 static int read_header(AVFormatContext *s, AVFormatParameters *ap) |
76 { | 76 { |
77 int i, header_remaining; | 77 int i, len, header_remaining; |
78 ASSContext *ass = s->priv_data; | 78 ASSContext *ass = s->priv_data; |
79 ByteIOContext *pb = s->pb; | 79 ByteIOContext *pb = s->pb; |
80 AVStream *st; | 80 AVStream *st; |
81 int allocated[2]={0}; | 81 int allocated[2]={0}; |
82 uint8_t *p, **dst[2]={0}; | 82 uint8_t *p, **dst[2]={0}; |
93 dst[0] = &st->codec->extradata; | 93 dst[0] = &st->codec->extradata; |
94 dst[1] = &ass->event_buffer; | 94 dst[1] = &ass->event_buffer; |
95 while(!url_feof(pb)){ | 95 while(!url_feof(pb)){ |
96 uint8_t line[MAX_LINESIZE]; | 96 uint8_t line[MAX_LINESIZE]; |
97 | 97 |
98 ff_get_line(pb, line, sizeof(line)); | 98 len = ff_get_line(pb, line, sizeof(line)); |
99 | 99 |
100 if(!memcmp(line, "[Events]", 8)) | 100 if(!memcmp(line, "[Events]", 8)) |
101 header_remaining= 2; | 101 header_remaining= 2; |
102 else if(line[0]=='[') | 102 else if(line[0]=='[') |
103 header_remaining= INT_MAX; | 103 header_remaining= INT_MAX; |
109 | 109 |
110 p = av_fast_realloc(*(dst[i]), &allocated[i], pos[i]+MAX_LINESIZE); | 110 p = av_fast_realloc(*(dst[i]), &allocated[i], pos[i]+MAX_LINESIZE); |
111 if(!p) | 111 if(!p) |
112 goto fail; | 112 goto fail; |
113 *(dst[i])= p; | 113 *(dst[i])= p; |
114 memcpy(p + pos[i], line, strlen(line)+1); | 114 memcpy(p + pos[i], line, len+1); |
115 pos[i] += strlen(line); | 115 pos[i] += len; |
116 if(i) ass->event_count++; | 116 if(i) ass->event_count++; |
117 else header_remaining--; | 117 else header_remaining--; |
118 } | 118 } |
119 st->codec->extradata_size= pos[0]; | 119 st->codec->extradata_size= pos[0]; |
120 | 120 |