History

libavdevice/avfoundation: use pts/dts provided by the CMSampleBuffer API

Matthieu Bouron committed 11 years ago

Commit cf16b451 parent 021b0231 file · +15 −6Browse files

Unified · Split

libavdevice/avfoundation.m+15−6
@@ -908,9 +908,14 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 907 unmodified lines
908 return AVERROR(EIO);908 return AVERROR(EIO);
909 }909 }
910 910
911 pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_pts,911 CMItemCount count;
912 AV_TIME_BASE_Q,912 CMSampleTimingInfo timing_info;
913 avf_time_base_q);913
914 if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_frame, 1, &timing_info, &count) == noErr) {
915 AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale);
916 pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q);
917 }
918
914 pkt->stream_index = ctx->video_stream_index;919 pkt->stream_index = ctx->video_stream_index;
915 pkt->flags |= AV_PKT_FLAG_KEY;920 pkt->flags |= AV_PKT_FLAG_KEY;
916 921
@@ -938,9 +943,13 @@ static int avf_read_packet(AVFormatContext *s, AVPacket *pkt) · 21 unmodified lines
938 return AVERROR(EIO);943 return AVERROR(EIO);
939 }944 }
940 945
941 pkt->pts = pkt->dts = av_rescale_q(av_gettime() - ctx->first_audio_pts,946 CMItemCount count;
942 AV_TIME_BASE_Q,947 CMSampleTimingInfo timing_info;
943 avf_time_base_q);948
949 if (CMSampleBufferGetOutputSampleTimingInfoArray(ctx->current_audio_frame, 1, &timing_info, &count) == noErr) {
950 AVRational timebase_q = av_make_q(1, timing_info.presentationTimeStamp.timescale);
951 pkt->pts = pkt->dts = av_rescale_q(timing_info.presentationTimeStamp.value, timebase_q, avf_time_base_q);
952 }
944 953
945 pkt->stream_index = ctx->audio_stream_index;954 pkt->stream_index = ctx->audio_stream_index;
946 pkt->flags |= AV_PKT_FLAG_KEY;955 pkt->flags |= AV_PKT_FLAG_KEY;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t