| 
																	
																	
																		
																	
																	
																 | 
																@@ -2911,10 +2911,10 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st) | 
															
														
														
													
														
															
																 | 
																 | 
																    MXFIndexTableSegment *segment = NULL; | 
																 | 
																 | 
																    MXFIndexTableSegment *segment = NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																    MXFPartition *p = NULL; | 
																 | 
																 | 
																    MXFPartition *p = NULL; | 
															
														
														
													
														
															
																 | 
																 | 
																    int essence_partition_count = 0; | 
																 | 
																 | 
																    int essence_partition_count = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    int edit_unit_byte_count = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																    int i, ret; | 
																 | 
																 | 
																    int i, ret; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    /* TODO: support raw video without an index if they exist */ | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																    if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO || !is_pcm(st->codecpar->codec_id) || track->wrapping != ClipWrapped) | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if (!track || track->wrapping != ClipWrapped) | 
															
														
														
													
														
															
																 | 
																 | 
																        return 0; | 
																 | 
																 | 
																        return 0; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    /* check if track already has an IndexTableSegment */ | 
																 | 
																 | 
																    /* check if track already has an IndexTableSegment */ | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -2940,6 +2940,17 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st) | 
															
														
														
													
														
															
																 | 
																 | 
																    if (essence_partition_count != 1) | 
																 | 
																 | 
																    if (essence_partition_count != 1) | 
															
														
														
													
														
															
																 | 
																 | 
																        return 0; | 
																 | 
																 | 
																        return 0; | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && is_pcm(st->codecpar->codec_id)) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    } else if (st->duration > 0 && p->first_essence_klv.length > 0 && p->first_essence_klv.length % st->duration == 0) { | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        edit_unit_byte_count = p->first_essence_klv.length / st->duration; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    if (edit_unit_byte_count <= 0) | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        return 0; | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    av_log(mxf->fc, AV_LOG_WARNING, "guessing index for stream %d using edit unit byte count %d\n", st->index, edit_unit_byte_count); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    if (!(segment = av_mallocz(sizeof(*segment)))) | 
																 | 
																 | 
																    if (!(segment = av_mallocz(sizeof(*segment)))) | 
															
														
														
													
														
															
																 | 
																 | 
																        return AVERROR(ENOMEM); | 
																 | 
																 | 
																        return AVERROR(ENOMEM); | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																	
																 | 
																@@ -2952,14 +2963,13 @@ static int mxf_handle_missing_index_segment(MXFContext *mxf, AVStream *st) | 
															
														
														
													
														
															
																 | 
																 | 
																     * using the same SID for index is forbidden in MXF. */ | 
																 | 
																 | 
																     * using the same SID for index is forbidden in MXF. */ | 
															
														
														
													
														
															
																 | 
																 | 
																    if (!track->index_sid) | 
																 | 
																 | 
																    if (!track->index_sid) | 
															
														
														
													
														
															
																 | 
																 | 
																        track->index_sid = track->body_sid; | 
																 | 
																 | 
																        track->index_sid = track->body_sid; | 
															
														
														
													
														
															
																 | 
																 | 
																    track->edit_rate = av_inv_q(st->time_base); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																
  | 
																 | 
																 | 
																
  | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->type = IndexTableSegment; | 
																 | 
																 | 
																    segment->type = IndexTableSegment; | 
															
														
														
													
														
															
																 | 
																 | 
																    /* stream will be treated as small EditUnitByteCount */ | 
																 | 
																 | 
																    /* stream will be treated as small EditUnitByteCount */ | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->edit_unit_byte_count = (av_get_bits_per_sample(st->codecpar->codec_id) * st->codecpar->channels) >> 3; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    segment->edit_unit_byte_count = edit_unit_byte_count; | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->index_start_position = 0; | 
																 | 
																 | 
																    segment->index_start_position = 0; | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->index_duration = st->duration; | 
																 | 
																 | 
																    segment->index_duration = st->duration; | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->index_edit_rate = track->edit_rate; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    segment->index_edit_rate = av_inv_q(st->time_base); | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->index_sid = track->index_sid; | 
																 | 
																 | 
																    segment->index_sid = track->index_sid; | 
															
														
														
													
														
															
																 | 
																 | 
																    segment->body_sid = p->body_sid; | 
																 | 
																 | 
																    segment->body_sid = p->body_sid; | 
															
														
														
													
														
															
																 | 
																 | 
																    return 0; | 
																 | 
																 | 
																    return 0; | 
															
														
														
													
												
													
														
															
																| 
																	
																		
																	
																	
																	
																 | 
																
  |