comparison parser.c @ 6983:29a10e3232d8 libavcodec

Factorize fetch_timestamp() into its own function
author michael
date Mon, 02 Jun 2008 13:05:38 +0000
parents abe4c0ba1be7
children 22a3d9efb4a2
comparison
equal deleted inserted replaced
6982:abe4c0ba1be7 6983:29a10e3232d8
72 } 72 }
73 } 73 }
74 s->fetch_timestamp=1; 74 s->fetch_timestamp=1;
75 s->pict_type = FF_I_TYPE; 75 s->pict_type = FF_I_TYPE;
76 return s; 76 return s;
77 }
78
79 void ff_fetch_timestamp(AVCodecParserContext *s){
80 int i;
81 s->dts= s->pts= AV_NOPTS_VALUE;
82 s->offset= 0;
83 for(i = 0; i < AV_PARSER_PTS_NB; i++) {
84 if ( s->next_frame_offset >= s->cur_frame_offset[i]
85 &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset)
86 && s->next_frame_offset < s->cur_frame_end[i]){
87 s->dts= s->cur_frame_dts[i];
88 s->pts= s->cur_frame_pts[i];
89 s->offset = s->next_frame_offset - s->cur_frame_offset[i];
90 }
91 }
77 } 92 }
78 93
79 /** 94 /**
80 * 95 *
81 * @param buf input 96 * @param buf input
125 140
126 if (s->fetch_timestamp){ 141 if (s->fetch_timestamp){
127 s->fetch_timestamp=0; 142 s->fetch_timestamp=0;
128 s->last_pts = s->pts; 143 s->last_pts = s->pts;
129 s->last_dts = s->dts; 144 s->last_dts = s->dts;
130 s->dts= s->pts= AV_NOPTS_VALUE; 145 ff_fetch_timestamp(s);
131 s->offset= 0;
132 for(i = 0; i < AV_PARSER_PTS_NB; i++) {
133 if ( s->next_frame_offset >= s->cur_frame_offset[i]
134 &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset)
135 && s->next_frame_offset < s->cur_frame_end[i]){
136 s->dts= s->cur_frame_dts[i];
137 s->pts= s->cur_frame_pts[i];
138 s->offset = s->next_frame_offset - s->cur_frame_offset[i];
139 }
140 }
141 } 146 }
142 147
143 /* WARNING: the returned index can be negative */ 148 /* WARNING: the returned index can be negative */
144 index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size); 149 index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size);
145 //av_log(NULL, AV_LOG_DEBUG, "parser: in:%"PRId64", %"PRId64", out:%"PRId64", %"PRId64", in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id); 150 //av_log(NULL, AV_LOG_DEBUG, "parser: in:%"PRId64", %"PRId64", out:%"PRId64", %"PRId64", in:%d out:%d id:%d\n", pts, dts, s->last_pts, s->last_dts, buf_size, *poutbuf_size, avctx->codec_id);