Mercurial > libavcodec.hg
comparison parser.c @ 9140:322fa07fd397 libavcodec
Add handling of frame position in the parser.
| author | schreter |
|---|---|
| date | Thu, 05 Mar 2009 07:35:06 +0000 |
| parents | 65f47b345904 |
| children | 5ebac9debadf |
comparison
equal
deleted
inserted
replaced
| 9139:4564ec1f21b0 | 9140:322fa07fd397 |
|---|---|
| 83 | 83 |
| 84 void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ | 84 void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){ |
| 85 int i; | 85 int i; |
| 86 | 86 |
| 87 s->dts= s->pts= AV_NOPTS_VALUE; | 87 s->dts= s->pts= AV_NOPTS_VALUE; |
| 88 s->pos= -1; | |
| 88 s->offset= 0; | 89 s->offset= 0; |
| 89 for(i = 0; i < AV_PARSER_PTS_NB; i++) { | 90 for(i = 0; i < AV_PARSER_PTS_NB; i++) { |
| 90 if ( s->cur_offset + off >= s->cur_frame_offset[i] | 91 if ( s->cur_offset + off >= s->cur_frame_offset[i] |
| 91 &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset) | 92 &&(s-> frame_offset < s->cur_frame_offset[i] || !s->frame_offset) |
| 92 //check is disabled becausue mpeg-ts doesnt send complete PES packets | 93 //check is disabled becausue mpeg-ts doesnt send complete PES packets |
| 93 && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){ | 94 && /*s->next_frame_offset + off <*/ s->cur_frame_end[i]){ |
| 94 s->dts= s->cur_frame_dts[i]; | 95 s->dts= s->cur_frame_dts[i]; |
| 95 s->pts= s->cur_frame_pts[i]; | 96 s->pts= s->cur_frame_pts[i]; |
| 97 s->pos= s->cur_frame_pos[i]; | |
| 96 s->offset = s->next_frame_offset - s->cur_frame_offset[i]; | 98 s->offset = s->next_frame_offset - s->cur_frame_offset[i]; |
| 97 if(remove) | 99 if(remove) |
| 98 s->cur_frame_offset[i]= INT64_MAX; | 100 s->cur_frame_offset[i]= INT64_MAX; |
| 99 if(s->cur_offset + off < s->cur_frame_end[i]) | 101 if(s->cur_offset + off < s->cur_frame_end[i]) |
| 100 break; | 102 break; |
| 123 * | 125 * |
| 124 * if(size) | 126 * if(size) |
| 125 * decode_frame(data, size); | 127 * decode_frame(data, size); |
| 126 * } | 128 * } |
| 127 * @endcode | 129 * @endcode |
| 130 * | |
| 131 * @deprecated Use av_parser_parse2() instead. | |
| 128 */ | 132 */ |
| 129 int av_parser_parse(AVCodecParserContext *s, | 133 int av_parser_parse(AVCodecParserContext *s, |
| 130 AVCodecContext *avctx, | 134 AVCodecContext *avctx, |
| 131 uint8_t **poutbuf, int *poutbuf_size, | 135 uint8_t **poutbuf, int *poutbuf_size, |
| 132 const uint8_t *buf, int buf_size, | 136 const uint8_t *buf, int buf_size, |
| 133 int64_t pts, int64_t dts) | 137 int64_t pts, int64_t dts) |
| 138 { | |
| 139 return av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, AV_NOPTS_VALUE); | |
| 140 } | |
| 141 | |
| 142 int av_parser_parse2(AVCodecParserContext *s, | |
| 143 AVCodecContext *avctx, | |
| 144 uint8_t **poutbuf, int *poutbuf_size, | |
| 145 const uint8_t *buf, int buf_size, | |
| 146 int64_t pts, int64_t dts, | |
| 147 int64_t pos) | |
| 134 { | 148 { |
| 135 int index, i; | 149 int index, i; |
| 136 uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; | 150 uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE]; |
| 137 | 151 |
| 138 if (buf_size == 0) { | 152 if (buf_size == 0) { |
| 145 s->cur_frame_start_index = i; | 159 s->cur_frame_start_index = i; |
| 146 s->cur_frame_offset[i] = s->cur_offset; | 160 s->cur_frame_offset[i] = s->cur_offset; |
| 147 s->cur_frame_end[i] = s->cur_offset + buf_size; | 161 s->cur_frame_end[i] = s->cur_offset + buf_size; |
| 148 s->cur_frame_pts[i] = pts; | 162 s->cur_frame_pts[i] = pts; |
| 149 s->cur_frame_dts[i] = dts; | 163 s->cur_frame_dts[i] = dts; |
| 164 s->cur_frame_pos[i] = pos; | |
| 150 } | 165 } |
| 151 | 166 |
| 152 if (s->fetch_timestamp){ | 167 if (s->fetch_timestamp){ |
| 153 s->fetch_timestamp=0; | 168 s->fetch_timestamp=0; |
| 154 s->last_pts = s->pts; | 169 s->last_pts = s->pts; |
| 155 s->last_dts = s->dts; | 170 s->last_dts = s->dts; |
| 171 s->last_pos = s->pos; | |
| 156 ff_fetch_timestamp(s, 0, 0); | 172 ff_fetch_timestamp(s, 0, 0); |
| 157 } | 173 } |
| 158 | 174 |
| 159 /* WARNING: the returned index can be negative */ | 175 /* WARNING: the returned index can be negative */ |
| 160 index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size); | 176 index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size); |
