[FFmpeg-devel] New Ticket #9006

Marton Balint cus at passwd.hu
Wed Nov 25 00:03:15 EET 2020



On Tue, 24 Nov 2020, Deep Thought wrote:

> I have opened a ticket explaining a problem with the code for
> merge_pmt_versions.
>
> Attached is also a patch which fixes this problem. The main idea is the
> following:
>
>
> for the INITIAL pmt, the old code finds matching streams by
> 1) checking the stream_identifier. If the current stream has one,
> and if an earlier processed stream has the same one, it is assumed
> that the two streams should be merged (I am not sure what this really
> means, but the result is playback problems).
>
> This behavior is wrong for streams having multiple audio streams with the
> same stream_identifier
>
> 2) for streams without a stream identifier, it will look for a stream which
> has the same position in the pmt as the current stream and will obviously
> not find one. This is correct
>
> So the patch solves the problem in 1) as follows:
> 1) if a stream has a stream identifier, it first computes a new variable
> pmt_stream_index which will equal for the first stream with that
> identifier, 1 for the second one with that identifier and so on
> 2) if a stream has no stream_identifier, pmt_stream_index will equal 0 for
> the first such stream, 1 for the second such stream ... This is the same
> as 1) but with stream_identifier==-1
>
> find_matching_stream then compares streams based on a DUAL criterion:
> pmt_stream_index must match, and stream_type must match.
>
> The result is that for the INITIAL pmt all audi streams will be considered
> different. If later the PMT changes, streams will be matched based on
> stream identifier as the primary criterion and based on pmt_stream_index as
> the secondary criterion.

It looks complicated and your patch was using tabs instead of spaces. I 
have attached a patch (untested) which should resolve this in a more 
starightforward way. Can you please test and comment?

Thanks,
Marton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-avformat-mpegts-use-stream-index-based-lookup-with-m.patch
Type: text/x-patch
Size: 2174 bytes
Desc: 
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20201124/a21dd9e8/attachment.bin>


More information about the ffmpeg-devel mailing list