|
|
@ -118,17 +118,25 @@ int av_parser_parse(AVCodecParserContext *s, |
|
|
|
k = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); |
|
|
|
k = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1); |
|
|
|
s->cur_frame_start_index = k; |
|
|
|
s->cur_frame_start_index = k; |
|
|
|
s->cur_frame_offset[k] = s->cur_offset; |
|
|
|
s->cur_frame_offset[k] = s->cur_offset; |
|
|
|
|
|
|
|
s->cur_frame_end[k] = s->cur_offset + buf_size; |
|
|
|
s->cur_frame_pts[k] = pts; |
|
|
|
s->cur_frame_pts[k] = pts; |
|
|
|
s->cur_frame_dts[k] = dts; |
|
|
|
s->cur_frame_dts[k] = dts; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* fill first PTS/DTS */ |
|
|
|
|
|
|
|
if (s->fetch_timestamp){ |
|
|
|
if (s->fetch_timestamp){ |
|
|
|
s->fetch_timestamp=0; |
|
|
|
s->fetch_timestamp=0; |
|
|
|
s->last_pts = pts; |
|
|
|
s->last_pts = s->pts; |
|
|
|
s->last_dts = dts; |
|
|
|
s->last_dts = s->dts; |
|
|
|
s->last_offset = 0; |
|
|
|
s->dts= s->pts= AV_NOPTS_VALUE; |
|
|
|
s->cur_frame_pts[k] = |
|
|
|
s->offset= 0; |
|
|
|
s->cur_frame_dts[k] = AV_NOPTS_VALUE; |
|
|
|
for(i = 0; i < AV_PARSER_PTS_NB; i++) { |
|
|
|
|
|
|
|
if ( s->last_frame_offset >= s->cur_frame_offset[i] |
|
|
|
|
|
|
|
&&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset) |
|
|
|
|
|
|
|
&& s->last_frame_offset < s->cur_frame_end[i]){ |
|
|
|
|
|
|
|
s->dts= s->cur_frame_dts[i]; |
|
|
|
|
|
|
|
s->pts= s->cur_frame_pts[i]; |
|
|
|
|
|
|
|
s->offset = s->last_frame_offset - s->cur_frame_offset[i]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -139,34 +147,10 @@ int av_parser_parse(AVCodecParserContext *s, |
|
|
|
if (*poutbuf_size) { |
|
|
|
if (*poutbuf_size) { |
|
|
|
/* fill the data for the current frame */ |
|
|
|
/* fill the data for the current frame */ |
|
|
|
s->frame_offset = s->last_frame_offset; |
|
|
|
s->frame_offset = s->last_frame_offset; |
|
|
|
s->pts = s->last_pts; |
|
|
|
|
|
|
|
s->dts = s->last_dts; |
|
|
|
|
|
|
|
s->offset = s->last_offset; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* offset of the next frame */ |
|
|
|
/* offset of the next frame */ |
|
|
|
s->last_frame_offset = s->cur_offset + index; |
|
|
|
s->last_frame_offset = s->cur_offset + index; |
|
|
|
/* find the packet in which the new frame starts. It
|
|
|
|
|
|
|
|
is tricky because of MPEG video start codes |
|
|
|
|
|
|
|
which can begin in one packet and finish in |
|
|
|
|
|
|
|
another packet. In the worst case, an MPEG |
|
|
|
|
|
|
|
video start code could be in 4 different |
|
|
|
|
|
|
|
packets. */ |
|
|
|
|
|
|
|
k = s->cur_frame_start_index; |
|
|
|
|
|
|
|
for(i = 0; i < AV_PARSER_PTS_NB; i++) { |
|
|
|
|
|
|
|
if (s->last_frame_offset >= s->cur_frame_offset[k]) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
k = (k - 1) & (AV_PARSER_PTS_NB - 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s->last_pts = s->cur_frame_pts[k]; |
|
|
|
|
|
|
|
s->last_dts = s->cur_frame_dts[k]; |
|
|
|
|
|
|
|
s->last_offset = s->last_frame_offset - s->cur_frame_offset[k]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* some parsers tell us the packet size even before seeing the first byte of the next packet,
|
|
|
|
|
|
|
|
so the next pts/dts is in the next chunk */ |
|
|
|
|
|
|
|
if(index == buf_size){ |
|
|
|
|
|
|
|
s->fetch_timestamp=1; |
|
|
|
s->fetch_timestamp=1; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (index < 0) |
|
|
|
if (index < 0) |
|
|
|
index = 0; |
|
|
|
index = 0; |
|
|
|