Ticket #429: ffmpeg-subtitle-interleave.diff
| File ffmpeg-subtitle-interleave.diff, 2.3 KB (added by , 15 years ago) |
|---|
-
libavformat/utils.c
old new 1858 1858 duration = INT64_MIN; 1859 1859 for(i = 0;i < ic->nb_streams; i++) { 1860 1860 st = ic->streams[i]; 1861 if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) { 1861 if (st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE && 1862 st->start_time != AV_NOPTS_VALUE && st->time_base.den) { 1862 1863 start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q); 1863 1864 if (st->codec->codec_id == CODEC_ID_DVB_TELETEXT) { 1864 1865 if (start_time1 < start_time_text) … … 3178 3181 3179 3182 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ 3180 3183 AVPacketList *pktl; 3181 int stream_count=0; 3184 int stream_count=0, noninterleaved_count=0; 3185 int64_t delta_dts_min = INT64_MAX; 3182 3186 int i; 3183 3187 3184 3188 if(pkt){ 3185 3189 ff_interleave_add_packet(s, pkt, ff_interleave_compare_dts); 3186 3190 } 3187 3191 3188 for(i=0; i < s->nb_streams; i++) 3189 stream_count+= !!s->streams[i]->last_in_packet_buffer; 3190 3191 if(stream_count && (s->nb_streams == stream_count || flush)){ 3192 for(i=0; i < s->nb_streams; i++) { 3193 if (s->streams[i]->last_in_packet_buffer) { 3194 int64_t delta_dts = 3195 av_rescale_q(s->streams[i]->last_in_packet_buffer->pkt.dts, 3196 s->streams[i]->time_base, 3197 AV_TIME_BASE_Q) - 3198 av_rescale_q(s->packet_buffer->pkt.dts, 3199 s->streams[s->packet_buffer->pkt.stream_index]->time_base, 3200 AV_TIME_BASE_Q); 3201 if (delta_dts < delta_dts_min) 3202 delta_dts_min = delta_dts; 3203 ++stream_count; 3204 } else { 3205 if(s->streams[i]->stream_copy == 2 || 3206 s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) 3207 ++noninterleaved_count; 3208 } 3209 } 3210 3211 if (s->nb_streams == stream_count) 3212 flush = 1; 3213 else if (!flush && 3214 s->nb_streams == stream_count+noninterleaved_count && 3215 delta_dts_min > 20*AV_TIME_BASE) { 3216 av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count); 3217 flush = 1; 3218 } 3219 if(stream_count && flush){ 3192 3220 pktl= s->packet_buffer; 3193 3221 *out= pktl->pkt; 3194 3222
