[FFmpeg-devel] [PATCH] Fix MPEG-TS seek and frame positions in general

Baptiste Coudurier baptiste.coudurier
Thu Feb 26 00:39:01 CET 2009


Hi Ivan,

On 2/24/2009 11:57 AM, Ivan Schreter wrote:
> Baptiste Coudurier wrote:
>> On 2/23/2009 1:01 PM, Ivan Schreter wrote:
>>  
>>> Ivan Schreter wrote:
>>>    
>>>> Baptiste Coudurier wrote:
>>>>        
>>>>> [...]
>>>>> I believe AVPacket->pos should be set to the point where a byte
>>>>> seek can
>>>>> occur for formats allowing it, this can be really useful for
>>>>> application
>>>>> constructing indexes and/or using AVIndex.
>>>>>
>>>>> So in this case I believe AVPacket->pos should be set to the 0x47 byte
>>>>> containing the start of the PES packet containing the frame.
>>>>>
>>>>>               
>>>> Um, this is the case with the patch...
>>>>
>>>> If I look in the ts file, the positions returned point exactly to
>>>> 0x47 byte. Did you see something different in your sample?
>>>>
>>>>         
>>> Ping Baptiste/Mans?
>>>     
>>
>> Yes, did you address my comment with stream->pos being -1 ?
>>
>>   
> Hm, I could not reproduce the problem with stream->pos being < 0... So I
> removed the special case. Updated patch attached.
> 
> OK now?
> 
> [...]
>
>  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.

[...]

-- 
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