comparison parser.c @ 4846:841ecebff8c8 libavcodec

timestamps generation improvement when parsing avi patch by Joakim \ elupus chez ecce dot se / original thread: date: 03/19/2007 01:47 AM subject: [Ffmpeg-devel] [RFC] Improvement for the odd timestamp generation when parser is in use.
author benoit
date Fri, 13 Apr 2007 07:50:04 +0000
parents 522e52c630bd
children 40f3a7f2b1fd
comparison
equal deleted inserted replaced
4845:78bb9129231b 4846:841ecebff8c8
122 /* fill first PTS/DTS */ 122 /* fill first PTS/DTS */
123 if (s->fetch_timestamp){ 123 if (s->fetch_timestamp){
124 s->fetch_timestamp=0; 124 s->fetch_timestamp=0;
125 s->last_pts = pts; 125 s->last_pts = pts;
126 s->last_dts = dts; 126 s->last_dts = dts;
127 s->last_offset = 0;
127 s->cur_frame_pts[k] = 128 s->cur_frame_pts[k] =
128 s->cur_frame_dts[k] = AV_NOPTS_VALUE; 129 s->cur_frame_dts[k] = AV_NOPTS_VALUE;
129 } 130 }
130 } 131 }
131 132
136 if (*poutbuf_size) { 137 if (*poutbuf_size) {
137 /* fill the data for the current frame */ 138 /* fill the data for the current frame */
138 s->frame_offset = s->last_frame_offset; 139 s->frame_offset = s->last_frame_offset;
139 s->pts = s->last_pts; 140 s->pts = s->last_pts;
140 s->dts = s->last_dts; 141 s->dts = s->last_dts;
142 s->offset = s->last_offset;
141 143
142 /* offset of the next frame */ 144 /* offset of the next frame */
143 s->last_frame_offset = s->cur_offset + index; 145 s->last_frame_offset = s->cur_offset + index;
144 /* find the packet in which the new frame starts. It 146 /* find the packet in which the new frame starts. It
145 is tricky because of MPEG video start codes 147 is tricky because of MPEG video start codes
154 k = (k - 1) & (AV_PARSER_PTS_NB - 1); 156 k = (k - 1) & (AV_PARSER_PTS_NB - 1);
155 } 157 }
156 158
157 s->last_pts = s->cur_frame_pts[k]; 159 s->last_pts = s->cur_frame_pts[k];
158 s->last_dts = s->cur_frame_dts[k]; 160 s->last_dts = s->cur_frame_dts[k];
161 s->last_offset = s->last_frame_offset - s->cur_frame_offset[k];
159 162
160 /* some parsers tell us the packet size even before seeing the first byte of the next packet, 163 /* some parsers tell us the packet size even before seeing the first byte of the next packet,
161 so the next pts/dts is in the next chunk */ 164 so the next pts/dts is in the next chunk */
162 if(index == buf_size){ 165 if(index == buf_size){
163 s->fetch_timestamp=1; 166 s->fetch_timestamp=1;