MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / init_input_stream

Function init_input_stream

ffmpeg-single-cmd/src/main/cpp/ffmpeg_mod.c:2875–2926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2873}
2874
2875static int init_input_stream(int ist_index, char *error, int error_len)
2876{
2877 int ret;
2878 InputStream *ist = input_streams[ist_index];
2879
2880 if (ist->decoding_needed) {
2881 AVCodec *codec = ist->dec;
2882 if (!codec) {
2883 snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d:%d",
2884 avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index);
2885 return AVERROR(EINVAL);
2886 }
2887
2888 ist->dec_ctx->opaque = ist;
2889 ist->dec_ctx->get_format = get_format;
2890 ist->dec_ctx->get_buffer2 = get_buffer;
2891 ist->dec_ctx->thread_safe_callbacks = 1;
2892
2893 av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
2894 if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
2895 (ist->decoding_needed & DECODING_FOR_OST)) {
2896 av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE);
2897 if (ist->decoding_needed & DECODING_FOR_FILTER)
2898 av_log(NULL, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
2899 }
2900
2901 av_dict_set(&ist->decoder_opts, "sub_text_format", "ass", AV_DICT_DONT_OVERWRITE);
2902
2903 /* Useful for subtitles retiming by lavf (FIXME), skipping samples in
2904 * audio, and video decoders such as cuvid or mediacodec */
2905 av_codec_set_pkt_timebase(ist->dec_ctx, ist->st->time_base);
2906
2907 if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0))
2908 av_dict_set(&ist->decoder_opts, "threads", "auto", 0);
2909 if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) {
2910 if (ret == AVERROR_EXPERIMENTAL)
2911 abort_codec_experimental(codec, 0);
2912
2913 snprintf(error, error_len,
2914 "Error while opening decoder for input stream "
2915 "#%d:%d : %s",
2916 ist->file_index, ist->st->index, av_err2str(ret));
2917 return ret;
2918 }
2919 assert_avoptions(ist->decoder_opts);
2920 }
2921
2922 ist->next_pts = AV_NOPTS_VALUE;
2923 ist->next_dts = AV_NOPTS_VALUE;
2924
2925 return 0;
2926}
2927
2928static InputStream *get_input_stream(OutputStream *ost)
2929{

Callers 1

transcode_initFunction · 0.85

Calls 2

abort_codec_experimentalFunction · 0.85
assert_avoptionsFunction · 0.85

Tested by

no test coverage detected