[FFmpeg-devel] [PATCH] First shot at AVCHD seeking via new seeking API

Michael Niedermayer michaelni
Mon Aug 3 03:33:20 CEST 2009


On Sun, Aug 02, 2009 at 07:46:25PM +0200, Ivan Schreter wrote:
> Hi Baptiste,
>
> Thanks for your comments. I've changed the code mostly according to your 
> suggestions, see inline comments.
>
> Baptiste Coudurier wrote:
>> On 07/26/2009 06:00 AM, Ivan Schreter wrote:
>>> Baptiste Coudurier wrote:
[...]
>
>>
>>>>
>>>>> + }
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + // Clean up the parser.
>>>>> + av_read_frame_flush(s);
>>>>> +}
>>>>> +
>>>>> +int64_t ff_gen_syncpoint_search(AVFormatContext *s,
>>>>> + int stream_index,
>>>>> + int64_t pos,
>>>>> + int64_t ts_min,
>>>>> + int64_t ts,
>>>>> + int64_t ts_max,
>>>>> + int flags)
>>>>> +{
>>>>> + AVSyncPoint sync[MAX_STREAMS], *sp;
>>>>> + AVStream *st;
>>>>> + int i;
>>>>> + int keyframes_to_find = 0;
>>>>> + int64_t curpos;
>>>>> + int64_t step;
>>>>> + int found_lo = 0, found_hi = 0;
>>>>> + int64_t min_distance;
>>>>> + int64_t min_pos = 0;
>>>>> +
>>>>> + if (stream_index>= 0&& !(flags& AVSEEK_FLAG_BYTE)) {
>>>>> + // Rescale timestamps to AV_TIME_BASE, if timestamp of a reference
>>>>> stream given.
>>>>> + st = s->streams[stream_index];
>>>>> + if (ts != AV_NOPTS_VALUE)
>>>>> + ts = av_rescale(ts, AV_TIME_BASE * (int64_t)st->time_base.num,
>>>>> st->time_base.den);
>>>>> + if (ts_min != INT64_MIN)
>>>>> + ts_min = av_rescale(ts_min, AV_TIME_BASE *
>>>>> (int64_t)st->time_base.num, st->time_base.den);
>>>>> + if (ts_max != INT64_MAX)
>>>>> + ts_max = av_rescale(ts_max, AV_TIME_BASE *
>>>>> (int64_t)st->time_base.num, st->time_base.den);
>>>>> + }
>>>>
>>>> I don't think rescaling is needed for now since in mpegts all streams
>>>> have same timebase.
>>> It is, since stream_index can be -1, which means, it's in AV_TIME_BASE.
>>
>> And that is done in mpegts read_seek2, now you rescale back.
> This rescaling in read_seek2 is only done, because there is no new generic 
> search function working with AV_TIME_BASE only, but rather with stream's 
> time base. But this is not used further in new code.
>
>> You specifically mentioned that this function must be called by demuxers.
> Yes, it's for demuxers only.
>
>> Besides this may be done in avformat_seek_file.
> Yes, but I don't want to break old seeking routines, since they would have 
> to rescale back.
>
>>> MPEG-specific. The rest of the code works in AV_TIME_BASE anyway and
>>> it's generic enough for other formats as well.
>> So I'd have to rescale in stream_index == -1 case also if the code were
>>
>> When you don't need to rescale, don't, for now you don't.
> I'm currently rescaling only one way - from stream timebase to 
> AV_TIME_BASE. This should be safe for all stream types, so I don't see a 
> reason to change this for MPEG-only 90kHz clock, as that is not 
> future-proof.

ive not checked to the code so i possibly miss somethng but timestamp
code must be exact, that is for example if you compare 2 timestamps
from 2 streams these must not be rescaled to AV_TIME_BASE but rather
the compare must be done exactly

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090803/5358d033/attachment.pgp>



More information about the ffmpeg-devel mailing list