Lines Matching refs:sc
197 MOVStreamContext *sc; in mov_read_covr() local
211 sc = av_mallocz(sizeof(*sc)); in mov_read_covr()
212 if (!sc) in mov_read_covr()
216 av_free(sc); in mov_read_covr()
220 st->priv_data = sc; in mov_read_covr()
629 MOVStreamContext *sc; in mov_read_dref() local
635 sc = st->priv_data; in mov_read_dref()
641 entries >= UINT_MAX / sizeof(*sc->drefs)) in mov_read_dref()
644 for (i = 0; i < sc->drefs_count; i++) { in mov_read_dref()
645 MOVDref *dref = &sc->drefs[i]; in mov_read_dref()
649 av_free(sc->drefs); in mov_read_dref()
650 sc->drefs_count = 0; in mov_read_dref()
651 sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); in mov_read_dref()
652 if (!sc->drefs) in mov_read_dref()
654 sc->drefs_count = entries; in mov_read_dref()
657 MOVDref *dref = &sc->drefs[i]; in mov_read_dref()
1354 MOVStreamContext *sc = st->priv_data; in search_frag_timestamp() local
1355 if (sc->has_sidx) in search_frag_timestamp()
1495 MOVStreamContext *sc; in mov_read_mdhd() local
1504 sc = st->priv_data; in mov_read_mdhd()
1506 if (sc->time_scale) { in mov_read_mdhd()
1526 sc->time_scale = avio_rb32(pb); in mov_read_mdhd()
1527 if (sc->time_scale <= 0) { in mov_read_mdhd()
1528 … av_log(c->fc, AV_LOG_ERROR, "Invalid mdhd time scale %d, defaulting to 1\n", sc->time_scale); in mov_read_mdhd()
1529 sc->time_scale = 1; in mov_read_mdhd()
2092 MOVStreamContext *sc; in mov_read_stco() local
2102 sc = st->priv_data; in mov_read_stco()
2112 if (sc->chunk_offsets) { in mov_read_stco()
2116 av_free(sc->chunk_offsets); in mov_read_stco()
2117 sc->chunk_count = 0; in mov_read_stco()
2118 sc->chunk_offsets = av_malloc_array(entries, sizeof(*sc->chunk_offsets)); in mov_read_stco()
2119 if (!sc->chunk_offsets) in mov_read_stco()
2121 sc->chunk_count = entries; in mov_read_stco()
2125 sc->chunk_offsets[i] = avio_rb32(pb); in mov_read_stco()
2128 sc->chunk_offsets[i] = avio_rb64(pb); in mov_read_stco()
2132 sc->chunk_count = i; in mov_read_stco()
2178 AVStream *st, MOVStreamContext *sc) in mov_parse_stsd_video() argument
2229 if (ff_get_qtpalette(st->codecpar->codec_id, pb, sc->palette)) { in mov_parse_stsd_video()
2231 sc->has_palette = 1; in mov_parse_stsd_video()
2236 AVStream *st, MOVStreamContext *sc) in mov_parse_stsd_audio() argument
2255 sc->audio_cid = avio_rb16(pb); in mov_parse_stsd_audio()
2264 (sc->stsd_version == 0 && version > 0)) { in mov_parse_stsd_audio()
2266 sc->samples_per_frame = avio_rb32(pb); in mov_parse_stsd_audio()
2268 sc->bytes_per_frame = avio_rb32(pb); in mov_parse_stsd_audio()
2280 sc->bytes_per_frame = avio_rb32(pb); in mov_parse_stsd_audio()
2281 sc->samples_per_frame = avio_rb32(pb); in mov_parse_stsd_audio()
2287 if (version == 0 || (version == 1 && sc->audio_cid != -2)) { in mov_parse_stsd_audio()
2298 if (sc->format == 0) { in mov_parse_stsd_audio()
2326 sc->samples_per_frame = 6; in mov_parse_stsd_audio()
2327 sc->bytes_per_frame = 2 * st->codecpar->ch_layout.nb_channels; in mov_parse_stsd_audio()
2330 sc->samples_per_frame = 6; in mov_parse_stsd_audio()
2331 sc->bytes_per_frame = 1 * st->codecpar->ch_layout.nb_channels; in mov_parse_stsd_audio()
2334 sc->samples_per_frame = 64; in mov_parse_stsd_audio()
2335 sc->bytes_per_frame = 34 * st->codecpar->ch_layout.nb_channels; in mov_parse_stsd_audio()
2338 sc->samples_per_frame = 160; in mov_parse_stsd_audio()
2339 sc->bytes_per_frame = 33; in mov_parse_stsd_audio()
2348 sc->sample_size = (bits_per_sample >> 3) * st->codecpar->ch_layout.nb_channels; in mov_parse_stsd_audio()
2353 AVStream *st, MOVStreamContext *sc, in mov_parse_stsd_subtitle() argument
2362 st->codecpar->width = sc->width; in mov_parse_stsd_subtitle()
2363 st->codecpar->height = sc->height; in mov_parse_stsd_subtitle()
2415 AVStream *st, MOVStreamContext *sc, in mov_parse_stsd_data() argument
2461 AVStream *st, MOVStreamContext *sc) in mov_finalize_stsd_codec() argument
2466 !st->codecpar->sample_rate && sc->time_scale > 1) in mov_finalize_stsd_codec()
2467 st->codecpar->sample_rate = sc->time_scale; in mov_finalize_stsd_codec()
2483 sc->dv_audio_container = 1; in mov_finalize_stsd_codec()
2495 sc->samples_per_frame = 160; in mov_finalize_stsd_codec()
2496 if (!sc->bytes_per_frame) in mov_finalize_stsd_codec()
2497 sc->bytes_per_frame = 35; in mov_finalize_stsd_codec()
2522 st->codecpar->block_align = sc->bytes_per_frame; in mov_finalize_stsd_codec()
2583 MOVStreamContext *sc; in ff_mov_read_stsd_entries() local
2588 sc = st->priv_data; in ff_mov_read_stsd_entries()
2613 sc->stsd_count++; in ff_mov_read_stsd_entries()
2617 sc->pseudo_stream_id = st->codecpar->codec_tag ? -1 : pseudo_stream_id; in ff_mov_read_stsd_entries()
2618 sc->dref_id= dref_id; in ff_mov_read_stsd_entries()
2619 sc->format = format; in ff_mov_read_stsd_entries()
2629 mov_parse_stsd_video(c, pb, st, sc); in ff_mov_read_stsd_entries()
2631 mov_parse_stsd_audio(c, pb, st, sc); in ff_mov_read_stsd_entries()
2641 mov_parse_stsd_subtitle(c, pb, st, sc, in ff_mov_read_stsd_entries()
2644 ret = mov_parse_stsd_data(c, pb, st, sc, in ff_mov_read_stsd_entries()
2657 if (sc->extradata && st->codecpar->extradata) { in ff_mov_read_stsd_entries()
2661 sc->extradata_size[pseudo_stream_id] = extra_size; in ff_mov_read_stsd_entries()
2662 sc->extradata[pseudo_stream_id] = st->codecpar->extradata; in ff_mov_read_stsd_entries()
2666 sc->stsd_count++; in ff_mov_read_stsd_entries()
2680 MOVStreamContext *sc; in mov_read_stsd() local
2686 sc = st->priv_data; in mov_read_stsd()
2688 sc->stsd_version = avio_r8(pb); in mov_read_stsd()
2698 if (sc->extradata) { in mov_read_stsd()
2705 sc->extradata = av_calloc(entries, sizeof(*sc->extradata)); in mov_read_stsd()
2706 if (!sc->extradata) in mov_read_stsd()
2709 sc->extradata_size = av_calloc(entries, sizeof(*sc->extradata_size)); in mov_read_stsd()
2710 if (!sc->extradata_size) { in mov_read_stsd()
2721 st->codecpar->extradata_size = sc->extradata_size[0]; in mov_read_stsd()
2722 if (sc->extradata_size[0]) { in mov_read_stsd()
2723 st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE); in mov_read_stsd()
2726 memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]); in mov_read_stsd()
2729 return mov_finalize_stsd_codec(c, pb, st, sc); in mov_read_stsd()
2731 if (sc->extradata) { in mov_read_stsd()
2733 for (j = 0; j < sc->stsd_count; j++) in mov_read_stsd()
2734 av_freep(&sc->extradata[j]); in mov_read_stsd()
2737 av_freep(&sc->extradata); in mov_read_stsd()
2738 av_freep(&sc->extradata_size); in mov_read_stsd()
2745 MOVStreamContext *sc; in mov_read_stsc() local
2751 sc = st->priv_data; in mov_read_stsc()
2764 if (sc->stsc_data) { in mov_read_stsc()
2768 av_free(sc->stsc_data); in mov_read_stsc()
2769 sc->stsc_count = 0; in mov_read_stsc()
2770 sc->stsc_data = av_malloc_array(entries, sizeof(*sc->stsc_data)); in mov_read_stsc()
2771 if (!sc->stsc_data) in mov_read_stsc()
2775 sc->stsc_data[i].first = avio_rb32(pb); in mov_read_stsc()
2776 sc->stsc_data[i].count = avio_rb32(pb); in mov_read_stsc()
2777 sc->stsc_data[i].id = avio_rb32(pb); in mov_read_stsc()
2780 sc->stsc_count = i; in mov_read_stsc()
2781 for (i = sc->stsc_count - 1; i < UINT_MAX; i--) { in mov_read_stsc()
2783 if ((i+1 < sc->stsc_count && sc->stsc_data[i].first >= sc->stsc_data[i+1].first) || in mov_read_stsc()
2784 (i > 0 && sc->stsc_data[i].first <= sc->stsc_data[i-1].first) || in mov_read_stsc()
2785 sc->stsc_data[i].first < first_min || in mov_read_stsc()
2786 sc->stsc_data[i].count < 1 || in mov_read_stsc()
2787 sc->stsc_data[i].id < 1) { in mov_read_stsc()
2788 …try %d is invalid (first=%d count=%d id=%d)\n", i, sc->stsc_data[i].first, sc->stsc_data[i].count,… in mov_read_stsc()
2789 if (i+1 >= sc->stsc_count) { in mov_read_stsc()
2790 if (sc->stsc_data[i].count == 0 && i > 0) { in mov_read_stsc()
2791 sc->stsc_count --; in mov_read_stsc()
2794 sc->stsc_data[i].first = FFMAX(sc->stsc_data[i].first, first_min); in mov_read_stsc()
2795 if (i > 0 && sc->stsc_data[i].first <= sc->stsc_data[i-1].first) in mov_read_stsc()
2796 sc->stsc_data[i].first = FFMIN(sc->stsc_data[i-1].first + 1LL, INT_MAX); in mov_read_stsc()
2797 sc->stsc_data[i].count = FFMAX(sc->stsc_data[i].count, 1); in mov_read_stsc()
2798 sc->stsc_data[i].id = FFMAX(sc->stsc_data[i].id, 1); in mov_read_stsc()
2801 av_assert0(sc->stsc_data[i+1].first >= 2); in mov_read_stsc()
2803 sc->stsc_data[i].first = sc->stsc_data[i+1].first - 1; in mov_read_stsc()
2804 sc->stsc_data[i].count = sc->stsc_data[i+1].count; in mov_read_stsc()
2805 sc->stsc_data[i].id = sc->stsc_data[i+1].id; in mov_read_stsc()
2823 static inline int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index) in mov_get_stsc_samples() argument
2827 if (mov_stsc_index_valid(index, sc->stsc_count)) in mov_get_stsc_samples()
2828 chunk_count = sc->stsc_data[index + 1].first - sc->stsc_data[index].first; in mov_get_stsc_samples()
2831 av_assert0(sc->stsc_data[index].first <= sc->chunk_count); in mov_get_stsc_samples()
2832 chunk_count = sc->chunk_count - (sc->stsc_data[index].first - 1); in mov_get_stsc_samples()
2835 return sc->stsc_data[index].count * (int64_t)chunk_count; in mov_get_stsc_samples()
2841 MOVStreamContext *sc; in mov_read_stps() local
2847 sc = st->priv_data; in mov_read_stps()
2852 if (sc->stps_data) in mov_read_stps()
2854 av_free(sc->stps_data); in mov_read_stps()
2855 sc->stps_count = 0; in mov_read_stps()
2856 sc->stps_data = av_malloc_array(entries, sizeof(*sc->stps_data)); in mov_read_stps()
2857 if (!sc->stps_data) in mov_read_stps()
2861 sc->stps_data[i] = avio_rb32(pb); in mov_read_stps()
2864 sc->stps_count = i; in mov_read_stps()
2878 MOVStreamContext *sc; in mov_read_stss() local
2885 sc = st->priv_data; in mov_read_stss()
2895 sc->keyframe_absent = 1; in mov_read_stss()
2900 if (sc->keyframes) in mov_read_stss()
2904 av_freep(&sc->keyframes); in mov_read_stss()
2905 sc->keyframe_count = 0; in mov_read_stss()
2906 sc->keyframes = av_malloc_array(entries, sizeof(*sc->keyframes)); in mov_read_stss()
2907 if (!sc->keyframes) in mov_read_stss()
2911 sc->keyframes[i] = avio_rb32(pb); in mov_read_stss()
2914 sc->keyframe_count = i; in mov_read_stss()
2927 MOVStreamContext *sc; in mov_read_stsz() local
2936 sc = st->priv_data; in mov_read_stsz()
2943 if (!sc->sample_size) /* do not overwrite value computed in stsd */ in mov_read_stsz()
2944 sc->sample_size = sample_size; in mov_read_stsz()
2945 sc->stsz_sample_size = sample_size; in mov_read_stsz()
2954 av_log(c->fc, AV_LOG_TRACE, "sample_size = %u sample_count = %u\n", sc->sample_size, entries); in mov_read_stsz()
2956 sc->sample_count = entries; in mov_read_stsz()
2969 if (sc->sample_sizes) in mov_read_stsz()
2971 av_free(sc->sample_sizes); in mov_read_stsz()
2972 sc->sample_count = 0; in mov_read_stsz()
2973 sc->sample_sizes = av_malloc_array(entries, sizeof(*sc->sample_sizes)); in mov_read_stsz()
2974 if (!sc->sample_sizes) in mov_read_stsz()
2981 av_freep(&sc->sample_sizes); in mov_read_stsz()
2987 av_freep(&sc->sample_sizes); in mov_read_stsz()
2996 sc->sample_sizes[i] = get_bits_long(&gb, field_size); in mov_read_stsz()
2997 if (sc->sample_sizes[i] < 0) { in mov_read_stsz()
2999 av_log(c->fc, AV_LOG_ERROR, "Invalid sample size %d\n", sc->sample_sizes[i]); in mov_read_stsz()
3002 sc->data_size += sc->sample_sizes[i]; in mov_read_stsz()
3005 sc->sample_count = i; in mov_read_stsz()
3015 MOVStreamContext *sc; in mov_read_stts() local
3025 sc = st->priv_data; in mov_read_stts()
3034 if (sc->stts_data) in mov_read_stts()
3036 av_freep(&sc->stts_data); in mov_read_stts()
3037 sc->stts_count = 0; in mov_read_stts()
3038 if (entries >= INT_MAX / sizeof(*sc->stts_data)) in mov_read_stts()
3045 MOVStts *stts_data = av_fast_realloc(sc->stts_data, &alloc_size, in mov_read_stts()
3046 min_entries * sizeof(*sc->stts_data)); in mov_read_stts()
3048 av_freep(&sc->stts_data); in mov_read_stts()
3049 sc->stts_count = 0; in mov_read_stts()
3052 sc->stts_count = min_entries; in mov_read_stts()
3053 sc->stts_data = stts_data; in mov_read_stts()
3058 sc->stts_data[i].count= sample_count; in mov_read_stts()
3059 sc->stts_data[i].duration= sample_duration; in mov_read_stts()
3072 sc->stts_data[i].duration = 1; in mov_read_stts()
3078 current_dts += sc->stts_data[i].duration * sample_count; in mov_read_stts()
3082 … uint32_t correction = (sc->stts_data[i].duration > drift) ? drift : sc->stts_data[i].duration - 1; in mov_read_stts()
3084 sc->stts_data[i].duration -= correction; in mov_read_stts()
3087 duration+=(int64_t)sc->stts_data[i].duration*(uint64_t)sc->stts_data[i].count; in mov_read_stts()
3088 total_sample_count+=sc->stts_data[i].count; in mov_read_stts()
3091 sc->stts_count = i; in mov_read_stts()
3094 duration <= INT64_MAX - sc->duration_for_fps && in mov_read_stts()
3095 total_sample_count <= INT_MAX - sc->nb_frames_for_fps) { in mov_read_stts()
3096 sc->duration_for_fps += duration; in mov_read_stts()
3097 sc->nb_frames_for_fps += total_sample_count; in mov_read_stts()
3108 sc->track_end = duration; in mov_read_stts()
3115 MOVStreamContext *sc; in mov_read_sdtp() local
3121 sc = st->priv_data; in mov_read_sdtp()
3130 if (sc->sdtp_data) in mov_read_sdtp()
3132 av_freep(&sc->sdtp_data); in mov_read_sdtp()
3133 sc->sdtp_count = 0; in mov_read_sdtp()
3135 sc->sdtp_data = av_malloc(entries); in mov_read_sdtp()
3136 if (!sc->sdtp_data) in mov_read_sdtp()
3140 sc->sdtp_data[i] = avio_r8(pb); in mov_read_sdtp()
3141 sc->sdtp_count = i; in mov_read_sdtp()
3146 static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logctx) in mov_update_dts_shift() argument
3153 sc->dts_shift = FFMAX(sc->dts_shift, -duration); in mov_update_dts_shift()
3160 MOVStreamContext *sc; in mov_read_ctts() local
3166 sc = st->priv_data; in mov_read_ctts()
3176 if (entries >= UINT_MAX / sizeof(*sc->ctts_data)) in mov_read_ctts()
3178 av_freep(&sc->ctts_data); in mov_read_ctts()
3179 … sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, entries * sizeof(*sc->ctts_data)); in mov_read_ctts()
3180 if (!sc->ctts_data) in mov_read_ctts()
3194 add_ctts_entry(&sc->ctts_data, &ctts_count, &sc->ctts_allocated_size, in mov_read_ctts()
3202 av_freep(&sc->ctts_data); in mov_read_ctts()
3203 sc->ctts_count = 0; in mov_read_ctts()
3208 mov_update_dts_shift(sc, duration, c->fc); in mov_read_ctts()
3211 sc->ctts_count = ctts_count; in mov_read_ctts()
3218 av_log(c->fc, AV_LOG_TRACE, "dts shift %d\n", sc->dts_shift); in mov_read_ctts()
3226 MOVStreamContext *sc; in mov_read_sgpd() local
3236 sc = st->priv_data; in mov_read_sgpd()
3253 av_freep(&sc->sgpd_sync); in mov_read_sgpd()
3254 sc->sgpd_sync_count = entry_count; in mov_read_sgpd()
3255 sc->sgpd_sync = av_calloc(entry_count, sizeof(*sc->sgpd_sync)); in mov_read_sgpd()
3256 if (!sc->sgpd_sync) in mov_read_sgpd()
3265 sc->sgpd_sync[i] = nal_unit_type; in mov_read_sgpd()
3282 MOVStreamContext *sc; in mov_read_sbgp() local
3292 sc = st->priv_data; in mov_read_sbgp()
3299 tablep = &sc->rap_group; in mov_read_sbgp()
3300 table_count = &sc->rap_group_count; in mov_read_sbgp()
3302 tablep = &sc->sync_group; in mov_read_sbgp()
3303 table_count = &sc->sync_group_count; in mov_read_sbgp()
3620 static void mov_current_sample_inc(MOVStreamContext *sc) in mov_current_sample_inc() argument
3622 sc->current_sample++; in mov_current_sample_inc()
3623 sc->current_index++; in mov_current_sample_inc()
3624 if (sc->index_ranges && in mov_current_sample_inc()
3625 sc->current_index >= sc->current_index_range->end && in mov_current_sample_inc()
3626 sc->current_index_range->end) { in mov_current_sample_inc()
3627 sc->current_index_range++; in mov_current_sample_inc()
3628 sc->current_index = sc->current_index_range->start; in mov_current_sample_inc()
3632 static void mov_current_sample_dec(MOVStreamContext *sc) in mov_current_sample_dec() argument
3634 sc->current_sample--; in mov_current_sample_dec()
3635 sc->current_index--; in mov_current_sample_dec()
3636 if (sc->index_ranges && in mov_current_sample_dec()
3637 sc->current_index < sc->current_index_range->start && in mov_current_sample_dec()
3638 sc->current_index_range > sc->index_ranges) { in mov_current_sample_dec()
3639 sc->current_index_range--; in mov_current_sample_dec()
3640 sc->current_index = sc->current_index_range->end - 1; in mov_current_sample_dec()
3644 static void mov_current_sample_set(MOVStreamContext *sc, int current_sample) in mov_current_sample_set() argument
3648 sc->current_sample = current_sample; in mov_current_sample_set()
3649 sc->current_index = current_sample; in mov_current_sample_set()
3650 if (!sc->index_ranges) { in mov_current_sample_set()
3654 for (sc->current_index_range = sc->index_ranges; in mov_current_sample_set()
3655 sc->current_index_range->end; in mov_current_sample_set()
3656 sc->current_index_range++) { in mov_current_sample_set()
3657 range_size = sc->current_index_range->end - sc->current_index_range->start; in mov_current_sample_set()
3659 sc->current_index = sc->current_index_range->start + current_sample; in mov_current_sample_set()
3975 static uint32_t get_sgpd_sync_index(const MOVStreamContext *sc, int nal_unit_type) in get_sgpd_sync_index() argument
3977 for (uint32_t i = 0; i < sc->sgpd_sync_count; i++) in get_sgpd_sync_index()
3978 if (sc->sgpd_sync[i] == HEVC_NAL_CRA_NUT) in get_sgpd_sync_index()
3988 MOVStreamContext *sc = st->priv_data; in build_open_gop_key_points() local
3990 if (st->codecpar->codec_id != AV_CODEC_ID_HEVC || !sc->sync_group_count) in build_open_gop_key_points()
3994 sc->sample_offsets_count = 0; in build_open_gop_key_points()
3995 for (uint32_t i = 0; i < sc->ctts_count; i++) { in build_open_gop_key_points()
3996 if (sc->ctts_data[i].count > INT_MAX - sc->sample_offsets_count) in build_open_gop_key_points()
3998 sc->sample_offsets_count += sc->ctts_data[i].count; in build_open_gop_key_points()
4000 av_freep(&sc->sample_offsets); in build_open_gop_key_points()
4001 sc->sample_offsets = av_calloc(sc->sample_offsets_count, sizeof(*sc->sample_offsets)); in build_open_gop_key_points()
4002 if (!sc->sample_offsets) in build_open_gop_key_points()
4005 for (uint32_t i = 0; i < sc->ctts_count; i++) in build_open_gop_key_points()
4006 for (int j = 0; j < sc->ctts_data[i].count; j++) in build_open_gop_key_points()
4007 sc->sample_offsets[k++] = sc->ctts_data[i].duration; in build_open_gop_key_points()
4011 cra_index = get_sgpd_sync_index(sc, HEVC_NAL_CRA_NUT); /* Clean Random Access */ in build_open_gop_key_points()
4016 sc->open_key_samples_count = 0; in build_open_gop_key_points()
4017 for (uint32_t i = 0; i < sc->sync_group_count; i++) in build_open_gop_key_points()
4018 if (sc->sync_group[i].index == cra_index) { in build_open_gop_key_points()
4019 if (sc->sync_group[i].count > INT_MAX - sc->open_key_samples_count) in build_open_gop_key_points()
4021 sc->open_key_samples_count += sc->sync_group[i].count; in build_open_gop_key_points()
4023 av_freep(&sc->open_key_samples); in build_open_gop_key_points()
4024 sc->open_key_samples = av_calloc(sc->open_key_samples_count, sizeof(*sc->open_key_samples)); in build_open_gop_key_points()
4025 if (!sc->open_key_samples) in build_open_gop_key_points()
4028 for (uint32_t i = 0; i < sc->sync_group_count; i++) { in build_open_gop_key_points()
4029 const MOVSbgp *sg = &sc->sync_group[i]; in build_open_gop_key_points()
4032 sc->open_key_samples[k++] = sample_id; in build_open_gop_key_points()
4039 sc->min_sample_duration = UINT_MAX; in build_open_gop_key_points()
4040 for (uint32_t i = 0; i < sc->stts_count; i++) in build_open_gop_key_points()
4041 sc->min_sample_duration = FFMIN(sc->min_sample_duration, sc->stts_data[i].duration); in build_open_gop_key_points()
4048 MOVStreamContext *sc = st->priv_data; in mov_build_index() local
4058 MOVCtts *ctts_data_old = sc->ctts_data; in mov_build_index()
4059 unsigned int ctts_count_old = sc->ctts_count; in mov_build_index()
4065 if (sc->elst_count) { in mov_build_index()
4070 for (i = 0; i < sc->elst_count; i++) { in mov_build_index()
4071 const MOVElst *e = &sc->elst_data[i]; in mov_build_index()
4092 empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale); in mov_build_index()
4097 sc->time_offset = start_time - (uint64_t)empty_duration; in mov_build_index()
4098 sc->min_corrected_pts = start_time; in mov_build_index()
4100 current_dts = -sc->time_offset; in mov_build_index()
4105 sc->start_pad = start_time; in mov_build_index()
4110 sc->stts_count == 1 && sc->stts_data[0].duration == 1)) { in mov_build_index()
4117 int rap_group_present = sc->rap_group_count && sc->rap_group; in mov_build_index()
4118 …int key_off = (sc->keyframe_count && sc->keyframes[0] > 0) || (sc->stps_count && sc->stps_data[0] … in mov_build_index()
4120 current_dts -= sc->dts_shift; in mov_build_index()
4122 if (!sc->sample_count || sti->nb_index_entries) in mov_build_index()
4124 if (sc->sample_count >= UINT_MAX / sizeof(*sti->index_entries) - sti->nb_index_entries) in mov_build_index()
4127 sti->nb_index_entries + sc->sample_count, in mov_build_index()
4132 …sti->index_entries_allocated_size = (sti->nb_index_entries + sc->sample_count) * sizeof(*sti->inde… in mov_build_index()
4136 if (sc->sample_count >= UINT_MAX / sizeof(*sc->ctts_data)) in mov_build_index()
4138 sc->ctts_count = 0; in mov_build_index()
4139 sc->ctts_allocated_size = 0; in mov_build_index()
4140 sc->ctts_data = av_fast_realloc(NULL, &sc->ctts_allocated_size, in mov_build_index()
4141 sc->sample_count * sizeof(*sc->ctts_data)); in mov_build_index()
4142 if (!sc->ctts_data) { in mov_build_index()
4147 memset((uint8_t*)(sc->ctts_data), 0, sc->ctts_allocated_size); in mov_build_index()
4150 sc->ctts_count < sc->sample_count; i++) in mov_build_index()
4152 sc->ctts_count < sc->sample_count; j++) in mov_build_index()
4153 add_ctts_entry(&sc->ctts_data, &sc->ctts_count, in mov_build_index()
4154 &sc->ctts_allocated_size, 1, in mov_build_index()
4159 for (i = 0; i < sc->chunk_count; i++) { in mov_build_index()
4160 int64_t next_offset = i+1 < sc->chunk_count ? sc->chunk_offsets[i+1] : INT64_MAX; in mov_build_index()
4161 current_offset = sc->chunk_offsets[i]; in mov_build_index()
4162 while (mov_stsc_index_valid(stsc_index, sc->stsc_count) && in mov_build_index()
4163 i + 1 == sc->stsc_data[stsc_index + 1].first) in mov_build_index()
4166 … if (next_offset > current_offset && sc->sample_size>0 && sc->sample_size < sc->stsz_sample_size && in mov_build_index()
4167 … sc->stsc_data[stsc_index].count * (int64_t)sc->stsz_sample_size > next_offset - current_offset) { in mov_build_index()
4168 …->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too large), ignoring\n", sc->stsz_sample_size); in mov_build_index()
4169 sc->stsz_sample_size = sc->sample_size; in mov_build_index()
4171 if (sc->stsz_sample_size>0 && sc->stsz_sample_size < sc->sample_size) { in mov_build_index()
4172 …->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too small), ignoring\n", sc->stsz_sample_size); in mov_build_index()
4173 sc->stsz_sample_size = sc->sample_size; in mov_build_index()
4176 for (j = 0; j < sc->stsc_data[stsc_index].count; j++) { in mov_build_index()
4178 if (current_sample >= sc->sample_count) { in mov_build_index()
4183 …if (!sc->keyframe_absent && (!sc->keyframe_count || current_sample+key_off == sc->keyframes[stss_i… in mov_build_index()
4185 if (stss_index + 1 < sc->keyframe_count) in mov_build_index()
4187 } else if (sc->stps_count && current_sample+key_off == sc->stps_data[stps_index]) { in mov_build_index()
4189 if (stps_index + 1 < sc->stps_count) in mov_build_index()
4192 if (rap_group_present && rap_group_index < sc->rap_group_count) { in mov_build_index()
4193 if (sc->rap_group[rap_group_index].index > 0) in mov_build_index()
4195 if (++rap_group_sample == sc->rap_group[rap_group_index].count) { in mov_build_index()
4200 if (sc->keyframe_absent in mov_build_index()
4201 && !sc->stps_count in mov_build_index()
4207 … sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample]; in mov_build_index()
4215 if (sc->pseudo_stream_id == -1 || in mov_build_index()
4216 sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) { in mov_build_index()
4238 current_dts += sc->stts_data[stts_index].duration; in mov_build_index()
4243 … if (stts_index + 1 < sc->stts_count && stts_sample == sc->stts_data[stts_index].count) { in mov_build_index()
4250 st->codecpar->bit_rate = stream_size*8*sc->time_scale/st->duration; in mov_build_index()
4254 if (!sc->chunk_count) in mov_build_index()
4258 for (i = 0; i < sc->stsc_count; i++) { in mov_build_index()
4261 chunk_samples = sc->stsc_data[i].count; in mov_build_index()
4262 if (i != sc->stsc_count - 1 && in mov_build_index()
4263 sc->samples_per_frame && chunk_samples % sc->samples_per_frame) { in mov_build_index()
4268 if (sc->samples_per_frame >= 160) { // gsm in mov_build_index()
4269 count = chunk_samples / sc->samples_per_frame; in mov_build_index()
4270 } else if (sc->samples_per_frame > 1) { in mov_build_index()
4271 unsigned samples = (1024/sc->samples_per_frame)*sc->samples_per_frame; in mov_build_index()
4277 if (mov_stsc_index_valid(i, sc->stsc_count)) in mov_build_index()
4278 chunk_count = sc->stsc_data[i+1].first - sc->stsc_data[i].first; in mov_build_index()
4280 chunk_count = sc->chunk_count - (sc->stsc_data[i].first - 1); in mov_build_index()
4296 for (i = 0; i < sc->chunk_count; i++) { in mov_build_index()
4297 current_offset = sc->chunk_offsets[i]; in mov_build_index()
4298 if (mov_stsc_index_valid(stsc_index, sc->stsc_count) && in mov_build_index()
4299 i + 1 == sc->stsc_data[stsc_index + 1].first) in mov_build_index()
4301 chunk_samples = sc->stsc_data[stsc_index].count; in mov_build_index()
4307 if (sc->samples_per_frame > 1 && !sc->bytes_per_frame) { in mov_build_index()
4310 sc->samples_per_frame); in mov_build_index()
4314 if (sc->samples_per_frame >= 160) { // gsm in mov_build_index()
4315 samples = sc->samples_per_frame; in mov_build_index()
4316 size = sc->bytes_per_frame; in mov_build_index()
4318 if (sc->samples_per_frame > 1) { in mov_build_index()
4319 samples = FFMIN((1024 / sc->samples_per_frame)* in mov_build_index()
4320 sc->samples_per_frame, chunk_samples); in mov_build_index()
4321 size = (samples / sc->samples_per_frame) * sc->bytes_per_frame; in mov_build_index()
4324 size = samples * sc->sample_size; in mov_build_index()
4360 st->start_time = sti->index_entries[0].timestamp + sc->dts_shift; in mov_build_index()
4361 if (sc->ctts_data) { in mov_build_index()
4362 st->start_time += sc->ctts_data[0].duration; in mov_build_index()
4470 static void fix_timescale(MOVContext *c, MOVStreamContext *sc) in fix_timescale() argument
4472 if (sc->time_scale <= 0) { in fix_timescale()
4473 av_log(c->fc, AV_LOG_WARNING, "stream %d, timescale not set\n", sc->ffindex); in fix_timescale()
4474 sc->time_scale = c->time_scale; in fix_timescale()
4475 if (sc->time_scale <= 0) in fix_timescale()
4476 sc->time_scale = 1; in fix_timescale()
4483 MOVStreamContext *sc; in mov_read_trak() local
4493 sc = av_mallocz(sizeof(MOVStreamContext)); in mov_read_trak()
4494 if (!sc) return AVERROR(ENOMEM); in mov_read_trak()
4496 st->priv_data = sc; in mov_read_trak()
4498 sc->ffindex = st->index; in mov_read_trak()
4508 if (!sc->chunk_count && !sc->stts_count && sc->stsc_count) { in mov_read_trak()
4509 sc->stsc_count = 0; in mov_read_trak()
4510 av_freep(&sc->stsc_data); in mov_read_trak()
4514 if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count || in mov_read_trak()
4515 (!sc->sample_size && !sc->sample_count))) || in mov_read_trak()
4516 (!sc->chunk_count && sc->sample_count)) { in mov_read_trak()
4521 if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) { in mov_read_trak()
4527 fix_timescale(c, sc); in mov_read_trak()
4529 avpriv_set_pts_info(st, 64, 1, sc->time_scale); in mov_read_trak()
4533 if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { in mov_read_trak()
4534 MOVDref *dref = &sc->drefs[sc->dref_id - 1]; in mov_read_trak()
4536 if (mov_open_dref(c, &sc->pb, c->fc->url, dref) < 0) in mov_read_trak()
4552 sc->pb = c->fc->pb; in mov_read_trak()
4553 sc->pb_is_copied = 1; in mov_read_trak()
4558 sc->height && sc->width && in mov_read_trak()
4559 (st->codecpar->width != sc->width || st->codecpar->height != sc->height)) { in mov_read_trak()
4560 st->sample_aspect_ratio = av_d2q(((double)st->codecpar->height * sc->width) / in mov_read_trak()
4561 ((double)st->codecpar->width * sc->height), INT_MAX); in mov_read_trak()
4565 if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) in mov_read_trak()
4567 sc->time_scale, sc->stts_data[0].duration, INT_MAX); in mov_read_trak()
4596 && sc->stts_count > 3 in mov_read_trak()
4597 && sc->stts_count*10 > st->nb_frames in mov_read_trak()
4598 && sc->time_scale == st->codecpar->sample_rate) { in mov_read_trak()
4602 av_freep(&sc->chunk_offsets); in mov_read_trak()
4603 av_freep(&sc->sample_sizes); in mov_read_trak()
4604 av_freep(&sc->keyframes); in mov_read_trak()
4605 av_freep(&sc->stts_data); in mov_read_trak()
4606 av_freep(&sc->stps_data); in mov_read_trak()
4607 av_freep(&sc->elst_data); in mov_read_trak()
4608 av_freep(&sc->rap_group); in mov_read_trak()
4609 av_freep(&sc->sync_group); in mov_read_trak()
4610 av_freep(&sc->sgpd_sync); in mov_read_trak()
4684 MOVStreamContext *sc; in mov_read_custom() local
4689 sc = st->priv_data; in mov_read_custom()
4738 sc->start_pad = priming; in mov_read_custom()
4792 MOVStreamContext *sc; in mov_read_tkhd() local
4799 sc = st->priv_data; in mov_read_tkhd()
4842 sc->width = width >> 16; in mov_read_tkhd()
4843 sc->height = height >> 16; in mov_read_tkhd()
4859 av_freep(&sc->display_matrix); in mov_read_tkhd()
4860 sc->display_matrix = av_malloc(sizeof(int32_t) * 9); in mov_read_tkhd()
4861 if (!sc->display_matrix) in mov_read_tkhd()
4866 sc->display_matrix[i * 3 + j] = res_display_matrix[i][j]; in mov_read_tkhd()
4871 if (width && height && sc->display_matrix) { in mov_read_tkhd()
4875 disp_transform[i] = hypot(sc->display_matrix[0 + i], in mov_read_tkhd()
4876 sc->display_matrix[3 + i]); in mov_read_tkhd()
4985 MOVStreamContext *sc; in mov_read_tfdt() local
5000 sc = st->priv_data; in mov_read_tfdt()
5001 if (sc->pseudo_stream_id + 1 != frag->stsd_id && sc->pseudo_stream_id != -1) in mov_read_tfdt()
5014 sc->track_end = base_media_decode_time; in mov_read_tfdt()
5024 MOVStreamContext *sc; in mov_read_trun() local
5054 sc = st->priv_data; in mov_read_trun()
5055 if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1) in mov_read_trun()
5080 if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data)) in mov_read_trun()
5088 dts = frag_stream_info->next_trun_dts - sc->time_offset; in mov_read_trun()
5113 dts = frag_stream_info->tfdt_dts - sc->time_offset; in mov_read_trun()
5119 dts = frag_stream_info->sidx_pts - sc->time_offset; in mov_read_trun()
5123 dts = sc->track_end - sc->time_offset; in mov_read_trun()
5129 dts = sc->track_end - sc->time_offset; in mov_read_trun()
5153 requested_size = (sti->nb_index_entries + entries) * sizeof(*sc->ctts_data); in mov_read_trun()
5154 old_ctts_allocated_size = sc->ctts_allocated_size; in mov_read_trun()
5155 ctts_data = av_fast_realloc(sc->ctts_data, &sc->ctts_allocated_size, in mov_read_trun()
5159 sc->ctts_data = ctts_data; in mov_read_trun()
5164 memset((uint8_t*)(sc->ctts_data) + old_ctts_allocated_size, 0, in mov_read_trun()
5165 sc->ctts_allocated_size - old_ctts_allocated_size); in mov_read_trun()
5173 memmove(sc->ctts_data + index_entry_pos + entries, in mov_read_trun()
5174 sc->ctts_data + index_entry_pos, in mov_read_trun()
5175 sizeof(*sc->ctts_data) * (sc->ctts_count - index_entry_pos)); in mov_read_trun()
5176 if (index_entry_pos < sc->current_sample) { in mov_read_trun()
5177 sc->current_sample += entries; in mov_read_trun()
5182 sc->ctts_count = sti->nb_index_entries; in mov_read_trun()
5204 mov_update_dts_shift(sc, ctts_duration, c->fc); in mov_read_trun()
5206 dts = pts - sc->dts_shift; in mov_read_trun()
5210 dts -= sc->time_offset; in mov_read_trun()
5218 sc->dts_shift, ctts_duration, in mov_read_trun()
5219 sc->time_offset, flags & MOV_TRUN_SAMPLE_CTS); in mov_read_trun()
5244 sc->ctts_data[index_entry_pos].count = 1; in mov_read_trun()
5245 sc->ctts_data[index_entry_pos].duration = ctts_duration; in mov_read_trun()
5258 sc->data_size += sample_size; in mov_read_trun()
5260 if (sample_duration <= INT64_MAX - sc->duration_for_fps && in mov_read_trun()
5261 1 <= INT_MAX - sc->nb_frames_for_fps in mov_read_trun()
5263 sc->duration_for_fps += sample_duration; in mov_read_trun()
5264 sc->nb_frames_for_fps ++; in mov_read_trun()
5268 frag_stream_info->next_trun_dts = dts + sc->time_offset; in mov_read_trun()
5277 memmove(sc->ctts_data + index_entry_pos, in mov_read_trun()
5278 sc->ctts_data + index_entry_pos + gap, in mov_read_trun()
5279 sizeof(*sc->ctts_data) * in mov_read_trun()
5280 (sc->ctts_count - (index_entry_pos + gap))); in mov_read_trun()
5283 sc->ctts_count -= gap; in mov_read_trun()
5284 if (index_entry_pos < sc->current_sample) { in mov_read_trun()
5285 sc->current_sample -= gap; in mov_read_trun()
5315 sc->track_end = dts + sc->time_offset; in mov_read_trun()
5316 if (st->duration < sc->track_end) in mov_read_trun()
5317 st->duration = sc->track_end; in mov_read_trun()
5331 MOVStreamContext *sc, *ref_sc = NULL; in mov_read_sidx() local
5354 sc = st->priv_data; in mov_read_sidx()
5406 st->duration = sc->track_end = pts; in mov_read_sidx()
5408 sc->has_sidx = 1; in mov_read_sidx()
5444 sc = st->priv_data; in mov_read_sidx()
5445 if (!sc->has_sidx) { in mov_read_sidx()
5446 … st->duration = sc->track_end = av_rescale(ref_st->duration, sc->time_scale, ref_sc->time_scale); in mov_read_sidx()
5534 MOVStreamContext *sc; in mov_read_elst() local
5540 sc = c->fc->streams[c->fc->nb_streams-1]->priv_data; in mov_read_elst()
5563 if (sc->elst_data) in mov_read_elst()
5565 av_free(sc->elst_data); in mov_read_elst()
5566 sc->elst_count = 0; in mov_read_elst()
5567 sc->elst_data = av_malloc_array(edit_count, sizeof(*sc->elst_data)); in mov_read_elst()
5568 if (!sc->elst_data) in mov_read_elst()
5573 MOVElst *e = &sc->elst_data[i]; in mov_read_elst()
5596 sc->elst_count = i; in mov_read_elst()
5603 MOVStreamContext *sc; in mov_read_tmcd() local
5607 sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; in mov_read_tmcd()
5608 sc->timecode_track = avio_rb32(pb); in mov_read_tmcd()
5658 MOVStreamContext *sc; in mov_read_smdm() local
5664 sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; in mov_read_smdm()
5676 if (sc->mastering) in mov_read_smdm()
5681 sc->mastering = av_mastering_display_metadata_alloc(); in mov_read_smdm()
5682 if (!sc->mastering) in mov_read_smdm()
5686 sc->mastering->display_primaries[i][0] = av_make_q(avio_rb16(pb), 1 << 16); in mov_read_smdm()
5687 sc->mastering->display_primaries[i][1] = av_make_q(avio_rb16(pb), 1 << 16); in mov_read_smdm()
5689 sc->mastering->white_point[0] = av_make_q(avio_rb16(pb), 1 << 16); in mov_read_smdm()
5690 sc->mastering->white_point[1] = av_make_q(avio_rb16(pb), 1 << 16); in mov_read_smdm()
5692 sc->mastering->max_luminance = av_make_q(avio_rb32(pb), 1 << 8); in mov_read_smdm()
5693 sc->mastering->min_luminance = av_make_q(avio_rb32(pb), 1 << 14); in mov_read_smdm()
5695 sc->mastering->has_primaries = 1; in mov_read_smdm()
5696 sc->mastering->has_luminance = 1; in mov_read_smdm()
5703 MOVStreamContext *sc; in mov_read_mdcv() local
5712 sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; in mov_read_mdcv()
5714 if (atom.size < 24 || sc->mastering) { in mov_read_mdcv()
5719 sc->mastering = av_mastering_display_metadata_alloc(); in mov_read_mdcv()
5720 if (!sc->mastering) in mov_read_mdcv()
5725 sc->mastering->display_primaries[j][0] = av_make_q(avio_rb16(pb), chroma_den); in mov_read_mdcv()
5726 sc->mastering->display_primaries[j][1] = av_make_q(avio_rb16(pb), chroma_den); in mov_read_mdcv()
5728 sc->mastering->white_point[0] = av_make_q(avio_rb16(pb), chroma_den); in mov_read_mdcv()
5729 sc->mastering->white_point[1] = av_make_q(avio_rb16(pb), chroma_den); in mov_read_mdcv()
5731 sc->mastering->max_luminance = av_make_q(avio_rb32(pb), luma_den); in mov_read_mdcv()
5732 sc->mastering->min_luminance = av_make_q(avio_rb32(pb), luma_den); in mov_read_mdcv()
5734 sc->mastering->has_luminance = 1; in mov_read_mdcv()
5735 sc->mastering->has_primaries = 1; in mov_read_mdcv()
5742 MOVStreamContext *sc; in mov_read_coll() local
5748 sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; in mov_read_coll()
5762 if (sc->coll){ in mov_read_coll()
5767 sc->coll = av_content_light_metadata_alloc(&sc->coll_size); in mov_read_coll()
5768 if (!sc->coll) in mov_read_coll()
5771 sc->coll->MaxCLL = avio_rb16(pb); in mov_read_coll()
5772 sc->coll->MaxFALL = avio_rb16(pb); in mov_read_coll()
5779 MOVStreamContext *sc; in mov_read_clli() local
5784 sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data; in mov_read_clli()
5791 if (sc->coll){ in mov_read_clli()
5796 sc->coll = av_content_light_metadata_alloc(&sc->coll_size); in mov_read_clli()
5797 if (!sc->coll) in mov_read_clli()
5800 sc->coll->MaxCLL = avio_rb16(pb); in mov_read_clli()
5801 sc->coll->MaxFALL = avio_rb16(pb); in mov_read_clli()
5809 MOVStreamContext *sc; in mov_read_st3d() local
5817 sc = st->priv_data; in mov_read_st3d()
5824 if (sc->stereo3d) in mov_read_st3d()
5845 sc->stereo3d = av_stereo3d_alloc(); in mov_read_st3d()
5846 if (!sc->stereo3d) in mov_read_st3d()
5849 sc->stereo3d->type = type; in mov_read_st3d()
5856 MOVStreamContext *sc; in mov_read_sv3d() local
5867 sc = st->priv_data; in mov_read_sv3d()
5970 sc->spherical = av_spherical_alloc(&sc->spherical_size); in mov_read_sv3d()
5971 if (!sc->spherical) in mov_read_sv3d()
5974 sc->spherical->projection = projection; in mov_read_sv3d()
5976 sc->spherical->yaw = yaw; in mov_read_sv3d()
5977 sc->spherical->pitch = pitch; in mov_read_sv3d()
5978 sc->spherical->roll = roll; in mov_read_sv3d()
5980 sc->spherical->padding = padding; in mov_read_sv3d()
5982 sc->spherical->bound_left = l; in mov_read_sv3d()
5983 sc->spherical->bound_top = t; in mov_read_sv3d()
5984 sc->spherical->bound_right = r; in mov_read_sv3d()
5985 sc->spherical->bound_bottom = b; in mov_read_sv3d()
5990 static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len) in mov_parse_uuid_spherical() argument
6005 if (!sc->spherical && in mov_parse_uuid_spherical()
6013 sc->spherical = av_spherical_alloc(&sc->spherical_size); in mov_parse_uuid_spherical()
6014 if (!sc->spherical) in mov_parse_uuid_spherical()
6017 sc->spherical->projection = AV_SPHERICAL_EQUIRECTANGULAR; in mov_parse_uuid_spherical()
6019 if (av_stristr(buffer, "<GSpherical:StereoMode>") && !sc->stereo3d) { in mov_parse_uuid_spherical()
6029 sc->stereo3d = av_stereo3d_alloc(); in mov_parse_uuid_spherical()
6030 if (!sc->stereo3d) in mov_parse_uuid_spherical()
6033 sc->stereo3d->type = mode; in mov_parse_uuid_spherical()
6039 sc->spherical->yaw = strtol(val, NULL, 10) * (1 << 16); in mov_parse_uuid_spherical()
6042 sc->spherical->pitch = strtol(val, NULL, 10) * (1 << 16); in mov_parse_uuid_spherical()
6045 sc->spherical->roll = strtol(val, NULL, 10) * (1 << 16); in mov_parse_uuid_spherical()
6056 MOVStreamContext *sc; in mov_read_uuid() local
6078 sc = st->priv_data; in mov_read_uuid()
6148 ret = mov_parse_uuid_spherical(sc, pb, len); in mov_read_uuid()
6151 if (!sc->spherical) in mov_read_uuid()
6183 MOVStreamContext *sc; in mov_read_frma() local
6190 sc = st->priv_data; in mov_read_frma()
6192 switch (sc->format) in mov_read_frma()
6206 sc->format = format; in mov_read_frma()
6210 if (format != sc->format) { in mov_read_frma()
6213 (char*)&format, (char*)&sc->format); in mov_read_frma()
6227 …urrent_encryption_info(MOVContext *c, MOVEncryptionIndex **encryption_index, MOVStreamContext **sc) in get_current_encryption_info() argument
6243 *sc = st->priv_data; in get_current_encryption_info()
6247 if (!(*sc)->cenc.default_encrypted_sample) in get_current_encryption_info()
6261 *sc = st->priv_data; in get_current_encryption_info()
6263 if (!(*sc)->cenc.encryption_index) { in get_current_encryption_info()
6265 if (!(*sc)->cenc.default_encrypted_sample) in get_current_encryption_info()
6267 (*sc)->cenc.encryption_index = av_mallocz(sizeof(*frag_stream_info->encryption_index)); in get_current_encryption_info()
6268 if (!(*sc)->cenc.encryption_index) in get_current_encryption_info()
6272 *encryption_index = (*sc)->cenc.encryption_index; in get_current_encryption_info()
6277 static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AV… in mov_read_sample_encryption_info() argument
6283 if (!sc->cenc.default_encrypted_sample) { in mov_read_sample_encryption_info()
6288 *sample = av_encryption_info_clone(sc->cenc.default_encrypted_sample); in mov_read_sample_encryption_info()
6292 if (sc->cenc.per_sample_iv_size != 0) { in mov_read_sample_encryption_info()
6293 if ((ret = ffio_read_size(pb, (*sample)->iv, sc->cenc.per_sample_iv_size)) < 0) { in mov_read_sample_encryption_info()
6332 MOVStreamContext *sc; in mov_read_senc() local
6336 ret = get_current_encryption_info(c, &encryption_index, &sc); in mov_read_senc()
6361 c, pb, sc, &encryption_index->encrypted_samples[i], use_subsamples); in mov_read_senc()
6384 static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryp… in mov_parse_auxiliary_info() argument
6424 …ret = mov_read_sample_encryption_info(c, pb, sc, sample, sample_info_size > sc->cenc.per_sample_iv… in mov_parse_auxiliary_info()
6481 MOVStreamContext *sc; in mov_read_saiz() local
6485 ret = get_current_encryption_info(c, &encryption_index, &sc); in mov_read_saiz()
6504 if (sc->cenc.default_encrypted_sample) { in mov_read_saiz()
6505 if (aux_info_type != sc->cenc.default_encrypted_sample->scheme) { in mov_read_saiz()
6526 } else if (!sc->cenc.default_encrypted_sample) { in mov_read_saiz()
6544 return mov_parse_auxiliary_info(c, sc, pb, encryption_index); in mov_read_saiz()
6554 MOVStreamContext *sc; in mov_read_saio() local
6559 ret = get_current_encryption_info(c, &encryption_index, &sc); in mov_read_saio()
6578 if (sc->cenc.default_encrypted_sample) { in mov_read_saio()
6579 if (aux_info_type != sc->cenc.default_encrypted_sample->scheme) { in mov_read_saio()
6600 } else if (!sc->cenc.default_encrypted_sample) { in mov_read_saio()
6639 return mov_parse_auxiliary_info(c, sc, pb, encryption_index); in mov_read_saio()
6853 MOVStreamContext *sc; in mov_read_schm() local
6858 sc = st->priv_data; in mov_read_schm()
6860 if (sc->pseudo_stream_id != 0) { in mov_read_schm()
6870 if (!sc->cenc.default_encrypted_sample) { in mov_read_schm()
6871 sc->cenc.default_encrypted_sample = av_encryption_info_alloc(0, 16, 16); in mov_read_schm()
6872 if (!sc->cenc.default_encrypted_sample) { in mov_read_schm()
6877 sc->cenc.default_encrypted_sample->scheme = avio_rb32(pb); in mov_read_schm()
6884 MOVStreamContext *sc; in mov_read_tenc() local
6890 sc = st->priv_data; in mov_read_tenc()
6892 if (sc->pseudo_stream_id != 0) { in mov_read_tenc()
6897 if (!sc->cenc.default_encrypted_sample) { in mov_read_tenc()
6898 sc->cenc.default_encrypted_sample = av_encryption_info_alloc(0, 16, 16); in mov_read_tenc()
6899 if (!sc->cenc.default_encrypted_sample) { in mov_read_tenc()
6914 sc->cenc.default_encrypted_sample->crypt_byte_block = pattern >> 4; in mov_read_tenc()
6915 sc->cenc.default_encrypted_sample->skip_byte_block = pattern & 0xf; in mov_read_tenc()
6919 if (is_protected && !sc->cenc.encryption_index) { in mov_read_tenc()
6921 sc->cenc.encryption_index = av_mallocz(sizeof(MOVEncryptionIndex)); in mov_read_tenc()
6922 if (!sc->cenc.encryption_index) in mov_read_tenc()
6925 sc->cenc.per_sample_iv_size = avio_r8(pb); in mov_read_tenc()
6926 if (sc->cenc.per_sample_iv_size != 0 && sc->cenc.per_sample_iv_size != 8 && in mov_read_tenc()
6927 sc->cenc.per_sample_iv_size != 16) { in mov_read_tenc()
6931 if (avio_read(pb, sc->cenc.default_encrypted_sample->key_id, 16) != 16) { in mov_read_tenc()
6936 if (is_protected && !sc->cenc.per_sample_iv_size) { in mov_read_tenc()
6943 if (avio_read(pb, sc->cenc.default_encrypted_sample->iv, iv_size) != iv_size) { in mov_read_tenc()
6992 static int cenc_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8… in cenc_scheme_decrypt() argument
6997 if (!sc->cenc.aes_ctr) { in cenc_scheme_decrypt()
6999 sc->cenc.aes_ctr = av_aes_ctr_alloc(); in cenc_scheme_decrypt()
7000 if (!sc->cenc.aes_ctr) { in cenc_scheme_decrypt()
7004 ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key); in cenc_scheme_decrypt()
7010 av_aes_ctr_set_full_iv(sc->cenc.aes_ctr, sample->iv); in cenc_scheme_decrypt()
7014 av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size); in cenc_scheme_decrypt()
7031 av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, bytes_of_protected_data); in cenc_scheme_decrypt()
7045 static int cbc1_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8… in cbc1_scheme_decrypt() argument
7051 if (!sc->cenc.aes_ctx) { in cbc1_scheme_decrypt()
7053 sc->cenc.aes_ctx = av_aes_alloc(); in cbc1_scheme_decrypt()
7054 if (!sc->cenc.aes_ctx) { in cbc1_scheme_decrypt()
7058 ret = av_aes_init(sc->cenc.aes_ctx, c->decryption_key, 16 * 8, 1); in cbc1_scheme_decrypt()
7069 av_aes_crypt(sc->cenc.aes_ctx, input, input, size/16, iv, 1); in cbc1_scheme_decrypt()
7091 av_aes_crypt(sc->cenc.aes_ctx, input, input, num_of_encrypted_blocks, iv, 1); in cbc1_scheme_decrypt()
7105 static int cens_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8… in cens_scheme_decrypt() argument
7110 if (!sc->cenc.aes_ctr) { in cens_scheme_decrypt()
7112 sc->cenc.aes_ctr = av_aes_ctr_alloc(); in cens_scheme_decrypt()
7113 if (!sc->cenc.aes_ctr) { in cens_scheme_decrypt()
7117 ret = av_aes_ctr_init(sc->cenc.aes_ctr, c->decryption_key); in cens_scheme_decrypt()
7123 av_aes_ctr_set_full_iv(sc->cenc.aes_ctr, sample->iv); in cens_scheme_decrypt()
7128 av_aes_ctr_crypt(sc->cenc.aes_ctr, input, input, size); in cens_scheme_decrypt()
7152 av_aes_ctr_crypt(sc->cenc.aes_ctr, data, data, 16*sample->crypt_byte_block); in cens_scheme_decrypt()
7170 static int cbcs_scheme_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8… in cbcs_scheme_decrypt() argument
7176 if (!sc->cenc.aes_ctx) { in cbcs_scheme_decrypt()
7178 sc->cenc.aes_ctx = av_aes_alloc(); in cbcs_scheme_decrypt()
7179 if (!sc->cenc.aes_ctx) { in cbcs_scheme_decrypt()
7183 ret = av_aes_init(sc->cenc.aes_ctx, c->decryption_key, 16 * 8, 1); in cbcs_scheme_decrypt()
7193 av_aes_crypt(sc->cenc.aes_ctx, input, input, size/16, iv, 1); in cbcs_scheme_decrypt()
7218 av_aes_crypt(sc->cenc.aes_ctx, data, data, sample->crypt_byte_block, iv, 1); in cbcs_scheme_decrypt()
7236 static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *inp… in cenc_decrypt() argument
7239 return cenc_scheme_decrypt(c, sc, sample, input, size); in cenc_decrypt()
7241 return cbc1_scheme_decrypt(c, sc, sample, input, size); in cenc_decrypt()
7243 return cens_scheme_decrypt(c, sc, sample, input, size); in cenc_decrypt()
7245 return cbcs_scheme_decrypt(c, sc, sample, input, size); in cenc_decrypt()
7252 static int cenc_filter(MOVContext *mov, AVStream* st, MOVStreamContext *sc, AVPacket *pkt, int curr… in cenc_filter() argument
7267 sc->cenc.frag_index_entry_base = frag_stream_info->index_entry; in cenc_filter()
7268 …encrypted_index = current_index - (frag_stream_info->index_entry - sc->cenc.frag_index_entry_base); in cenc_filter()
7271 encryption_index = sc->cenc.encryption_index; in cenc_filter()
7275 encryption_index = sc->cenc.encryption_index; in cenc_filter()
7292 encrypted_sample = sc->cenc.default_encrypted_sample; in cenc_filter()
7302 return cenc_decrypt(mov, sc, encrypted_sample, pkt->data, pkt->size); in cenc_filter()
7645 MOVStreamContext *sc; in mov_read_iloc() local
7663 sc = av_mallocz(sizeof(MOVStreamContext)); in mov_read_iloc()
7664 if (!sc) in mov_read_iloc()
7667 st->priv_data = sc; in mov_read_iloc()
7670 sc->ffindex = st->index; in mov_read_iloc()
7675 sc->time_scale = 1; in mov_read_iloc()
7676 sc = st->priv_data; in mov_read_iloc()
7677 sc->pb = c->fc->pb; in mov_read_iloc()
7678 sc->pb_is_copied = 1; in mov_read_iloc()
7696 sc->stsc_count = 1; in mov_read_iloc()
7697 sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data)); in mov_read_iloc()
7698 if (!sc->stsc_data) in mov_read_iloc()
7700 sc->stsc_data[0].first = 1; in mov_read_iloc()
7701 sc->stsc_data[0].count = 1; in mov_read_iloc()
7702 sc->stsc_data[0].id = 1; in mov_read_iloc()
7703 sc->chunk_count = 1; in mov_read_iloc()
7704 sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets)); in mov_read_iloc()
7705 if (!sc->chunk_offsets) in mov_read_iloc()
7707 sc->sample_count = 1; in mov_read_iloc()
7708 sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes)); in mov_read_iloc()
7709 if (!sc->sample_sizes) in mov_read_iloc()
7711 sc->stts_count = 1; in mov_read_iloc()
7712 sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data)); in mov_read_iloc()
7713 if (!sc->stts_data) in mov_read_iloc()
7715 sc->stts_data[0].count = 1; in mov_read_iloc()
7717 sc->stts_data[0].duration = 0; in mov_read_iloc()
7739 sc->sample_sizes[0] = extent_length; in mov_read_iloc()
7740 sc->chunk_offsets[0] = base_offset + extent_offset; in mov_read_iloc()
8114 MOVStreamContext *sc; in mov_read_chapters() local
8134 sc = st->priv_data; in mov_read_chapters()
8135 cur_pos = avio_tell(sc->pb); in mov_read_chapters()
8142 if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { in mov_read_chapters()
8147 if (ff_add_attached_pic(s, st, sc->pb, NULL, sample->size) < 0) in mov_read_chapters()
8166 if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) { in mov_read_chapters()
8172 len = avio_rb16(sc->pb); in mov_read_chapters()
8185 ch = avio_rb16(sc->pb); in mov_read_chapters()
8187 avio_get_str16be(sc->pb, len, title, title_len); in mov_read_chapters()
8189 avio_get_str16le(sc->pb, len, title, title_len); in mov_read_chapters()
8195 avio_get_str(sc->pb, INT_MAX, title + 2, len - 1); in mov_read_chapters()
8204 avio_seek(sc->pb, cur_pos, SEEK_SET); in mov_read_chapters()
8224 MOVStreamContext *sc = st->priv_data; in mov_read_rtmd_track() local
8227 int64_t cur_pos = avio_tell(sc->pb); in mov_read_rtmd_track()
8233 avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET); in mov_read_rtmd_track()
8244 avio_seek(sc->pb, cur_pos, SEEK_SET); in mov_read_rtmd_track()
8250 MOVStreamContext *sc = st->priv_data; in mov_read_timecode_track() local
8253 int64_t cur_pos = avio_tell(sc->pb); in mov_read_timecode_track()
8256 int tmcd_nb_frames = sc->tmcd_nb_frames; in mov_read_timecode_track()
8265 avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET); in mov_read_timecode_track()
8268 if (sc->tmcd_flags & 0x0001) flags |= AV_TIMECODE_FLAG_DROPFRAME; in mov_read_timecode_track()
8269 if (sc->tmcd_flags & 0x0002) flags |= AV_TIMECODE_FLAG_24HOURSMAX; in mov_read_timecode_track()
8270 if (sc->tmcd_flags & 0x0004) flags |= AV_TIMECODE_FLAG_ALLOWNEGATIVE; in mov_read_timecode_track()
8291 avio_seek(sc->pb, cur_pos, SEEK_SET); in mov_read_timecode_track()
8314 MOVStreamContext *sc = st->priv_data; in mov_read_close() local
8316 if (!sc) in mov_read_close()
8319 av_freep(&sc->ctts_data); in mov_read_close()
8320 for (j = 0; j < sc->drefs_count; j++) { in mov_read_close()
8321 av_freep(&sc->drefs[j].path); in mov_read_close()
8322 av_freep(&sc->drefs[j].dir); in mov_read_close()
8324 av_freep(&sc->drefs); in mov_read_close()
8326 sc->drefs_count = 0; in mov_read_close()
8328 if (!sc->pb_is_copied) in mov_read_close()
8329 ff_format_io_close(s, &sc->pb); in mov_read_close()
8331 sc->pb = NULL; in mov_read_close()
8332 av_freep(&sc->chunk_offsets); in mov_read_close()
8333 av_freep(&sc->stsc_data); in mov_read_close()
8334 av_freep(&sc->sample_sizes); in mov_read_close()
8335 av_freep(&sc->keyframes); in mov_read_close()
8336 av_freep(&sc->stts_data); in mov_read_close()
8337 av_freep(&sc->sdtp_data); in mov_read_close()
8338 av_freep(&sc->stps_data); in mov_read_close()
8339 av_freep(&sc->elst_data); in mov_read_close()
8340 av_freep(&sc->rap_group); in mov_read_close()
8341 av_freep(&sc->sync_group); in mov_read_close()
8342 av_freep(&sc->sgpd_sync); in mov_read_close()
8343 av_freep(&sc->sample_offsets); in mov_read_close()
8344 av_freep(&sc->open_key_samples); in mov_read_close()
8345 av_freep(&sc->display_matrix); in mov_read_close()
8346 av_freep(&sc->index_ranges); in mov_read_close()
8348 if (sc->extradata) in mov_read_close()
8349 for (j = 0; j < sc->stsd_count; j++) in mov_read_close()
8350 av_free(sc->extradata[j]); in mov_read_close()
8351 av_freep(&sc->extradata); in mov_read_close()
8352 av_freep(&sc->extradata_size); in mov_read_close()
8354 mov_free_encryption_index(&sc->cenc.encryption_index); in mov_read_close()
8355 av_encryption_info_free(sc->cenc.default_encrypted_sample); in mov_read_close()
8356 av_aes_ctr_free(sc->cenc.aes_ctr); in mov_read_close()
8358 av_freep(&sc->stereo3d); in mov_read_close()
8359 av_freep(&sc->spherical); in mov_read_close()
8360 av_freep(&sc->mastering); in mov_read_close()
8361 av_freep(&sc->coll); in mov_read_close()
8399 MOVStreamContext *sc = st->priv_data; in tmcd_is_referenced() local
8402 sc->timecode_track == tmcd_id) in tmcd_is_referenced()
8579 MOVStreamContext *sc = st->priv_data; in mov_read_header() local
8580 if (sc->timecode_track > 0) { in mov_read_header()
8585 if (s->streams[j]->id == sc->timecode_track) in mov_read_header()
8600 MOVStreamContext *sc = st->priv_data; in mov_read_header() local
8601 fix_timescale(mov, sc); in mov_read_header()
8604 sti->skip_samples = sc->start_pad; in mov_read_header()
8606 …if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && sc->nb_frames_for_fps > 0 && sc->duration_fo… in mov_read_header()
8608 sc->time_scale*(int64_t)sc->nb_frames_for_fps, sc->duration_for_fps, INT_MAX); in mov_read_header()
8611 st->codecpar->width = sc->width; in mov_read_header()
8612 st->codecpar->height = sc->height; in mov_read_header()
8630 MOVStreamContext *sc = st->priv_data; in mov_read_header() local
8633 … st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) sc->time_scale) * 8, st->duration); in mov_read_header()
8636 sc->data_size, sc->time_scale); in mov_read_header()
8648 MOVStreamContext *sc = st->priv_data; in mov_read_header() local
8649 if (sc->duration_for_fps > 0) { in mov_read_header()
8651 …st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) sc->time_scale) * 8, sc->duration_fo… in mov_read_header()
8654 sc->data_size, sc->time_scale); in mov_read_header()
8673 MOVStreamContext *sc = st->priv_data; in mov_read_header() local
8682 if (sc->display_matrix) { in mov_read_header()
8683 … err = av_stream_add_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, (uint8_t*)sc->display_matrix, in mov_read_header()
8688 sc->display_matrix = NULL; in mov_read_header()
8690 if (sc->stereo3d) { in mov_read_header()
8692 (uint8_t *)sc->stereo3d, in mov_read_header()
8693 sizeof(*sc->stereo3d)); in mov_read_header()
8697 sc->stereo3d = NULL; in mov_read_header()
8699 if (sc->spherical) { in mov_read_header()
8701 (uint8_t *)sc->spherical, in mov_read_header()
8702 sc->spherical_size); in mov_read_header()
8706 sc->spherical = NULL; in mov_read_header()
8708 if (sc->mastering) { in mov_read_header()
8710 (uint8_t *)sc->mastering, in mov_read_header()
8711 sizeof(*sc->mastering)); in mov_read_header()
8715 sc->mastering = NULL; in mov_read_header()
8717 if (sc->coll) { in mov_read_header()
8719 (uint8_t *)sc->coll, in mov_read_header()
8720 sc->coll_size); in mov_read_header()
8724 sc->coll = NULL; in mov_read_header()
8809 static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt) in mov_change_extradata() argument
8815 sc->last_stsd_index = sc->stsc_data[sc->stsc_index].id - 1; in mov_change_extradata()
8818 extradata_size = sc->extradata_size[sc->last_stsd_index]; in mov_change_extradata()
8819 extradata = sc->extradata[sc->last_stsd_index]; in mov_change_extradata()
8856 MOVStreamContext *sc; in mov_read_packet() local
8871 sc = st->priv_data; in mov_read_packet()
8873 current_index = sc->current_index; in mov_read_packet()
8874 mov_current_sample_inc(sc); in mov_read_packet()
8882 int64_t ret64 = avio_seek(sc->pb, sample->pos, SEEK_SET); in mov_read_packet()
8885 sc->ffindex, sample->pos); in mov_read_packet()
8886 if (should_retry(sc->pb, ret64)) { in mov_read_packet()
8887 mov_current_sample_dec(sc); in mov_read_packet()
8895 …>fc, AV_LOG_DEBUG, "Nonkey frame from stream %d discarded due to AVDISCARD_NONKEY\n", sc->ffindex); in mov_read_packet()
8900 ret = get_eia608_packet(sc->pb, pkt, sample->size); in mov_read_packet()
8902 ret = av_get_packet(sc->pb, pkt, sample->size); in mov_read_packet()
8904 if (should_retry(sc->pb, ret)) { in mov_read_packet()
8905 mov_current_sample_dec(sc); in mov_read_packet()
8910 if (mov->dv_demux && sc->dv_audio_container) { in mov_read_packet()
8920 if (sc->has_palette) { in mov_read_packet()
8927 memcpy(pal, sc->palette, AVPALETTE_SIZE); in mov_read_packet()
8928 sc->has_palette = 0; in mov_read_packet()
8937 pkt->stream_index = sc->ffindex; in mov_read_packet()
8942 if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { in mov_read_packet()
8943 pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration; in mov_read_packet()
8945 sc->ctts_sample++; in mov_read_packet()
8946 if (sc->ctts_index < sc->ctts_count && in mov_read_packet()
8947 sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { in mov_read_packet()
8948 sc->ctts_index++; in mov_read_packet()
8949 sc->ctts_sample = 0; in mov_read_packet()
8952 int64_t next_dts = (sc->current_sample < ffstream(st)->nb_index_entries) ? in mov_read_packet()
8953 ffstream(st)->index_entries[sc->current_sample].timestamp : st->duration; in mov_read_packet()
8961 if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) { in mov_read_packet()
8962 uint8_t sample_flags = sc->sdtp_data[sc->current_sample - 1]; in mov_read_packet()
8970 if (sc->stsc_data) { in mov_read_packet()
8971 if (sc->stsc_data[sc->stsc_index].id > 0 && in mov_read_packet()
8972 sc->stsc_data[sc->stsc_index].id - 1 < sc->stsd_count && in mov_read_packet()
8973 sc->stsc_data[sc->stsc_index].id - 1 != sc->last_stsd_index) { in mov_read_packet()
8974 ret = mov_change_extradata(sc, pkt); in mov_read_packet()
8980 sc->stsc_sample++; in mov_read_packet()
8981 if (mov_stsc_index_valid(sc->stsc_index, sc->stsc_count) && in mov_read_packet()
8982 mov_get_stsc_samples(sc, sc->stsc_index) == sc->stsc_sample) { in mov_read_packet()
8983 sc->stsc_index++; in mov_read_packet()
8984 sc->stsc_sample = 0; in mov_read_packet()
8991 ret = cenc_filter(mov, st, sc, pkt, current_index); in mov_read_packet()
9018 static int is_open_key_sample(const MOVStreamContext *sc, int sample) in is_open_key_sample() argument
9021 for (int i = 0; i < sc->open_key_samples_count; i++) { in is_open_key_sample()
9022 const int oks = sc->open_key_samples[i]; in is_open_key_sample()
9037 MOVStreamContext *sc = st->priv_data; in can_seek_to_key_sample() local
9044 if (sample >= sc->sample_offsets_count) in can_seek_to_key_sample()
9048 key_sample_pts = key_sample_dts + sc->sample_offsets[sample] + sc->dts_shift; in can_seek_to_key_sample()
9055 if (is_open_key_sample(sc, sample) && key_sample_pts > requested_pts) in can_seek_to_key_sample()
9063 MOVStreamContext *sc = st->priv_data; in mov_seek_stream() local
9070 timestamp -= (sc->min_corrected_pts + sc->dts_shift); in mov_seek_stream()
9086 timestamp -= FFMAX(sc->min_sample_duration, 1); in mov_seek_stream()
9089 mov_current_sample_set(sc, sample); in mov_seek_stream()
9090 av_log(s, AV_LOG_TRACE, "stream %d, found sample %d\n", st->index, sc->current_sample); in mov_seek_stream()
9092 if (sc->ctts_data) { in mov_seek_stream()
9094 for (i = 0; i < sc->ctts_count; i++) { in mov_seek_stream()
9095 int next = time_sample + sc->ctts_data[i].count; in mov_seek_stream()
9096 if (next > sc->current_sample) { in mov_seek_stream()
9097 sc->ctts_index = i; in mov_seek_stream()
9098 sc->ctts_sample = sc->current_sample - time_sample; in mov_seek_stream()
9106 if (sc->chunk_count) { in mov_seek_stream()
9108 for (i = 0; i < sc->stsc_count; i++) { in mov_seek_stream()
9109 int64_t next = time_sample + mov_get_stsc_samples(sc, i); in mov_seek_stream()
9110 if (next > sc->current_sample) { in mov_seek_stream()
9111 sc->stsc_index = i; in mov_seek_stream()
9112 sc->stsc_sample = sc->current_sample - time_sample; in mov_seek_stream()
9125 MOVStreamContext *sc = st->priv_data; in mov_get_skip_samples() local
9137 return FFMAX(sc->start_pad - off, 0); in mov_get_skip_samples()
9177 MOVStreamContext *sc; in mov_read_seek() local
9179 sc = st->priv_data; in mov_read_seek()
9180 mov_current_sample_set(sc, 0); in mov_read_seek()
9183 MOVStreamContext *sc; in mov_read_seek() local
9187 sc = st->priv_data; in mov_read_seek()
9188 if (sc->ffindex == stream_index && sc->current_sample == sample) in mov_read_seek()
9190 mov_current_sample_inc(sc); in mov_read_seek()