On 05/22/2013 01:59 PM, John Stebbins wrote:
> On 05/22/2013 01:31 PM, John Stebbins wrote:
>> On 05/22/2013 07:25 AM, Luca Barbato wrote:
>>> On 05/22/2013 04:24 PM, Justin Ruggles wrote:
>>>> On 05/30/2012 05:42 PM, Alex Converse wrote:
>>>>> ---
>>>>>  libavformat/movenc.c |   22 +++++++++++++++-------
>>>>>  1 files changed, 15 insertions(+), 7 deletions(-)
>>>>>
>>>>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>>>>> index fa6e957..a8c68af 100644
>>>>> --- a/libavformat/movenc.c
>>>>> +++ b/libavformat/movenc.c
>>>>> @@ -1464,10 +1464,15 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>>>> MOVTrack *track)
>>>>>                                        track->timescale, AV_ROUND_UP);
>>>>>      int version = duration < INT32_MAX ? 0 : 1;
>>>>>      int entry_size, entry_count, size;
>>>>> -    int64_t delay, start_ct = track->cluster[0].cts;
>>>>> -    delay = av_rescale_rnd(track->cluster[0].dts + start_ct, 
>>>>> MOV_TIMESCALE,
>>>>> -                           track->timescale, AV_ROUND_DOWN);
>>>>> -    version |= delay < INT32_MAX ? 0 : 1;
>>>>> +    int64_t delay, trim = 0;
>>>>> +    delay = av_rescale_rnd(track->cluster[0].dts + track->cluster[0].cts,
>>>>> +                           MOV_TIMESCALE, track->timescale, 
>>>>> AV_ROUND_DOWN);
>>>>> +    if (track->cluster[0].cts) {
>>>>> +        trim = track->cluster[0].cts;
>>>>> +    } else if (track->cluster[0].dts < 0) {
>>>>> +        trim = -track->cluster[0].dts;
>>>>> +    }
>>>>> +    version |= delay < INT32_MAX && trim < INT32_MAX ? 0 : 1;
>>>>>  
>>>>>      entry_size = (version == 1) ? 20 : 12;
>>>>>      entry_count = 1 + (delay > 0);
>>>>> @@ -1496,10 +1501,10 @@ static int mov_write_edts_tag(AVIOContext *pb, 
>>>>> MOVTrack *track)
>>>>>      /* duration */
>>>>>      if (version == 1) {
>>>>>          avio_wb64(pb, duration);
>>>>> -        avio_wb64(pb, start_ct);
>>>>> +        avio_wb64(pb, trim);
>>>>>      } else {
>>>>>          avio_wb32(pb, duration);
>>>>> -        avio_wb32(pb, start_ct);
>>>>> +        avio_wb32(pb, trim);
>>>>>      }
>>>>>      avio_wb32(pb, 0x00010000);
>>>>>      return size;
>>>>> @@ -2882,8 +2887,11 @@ int ff_mov_write_packet(AVFormatContext *s, 
>>>>> AVPacket *pkt)
>>>>>           * of this packet to be what the previous packets duration 
>>>>> implies. */
>>>>>          trk->cluster[trk->entry].dts = trk->start_dts + 
>>>>> trk->track_duration;
>>>>>      }
>>>>> -    if (trk->start_dts == AV_NOPTS_VALUE)
>>>>> +    if (trk->start_dts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE) {
>>>>>          trk->start_dts = pkt->dts;
>>>>> +        if (trk->start_dts < 0 && pkt->pts == pkt->dts)
>>>>> +            trk->start_dts = 0;
>>>>> +    }
>>>>>      trk->track_duration = pkt->dts - trk->start_dts + pkt->duration;
>>>>>  
>>>>>      if (pkt->pts == AV_NOPTS_VALUE) {
>>>> Should we go ahead and commit this? It is good enough for me, and it
>>>> fixes the most common cases.
>>>>
>>> Fine for me.
>>>
>>>
>> Hi,
>>
>> Can you explain what this is suppose to be doing?  I just looks wrong to me 
>> but I may just not understand.
>>
>> For one thing, trim does not seem to be scaled properly (by timescale).
> Never mind about the timescale comment.  Brainfart.
>
> I think I'm starting to understand what this does.  I'm just trying to 
> understand how this might affect me since I am
> adding an avformat muxer to HandBrake.  I don't quite understand what the 
> purpose is of this "media time" field that is
> being modified.  Maybe an example would help me.  What would be the net 
> result if track->cluster[0].cts == 0 and
> track->cluster[0].dts is a positive number?
>
>

Ugh, again with the brainfart.  trim == 0 when dts > 0.  So when dts is < 0, 
what does this trim value mean to a
player.  Sorry for the spam :-\

-- 
John      GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to