[FFmpeg-devel] [PATCH] Fix MPEG-TS seek and frame positions in general
Baptiste Coudurier
baptiste.coudurier
Thu Feb 26 20:57:04 CET 2009
Ivan Schreter wrote:
> Baptiste Coudurier wrote:
>> Hi Ivan,
>>
>> On 2/24/2009 11:57 AM, Ivan Schreter wrote:
>>
>>> [...]
>>>
>>> typedef struct MpegTSPESFilter {
>>> PESCallback *pes_cb;
>>> @@ -147,6 +147,7 @@
>>> int total_size;
>>> int pes_header_size;
>>> int64_t pts, dts;
>>> + int64_t stream_pos; /**< position of first TS packet of this PES
>>> packet */
>>> uint8_t header[MAX_PES_HEADER_SIZE];
>>> };
>>>
>>> @@ -810,7 +811,8 @@
>>>
>>> /* return non zero if a packet could be constructed */
>>> static void mpegts_push_data(MpegTSFilter *filter,
>>> - const uint8_t *buf, int buf_size, int
>>> is_start)
>>> + const uint8_t *buf, int buf_size, int
>>> is_start,
>>> + int64_t pos)
>>> {
>>> PESContext *pes = filter->u.pes_filter.opaque;
>>> MpegTSContext *ts = pes->ts;
>>> @@ -823,6 +825,8 @@
>>> if (is_start) {
>>> pes->state = MPEGTS_HEADER;
>>> pes->data_index = 0;
>>> + /* Note: file position points just after the TS packet, so
>>> subtract it */
>>> + pes->stream_pos = pos - ts->raw_packet_size;
>>>
>>
>> Is it possible to adjust pos before passing it to the callback, easier
>> and can spare one comment.
>>
>>
> Sure...
>
> I was just thinking, we can save the subtraction, since only if is_start
> is set, this subtraction will be done. But here updated patch.
>
> Regards,
>
> Ivan
>
>
> ------------------------------------------------------------------------
>
> Index: libavformat/mpegts.c
> ===================================================================
> --- libavformat/mpegts.c (revision 17012)
> +++ libavformat/mpegts.c (working copy)
> @@ -48,7 +48,7 @@
>
> typedef struct MpegTSFilter MpegTSFilter;
>
> -typedef void PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start);
> +typedef void PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start, int64_t pos);
>
> typedef struct MpegTSPESFilter {
> PESCallback *pes_cb;
> @@ -147,6 +147,7 @@
> int total_size;
> int pes_header_size;
> int64_t pts, dts;
> + int64_t stream_pos; /**< position of first TS packet of this PES packet */
> uint8_t header[MAX_PES_HEADER_SIZE];
> };
>
Maybe ts_packet_pos ?
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
checking for life_signs in -lkenny... no
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list