[FFmpeg-devel] [PATCH 4/4] libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

2015-03-13 Thread matthieu . bouron
From: Matthieu Bouron 

---
 libavdevice/avfoundation.m | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 8112229..5bcd6a4 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -881,9 +881,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return AVERROR(EIO);
 }
 
-pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts,
-   AV_TIME_BASE_Q,
-   avf_time_base_q);
+CMItemCount count;
+CMSampleTimingInfo timing_info;
+
+if 
(CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1, 
&timing_info, &count) == noErr) {
+AVRational timebase_q = av_make_q(1, 
timing_info.presentationTimeStamp.timescale);
+pkt->pts = pkt->dts = 
av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, 
avf_time_base_q);
+}
+
 pkt->stream_index  = ctx->video_stream_index;
 pkt->flags|= AV_PKT_FLAG_KEY;
 
@@ -911,9 +916,13 @@ static int avf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return AVERROR(EIO);
 }
 
-pkt->pts = pkt->dts = av_rescale_q(av_gettime() - 
ctx->first_audio_pts,
-   AV_TIME_BASE_Q,
-   avf_time_base_q);
+CMItemCount count;
+CMSampleTimingInfo timing_info;
+
+if 
(CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1, 
&timing_info, &count) == noErr) {
+AVRational timebase_q = av_make_q(1, 
timing_info.presentationTimeStamp.timescale);
+pkt->pts = pkt->dts = 
av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, 
avf_time_base_q);
+}
 
 pkt->stream_index  = ctx->audio_stream_index;
 pkt->flags|= AV_PKT_FLAG_KEY;
-- 
2.3.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

2015-03-18 Thread Matthieu Bouron
On Fri, Mar 13, 2015 at 8:16 PM,  wrote:

> From: Matthieu Bouron 
>
> ---
>  libavdevice/avfoundation.m | 21 +++--
>  1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index 8112229..5bcd6a4 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -881,9 +881,14 @@ static int avf_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return AVERROR(EIO);
>  }
>
> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
> ctx->first_pts,
> -   AV_TIME_BASE_Q,
> -   avf_time_base_q);
> +CMItemCount count;
> +CMSampleTimingInfo timing_info;
> +
> +if
> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1,
> &timing_info, &count) == noErr) {
> +AVRational timebase_q = av_make_q(1,
> timing_info.presentationTimeStamp.timescale);
> +pkt->pts = pkt->dts =
> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
> avf_time_base_q);
> +}
> +
>  pkt->stream_index  = ctx->video_stream_index;
>  pkt->flags|= AV_PKT_FLAG_KEY;
>
> @@ -911,9 +916,13 @@ static int avf_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return AVERROR(EIO);
>  }
>
> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
> ctx->first_audio_pts,
> -   AV_TIME_BASE_Q,
> -   avf_time_base_q);
> +CMItemCount count;
> +CMSampleTimingInfo timing_info;
> +
> +if
> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1,
> &timing_info, &count) == noErr) {
> +AVRational timebase_q = av_make_q(1,
> timing_info.presentationTimeStamp.timescale);
> +pkt->pts = pkt->dts =
> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
> avf_time_base_q);
> +}
>
>  pkt->stream_index  = ctx->audio_stream_index;
>  pkt->flags|= AV_PKT_FLAG_KEY;
> --
> 2.3.2
>
>
ping
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

2015-03-21 Thread Thilo Borgmann
Am 18.03.15 um 09:37 schrieb Matthieu Bouron:
> On Fri, Mar 13, 2015 at 8:16 PM,  wrote:
> 
>> From: Matthieu Bouron 
>>
>> ---
>>  libavdevice/avfoundation.m | 21 +++--
>>  1 file changed, 15 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
>> index 8112229..5bcd6a4 100644
>> --- a/libavdevice/avfoundation.m
>> +++ b/libavdevice/avfoundation.m
>> @@ -881,9 +881,14 @@ static int avf_read_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>  return AVERROR(EIO);
>>  }
>>
>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
>> ctx->first_pts,
>> -   AV_TIME_BASE_Q,
>> -   avf_time_base_q);
>> +CMItemCount count;
>> +CMSampleTimingInfo timing_info;
>> +
>> +if
>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1,
>> &timing_info, &count) == noErr) {
>> +AVRational timebase_q = av_make_q(1,
>> timing_info.presentationTimeStamp.timescale);
>> +pkt->pts = pkt->dts =
>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
>> avf_time_base_q);
>> +}
>> +
>>  pkt->stream_index  = ctx->video_stream_index;
>>  pkt->flags|= AV_PKT_FLAG_KEY;
>>
>> @@ -911,9 +916,13 @@ static int avf_read_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>  return AVERROR(EIO);
>>  }
>>
>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
>> ctx->first_audio_pts,
>> -   AV_TIME_BASE_Q,
>> -   avf_time_base_q);
>> +CMItemCount count;
>> +CMSampleTimingInfo timing_info;
>> +
>> +if
>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1,
>> &timing_info, &count) == noErr) {
>> +AVRational timebase_q = av_make_q(1,
>> timing_info.presentationTimeStamp.timescale);
>> +pkt->pts = pkt->dts =
>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
>> avf_time_base_q);
>> +}
>>
>>  pkt->stream_index  = ctx->audio_stream_index;
>>  pkt->flags|= AV_PKT_FLAG_KEY;
>> --
>> 2.3.2
>>
>>
> ping

Ok if tested.

-Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

2015-03-28 Thread Thilo Borgmann
Am 21.03.15 um 18:45 schrieb Thilo Borgmann:
> Am 18.03.15 um 09:37 schrieb Matthieu Bouron:
>> On Fri, Mar 13, 2015 at 8:16 PM,  wrote:
>>
>>> From: Matthieu Bouron 
>>>
>>> ---
>>>  libavdevice/avfoundation.m | 21 +++--
>>>  1 file changed, 15 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
>>> index 8112229..5bcd6a4 100644
>>> --- a/libavdevice/avfoundation.m
>>> +++ b/libavdevice/avfoundation.m
>>> @@ -881,9 +881,14 @@ static int avf_read_packet(AVFormatContext *s,
>>> AVPacket *pkt)
>>>  return AVERROR(EIO);
>>>  }
>>>
>>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
>>> ctx->first_pts,
>>> -   AV_TIME_BASE_Q,
>>> -   avf_time_base_q);
>>> +CMItemCount count;
>>> +CMSampleTimingInfo timing_info;
>>> +
>>> +if
>>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1,
>>> &timing_info, &count) == noErr) {
>>> +AVRational timebase_q = av_make_q(1,
>>> timing_info.presentationTimeStamp.timescale);
>>> +pkt->pts = pkt->dts =
>>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
>>> avf_time_base_q);
>>> +}
>>> +
>>>  pkt->stream_index  = ctx->video_stream_index;
>>>  pkt->flags|= AV_PKT_FLAG_KEY;
>>>
>>> @@ -911,9 +916,13 @@ static int avf_read_packet(AVFormatContext *s,
>>> AVPacket *pkt)
>>>  return AVERROR(EIO);
>>>  }
>>>
>>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
>>> ctx->first_audio_pts,
>>> -   AV_TIME_BASE_Q,
>>> -   avf_time_base_q);
>>> +CMItemCount count;
>>> +CMSampleTimingInfo timing_info;
>>> +
>>> +if
>>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1,
>>> &timing_info, &count) == noErr) {
>>> +AVRational timebase_q = av_make_q(1,
>>> timing_info.presentationTimeStamp.timescale);
>>> +pkt->pts = pkt->dts =
>>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
>>> avf_time_base_q);
>>> +}
>>>
>>>  pkt->stream_index  = ctx->audio_stream_index;
>>>  pkt->flags|= AV_PKT_FLAG_KEY;
>>> --
>>> 2.3.2
>>>
>>>
>> ping
> 
> Ok if tested.

Please apply.

Thanks,
Thilo

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

2015-03-28 Thread Michael Niedermayer
On Sun, Mar 29, 2015 at 12:26:31AM +0100, Thilo Borgmann wrote:
> Am 21.03.15 um 18:45 schrieb Thilo Borgmann:
> > Am 18.03.15 um 09:37 schrieb Matthieu Bouron:
> >> On Fri, Mar 13, 2015 at 8:16 PM,  wrote:
> >>
> >>> From: Matthieu Bouron 
> >>>
> >>> ---
> >>>  libavdevice/avfoundation.m | 21 +++--
> >>>  1 file changed, 15 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> >>> index 8112229..5bcd6a4 100644
> >>> --- a/libavdevice/avfoundation.m
> >>> +++ b/libavdevice/avfoundation.m
> >>> @@ -881,9 +881,14 @@ static int avf_read_packet(AVFormatContext *s,
> >>> AVPacket *pkt)
> >>>  return AVERROR(EIO);
> >>>  }
> >>>
> >>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
> >>> ctx->first_pts,
> >>> -   AV_TIME_BASE_Q,
> >>> -   avf_time_base_q);
> >>> +CMItemCount count;
> >>> +CMSampleTimingInfo timing_info;
> >>> +
> >>> +if
> >>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1,
> >>> &timing_info, &count) == noErr) {
> >>> +AVRational timebase_q = av_make_q(1,
> >>> timing_info.presentationTimeStamp.timescale);
> >>> +pkt->pts = pkt->dts =
> >>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
> >>> avf_time_base_q);
> >>> +}
> >>> +
> >>>  pkt->stream_index  = ctx->video_stream_index;
> >>>  pkt->flags|= AV_PKT_FLAG_KEY;
> >>>
> >>> @@ -911,9 +916,13 @@ static int avf_read_packet(AVFormatContext *s,
> >>> AVPacket *pkt)
> >>>  return AVERROR(EIO);
> >>>  }
> >>>
> >>> -pkt->pts = pkt->dts = av_rescale_q(av_gettime() -
> >>> ctx->first_audio_pts,
> >>> -   AV_TIME_BASE_Q,
> >>> -   avf_time_base_q);
> >>> +CMItemCount count;
> >>> +CMSampleTimingInfo timing_info;
> >>> +
> >>> +if
> >>> (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1,
> >>> &timing_info, &count) == noErr) {
> >>> +AVRational timebase_q = av_make_q(1,
> >>> timing_info.presentationTimeStamp.timescale);
> >>> +pkt->pts = pkt->dts =
> >>> av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q,
> >>> avf_time_base_q);
> >>> +}
> >>>
> >>>  pkt->stream_index  = ctx->audio_stream_index;
> >>>  pkt->flags|= AV_PKT_FLAG_KEY;
> >>> --
> >>> 2.3.2
> >>>
> >>>
> >> ping
> > 
> > Ok if tested.
> 
> Please apply.

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel