| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <float.h> | ||
| 20 | #include <stdint.h> | ||
| 21 | |||
| 22 | #include "ffmpeg.h" | ||
| 23 | #include "ffmpeg_sched.h" | ||
| 24 | #include "ffmpeg_utils.h" | ||
| 25 | |||
| 26 | #include "libavutil/avassert.h" | ||
| 27 | #include "libavutil/avstring.h" | ||
| 28 | #include "libavutil/display.h" | ||
| 29 | #include "libavutil/error.h" | ||
| 30 | #include "libavutil/intreadwrite.h" | ||
| 31 | #include "libavutil/mastering_display_metadata.h" | ||
| 32 | #include "libavutil/mem.h" | ||
| 33 | #include "libavutil/opt.h" | ||
| 34 | #include "libavutil/parseutils.h" | ||
| 35 | #include "libavutil/pixdesc.h" | ||
| 36 | #include "libavutil/time.h" | ||
| 37 | #include "libavutil/timestamp.h" | ||
| 38 | |||
| 39 | #include "libavcodec/bsf.h" | ||
| 40 | #include "libavcodec/packet.h" | ||
| 41 | |||
| 42 | #include "libavformat/avformat.h" | ||
| 43 | |||
| 44 | typedef struct DemuxStreamGroup { | ||
| 45 | InputStreamGroup istg; | ||
| 46 | |||
| 47 | // name used for logging | ||
| 48 | char log_name[32]; | ||
| 49 | |||
| 50 | // Temporary fields for LCEVC merging | ||
| 51 | AVBitStreamFilterGraph *graph; | ||
| 52 | AVBitStreamFilterContext *lcevc[2]; | ||
| 53 | AVBitStreamFilterContext *sink; | ||
| 54 | int graph_enabled; | ||
| 55 | } DemuxStreamGroup; | ||
| 56 | |||
| 57 | typedef struct DemuxStream { | ||
| 58 | InputStream ist; | ||
| 59 | |||
| 60 | // name used for logging | ||
| 61 | char log_name[32]; | ||
| 62 | |||
| 63 | int sch_idx_stream; | ||
| 64 | int sch_idx_dec; | ||
| 65 | |||
| 66 | double ts_scale; | ||
| 67 | |||
| 68 | /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ | ||
| 69 | int decoding_needed; | ||
| 70 | #define DECODING_FOR_OST 1 | ||
| 71 | #define DECODING_FOR_FILTER 2 | ||
| 72 | |||
| 73 | /* true if stream data should be discarded */ | ||
| 74 | int discard; | ||
| 75 | |||
| 76 | // scheduler returned EOF for this stream | ||
| 77 | int finished; | ||
| 78 | |||
| 79 | int streamcopy_needed; | ||
| 80 | int have_sub2video; | ||
| 81 | int reinit_filters; | ||
| 82 | int autorotate; | ||
| 83 | int apply_cropping; | ||
| 84 | int force_display_matrix; | ||
| 85 | int force_mastering_display; | ||
| 86 | int force_content_light; | ||
| 87 | int drop_changed; | ||
| 88 | |||
| 89 | |||
| 90 | int wrap_correction_done; | ||
| 91 | int saw_first_ts; | ||
| 92 | /// dts of the first packet read for this stream (in AV_TIME_BASE units) | ||
| 93 | int64_t first_dts; | ||
| 94 | |||
| 95 | /* predicted dts of the next packet read for this stream or (when there are | ||
| 96 | * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */ | ||
| 97 | int64_t next_dts; | ||
| 98 | /// dts of the last packet read for this stream (in AV_TIME_BASE units) | ||
| 99 | int64_t dts; | ||
| 100 | |||
| 101 | const AVCodecDescriptor *codec_desc; | ||
| 102 | |||
| 103 | AVDictionary *decoder_opts; | ||
| 104 | DecoderOpts dec_opts; | ||
| 105 | char dec_name[16]; | ||
| 106 | // decoded media properties, as estimated by opening the decoder | ||
| 107 | AVFrame *decoded_params; | ||
| 108 | |||
| 109 | AVBSFContext *bsf; | ||
| 110 | |||
| 111 | DemuxStreamGroup **dsg; | ||
| 112 | int nb_dsg; | ||
| 113 | |||
| 114 | /* number of packets successfully read for this stream */ | ||
| 115 | uint64_t nb_packets; | ||
| 116 | // combined size of all the packets read | ||
| 117 | uint64_t data_size; | ||
| 118 | } DemuxStream; | ||
| 119 | |||
| 120 | typedef struct Demuxer { | ||
| 121 | InputFile f; | ||
| 122 | |||
| 123 | // name used for logging | ||
| 124 | char log_name[32]; | ||
| 125 | |||
| 126 | int64_t wallclock_start; | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Extra timestamp offset added by discontinuity handling. | ||
| 130 | */ | ||
| 131 | int64_t ts_offset_discont; | ||
| 132 | int64_t last_ts; | ||
| 133 | |||
| 134 | int64_t recording_time; | ||
| 135 | int accurate_seek; | ||
| 136 | |||
| 137 | /* number of times input stream should be looped */ | ||
| 138 | int loop; | ||
| 139 | int have_audio_dec; | ||
| 140 | /* duration of the looped segment of the input file */ | ||
| 141 | Timestamp duration; | ||
| 142 | /* pts with the smallest/largest values ever seen */ | ||
| 143 | Timestamp min_pts; | ||
| 144 | Timestamp max_pts; | ||
| 145 | |||
| 146 | /* number of streams that the user was warned of */ | ||
| 147 | int nb_streams_warn; | ||
| 148 | |||
| 149 | float readrate; | ||
| 150 | double readrate_initial_burst; | ||
| 151 | float readrate_catchup; | ||
| 152 | |||
| 153 | // latest wallclock time at which packet reading resumed after a stall - used for readrate | ||
| 154 | int64_t resume_wc; | ||
| 155 | // relative timestamp of first packet sent after the latest stall - used for readrate | ||
| 156 | int64_t resume_progress; | ||
| 157 | // measure of how far behind packet reading is against spceified readrate | ||
| 158 | int64_t lag; | ||
| 159 | |||
| 160 | Scheduler *sch; | ||
| 161 | |||
| 162 | AVPacket *pkt_heartbeat; | ||
| 163 | |||
| 164 | int read_started; | ||
| 165 | int nb_streams_used; | ||
| 166 | int nb_streams_finished; | ||
| 167 | } Demuxer; | ||
| 168 | |||
| 169 | typedef struct DemuxThreadContext { | ||
| 170 | // packet used for reading from the demuxer | ||
| 171 | AVPacket *pkt_demux; | ||
| 172 | // packet for reading from BSFs | ||
| 173 | AVPacket *pkt_bsf; | ||
| 174 | } DemuxThreadContext; | ||
| 175 | |||
| 176 | 75 | static DemuxStreamGroup *dsg_from_istg(InputStreamGroup *istg) | |
| 177 | { | ||
| 178 | 75 | return (DemuxStreamGroup*)istg; | |
| 179 | } | ||
| 180 | |||
| 181 | 2275760 | static DemuxStream *ds_from_ist(InputStream *ist) | |
| 182 | { | ||
| 183 | 2275760 | return (DemuxStream*)ist; | |
| 184 | } | ||
| 185 | |||
| 186 | 22686 | static Demuxer *demuxer_from_ifile(InputFile *f) | |
| 187 | { | ||
| 188 | 22686 | return (Demuxer*)f; | |
| 189 | } | ||
| 190 | |||
| 191 | 114 | InputStream *ist_find_unused(enum AVMediaType type) | |
| 192 | { | ||
| 193 |
1/2✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
|
136 | for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { |
| 194 | 136 | DemuxStream *ds = ds_from_ist(ist); | |
| 195 |
4/4✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 20 times.
|
136 | if (ist->par->codec_type == type && ds->discard && |
| 196 |
1/2✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
|
114 | ist->user_set_discard != AVDISCARD_ALL) |
| 197 | 114 | return ist; | |
| 198 | } | ||
| 199 | ✗ | return NULL; | |
| 200 | } | ||
| 201 | |||
| 202 | 1665 | static void report_new_stream(Demuxer *d, const AVPacket *pkt) | |
| 203 | { | ||
| 204 | 1665 | const AVStream *st = d->f.ctx->streams[pkt->stream_index]; | |
| 205 | |||
| 206 |
1/2✓ Branch 0 taken 1665 times.
✗ Branch 1 not taken.
|
1665 | if (pkt->stream_index < d->nb_streams_warn) |
| 207 | 1665 | return; | |
| 208 | ✗ | av_log(d, AV_LOG_WARNING, | |
| 209 | "New %s stream with index %d at pos:%"PRId64" and DTS:%ss\n", | ||
| 210 | ✗ | av_get_media_type_string(st->codecpar->codec_type), | |
| 211 | ✗ | pkt->stream_index, pkt->pos, av_ts2timestr(pkt->dts, &st->time_base)); | |
| 212 | ✗ | d->nb_streams_warn = pkt->stream_index + 1; | |
| 213 | } | ||
| 214 | |||
| 215 | 11 | static int seek_to_start(Demuxer *d, Timestamp end_pts) | |
| 216 | { | ||
| 217 | 11 | InputFile *ifile = &d->f; | |
| 218 | 11 | AVFormatContext *is = ifile->ctx; | |
| 219 | int ret; | ||
| 220 | |||
| 221 | 11 | ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0); | |
| 222 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (ret < 0) |
| 223 | ✗ | return ret; | |
| 224 | |||
| 225 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
|
11 | if (end_pts.ts != AV_NOPTS_VALUE && |
| 226 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
6 | (d->max_pts.ts == AV_NOPTS_VALUE || |
| 227 | 3 | av_compare_ts(d->max_pts.ts, d->max_pts.tb, end_pts.ts, end_pts.tb) < 0)) | |
| 228 | 3 | d->max_pts = end_pts; | |
| 229 | |||
| 230 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (d->max_pts.ts != AV_NOPTS_VALUE) { |
| 231 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | int64_t min_pts = d->min_pts.ts == AV_NOPTS_VALUE ? 0 : d->min_pts.ts; |
| 232 | 11 | d->duration.ts = d->max_pts.ts - av_rescale_q(min_pts, d->min_pts.tb, d->max_pts.tb); | |
| 233 | } | ||
| 234 | 11 | d->duration.tb = d->max_pts.tb; | |
| 235 | |||
| 236 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (d->loop > 0) |
| 237 | 11 | d->loop--; | |
| 238 | |||
| 239 | 11 | return ret; | |
| 240 | } | ||
| 241 | |||
| 242 | 517567 | static void ts_discontinuity_detect(Demuxer *d, InputStream *ist, | |
| 243 | AVPacket *pkt) | ||
| 244 | { | ||
| 245 | 517567 | InputFile *ifile = &d->f; | |
| 246 | 517567 | DemuxStream *ds = ds_from_ist(ist); | |
| 247 | 517567 | const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT; | |
| 248 | 517567 | int disable_discontinuity_correction = copy_ts; | |
| 249 | 517567 | int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, pkt->time_base, AV_TIME_BASE_Q, | |
| 250 | AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); | ||
| 251 | |||
| 252 |
6/6✓ Branch 0 taken 115 times.
✓ Branch 1 taken 517452 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 86 times.
✓ Branch 5 taken 26 times.
|
517567 | if (copy_ts && ds->next_dts != AV_NOPTS_VALUE && |
| 253 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | fmt_is_discont && ist->st->pts_wrap_bits < 60) { |
| 254 | ✗ | int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits), | |
| 255 | ✗ | pkt->time_base, AV_TIME_BASE_Q, | |
| 256 | AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); | ||
| 257 | ✗ | if (FFABS(wrap_dts - ds->next_dts) < FFABS(pkt_dts - ds->next_dts)/10) | |
| 258 | ✗ | disable_discontinuity_correction = 0; | |
| 259 | } | ||
| 260 | |||
| 261 |
4/4✓ Branch 0 taken 510179 times.
✓ Branch 1 taken 7388 times.
✓ Branch 2 taken 510067 times.
✓ Branch 3 taken 112 times.
|
1027634 | if (ds->next_dts != AV_NOPTS_VALUE && !disable_discontinuity_correction) { |
| 262 | 510067 | int64_t delta = pkt_dts - ds->next_dts; | |
| 263 |
2/2✓ Branch 0 taken 23911 times.
✓ Branch 1 taken 486156 times.
|
510067 | if (fmt_is_discont) { |
| 264 |
4/4✓ Branch 0 taken 23854 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 23828 times.
✓ Branch 3 taken 83 times.
|
23911 | if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || |
| 265 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 23819 times.
|
23828 | pkt_dts + AV_TIME_BASE/10 < ds->dts) { |
| 266 | 92 | d->ts_offset_discont -= delta; | |
| 267 | 92 | av_log(ist, AV_LOG_WARNING, | |
| 268 | "timestamp discontinuity " | ||
| 269 | "(stream id=%d): %"PRId64", new offset= %"PRId64"\n", | ||
| 270 | 92 | ist->st->id, delta, d->ts_offset_discont); | |
| 271 | 92 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
| 272 |
1/2✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
|
92 | if (pkt->pts != AV_NOPTS_VALUE) |
| 273 | 92 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
| 274 | } | ||
| 275 | } else { | ||
| 276 |
3/4✓ Branch 0 taken 466733 times.
✓ Branch 1 taken 19423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 486156 times.
|
486156 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
| 277 | ✗ | av_log(ist, AV_LOG_WARNING, | |
| 278 | "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", | ||
| 279 | pkt->dts, ds->next_dts, pkt->stream_index); | ||
| 280 | ✗ | pkt->dts = AV_NOPTS_VALUE; | |
| 281 | } | ||
| 282 |
2/2✓ Branch 0 taken 484035 times.
✓ Branch 1 taken 2121 times.
|
486156 | if (pkt->pts != AV_NOPTS_VALUE){ |
| 283 | 484035 | int64_t pkt_pts = av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); | |
| 284 | 484035 | delta = pkt_pts - ds->next_dts; | |
| 285 |
3/4✓ Branch 0 taken 465050 times.
✓ Branch 1 taken 18985 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 484035 times.
|
484035 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
| 286 | ✗ | av_log(ist, AV_LOG_WARNING, | |
| 287 | "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", | ||
| 288 | pkt->pts, ds->next_dts, pkt->stream_index); | ||
| 289 | ✗ | pkt->pts = AV_NOPTS_VALUE; | |
| 290 | } | ||
| 291 | } | ||
| 292 | } | ||
| 293 |
6/6✓ Branch 0 taken 7388 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 7385 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 7247 times.
|
7500 | } else if (ds->next_dts == AV_NOPTS_VALUE && !copy_ts && |
| 294 |
1/2✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
|
138 | fmt_is_discont && d->last_ts != AV_NOPTS_VALUE) { |
| 295 | 138 | int64_t delta = pkt_dts - d->last_ts; | |
| 296 |
3/4✓ Branch 0 taken 90 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
|
138 | if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE) { |
| 297 | ✗ | d->ts_offset_discont -= delta; | |
| 298 | ✗ | av_log(ist, AV_LOG_DEBUG, | |
| 299 | "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", | ||
| 300 | delta, d->ts_offset_discont); | ||
| 301 | ✗ | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
| 302 | ✗ | if (pkt->pts != AV_NOPTS_VALUE) | |
| 303 | ✗ | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | 517567 | d->last_ts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); | |
| 308 | 517567 | } | |
| 309 | |||
| 310 | 565477 | static void ts_discontinuity_process(Demuxer *d, InputStream *ist, | |
| 311 | AVPacket *pkt) | ||
| 312 | { | ||
| 313 | 565477 | int64_t offset = av_rescale_q(d->ts_offset_discont, AV_TIME_BASE_Q, | |
| 314 | pkt->time_base); | ||
| 315 | |||
| 316 | // apply previously-detected timestamp-discontinuity offset | ||
| 317 | // (to all streams, not just audio/video) | ||
| 318 |
2/2✓ Branch 0 taken 520863 times.
✓ Branch 1 taken 44614 times.
|
565477 | if (pkt->dts != AV_NOPTS_VALUE) |
| 319 | 520863 | pkt->dts += offset; | |
| 320 |
2/2✓ Branch 0 taken 518743 times.
✓ Branch 1 taken 46734 times.
|
565477 | if (pkt->pts != AV_NOPTS_VALUE) |
| 321 | 518743 | pkt->pts += offset; | |
| 322 | |||
| 323 | // detect timestamp discontinuities for audio/video | ||
| 324 |
2/2✓ Branch 0 taken 347563 times.
✓ Branch 1 taken 217914 times.
|
565477 | if ((ist->par->codec_type == AVMEDIA_TYPE_VIDEO || |
| 325 |
2/2✓ Branch 0 taken 344263 times.
✓ Branch 1 taken 3300 times.
|
347563 | ist->par->codec_type == AVMEDIA_TYPE_AUDIO) && |
| 326 |
2/2✓ Branch 0 taken 517567 times.
✓ Branch 1 taken 44610 times.
|
562177 | pkt->dts != AV_NOPTS_VALUE) |
| 327 | 517567 | ts_discontinuity_detect(d, ist, pkt); | |
| 328 | 565477 | } | |
| 329 | |||
| 330 | 565477 | static int ist_dts_update(DemuxStream *ds, AVPacket *pkt, FrameData *fd) | |
| 331 | { | ||
| 332 | 565477 | InputStream *ist = &ds->ist; | |
| 333 | 565477 | const AVCodecParameters *par = ist->par; | |
| 334 | |||
| 335 |
2/2✓ Branch 0 taken 8081 times.
✓ Branch 1 taken 557396 times.
|
565477 | if (!ds->saw_first_ts) { |
| 336 | 8081 | ds->first_dts = | |
| 337 |
2/2✓ Branch 0 taken 5454 times.
✓ Branch 1 taken 2627 times.
|
8081 | ds->dts = ist->st->avg_frame_rate.num ? - ist->par->video_delay * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; |
| 338 |
2/2✓ Branch 0 taken 7466 times.
✓ Branch 1 taken 615 times.
|
8081 | if (pkt->pts != AV_NOPTS_VALUE) { |
| 339 | 7466 | ds->first_dts = | |
| 340 | 7466 | ds->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); | |
| 341 | } | ||
| 342 | 8081 | ds->saw_first_ts = 1; | |
| 343 | } | ||
| 344 | |||
| 345 |
2/2✓ Branch 0 taken 8081 times.
✓ Branch 1 taken 557396 times.
|
565477 | if (ds->next_dts == AV_NOPTS_VALUE) |
| 346 | 8081 | ds->next_dts = ds->dts; | |
| 347 | |||
| 348 |
2/2✓ Branch 0 taken 520863 times.
✓ Branch 1 taken 44614 times.
|
565477 | if (pkt->dts != AV_NOPTS_VALUE) |
| 349 | 520863 | ds->next_dts = ds->dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); | |
| 350 | |||
| 351 | 565477 | ds->dts = ds->next_dts; | |
| 352 |
3/3✓ Branch 0 taken 344263 times.
✓ Branch 1 taken 217914 times.
✓ Branch 2 taken 3300 times.
|
565477 | switch (par->codec_type) { |
| 353 | 344263 | case AVMEDIA_TYPE_AUDIO: | |
| 354 | av_assert1(pkt->duration >= 0); | ||
| 355 |
1/2✓ Branch 0 taken 344263 times.
✗ Branch 1 not taken.
|
344263 | if (par->sample_rate) { |
| 356 | 344263 | ds->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) / | |
| 357 | 344263 | par->sample_rate; | |
| 358 | } else { | ||
| 359 | ✗ | ds->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); | |
| 360 | } | ||
| 361 | 344263 | break; | |
| 362 | 217914 | case AVMEDIA_TYPE_VIDEO: | |
| 363 |
2/2✓ Branch 0 taken 746 times.
✓ Branch 1 taken 217168 times.
|
217914 | if (ist->framerate.num) { |
| 364 | // TODO: Remove work-around for c99-to-c89 issue 7 | ||
| 365 | 746 | AVRational time_base_q = AV_TIME_BASE_Q; | |
| 366 | 746 | int64_t next_dts = av_rescale_q(ds->next_dts, time_base_q, av_inv_q(ist->framerate)); | |
| 367 | 746 | ds->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); | |
| 368 |
2/2✓ Branch 0 taken 214572 times.
✓ Branch 1 taken 2596 times.
|
217168 | } else if (pkt->duration) { |
| 369 | 214572 | ds->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); | |
| 370 |
2/2✓ Branch 0 taken 49 times.
✓ Branch 1 taken 2547 times.
|
2596 | } else if (ist->par->framerate.num != 0) { |
| 371 | 49 | AVRational field_rate = av_mul_q(ist->par->framerate, | |
| 372 | 49 | (AVRational){ 2, 1 }); | |
| 373 | 49 | int fields = 2; | |
| 374 | |||
| 375 |
1/2✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
|
49 | if (ds->codec_desc && |
| 376 |
4/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 10 times.
|
73 | (ds->codec_desc->props & AV_CODEC_PROP_FIELDS) && |
| 377 | 24 | av_stream_get_parser(ist->st)) | |
| 378 | 14 | fields = 1 + av_stream_get_parser(ist->st)->repeat_pict; | |
| 379 | |||
| 380 | 49 | ds->next_dts += av_rescale_q(fields, av_inv_q(field_rate), AV_TIME_BASE_Q); | |
| 381 | } | ||
| 382 | 217914 | break; | |
| 383 | } | ||
| 384 | |||
| 385 | 565477 | fd->dts_est = ds->dts; | |
| 386 | |||
| 387 | 565477 | return 0; | |
| 388 | } | ||
| 389 | |||
| 390 | 565477 | static int ts_fixup(Demuxer *d, AVPacket *pkt, FrameData *fd) | |
| 391 | { | ||
| 392 | 565477 | InputFile *ifile = &d->f; | |
| 393 | 565477 | InputStream *ist = ifile->streams[pkt->stream_index]; | |
| 394 | 565477 | DemuxStream *ds = ds_from_ist(ist); | |
| 395 | 565477 | const int64_t start_time = ifile->start_time_effective; | |
| 396 | int64_t duration; | ||
| 397 | int ret; | ||
| 398 | |||
| 399 | 565477 | pkt->time_base = ist->st->time_base; | |
| 400 | |||
| 401 | #define SHOW_TS_DEBUG(tag_) \ | ||
| 402 | if (debug_ts) { \ | ||
| 403 | av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \ | ||
| 404 | "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \ | ||
| 405 | tag_, ifile->index, pkt->stream_index, \ | ||
| 406 | av_get_media_type_string(ist->st->codecpar->codec_type), \ | ||
| 407 | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \ | ||
| 408 | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \ | ||
| 409 | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \ | ||
| 410 | } | ||
| 411 | |||
| 412 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | SHOW_TS_DEBUG("demuxer"); |
| 413 | |||
| 414 |
4/4✓ Branch 0 taken 477563 times.
✓ Branch 1 taken 87914 times.
✓ Branch 2 taken 377519 times.
✓ Branch 3 taken 100044 times.
|
565477 | if (!ds->wrap_correction_done && start_time != AV_NOPTS_VALUE && |
| 415 |
2/2✓ Branch 0 taken 503 times.
✓ Branch 1 taken 377016 times.
|
377519 | ist->st->pts_wrap_bits < 64) { |
| 416 | int64_t stime, stime2; | ||
| 417 | |||
| 418 | 503 | stime = av_rescale_q(start_time, AV_TIME_BASE_Q, pkt->time_base); | |
| 419 | 503 | stime2= stime + (1ULL<<ist->st->pts_wrap_bits); | |
| 420 | 503 | ds->wrap_correction_done = 1; | |
| 421 | |||
| 422 |
5/6✓ Branch 0 taken 459 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 419 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 419 times.
|
503 | if(stime2 > stime && pkt->dts != AV_NOPTS_VALUE && pkt->dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) { |
| 423 | ✗ | pkt->dts -= 1ULL<<ist->st->pts_wrap_bits; | |
| 424 | ✗ | ds->wrap_correction_done = 0; | |
| 425 | } | ||
| 426 |
5/6✓ Branch 0 taken 459 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 412 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 412 times.
|
503 | if(stime2 > stime && pkt->pts != AV_NOPTS_VALUE && pkt->pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) { |
| 427 | ✗ | pkt->pts -= 1ULL<<ist->st->pts_wrap_bits; | |
| 428 | ✗ | ds->wrap_correction_done = 0; | |
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 |
2/2✓ Branch 0 taken 520863 times.
✓ Branch 1 taken 44614 times.
|
565477 | if (pkt->dts != AV_NOPTS_VALUE) |
| 433 | 520863 | pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); | |
| 434 |
2/2✓ Branch 0 taken 518743 times.
✓ Branch 1 taken 46734 times.
|
565477 | if (pkt->pts != AV_NOPTS_VALUE) |
| 435 | 518743 | pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); | |
| 436 | |||
| 437 |
2/2✓ Branch 0 taken 518743 times.
✓ Branch 1 taken 46734 times.
|
565477 | if (pkt->pts != AV_NOPTS_VALUE) |
| 438 | 518743 | pkt->pts *= ds->ts_scale; | |
| 439 |
2/2✓ Branch 0 taken 520863 times.
✓ Branch 1 taken 44614 times.
|
565477 | if (pkt->dts != AV_NOPTS_VALUE) |
| 440 | 520863 | pkt->dts *= ds->ts_scale; | |
| 441 | |||
| 442 | 565477 | duration = av_rescale_q(d->duration.ts, d->duration.tb, pkt->time_base); | |
| 443 |
2/2✓ Branch 0 taken 518743 times.
✓ Branch 1 taken 46734 times.
|
565477 | if (pkt->pts != AV_NOPTS_VALUE) { |
| 444 | // audio decoders take precedence for estimating total file duration | ||
| 445 |
2/2✓ Branch 0 taken 232183 times.
✓ Branch 1 taken 286560 times.
|
518743 | int64_t pkt_duration = d->have_audio_dec ? 0 : pkt->duration; |
| 446 | |||
| 447 | 518743 | pkt->pts += duration; | |
| 448 | |||
| 449 | // update max/min pts that will be used to compute total file duration | ||
| 450 | // when using -stream_loop | ||
| 451 |
4/4✓ Branch 0 taken 511695 times.
✓ Branch 1 taken 7048 times.
✓ Branch 2 taken 489911 times.
✓ Branch 3 taken 21784 times.
|
1030438 | if (d->max_pts.ts == AV_NOPTS_VALUE || |
| 452 | 511695 | av_compare_ts(d->max_pts.ts, d->max_pts.tb, | |
| 453 | 511695 | pkt->pts + pkt_duration, pkt->time_base) < 0) { | |
| 454 | 496959 | d->max_pts = (Timestamp){ .ts = pkt->pts + pkt_duration, | |
| 455 | 496959 | .tb = pkt->time_base }; | |
| 456 | } | ||
| 457 |
4/4✓ Branch 0 taken 511695 times.
✓ Branch 1 taken 7048 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 511667 times.
|
1030438 | if (d->min_pts.ts == AV_NOPTS_VALUE || |
| 458 | 511695 | av_compare_ts(d->min_pts.ts, d->min_pts.tb, | |
| 459 | pkt->pts, pkt->time_base) > 0) { | ||
| 460 | 7076 | d->min_pts = (Timestamp){ .ts = pkt->pts, | |
| 461 | 7076 | .tb = pkt->time_base }; | |
| 462 | } | ||
| 463 | } | ||
| 464 | |||
| 465 |
2/2✓ Branch 0 taken 520863 times.
✓ Branch 1 taken 44614 times.
|
565477 | if (pkt->dts != AV_NOPTS_VALUE) |
| 466 | 520863 | pkt->dts += duration; | |
| 467 | |||
| 468 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | SHOW_TS_DEBUG("demuxer+tsfixup"); |
| 469 | |||
| 470 | // detect and try to correct for timestamp discontinuities | ||
| 471 | 565477 | ts_discontinuity_process(d, ist, pkt); | |
| 472 | |||
| 473 | // update estimated/predicted dts | ||
| 474 | 565477 | ret = ist_dts_update(ds, pkt, fd); | |
| 475 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | if (ret < 0) |
| 476 | ✗ | return ret; | |
| 477 | |||
| 478 | 565477 | return 0; | |
| 479 | } | ||
| 480 | |||
| 481 | 565477 | static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags) | |
| 482 | { | ||
| 483 | 565477 | InputFile *f = &d->f; | |
| 484 | 565477 | InputStream *ist = f->streams[pkt->stream_index]; | |
| 485 | 565477 | DemuxStream *ds = ds_from_ist(ist); | |
| 486 | FrameData *fd; | ||
| 487 | 565477 | int ret = 0; | |
| 488 | |||
| 489 | 565477 | fd = packet_data(pkt); | |
| 490 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | if (!fd) |
| 491 | ✗ | return AVERROR(ENOMEM); | |
| 492 | |||
| 493 | 565477 | ret = ts_fixup(d, pkt, fd); | |
| 494 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | if (ret < 0) |
| 495 | ✗ | return ret; | |
| 496 | |||
| 497 |
2/2✓ Branch 0 taken 238 times.
✓ Branch 1 taken 565239 times.
|
565477 | if (d->recording_time != INT64_MAX) { |
| 498 | 238 | int64_t start_time = 0; | |
| 499 |
2/2✓ Branch 0 taken 87 times.
✓ Branch 1 taken 151 times.
|
238 | if (copy_ts) { |
| 500 |
1/2✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
|
87 | start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0; |
| 501 |
1/2✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
|
87 | start_time += start_at_zero ? 0 : f->start_time_effective; |
| 502 | } | ||
| 503 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 211 times.
|
238 | if (ds->dts >= d->recording_time + start_time) |
| 504 | 27 | *send_flags |= DEMUX_SEND_STREAMCOPY_EOF; | |
| 505 | } | ||
| 506 | |||
| 507 | 565477 | ds->data_size += pkt->size; | |
| 508 | 565477 | ds->nb_packets++; | |
| 509 | |||
| 510 | 565477 | fd->wallclock[LATENCY_PROBE_DEMUX] = av_gettime_relative(); | |
| 511 | |||
| 512 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | if (debug_ts) { |
| 513 | ✗ | av_log(ist, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n", | |
| 514 | f->index, pkt->stream_index, | ||
| 515 | ✗ | av_get_media_type_string(ist->par->codec_type), | |
| 516 | ✗ | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), | |
| 517 | ✗ | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), | |
| 518 | ✗ | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base), | |
| 519 | ✗ | av_ts2str(f->ts_offset), av_ts2timestr(f->ts_offset, &AV_TIME_BASE_Q)); | |
| 520 | } | ||
| 521 | |||
| 522 | 565477 | return 0; | |
| 523 | } | ||
| 524 | |||
| 525 | 218 | static void readrate_sleep(Demuxer *d) | |
| 526 | { | ||
| 527 | 218 | InputFile *f = &d->f; | |
| 528 | 436 | int64_t file_start = copy_ts * ( | |
| 529 |
1/2✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
|
218 | (f->start_time_effective != AV_NOPTS_VALUE ? f->start_time_effective * !start_at_zero : 0) + |
| 530 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
|
218 | (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) |
| 531 | ); | ||
| 532 | 218 | int64_t initial_burst = AV_TIME_BASE * d->readrate_initial_burst; | |
| 533 | 218 | int resume_warn = 0; | |
| 534 | |||
| 535 | 218 | DemuxStream *slowest = NULL; | |
| 536 | 218 | int64_t progress = INT64_MAX; | |
| 537 | |||
| 538 |
2/2✓ Branch 0 taken 218 times.
✓ Branch 1 taken 218 times.
|
436 | for (int i = 0; i < f->nb_streams; i++) { |
| 539 | 218 | InputStream *ist = f->streams[i]; | |
| 540 | 218 | DemuxStream *ds = ds_from_ist(ist); | |
| 541 | int64_t stream_ts_offset, pts, pts_diff; | ||
| 542 |
3/6✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 218 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 218 times.
|
218 | if (ds->discard || ds->finished || ds->first_dts == AV_NOPTS_VALUE) |
| 543 | ✗ | continue; | |
| 544 | |||
| 545 | 218 | stream_ts_offset = FFMAX(ds->first_dts, file_start); | |
| 546 | 218 | pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE); | |
| 547 | 218 | pts_diff = pts - stream_ts_offset; | |
| 548 |
1/2✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
|
218 | if (pts_diff < progress) { |
| 549 | 218 | progress = pts_diff; | |
| 550 | 218 | slowest = ds; | |
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 |
3/4✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 195 times.
|
218 | if (!slowest || progress <= initial_burst) |
| 555 | 23 | return; | |
| 556 | |||
| 557 | 195 | int64_t now = av_gettime_relative(); | |
| 558 | 195 | int64_t wc_elapsed = now - d->wallclock_start; | |
| 559 | 195 | int64_t max_prog = initial_burst + (int64_t)(wc_elapsed * d->readrate); | |
| 560 | 195 | int64_t lag = FFMAX(max_prog - progress, 0); | |
| 561 | int64_t limit; | ||
| 562 | |||
| 563 |
3/6✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 195 times.
|
195 | if ( (!d->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > d->lag + 0.3 * AV_TIME_BASE) ) { |
| 564 | ✗ | d->lag = lag; | |
| 565 | ✗ | d->resume_wc = now; | |
| 566 | ✗ | d->resume_progress = progress; | |
| 567 | |||
| 568 | ✗ | int64_t pts = FFMAX(slowest->first_dts, file_start) + progress; | |
| 569 | ✗ | av_log_once(slowest, AV_LOG_WARNING, AV_LOG_DEBUG, &resume_warn, | |
| 570 | "Resumed reading at pts %0.3f with rate %0.3f after a lag of %0.3fs\n", | ||
| 571 | ✗ | (float)pts/AV_TIME_BASE, d->readrate_catchup, (float)lag/AV_TIME_BASE); | |
| 572 | } | ||
| 573 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
195 | if (d->lag && !lag) |
| 574 | ✗ | d->lag = d->resume_wc = d->resume_progress = 0; | |
| 575 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
|
195 | if (d->resume_wc) { |
| 576 | ✗ | int64_t elapsed = now - d->resume_wc; | |
| 577 | ✗ | limit = d->resume_progress + (int64_t)(elapsed * d->readrate_catchup); | |
| 578 | } else { | ||
| 579 | 195 | limit = max_prog; | |
| 580 | } | ||
| 581 | |||
| 582 |
2/2✓ Branch 0 taken 193 times.
✓ Branch 1 taken 2 times.
|
195 | if (progress > limit) |
| 583 | 193 | av_usleep(progress - limit); | |
| 584 | } | ||
| 585 | |||
| 586 | 558041 | static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags, | |
| 587 | const char *pkt_desc) | ||
| 588 | { | ||
| 589 | int ret; | ||
| 590 | |||
| 591 | 558041 | pkt->stream_index = ds->sch_idx_stream; | |
| 592 | |||
| 593 | 558041 | ret = sch_demux_send(d->sch, d->f.index, pkt, flags); | |
| 594 |
2/2✓ Branch 0 taken 2482 times.
✓ Branch 1 taken 555559 times.
|
558041 | if (ret == AVERROR_EOF) { |
| 595 | 2482 | av_packet_unref(pkt); | |
| 596 | |||
| 597 | 2482 | av_log(ds, AV_LOG_VERBOSE, "All consumers of this stream are done\n"); | |
| 598 | 2482 | ds->finished = 1; | |
| 599 | |||
| 600 |
2/2✓ Branch 0 taken 2445 times.
✓ Branch 1 taken 37 times.
|
2482 | if (++d->nb_streams_finished == d->nb_streams_used) { |
| 601 | 2445 | av_log(d, AV_LOG_VERBOSE, "All consumers are done\n"); | |
| 602 | 2445 | return AVERROR_EOF; | |
| 603 | } | ||
| 604 |
2/2✓ Branch 0 taken 486 times.
✓ Branch 1 taken 555073 times.
|
555559 | } else if (ret < 0) { |
| 605 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
|
486 | if (ret != AVERROR_EXIT) |
| 606 | ✗ | av_log(d, AV_LOG_ERROR, | |
| 607 | "Unable to send %s packet to consumers: %s\n", | ||
| 608 | ✗ | pkt_desc, av_err2str(ret)); | |
| 609 | 486 | return ret; | |
| 610 | } | ||
| 611 | |||
| 612 | 555110 | return 0; | |
| 613 | } | ||
| 614 | |||
| 615 | ✗ | static int do_bsf_graph(Demuxer *d, DemuxThreadContext *dt, DemuxStreamGroup *dsg, | |
| 616 | DemuxStream *ds, AVPacket *pkt) | ||
| 617 | { | ||
| 618 | ✗ | const AVStreamGroup *stg = dsg->istg.stg; | |
| 619 | ✗ | const AVStreamGroupLayeredVideo *lcevc = stg->params.layered_video; | |
| 620 | ✗ | const int enhancement = ds->ist.index == stg->streams[lcevc->el_index]->index; | |
| 621 | ✗ | AVBitStreamFilterContext *source = dsg->lcevc[enhancement]; | |
| 622 | ✗ | int ret, flags = AV_BSF_SOURCE_FLAG_PUSH; | |
| 623 | |||
| 624 | ✗ | if (enhancement) | |
| 625 | ✗ | flags |= AV_BSF_SOURCE_FLAG_KEEP_REF; | |
| 626 | |||
| 627 | ✗ | ret = av_bsf_source_add_packet(source, pkt, flags); | |
| 628 | ✗ | if (ret < 0) { | |
| 629 | ✗ | if (pkt) | |
| 630 | ✗ | av_packet_unref(pkt); | |
| 631 | ✗ | av_log(dsg, AV_LOG_ERROR, "Error submitting a packet for filtering: %s\n", | |
| 632 | ✗ | av_err2str(ret)); | |
| 633 | ✗ | return ret; | |
| 634 | } | ||
| 635 | |||
| 636 | ✗ | if (pkt && enhancement) { | |
| 637 | ✗ | if (ds->discard) | |
| 638 | ✗ | av_packet_unref(pkt); | |
| 639 | else { | ||
| 640 | ✗ | ret = do_send(d, ds, pkt, 0, "filtered"); | |
| 641 | ✗ | if (ret < 0) { | |
| 642 | ✗ | av_packet_unref(pkt); | |
| 643 | ✗ | return ret; | |
| 644 | } | ||
| 645 | } | ||
| 646 | ✗ | return 0; | |
| 647 | } | ||
| 648 | |||
| 649 | while (1) { | ||
| 650 | ✗ | ret = av_bsf_sink_get_packet(dsg->sink, dt->pkt_bsf, 0); | |
| 651 | ✗ | if (ret == AVERROR(EAGAIN)) | |
| 652 | ✗ | return 0; | |
| 653 | ✗ | else if (ret < 0) { | |
| 654 | ✗ | if (ret != AVERROR_EOF) | |
| 655 | ✗ | av_log(dsg, AV_LOG_ERROR, | |
| 656 | "Error applying bitstream filters to a packet: %s\n", | ||
| 657 | ✗ | av_err2str(ret)); | |
| 658 | ✗ | return ret; | |
| 659 | } | ||
| 660 | |||
| 661 | ✗ | dt->pkt_bsf->time_base = av_bsf_sink_get_time_base(dsg->sink); | |
| 662 | |||
| 663 | ✗ | ret = do_send(d, ds, dt->pkt_bsf, 0, "filtered"); | |
| 664 | ✗ | if (ret < 0) { | |
| 665 | ✗ | av_packet_unref(dt->pkt_bsf); | |
| 666 | ✗ | return ret; | |
| 667 | } | ||
| 668 | } | ||
| 669 | |||
| 670 | return 0; | ||
| 671 | } | ||
| 672 | |||
| 673 | 565480 | static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds, | |
| 674 | AVPacket *pkt, unsigned flags) | ||
| 675 | { | ||
| 676 | 565480 | InputFile *f = &d->f; | |
| 677 | 565480 | DemuxStreamGroup *dsg = NULL; | |
| 678 | int ret; | ||
| 679 | |||
| 680 |
2/2✓ Branch 0 taken 90 times.
✓ Branch 1 taken 565390 times.
|
565480 | for (int i = 0; i < ds->nb_dsg; i++) { |
| 681 | 90 | const InputStreamGroup *istg = &ds->dsg[i]->istg; | |
| 682 | |||
| 683 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
|
90 | if (istg->stg->type != AV_STREAM_GROUP_PARAMS_LCEVC) |
| 684 | ✗ | continue; | |
| 685 | 90 | dsg = ds->dsg[i]; | |
| 686 | 90 | break; | |
| 687 | } | ||
| 688 | |||
| 689 | // pkt can be NULL only when flushing BSFs | ||
| 690 |
6/8✓ Branch 0 taken 565450 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 565360 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 565360 times.
|
565480 | av_assert0(ds->bsf || (dsg && dsg->graph) || pkt); |
| 691 | |||
| 692 | // send heartbeat for sub2video streams | ||
| 693 |
4/6✓ Branch 0 taken 948 times.
✓ Branch 1 taken 564532 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 948 times.
✗ Branch 5 not taken.
|
565480 | if (d->pkt_heartbeat && pkt && pkt->pts != AV_NOPTS_VALUE) { |
| 694 |
2/2✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 948 times.
|
5280 | for (int i = 0; i < f->nb_streams; i++) { |
| 695 | 4332 | DemuxStream *ds1 = ds_from_ist(f->streams[i]); | |
| 696 | |||
| 697 |
3/4✓ Branch 0 taken 4332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3384 times.
✓ Branch 3 taken 948 times.
|
4332 | if (ds1->finished || !ds1->have_sub2video) |
| 698 | 3384 | continue; | |
| 699 | |||
| 700 | 948 | d->pkt_heartbeat->pts = pkt->pts; | |
| 701 | 948 | d->pkt_heartbeat->time_base = pkt->time_base; | |
| 702 | 948 | d->pkt_heartbeat->opaque = (void*)(intptr_t)PKT_OPAQUE_SUB_HEARTBEAT; | |
| 703 | |||
| 704 | 948 | ret = do_send(d, ds1, d->pkt_heartbeat, 0, "heartbeat"); | |
| 705 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 948 times.
|
948 | if (ret < 0) |
| 706 | ✗ | return ret; | |
| 707 | } | ||
| 708 | } | ||
| 709 | |||
| 710 |
3/4✓ Branch 0 taken 90 times.
✓ Branch 1 taken 565390 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
|
565480 | if (dsg && dsg->graph_enabled) { |
| 711 | ✗ | ret = do_bsf_graph(d, dt, dsg, ds, pkt); | |
| 712 | ✗ | if (ret < 0) | |
| 713 | ✗ | return ret; | |
| 714 | } | ||
| 715 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 565450 times.
|
565480 | if (ds->bsf) { |
| 716 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
|
30 | if (pkt) |
| 717 | 27 | av_packet_rescale_ts(pkt, pkt->time_base, ds->bsf->time_base_in); | |
| 718 | |||
| 719 | 30 | ret = av_bsf_send_packet(ds->bsf, pkt); | |
| 720 |
1/2✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
|
30 | if (ret < 0) { |
| 721 | ✗ | if (pkt) | |
| 722 | ✗ | av_packet_unref(pkt); | |
| 723 | ✗ | av_log(ds, AV_LOG_ERROR, "Error submitting a packet for filtering: %s\n", | |
| 724 | ✗ | av_err2str(ret)); | |
| 725 | ✗ | return ret; | |
| 726 | } | ||
| 727 | |||
| 728 | while (1) { | ||
| 729 | 56 | ret = av_bsf_receive_packet(ds->bsf, dt->pkt_bsf); | |
| 730 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 30 times.
|
56 | if (ret == AVERROR(EAGAIN)) |
| 731 | 26 | return 0; | |
| 732 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27 times.
|
30 | else if (ret < 0) { |
| 733 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret != AVERROR_EOF) |
| 734 | ✗ | av_log(ds, AV_LOG_ERROR, | |
| 735 | "Error applying bitstream filters to a packet: %s\n", | ||
| 736 | ✗ | av_err2str(ret)); | |
| 737 | 3 | return ret; | |
| 738 | } | ||
| 739 | |||
| 740 | 27 | dt->pkt_bsf->time_base = ds->bsf->time_base_out; | |
| 741 | |||
| 742 | 27 | ret = do_send(d, ds, dt->pkt_bsf, 0, "filtered"); | |
| 743 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26 times.
|
27 | if (ret < 0) { |
| 744 | 1 | av_packet_unref(dt->pkt_bsf); | |
| 745 | 1 | return ret; | |
| 746 | } | ||
| 747 | } | ||
| 748 |
3/4✓ Branch 0 taken 8384 times.
✓ Branch 1 taken 557066 times.
✓ Branch 2 taken 8384 times.
✗ Branch 3 not taken.
|
565450 | } else if (ds->discard && pkt) { |
| 749 | 8384 | av_packet_unref(pkt); | |
| 750 |
3/4✓ Branch 0 taken 90 times.
✓ Branch 1 taken 556976 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
|
557066 | } else if (!dsg || !dsg->graph_enabled) { |
| 751 | 557066 | ret = do_send(d, ds, pkt, flags, "demuxed"); | |
| 752 |
2/2✓ Branch 0 taken 2930 times.
✓ Branch 1 taken 554136 times.
|
557066 | if (ret < 0) |
| 753 | 2930 | return ret; | |
| 754 | } | ||
| 755 | |||
| 756 | 562520 | return 0; | |
| 757 | } | ||
| 758 | |||
| 759 | 4664 | static int demux_bsf_flush(Demuxer *d, DemuxThreadContext *dt) | |
| 760 | { | ||
| 761 | 4664 | InputFile *f = &d->f; | |
| 762 | int ret; | ||
| 763 | |||
| 764 |
2/2✓ Branch 0 taken 5220 times.
✓ Branch 1 taken 4664 times.
|
9884 | for (unsigned i = 0; i < f->nb_streams; i++) { |
| 765 | 5220 | DemuxStream *ds = ds_from_ist(f->streams[i]); | |
| 766 | 5220 | DemuxStreamGroup *dsg = NULL; | |
| 767 | |||
| 768 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5214 times.
|
5220 | for (int j = 0; j < ds->nb_dsg; j++) { |
| 769 | 6 | const InputStreamGroup *istg = &ds->dsg[j]->istg; | |
| 770 | |||
| 771 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (istg->stg->type != AV_STREAM_GROUP_PARAMS_LCEVC) |
| 772 | ✗ | continue; | |
| 773 | 6 | dsg = ds->dsg[j]; | |
| 774 | 6 | break; | |
| 775 | } | ||
| 776 | |||
| 777 |
5/6✓ Branch 0 taken 5217 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5211 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
5220 | if (!ds->bsf && (!dsg || !dsg->graph_enabled)) |
| 778 | 5217 | continue; | |
| 779 | |||
| 780 | 3 | ret = demux_send(d, dt, ds, NULL, 0); | |
| 781 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | ret = (ret == AVERROR_EOF) ? 0 : (ret < 0) ? ret : AVERROR_BUG; |
| 782 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) { |
| 783 | ✗ | av_log(ds, AV_LOG_ERROR, "Error flushing BSFs: %s\n", | |
| 784 | ✗ | av_err2str(ret)); | |
| 785 | ✗ | return ret; | |
| 786 | } | ||
| 787 | |||
| 788 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ds->bsf) |
| 789 | 3 | av_bsf_flush(ds->bsf); | |
| 790 | } | ||
| 791 | |||
| 792 | 4664 | return 0; | |
| 793 | } | ||
| 794 | |||
| 795 | 7584 | static void discard_unused_programs(InputFile *ifile) | |
| 796 | { | ||
| 797 |
2/2✓ Branch 0 taken 57 times.
✓ Branch 1 taken 7584 times.
|
7641 | for (int j = 0; j < ifile->ctx->nb_programs; j++) { |
| 798 | 57 | AVProgram *p = ifile->ctx->programs[j]; | |
| 799 | 57 | int discard = AVDISCARD_ALL; | |
| 800 | |||
| 801 |
1/2✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
|
75 | for (int k = 0; k < p->nb_stream_indexes; k++) { |
| 802 | 75 | DemuxStream *ds = ds_from_ist(ifile->streams[p->stream_index[k]]); | |
| 803 | |||
| 804 |
2/2✓ Branch 0 taken 57 times.
✓ Branch 1 taken 18 times.
|
75 | if (!ds->discard) { |
| 805 | 57 | discard = AVDISCARD_DEFAULT; | |
| 806 | 57 | break; | |
| 807 | } | ||
| 808 | } | ||
| 809 | 57 | p->discard = discard; | |
| 810 | } | ||
| 811 | 7584 | } | |
| 812 | |||
| 813 | 7584 | static void thread_set_name(InputFile *f) | |
| 814 | { | ||
| 815 | char name[16]; | ||
| 816 | 7584 | snprintf(name, sizeof(name), "dmx%d:%s", f->index, f->ctx->iformat->name); | |
| 817 | 7584 | ff_thread_setname(name); | |
| 818 | 7584 | } | |
| 819 | |||
| 820 | 7584 | static void demux_thread_uninit(DemuxThreadContext *dt) | |
| 821 | { | ||
| 822 | 7584 | av_packet_free(&dt->pkt_demux); | |
| 823 | 7584 | av_packet_free(&dt->pkt_bsf); | |
| 824 | |||
| 825 | 7584 | memset(dt, 0, sizeof(*dt)); | |
| 826 | 7584 | } | |
| 827 | |||
| 828 | 7584 | static int demux_thread_init(DemuxThreadContext *dt) | |
| 829 | { | ||
| 830 | 7584 | memset(dt, 0, sizeof(*dt)); | |
| 831 | |||
| 832 | 7584 | dt->pkt_demux = av_packet_alloc(); | |
| 833 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7584 times.
|
7584 | if (!dt->pkt_demux) |
| 834 | ✗ | return AVERROR(ENOMEM); | |
| 835 | |||
| 836 | 7584 | dt->pkt_bsf = av_packet_alloc(); | |
| 837 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7584 times.
|
7584 | if (!dt->pkt_bsf) |
| 838 | ✗ | return AVERROR(ENOMEM); | |
| 839 | |||
| 840 | 7584 | return 0; | |
| 841 | } | ||
| 842 | |||
| 843 | 7584 | static int input_thread(void *arg) | |
| 844 | { | ||
| 845 | 7584 | Demuxer *d = arg; | |
| 846 | 7584 | InputFile *f = &d->f; | |
| 847 | |||
| 848 | DemuxThreadContext dt; | ||
| 849 | |||
| 850 | 7584 | int ret = 0; | |
| 851 | |||
| 852 | 7584 | ret = demux_thread_init(&dt); | |
| 853 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7584 times.
|
7584 | if (ret < 0) |
| 854 | ✗ | goto finish; | |
| 855 | |||
| 856 | 7584 | thread_set_name(f); | |
| 857 | |||
| 858 | 7584 | discard_unused_programs(f); | |
| 859 | |||
| 860 | 7584 | d->read_started = 1; | |
| 861 | 7584 | d->wallclock_start = av_gettime_relative(); | |
| 862 | |||
| 863 | 564223 | while (1) { | |
| 864 | DemuxStream *ds; | ||
| 865 | 571807 | unsigned send_flags = 0; | |
| 866 | |||
| 867 | 571807 | ret = av_read_frame(f->ctx, dt.pkt_demux); | |
| 868 | |||
| 869 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 571806 times.
|
571807 | if (ret == AVERROR(EAGAIN)) { |
| 870 | 1 | av_usleep(10000); | |
| 871 | 1677 | continue; | |
| 872 | } | ||
| 873 |
2/2✓ Branch 0 taken 4664 times.
✓ Branch 1 taken 567142 times.
|
571806 | if (ret < 0) { |
| 874 | int ret_bsf; | ||
| 875 | |||
| 876 |
2/2✓ Branch 0 taken 4609 times.
✓ Branch 1 taken 55 times.
|
4664 | if (ret == AVERROR_EOF) |
| 877 | 4609 | av_log(d, AV_LOG_VERBOSE, "EOF while reading input\n"); | |
| 878 | else { | ||
| 879 | 55 | av_log(d, AV_LOG_ERROR, "Error during demuxing: %s\n", | |
| 880 | 55 | av_err2str(ret)); | |
| 881 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
|
55 | ret = exit_on_error ? ret : 0; |
| 882 | } | ||
| 883 | |||
| 884 | 4664 | ret_bsf = demux_bsf_flush(d, &dt); | |
| 885 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 4609 times.
|
4664 | ret = err_merge(ret == AVERROR_EOF ? 0 : ret, ret_bsf); |
| 886 | |||
| 887 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 4653 times.
|
4664 | if (d->loop) { |
| 888 | /* signal looping to our consumers */ | ||
| 889 | 11 | dt.pkt_demux->stream_index = -1; | |
| 890 | 11 | ret = sch_demux_send(d->sch, f->index, dt.pkt_demux, 0); | |
| 891 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (ret >= 0) |
| 892 | 11 | ret = seek_to_start(d, (Timestamp){ .ts = dt.pkt_demux->pts, | |
| 893 | 11 | .tb = dt.pkt_demux->time_base }); | |
| 894 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (ret >= 0) |
| 895 | 11 | continue; | |
| 896 | |||
| 897 | /* fallthrough to the error path */ | ||
| 898 | } | ||
| 899 | |||
| 900 | 4653 | break; | |
| 901 | } | ||
| 902 | |||
| 903 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 567142 times.
|
567142 | if (do_pkt_dump) { |
| 904 | ✗ | av_pkt_dump_log2(NULL, AV_LOG_INFO, dt.pkt_demux, do_hex_dump, | |
| 905 | ✗ | f->ctx->streams[dt.pkt_demux->stream_index]); | |
| 906 | } | ||
| 907 | |||
| 908 | /* the following test is needed in case new streams appear | ||
| 909 | dynamically in stream : we ignore them */ | ||
| 910 | 1134284 | ds = dt.pkt_demux->stream_index < f->nb_streams ? | |
| 911 |
1/2✓ Branch 0 taken 567142 times.
✗ Branch 1 not taken.
|
567142 | ds_from_ist(f->streams[dt.pkt_demux->stream_index]) : NULL; |
| 912 |
3/4✓ Branch 0 taken 567142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1665 times.
✓ Branch 3 taken 565477 times.
|
567142 | if (!ds || ds->finished) { |
| 913 | 1665 | report_new_stream(d, dt.pkt_demux); | |
| 914 | 1665 | av_packet_unref(dt.pkt_demux); | |
| 915 | 1665 | continue; | |
| 916 | } | ||
| 917 | |||
| 918 |
2/2✓ Branch 0 taken 114 times.
✓ Branch 1 taken 565363 times.
|
565477 | if (dt.pkt_demux->flags & AV_PKT_FLAG_CORRUPT) { |
| 919 | 114 | av_log(d, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING, | |
| 920 | "corrupt input packet in stream %d\n", | ||
| 921 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
|
114 | dt.pkt_demux->stream_index); |
| 922 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
|
114 | if (exit_on_error) { |
| 923 | ✗ | av_packet_unref(dt.pkt_demux); | |
| 924 | ✗ | ret = AVERROR_INVALIDDATA; | |
| 925 | ✗ | break; | |
| 926 | } | ||
| 927 | } | ||
| 928 | |||
| 929 | 565477 | ret = input_packet_process(d, dt.pkt_demux, &send_flags); | |
| 930 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 565477 times.
|
565477 | if (ret < 0) |
| 931 | ✗ | break; | |
| 932 | |||
| 933 |
2/2✓ Branch 0 taken 218 times.
✓ Branch 1 taken 565259 times.
|
565477 | if (d->readrate) |
| 934 | 218 | readrate_sleep(d); | |
| 935 | |||
| 936 | 565477 | ret = demux_send(d, &dt, ds, dt.pkt_demux, send_flags); | |
| 937 |
2/2✓ Branch 0 taken 2931 times.
✓ Branch 1 taken 562546 times.
|
565477 | if (ret < 0) |
| 938 | 2931 | break; | |
| 939 | } | ||
| 940 | |||
| 941 | // EOF/EXIT is normal termination | ||
| 942 |
4/4✓ Branch 0 taken 5139 times.
✓ Branch 1 taken 2445 times.
✓ Branch 2 taken 4653 times.
✓ Branch 3 taken 486 times.
|
7584 | if (ret == AVERROR_EOF || ret == AVERROR_EXIT) |
| 943 | 2931 | ret = 0; | |
| 944 | |||
| 945 | 4653 | finish: | |
| 946 | 7584 | demux_thread_uninit(&dt); | |
| 947 | |||
| 948 | 7584 | return ret; | |
| 949 | } | ||
| 950 | |||
| 951 | 7584 | static void demux_final_stats(Demuxer *d) | |
| 952 | { | ||
| 953 | 7584 | InputFile *f = &d->f; | |
| 954 | 7584 | uint64_t total_packets = 0, total_size = 0; | |
| 955 | |||
| 956 | 7584 | av_log(f, AV_LOG_VERBOSE, "Input file #%d (%s):\n", | |
| 957 | 7584 | f->index, f->ctx->url); | |
| 958 | |||
| 959 |
2/2✓ Branch 0 taken 8205 times.
✓ Branch 1 taken 7584 times.
|
15789 | for (int j = 0; j < f->nb_streams; j++) { |
| 960 | 8205 | InputStream *ist = f->streams[j]; | |
| 961 | 8205 | DemuxStream *ds = ds_from_ist(ist); | |
| 962 | 8205 | enum AVMediaType type = ist->par->codec_type; | |
| 963 | |||
| 964 |
3/4✓ Branch 0 taken 7879 times.
✓ Branch 1 taken 326 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7879 times.
|
8205 | if (ds->discard || type == AVMEDIA_TYPE_ATTACHMENT) |
| 965 | 326 | continue; | |
| 966 | |||
| 967 | 7879 | total_size += ds->data_size; | |
| 968 | 7879 | total_packets += ds->nb_packets; | |
| 969 | |||
| 970 | 7879 | av_log(f, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", | |
| 971 | f->index, j, av_get_media_type_string(type)); | ||
| 972 | 7879 | av_log(f, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", | |
| 973 | ds->nb_packets, ds->data_size); | ||
| 974 | |||
| 975 |
2/2✓ Branch 0 taken 7073 times.
✓ Branch 1 taken 806 times.
|
7879 | if (ds->decoding_needed) { |
| 976 | 7073 | av_log(f, AV_LOG_VERBOSE, | |
| 977 | "%"PRIu64" frames decoded; %"PRIu64" decode errors", | ||
| 978 | 7073 | ist->decoder->frames_decoded, ist->decoder->decode_errors); | |
| 979 |
2/2✓ Branch 0 taken 1297 times.
✓ Branch 1 taken 5776 times.
|
7073 | if (type == AVMEDIA_TYPE_AUDIO) |
| 980 | 1297 | av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->decoder->samples_decoded); | |
| 981 | 7073 | av_log(f, AV_LOG_VERBOSE, "; "); | |
| 982 | } | ||
| 983 | |||
| 984 | 7879 | av_log(f, AV_LOG_VERBOSE, "\n"); | |
| 985 | } | ||
| 986 | |||
| 987 | 7584 | av_log(f, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", | |
| 988 | total_packets, total_size); | ||
| 989 | 7584 | } | |
| 990 | |||
| 991 | 8225 | static void ist_free(InputStream **pist) | |
| 992 | { | ||
| 993 | 8225 | InputStream *ist = *pist; | |
| 994 | DemuxStream *ds; | ||
| 995 | |||
| 996 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (!ist) |
| 997 | ✗ | return; | |
| 998 | 8225 | ds = ds_from_ist(ist); | |
| 999 | |||
| 1000 | 8225 | dec_free(&ist->decoder); | |
| 1001 | |||
| 1002 | 8225 | av_dict_free(&ds->decoder_opts); | |
| 1003 | 8225 | av_freep(&ist->filters); | |
| 1004 | 8225 | av_freep(&ds->dec_opts.hwaccel_device); | |
| 1005 | |||
| 1006 | 8225 | avcodec_parameters_free(&ist->par); | |
| 1007 | |||
| 1008 | 8225 | av_frame_free(&ds->decoded_params); | |
| 1009 | |||
| 1010 | 8225 | av_freep(&ds->dsg); | |
| 1011 | 8225 | av_bsf_free(&ds->bsf); | |
| 1012 | |||
| 1013 | 8225 | av_freep(pist); | |
| 1014 | } | ||
| 1015 | |||
| 1016 | 75 | static void istg_free(InputStreamGroup **pistg) | |
| 1017 | { | ||
| 1018 | 75 | InputStreamGroup *istg = *pistg; | |
| 1019 | DemuxStreamGroup *dsg; | ||
| 1020 | |||
| 1021 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
|
75 | if (!istg) |
| 1022 | ✗ | return; | |
| 1023 | |||
| 1024 | 75 | dsg = dsg_from_istg(istg); | |
| 1025 | |||
| 1026 | 75 | av_bsf_graph_free(&dsg->graph); | |
| 1027 | |||
| 1028 | 75 | av_freep(pistg); | |
| 1029 | } | ||
| 1030 | |||
| 1031 | 7606 | void ifile_close(InputFile **pf) | |
| 1032 | { | ||
| 1033 | 7606 | InputFile *f = *pf; | |
| 1034 | 7606 | Demuxer *d = demuxer_from_ifile(f); | |
| 1035 | |||
| 1036 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
|
7606 | if (!f) |
| 1037 | ✗ | return; | |
| 1038 | |||
| 1039 |
2/2✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 22 times.
|
7606 | if (d->read_started) |
| 1040 | 7584 | demux_final_stats(d); | |
| 1041 | |||
| 1042 |
2/2✓ Branch 0 taken 8225 times.
✓ Branch 1 taken 7606 times.
|
15831 | for (int i = 0; i < f->nb_streams; i++) |
| 1043 | 8225 | ist_free(&f->streams[i]); | |
| 1044 | 7606 | av_freep(&f->streams); | |
| 1045 | |||
| 1046 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7606 times.
|
7681 | for (int i = 0; i < f->nb_stream_groups; i++) |
| 1047 | 75 | istg_free(&f->stream_groups[i]); | |
| 1048 | 7606 | av_freep(&f->stream_groups); | |
| 1049 | |||
| 1050 | 7606 | avformat_close_input(&f->ctx); | |
| 1051 | |||
| 1052 | 7606 | av_packet_free(&d->pkt_heartbeat); | |
| 1053 | |||
| 1054 | 7606 | av_freep(pf); | |
| 1055 | } | ||
| 1056 | |||
| 1057 | 7978 | int ist_use(InputStream *ist, int decoding_needed, | |
| 1058 | const ViewSpecifier *vs, SchedulerNode *src) | ||
| 1059 | { | ||
| 1060 | 7978 | Demuxer *d = demuxer_from_ifile(ist->file); | |
| 1061 | 7978 | DemuxStream *ds = ds_from_ist(ist); | |
| 1062 | int ret; | ||
| 1063 | |||
| 1064 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7978 times.
|
7978 | if (ist->user_set_discard == AVDISCARD_ALL) { |
| 1065 | ✗ | av_log(ist, AV_LOG_ERROR, "Cannot %s a disabled input stream\n", | |
| 1066 | decoding_needed ? "decode" : "streamcopy"); | ||
| 1067 | ✗ | return AVERROR(EINVAL); | |
| 1068 | } | ||
| 1069 | |||
| 1070 |
3/4✓ Branch 0 taken 7144 times.
✓ Branch 1 taken 834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7144 times.
|
7978 | if (decoding_needed && !ist->dec) { |
| 1071 | ✗ | av_log(ist, AV_LOG_ERROR, | |
| 1072 | "Decoding requested, but no decoder found for: %s\n", | ||
| 1073 | ✗ | avcodec_get_name(ist->par->codec_id)); | |
| 1074 | ✗ | return AVERROR(EINVAL); | |
| 1075 | } | ||
| 1076 | |||
| 1077 |
2/2✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 96 times.
|
7978 | if (ds->sch_idx_stream < 0) { |
| 1078 | 7882 | ret = sch_add_demux_stream(d->sch, d->f.index); | |
| 1079 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7882 times.
|
7882 | if (ret < 0) |
| 1080 | ✗ | return ret; | |
| 1081 | 7882 | ds->sch_idx_stream = ret; | |
| 1082 | } | ||
| 1083 | |||
| 1084 |
2/2✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 96 times.
|
7978 | if (ds->discard) { |
| 1085 | 7882 | ds->discard = 0; | |
| 1086 | 7882 | d->nb_streams_used++; | |
| 1087 | } | ||
| 1088 | |||
| 1089 | 7978 | ist->st->discard = ist->user_set_discard; | |
| 1090 | 7978 | ds->decoding_needed |= decoding_needed; | |
| 1091 | 7978 | ds->streamcopy_needed |= !decoding_needed; | |
| 1092 | |||
| 1093 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7975 times.
|
7978 | for (int i = 0; i < ds->nb_dsg; i++) { |
| 1094 | 3 | DemuxStreamGroup *dsg = ds->dsg[i]; | |
| 1095 | 3 | const InputStreamGroup *istg = &dsg->istg; | |
| 1096 | |||
| 1097 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | if (!dsg->graph || istg->stg->type != AV_STREAM_GROUP_PARAMS_LCEVC) |
| 1098 | ✗ | continue; | |
| 1099 | 3 | const AVStreamGroupLayeredVideo *lcevc = istg->stg->params.layered_video; | |
| 1100 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (ist->st->index == istg->stg->streams[lcevc->el_index]->index) |
| 1101 | 3 | break; | |
| 1102 | |||
| 1103 | ✗ | AVBitStreamFilterContext *lcevc_merge = av_bsf_graph_get_filter(dsg->graph, "lcevc_merge"); | |
| 1104 | |||
| 1105 | ✗ | for (int j = 0; j < 2; j++) { | |
| 1106 | ✗ | ret = av_bsf_init_dict(dsg->lcevc[j], NULL); | |
| 1107 | ✗ | if (ret < 0) | |
| 1108 | ✗ | return ret; | |
| 1109 | } | ||
| 1110 | |||
| 1111 | ✗ | ret = av_bsf_init_dict(lcevc_merge, NULL); | |
| 1112 | ✗ | if (ret < 0) | |
| 1113 | ✗ | return ret; | |
| 1114 | ✗ | ret = av_bsf_init_dict(dsg->sink, NULL); | |
| 1115 | ✗ | if (ret < 0) | |
| 1116 | ✗ | return ret; | |
| 1117 | |||
| 1118 | ✗ | ret = av_bsf_link(dsg->lcevc[0], 0, lcevc_merge, 0); | |
| 1119 | ✗ | if (ret < 0) | |
| 1120 | ✗ | return ret; | |
| 1121 | ✗ | ret = av_bsf_link(dsg->lcevc[1], 0, lcevc_merge, 1); | |
| 1122 | ✗ | if (ret < 0) | |
| 1123 | ✗ | return ret; | |
| 1124 | ✗ | ret = av_bsf_link(lcevc_merge, 0, dsg->sink, 0); | |
| 1125 | ✗ | if (ret < 0) | |
| 1126 | ✗ | return ret; | |
| 1127 | |||
| 1128 | ✗ | ret = av_bsf_graph_config(dsg->graph, d); | |
| 1129 | ✗ | if (ret < 0) | |
| 1130 | ✗ | return ret; | |
| 1131 | |||
| 1132 | ✗ | InputStream *lcevc_ist = d->f.streams[istg->stg->streams[lcevc->el_index]->index]; | |
| 1133 | ✗ | lcevc_ist->st->discard = 0; | |
| 1134 | |||
| 1135 | ✗ | dsg->graph_enabled = 1; | |
| 1136 | |||
| 1137 | ✗ | break; | |
| 1138 | } | ||
| 1139 | |||
| 1140 |
4/4✓ Branch 0 taken 7144 times.
✓ Branch 1 taken 834 times.
✓ Branch 2 taken 7074 times.
✓ Branch 3 taken 70 times.
|
7978 | if (decoding_needed && ds->sch_idx_dec < 0) { |
| 1141 | 7074 | int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; | |
| 1142 | 7074 | int is_unreliable = !!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS); | |
| 1143 | int64_t use_wallclock_as_timestamps; | ||
| 1144 | |||
| 1145 | 7074 | ret = av_opt_get_int(d->f.ctx, "use_wallclock_as_timestamps", 0, &use_wallclock_as_timestamps); | |
| 1146 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
|
7074 | if (ret < 0) |
| 1147 | ✗ | return ret; | |
| 1148 | |||
| 1149 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
|
7074 | if (use_wallclock_as_timestamps) |
| 1150 | ✗ | is_unreliable = 0; | |
| 1151 | |||
| 1152 | 21222 | ds->dec_opts.flags |= (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) | | |
| 1153 |
2/2✓ Branch 0 taken 597 times.
✓ Branch 1 taken 6477 times.
|
7074 | (!!is_unreliable * DECODER_FLAG_TS_UNRELIABLE) | |
| 1154 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7072 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
7074 | (!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS); |
| 1155 | |||
| 1156 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 7042 times.
|
7074 | if (ist->framerate.num) { |
| 1157 | 32 | ds->dec_opts.flags |= DECODER_FLAG_FRAMERATE_FORCED; | |
| 1158 | 32 | ds->dec_opts.framerate = ist->framerate; | |
| 1159 | } else | ||
| 1160 | 7042 | ds->dec_opts.framerate = ist->st->avg_frame_rate; | |
| 1161 | |||
| 1162 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7073 times.
|
7074 | if (ist->dec->id == AV_CODEC_ID_DVB_SUBTITLE && |
| 1163 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | (ds->decoding_needed & DECODING_FOR_OST)) { |
| 1164 | 1 | av_dict_set(&ds->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); | |
| 1165 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ds->decoding_needed & DECODING_FOR_FILTER) |
| 1166 | ✗ | av_log(ist, AV_LOG_WARNING, | |
| 1167 | "Warning using DVB subtitles for filtering and output at the " | ||
| 1168 | "same time is not fully supported, also see -compute_edt [0|1]\n"); | ||
| 1169 | } | ||
| 1170 | |||
| 1171 | 7074 | snprintf(ds->dec_name, sizeof(ds->dec_name), "%d:%d", ist->file->index, ist->index); | |
| 1172 | 7074 | ds->dec_opts.name = ds->dec_name; | |
| 1173 | |||
| 1174 | 7074 | ds->dec_opts.codec = ist->dec; | |
| 1175 | 7074 | ds->dec_opts.par = ist->par; | |
| 1176 | |||
| 1177 | 7074 | ds->dec_opts.log_parent = ist; | |
| 1178 | |||
| 1179 | 7074 | ds->decoded_params = av_frame_alloc(); | |
| 1180 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
|
7074 | if (!ds->decoded_params) |
| 1181 | ✗ | return AVERROR(ENOMEM); | |
| 1182 | |||
| 1183 | 7074 | ret = dec_init(&ist->decoder, d->sch, | |
| 1184 | 7074 | &ds->decoder_opts, &ds->dec_opts, ds->decoded_params); | |
| 1185 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
|
7074 | if (ret < 0) |
| 1186 | ✗ | return ret; | |
| 1187 | 7074 | ds->sch_idx_dec = ret; | |
| 1188 | |||
| 1189 | 7074 | ret = sch_connect(d->sch, SCH_DSTREAM(d->f.index, ds->sch_idx_stream), | |
| 1190 | 7074 | SCH_DEC_IN(ds->sch_idx_dec)); | |
| 1191 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7074 times.
|
7074 | if (ret < 0) |
| 1192 | ✗ | return ret; | |
| 1193 | |||
| 1194 | 7074 | d->have_audio_dec |= is_audio; | |
| 1195 | } | ||
| 1196 | |||
| 1197 |
4/4✓ Branch 0 taken 7144 times.
✓ Branch 1 taken 834 times.
✓ Branch 2 taken 5742 times.
✓ Branch 3 taken 1402 times.
|
7978 | if (decoding_needed && ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { |
| 1198 | 5742 | ret = dec_request_view(ist->decoder, vs, src); | |
| 1199 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5742 times.
|
5742 | if (ret < 0) |
| 1200 | ✗ | return ret; | |
| 1201 | } else { | ||
| 1202 | 2236 | *src = decoding_needed ? | |
| 1203 |
2/2✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 834 times.
|
2236 | SCH_DEC_OUT(ds->sch_idx_dec, 0) : |
| 1204 | 834 | SCH_DSTREAM(d->f.index, ds->sch_idx_stream); | |
| 1205 | } | ||
| 1206 | |||
| 1207 | 7978 | return 0; | |
| 1208 | } | ||
| 1209 | |||
| 1210 | 7102 | int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, | |
| 1211 | const ViewSpecifier *vs, InputFilterOptions *opts, | ||
| 1212 | SchedulerNode *src) | ||
| 1213 | { | ||
| 1214 | 7102 | Demuxer *d = demuxer_from_ifile(ist->file); | |
| 1215 | 7102 | DemuxStream *ds = ds_from_ist(ist); | |
| 1216 | 7102 | int64_t tsoffset = 0; | |
| 1217 | int ret; | ||
| 1218 | |||
| 1219 |
2/2✓ Branch 0 taken 6928 times.
✓ Branch 1 taken 174 times.
|
7102 | ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER, |
| 1220 | vs, src); | ||
| 1221 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | if (ret < 0) |
| 1222 | ✗ | return ret; | |
| 1223 | |||
| 1224 | 7102 | ret = GROW_ARRAY(ist->filters, ist->nb_filters); | |
| 1225 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | if (ret < 0) |
| 1226 | ✗ | return ret; | |
| 1227 | |||
| 1228 | 7102 | ist->filters[ist->nb_filters - 1] = ifilter; | |
| 1229 | |||
| 1230 |
2/2✓ Branch 0 taken 5742 times.
✓ Branch 1 taken 1360 times.
|
7102 | if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { |
| 1231 | 5742 | const AVPacketSideData *sd = av_packet_side_data_get(ist->par->coded_side_data, | |
| 1232 | 5742 | ist->par->nb_coded_side_data, | |
| 1233 | AV_PKT_DATA_FRAME_CROPPING); | ||
| 1234 |
3/4✓ Branch 0 taken 32 times.
✓ Branch 1 taken 5710 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
5742 | if (ist->framerate.num > 0 && ist->framerate.den > 0) { |
| 1235 | 32 | opts->framerate = ist->framerate; | |
| 1236 | 32 | opts->flags |= IFILTER_FLAG_CFR; | |
| 1237 | } else | ||
| 1238 | 5710 | opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); | |
| 1239 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5735 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
5742 | if (sd && sd->size >= sizeof(uint32_t) * 4) { |
| 1240 | 7 | opts->crop_top = AV_RL32(sd->data + 0); | |
| 1241 | 7 | opts->crop_bottom = AV_RL32(sd->data + 4); | |
| 1242 | 7 | opts->crop_left = AV_RL32(sd->data + 8); | |
| 1243 | 7 | opts->crop_right = AV_RL32(sd->data + 12); | |
| 1244 |
3/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
7 | if (ds->apply_cropping && ds->apply_cropping != CROP_CODEC && |
| 1245 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | (opts->crop_top | opts->crop_bottom | opts->crop_left | opts->crop_right)) |
| 1246 | 6 | opts->flags |= IFILTER_FLAG_CROP; | |
| 1247 | } | ||
| 1248 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1356 times.
|
1360 | } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
| 1249 | /* Compute the size of the canvas for the subtitles stream. | ||
| 1250 | If the subtitles codecpar has set a size, use it. Otherwise use the | ||
| 1251 | maximum dimensions of the video streams in the same file. */ | ||
| 1252 | 4 | opts->sub2video_width = ist->par->width; | |
| 1253 | 4 | opts->sub2video_height = ist->par->height; | |
| 1254 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
4 | if (!(opts->sub2video_width && opts->sub2video_height)) { |
| 1255 | ✗ | for (int j = 0; j < d->f.nb_streams; j++) { | |
| 1256 | ✗ | AVCodecParameters *par1 = d->f.streams[j]->par; | |
| 1257 | ✗ | if (par1->codec_type == AVMEDIA_TYPE_VIDEO) { | |
| 1258 | ✗ | opts->sub2video_width = FFMAX(opts->sub2video_width, par1->width); | |
| 1259 | ✗ | opts->sub2video_height = FFMAX(opts->sub2video_height, par1->height); | |
| 1260 | } | ||
| 1261 | } | ||
| 1262 | } | ||
| 1263 | |||
| 1264 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
4 | if (!(opts->sub2video_width && opts->sub2video_height)) { |
| 1265 | ✗ | opts->sub2video_width = FFMAX(opts->sub2video_width, 720); | |
| 1266 | ✗ | opts->sub2video_height = FFMAX(opts->sub2video_height, 576); | |
| 1267 | } | ||
| 1268 | |||
| 1269 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (!d->pkt_heartbeat) { |
| 1270 | 4 | d->pkt_heartbeat = av_packet_alloc(); | |
| 1271 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (!d->pkt_heartbeat) |
| 1272 | ✗ | return AVERROR(ENOMEM); | |
| 1273 | } | ||
| 1274 | 4 | ds->have_sub2video = 1; | |
| 1275 | } | ||
| 1276 | |||
| 1277 | 7102 | ret = av_frame_copy_props(opts->fallback, ds->decoded_params); | |
| 1278 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | if (ret < 0) |
| 1279 | ✗ | return ret; | |
| 1280 | 7102 | opts->fallback->format = ds->decoded_params->format; | |
| 1281 | 7102 | opts->fallback->width = ds->decoded_params->width; | |
| 1282 | 7102 | opts->fallback->height = ds->decoded_params->height; | |
| 1283 | |||
| 1284 | 7102 | ret = av_channel_layout_copy(&opts->fallback->ch_layout, &ds->decoded_params->ch_layout); | |
| 1285 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | if (ret < 0) |
| 1286 | ✗ | return ret; | |
| 1287 | |||
| 1288 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7098 times.
|
7102 | if (copy_ts) { |
| 1289 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | tsoffset = d->f.start_time == AV_NOPTS_VALUE ? 0 : d->f.start_time; |
| 1290 |
3/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
|
4 | if (!start_at_zero && d->f.ctx->start_time != AV_NOPTS_VALUE) |
| 1291 | 3 | tsoffset += d->f.ctx->start_time; | |
| 1292 | } | ||
| 1293 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1 times.
|
23 | opts->trim_start_us = ((d->f.start_time == AV_NOPTS_VALUE) || !d->accurate_seek) ? |
| 1294 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 7079 times.
|
7125 | AV_NOPTS_VALUE : tsoffset; |
| 1295 | 7102 | opts->trim_end_us = d->recording_time; | |
| 1296 | |||
| 1297 | 7102 | opts->name = av_strdup(ds->dec_name); | |
| 1298 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | if (!opts->name) |
| 1299 | ✗ | return AVERROR(ENOMEM); | |
| 1300 | |||
| 1301 | 21306 | opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | | |
| 1302 |
2/2✓ Branch 0 taken 7099 times.
✓ Branch 1 taken 3 times.
|
7102 | IFILTER_FLAG_REINIT * !!(ds->reinit_filters) | |
| 1303 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7102 times.
|
7102 | IFILTER_FLAG_DROPCHANGED* !!(ds->drop_changed); |
| 1304 | |||
| 1305 | 7102 | return 0; | |
| 1306 | } | ||
| 1307 | |||
| 1308 | 16297 | static int choose_decoder(const OptionsContext *o, void *logctx, | |
| 1309 | AVFormatContext *s, AVStream *st, | ||
| 1310 | enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type, | ||
| 1311 | const AVCodec **pcodec) | ||
| 1312 | |||
| 1313 | { | ||
| 1314 | 16297 | const char *codec_name = NULL; | |
| 1315 | |||
| 1316 | 16297 | opt_match_per_stream_str(logctx, &o->codec_names, s, st, &codec_name); | |
| 1317 |
2/2✓ Branch 0 taken 6394 times.
✓ Branch 1 taken 9903 times.
|
16297 | if (codec_name) { |
| 1318 | 6394 | int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec); | |
| 1319 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6394 times.
|
6394 | if (ret < 0) |
| 1320 | ✗ | return ret; | |
| 1321 | 6394 | st->codecpar->codec_id = (*pcodec)->id; | |
| 1322 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6394 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6394 | if (recast_media && st->codecpar->codec_type != (*pcodec)->type) |
| 1323 | ✗ | st->codecpar->codec_type = (*pcodec)->type; | |
| 1324 | 6394 | return 0; | |
| 1325 | } else { | ||
| 1326 |
3/4✓ Branch 0 taken 6011 times.
✓ Branch 1 taken 3892 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6011 times.
|
9903 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
| 1327 | ✗ | hwaccel_id == HWACCEL_GENERIC && | |
| 1328 | hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) { | ||
| 1329 | const AVCodec *c; | ||
| 1330 | ✗ | void *i = NULL; | |
| 1331 | |||
| 1332 | ✗ | while ((c = av_codec_iterate(&i))) { | |
| 1333 | const AVCodecHWConfig *config; | ||
| 1334 | |||
| 1335 | ✗ | if (c->id != st->codecpar->codec_id || | |
| 1336 | ✗ | !av_codec_is_decoder(c)) | |
| 1337 | ✗ | continue; | |
| 1338 | |||
| 1339 | ✗ | for (int j = 0; config = avcodec_get_hw_config(c, j); j++) { | |
| 1340 | ✗ | if (config->device_type == hwaccel_device_type) { | |
| 1341 | ✗ | av_log(logctx, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n", | |
| 1342 | ✗ | c->name, av_hwdevice_get_type_name(hwaccel_device_type)); | |
| 1343 | ✗ | *pcodec = c; | |
| 1344 | ✗ | return 0; | |
| 1345 | } | ||
| 1346 | } | ||
| 1347 | } | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | 9903 | *pcodec = avcodec_find_decoder(st->codecpar->codec_id); | |
| 1351 | 9903 | return 0; | |
| 1352 | } | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | 1854 | static int guess_input_channel_layout(InputStream *ist, AVCodecParameters *par, | |
| 1356 | int guess_layout_max) | ||
| 1357 | { | ||
| 1358 |
2/2✓ Branch 0 taken 827 times.
✓ Branch 1 taken 1027 times.
|
1854 | if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { |
| 1359 | char layout_name[256]; | ||
| 1360 | |||
| 1361 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 823 times.
|
827 | if (par->ch_layout.nb_channels > guess_layout_max) |
| 1362 | 14 | return 0; | |
| 1363 | 823 | av_channel_layout_default(&par->ch_layout, par->ch_layout.nb_channels); | |
| 1364 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 813 times.
|
823 | if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) |
| 1365 | 10 | return 0; | |
| 1366 | 813 | av_channel_layout_describe(&par->ch_layout, layout_name, sizeof(layout_name)); | |
| 1367 | 813 | av_log(ist, AV_LOG_WARNING, "Guessed Channel Layout: %s\n", layout_name); | |
| 1368 | } | ||
| 1369 | 1840 | return 1; | |
| 1370 | } | ||
| 1371 | |||
| 1372 | 6200 | static int add_display_matrix_to_stream(const OptionsContext *o, | |
| 1373 | AVFormatContext *ctx, InputStream *ist) | ||
| 1374 | { | ||
| 1375 | 6200 | AVStream *st = ist->st; | |
| 1376 | 6200 | DemuxStream *ds = ds_from_ist(ist); | |
| 1377 | AVPacketSideData *sd; | ||
| 1378 | 6200 | double rotation = DBL_MAX; | |
| 1379 | 6200 | int hflip = -1, vflip = -1; | |
| 1380 | 6200 | int hflip_set = 0, vflip_set = 0, rotation_set = 0; | |
| 1381 | int32_t *buf; | ||
| 1382 | |||
| 1383 | 6200 | opt_match_per_stream_dbl(ist, &o->display_rotations, ctx, st, &rotation); | |
| 1384 | 6200 | opt_match_per_stream_int(ist, &o->display_hflips, ctx, st, &hflip); | |
| 1385 | 6200 | opt_match_per_stream_int(ist, &o->display_vflips, ctx, st, &vflip); | |
| 1386 | |||
| 1387 | 6200 | rotation_set = rotation != DBL_MAX; | |
| 1388 | 6200 | hflip_set = hflip != -1; | |
| 1389 | 6200 | vflip_set = vflip != -1; | |
| 1390 | |||
| 1391 |
4/6✓ Branch 0 taken 6198 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6198 times.
✗ Branch 5 not taken.
|
6200 | if (!rotation_set && !hflip_set && !vflip_set) |
| 1392 | 6198 | return 0; | |
| 1393 | |||
| 1394 | 2 | sd = av_packet_side_data_new(&st->codecpar->coded_side_data, | |
| 1395 | 2 | &st->codecpar->nb_coded_side_data, | |
| 1396 | AV_PKT_DATA_DISPLAYMATRIX, | ||
| 1397 | sizeof(int32_t) * 9, 0); | ||
| 1398 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!sd) { |
| 1399 | ✗ | av_log(ist, AV_LOG_FATAL, "Failed to generate a display matrix!\n"); | |
| 1400 | ✗ | return AVERROR(ENOMEM); | |
| 1401 | } | ||
| 1402 | |||
| 1403 | 2 | buf = (int32_t *)sd->data; | |
| 1404 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
4 | av_display_rotation_set(buf, |
| 1405 | 2 | rotation_set ? -(rotation) : -0.0f); | |
| 1406 | |||
| 1407 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | av_display_matrix_flip(buf, |
| 1408 | hflip_set ? hflip : 0, | ||
| 1409 | vflip_set ? vflip : 0); | ||
| 1410 | |||
| 1411 | 2 | ds->force_display_matrix = 1; | |
| 1412 | |||
| 1413 | 2 | return 0; | |
| 1414 | } | ||
| 1415 | |||
| 1416 | 6200 | static int add_mastering_display_to_stream(const OptionsContext *o, | |
| 1417 | AVFormatContext *ctx, InputStream *ist) | ||
| 1418 | { | ||
| 1419 | 6200 | AVStream *st = ist->st; | |
| 1420 | 6200 | DemuxStream *ds = ds_from_ist(ist); | |
| 1421 | AVMasteringDisplayMetadata *master_display; | ||
| 1422 | AVPacketSideData *sd; | ||
| 1423 | 6200 | const char *p = NULL; | |
| 1424 | 6200 | const int chroma_den = 50000; | |
| 1425 | 6200 | const int luma_den = 10000; | |
| 1426 | size_t size; | ||
| 1427 | int ret; | ||
| 1428 | |||
| 1429 | 6200 | opt_match_per_stream_str(ist, &o->mastering_displays, ctx, st, &p); | |
| 1430 | |||
| 1431 |
1/2✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
|
6200 | if (!p) |
| 1432 | 6200 | return 0; | |
| 1433 | |||
| 1434 | ✗ | master_display = av_mastering_display_metadata_alloc_size(&size); | |
| 1435 | ✗ | if (!master_display) | |
| 1436 | ✗ | return AVERROR(ENOMEM); | |
| 1437 | |||
| 1438 | ✗ | ret = sscanf(p, | |
| 1439 | "G(%u,%u)B(%u,%u)R(%u,%u)WP(%u,%u)L(%u,%u)", | ||
| 1440 | ✗ | (unsigned*)&master_display->display_primaries[1][0].num, | |
| 1441 | ✗ | (unsigned*)&master_display->display_primaries[1][1].num, | |
| 1442 | ✗ | (unsigned*)&master_display->display_primaries[2][0].num, | |
| 1443 | ✗ | (unsigned*)&master_display->display_primaries[2][1].num, | |
| 1444 | ✗ | (unsigned*)&master_display->display_primaries[0][0].num, | |
| 1445 | ✗ | (unsigned*)&master_display->display_primaries[0][1].num, | |
| 1446 | ✗ | (unsigned*)&master_display->white_point[0].num, | |
| 1447 | ✗ | (unsigned*)&master_display->white_point[1].num, | |
| 1448 | ✗ | (unsigned*)&master_display->max_luminance.num, | |
| 1449 | ✗ | (unsigned*)&master_display->min_luminance.num); | |
| 1450 | |||
| 1451 | ✗ | if (ret != 10 || | |
| 1452 | ✗ | (unsigned)(master_display->display_primaries[1][0].num | master_display->display_primaries[1][1].num | | |
| 1453 | ✗ | master_display->display_primaries[2][0].num | master_display->display_primaries[2][1].num | | |
| 1454 | ✗ | master_display->display_primaries[0][0].num | master_display->display_primaries[0][1].num | | |
| 1455 | ✗ | master_display->white_point[0].num | master_display->white_point[1].num) > UINT16_MAX || | |
| 1456 | ✗ | (unsigned)(master_display->max_luminance.num | master_display->min_luminance.num) > INT_MAX || | |
| 1457 | ✗ | master_display->min_luminance.num > master_display->max_luminance.num) { | |
| 1458 | ✗ | av_freep(&master_display); | |
| 1459 | ✗ | av_log(ist, AV_LOG_ERROR, "Failed to parse mastering display option\n"); | |
| 1460 | ✗ | return AVERROR(EINVAL); | |
| 1461 | } | ||
| 1462 | |||
| 1463 | ✗ | master_display->display_primaries[1][0].den = chroma_den; | |
| 1464 | ✗ | master_display->display_primaries[1][1].den = chroma_den; | |
| 1465 | ✗ | master_display->display_primaries[2][0].den = chroma_den; | |
| 1466 | ✗ | master_display->display_primaries[2][1].den = chroma_den; | |
| 1467 | ✗ | master_display->display_primaries[0][0].den = chroma_den; | |
| 1468 | ✗ | master_display->display_primaries[0][1].den = chroma_den; | |
| 1469 | ✗ | master_display->white_point[0].den = chroma_den; | |
| 1470 | ✗ | master_display->white_point[1].den = chroma_den; | |
| 1471 | ✗ | master_display->max_luminance.den = luma_den; | |
| 1472 | ✗ | master_display->min_luminance.den = luma_den; | |
| 1473 | |||
| 1474 | ✗ | master_display->has_primaries = 1; | |
| 1475 | ✗ | master_display->has_luminance = 1; | |
| 1476 | |||
| 1477 | ✗ | sd = av_packet_side_data_add(&st->codecpar->coded_side_data, | |
| 1478 | ✗ | &st->codecpar->nb_coded_side_data, | |
| 1479 | AV_PKT_DATA_MASTERING_DISPLAY_METADATA, | ||
| 1480 | (uint8_t *)master_display, size, 0); | ||
| 1481 | ✗ | if (!sd) { | |
| 1482 | ✗ | av_freep(&master_display); | |
| 1483 | ✗ | return AVERROR(ENOMEM); | |
| 1484 | } | ||
| 1485 | |||
| 1486 | ✗ | ds->force_mastering_display = 1; | |
| 1487 | |||
| 1488 | ✗ | return 0; | |
| 1489 | } | ||
| 1490 | |||
| 1491 | 6200 | static int add_content_light_to_stream(const OptionsContext *o, | |
| 1492 | AVFormatContext *ctx, InputStream *ist) | ||
| 1493 | { | ||
| 1494 | 6200 | AVStream *st = ist->st; | |
| 1495 | 6200 | DemuxStream *ds = ds_from_ist(ist); | |
| 1496 | AVContentLightMetadata *cll; | ||
| 1497 | AVPacketSideData *sd; | ||
| 1498 | 6200 | const char *p = NULL; | |
| 1499 | size_t size; | ||
| 1500 | int ret; | ||
| 1501 | |||
| 1502 | 6200 | opt_match_per_stream_str(ist, &o->content_lights, ctx, st, &p); | |
| 1503 | |||
| 1504 |
1/2✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
|
6200 | if (!p) |
| 1505 | 6200 | return 0; | |
| 1506 | |||
| 1507 | ✗ | cll = av_content_light_metadata_alloc(&size); | |
| 1508 | ✗ | if (!cll) | |
| 1509 | ✗ | return AVERROR(ENOMEM); | |
| 1510 | |||
| 1511 | ✗ | ret = sscanf(p, "%u,%u", | |
| 1512 | ✗ | (unsigned*)&cll->MaxCLL, | |
| 1513 | ✗ | (unsigned*)&cll->MaxFALL); | |
| 1514 | |||
| 1515 | ✗ | if (ret != 2 || (unsigned)(cll->MaxCLL | cll->MaxFALL) > UINT16_MAX) { | |
| 1516 | ✗ | av_freep(&cll); | |
| 1517 | ✗ | av_log(ist, AV_LOG_ERROR, "Failed to parse content light option\n"); | |
| 1518 | ✗ | return AVERROR(EINVAL); | |
| 1519 | } | ||
| 1520 | |||
| 1521 | ✗ | sd = av_packet_side_data_add(&st->codecpar->coded_side_data, | |
| 1522 | ✗ | &st->codecpar->nb_coded_side_data, | |
| 1523 | AV_PKT_DATA_CONTENT_LIGHT_LEVEL, | ||
| 1524 | (uint8_t *)cll, size, 0); | ||
| 1525 | ✗ | if (!sd) { | |
| 1526 | ✗ | av_freep(&cll); | |
| 1527 | ✗ | return AVERROR(ENOMEM); | |
| 1528 | } | ||
| 1529 | |||
| 1530 | ✗ | ds->force_content_light = 1; | |
| 1531 | |||
| 1532 | ✗ | return 0; | |
| 1533 | } | ||
| 1534 | |||
| 1535 | 1431 | static const char *input_stream_item_name(void *obj) | |
| 1536 | { | ||
| 1537 | 1431 | const DemuxStream *ds = obj; | |
| 1538 | |||
| 1539 | 1431 | return ds->log_name; | |
| 1540 | } | ||
| 1541 | |||
| 1542 | static const AVClass input_stream_class = { | ||
| 1543 | .class_name = "InputStream", | ||
| 1544 | .version = LIBAVUTIL_VERSION_INT, | ||
| 1545 | .item_name = input_stream_item_name, | ||
| 1546 | .category = AV_CLASS_CATEGORY_DEMUXER, | ||
| 1547 | }; | ||
| 1548 | |||
| 1549 | 8225 | static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st) | |
| 1550 | { | ||
| 1551 | 8225 | const char *type_str = av_get_media_type_string(st->codecpar->codec_type); | |
| 1552 | 8225 | InputFile *f = &d->f; | |
| 1553 | DemuxStream *ds; | ||
| 1554 | |||
| 1555 | 8225 | ds = allocate_array_elem(&f->streams, sizeof(*ds), &f->nb_streams); | |
| 1556 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (!ds) |
| 1557 | ✗ | return NULL; | |
| 1558 | |||
| 1559 | 8225 | ds->sch_idx_stream = -1; | |
| 1560 | 8225 | ds->sch_idx_dec = -1; | |
| 1561 | |||
| 1562 | 8225 | ds->ist.st = st; | |
| 1563 | 8225 | ds->ist.file = f; | |
| 1564 | 8225 | ds->ist.index = st->index; | |
| 1565 | 8225 | ds->ist.class = &input_stream_class; | |
| 1566 | |||
| 1567 |
1/2✓ Branch 0 taken 8225 times.
✗ Branch 1 not taken.
|
8225 | snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s", |
| 1568 | 8225 | type_str ? *type_str : '?', d->f.index, st->index, | |
| 1569 | 8225 | avcodec_get_name(st->codecpar->codec_id)); | |
| 1570 | |||
| 1571 | 8225 | return ds; | |
| 1572 | } | ||
| 1573 | |||
| 1574 | 8225 | static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictionary **opts_used) | |
| 1575 | { | ||
| 1576 | 8225 | AVFormatContext *ic = d->f.ctx; | |
| 1577 | 8225 | AVCodecParameters *par = st->codecpar; | |
| 1578 | DemuxStream *ds; | ||
| 1579 | InputStream *ist; | ||
| 1580 | 8225 | const char *framerate = NULL, *hwaccel_device = NULL; | |
| 1581 | 8225 | const char *hwaccel = NULL; | |
| 1582 | 8225 | const char *apply_cropping = NULL; | |
| 1583 | 8225 | const char *hwaccel_output_format = NULL; | |
| 1584 | 8225 | const char *codec_tag = NULL; | |
| 1585 | 8225 | const char *bsfs = NULL; | |
| 1586 | char *next; | ||
| 1587 | 8225 | const char *discard_str = NULL; | |
| 1588 | AVBPrint bp; | ||
| 1589 | int ret; | ||
| 1590 | |||
| 1591 | 8225 | ds = demux_stream_alloc(d, st); | |
| 1592 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (!ds) |
| 1593 | ✗ | return AVERROR(ENOMEM); | |
| 1594 | |||
| 1595 | 8225 | ist = &ds->ist; | |
| 1596 | |||
| 1597 | 8225 | ds->discard = 1; | |
| 1598 | 8225 | st->discard = AVDISCARD_ALL; | |
| 1599 | 8225 | ds->first_dts = AV_NOPTS_VALUE; | |
| 1600 | 8225 | ds->next_dts = AV_NOPTS_VALUE; | |
| 1601 | |||
| 1602 | 8225 | ds->dec_opts.time_base = st->time_base; | |
| 1603 | |||
| 1604 | 8225 | ds->ts_scale = 1.0; | |
| 1605 | 8225 | opt_match_per_stream_dbl(ist, &o->ts_scale, ic, st, &ds->ts_scale); | |
| 1606 | |||
| 1607 | 8225 | ds->autorotate = 1; | |
| 1608 | 8225 | opt_match_per_stream_int(ist, &o->autorotate, ic, st, &ds->autorotate); | |
| 1609 | |||
| 1610 | 8225 | ds->apply_cropping = CROP_ALL; | |
| 1611 | 8225 | opt_match_per_stream_str(ist, &o->apply_cropping, ic, st, &apply_cropping); | |
| 1612 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8224 times.
|
8225 | if (apply_cropping) { |
| 1613 | 1 | const AVOption opts[] = { | |
| 1614 | { "apply_cropping", NULL, 0, AV_OPT_TYPE_INT, | ||
| 1615 | { .i64 = CROP_ALL }, CROP_DISABLED, CROP_CONTAINER, AV_OPT_FLAG_DECODING_PARAM, .unit = "apply_cropping" }, | ||
| 1616 | { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CROP_DISABLED }, .unit = "apply_cropping" }, | ||
| 1617 | { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CROP_ALL }, .unit = "apply_cropping" }, | ||
| 1618 | { "codec", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CROP_CODEC }, .unit = "apply_cropping" }, | ||
| 1619 | { "container", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CROP_CONTAINER }, .unit = "apply_cropping" }, | ||
| 1620 | { NULL }, | ||
| 1621 | }; | ||
| 1622 | 1 | const AVClass class = { | |
| 1623 | .class_name = "apply_cropping", | ||
| 1624 | .item_name = av_default_item_name, | ||
| 1625 | .option = opts, | ||
| 1626 | .version = LIBAVUTIL_VERSION_INT, | ||
| 1627 | }; | ||
| 1628 | 1 | const AVClass *pclass = &class; | |
| 1629 | |||
| 1630 | 1 | ret = av_opt_eval_int(&pclass, opts, apply_cropping, &ds->apply_cropping); | |
| 1631 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ret < 0) { |
| 1632 | ✗ | av_log(ist, AV_LOG_ERROR, "Invalid apply_cropping value '%s'.\n", apply_cropping); | |
| 1633 | ✗ | return ret; | |
| 1634 | } | ||
| 1635 | } | ||
| 1636 | |||
| 1637 | 8225 | opt_match_per_stream_str(ist, &o->codec_tags, ic, st, &codec_tag); | |
| 1638 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8223 times.
|
8225 | if (codec_tag) { |
| 1639 | 2 | uint32_t tag = strtol(codec_tag, &next, 0); | |
| 1640 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (*next) { |
| 1641 | 2 | uint8_t buf[4] = { 0 }; | |
| 1642 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag))); |
| 1643 | 2 | tag = AV_RL32(buf); | |
| 1644 | } | ||
| 1645 | |||
| 1646 | 2 | st->codecpar->codec_tag = tag; | |
| 1647 | } | ||
| 1648 | |||
| 1649 |
2/2✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 2025 times.
|
8225 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { |
| 1650 | 6200 | ret = add_display_matrix_to_stream(o, ic, ist); | |
| 1651 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
|
6200 | if (ret < 0) |
| 1652 | ✗ | return ret; | |
| 1653 | |||
| 1654 | 6200 | ret = add_mastering_display_to_stream(o, ic, ist); | |
| 1655 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
|
6200 | if (ret < 0) |
| 1656 | ✗ | return ret; | |
| 1657 | |||
| 1658 | 6200 | ret = add_content_light_to_stream(o, ic, ist); | |
| 1659 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
|
6200 | if (ret < 0) |
| 1660 | ✗ | return ret; | |
| 1661 | |||
| 1662 | 6200 | opt_match_per_stream_str(ist, &o->hwaccels, ic, st, &hwaccel); | |
| 1663 | 6200 | opt_match_per_stream_str(ist, &o->hwaccel_output_formats, ic, st, | |
| 1664 | &hwaccel_output_format); | ||
| 1665 |
4/6✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5861 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5861 times.
|
6200 | if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) { |
| 1666 | ✗ | av_log(ist, AV_LOG_WARNING, | |
| 1667 | "WARNING: defaulting hwaccel_output_format to cuda for compatibility " | ||
| 1668 | "with old commandlines. This behaviour is DEPRECATED and will be removed " | ||
| 1669 | "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n"); | ||
| 1670 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_CUDA; | |
| 1671 |
4/6✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5861 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5861 times.
|
6200 | } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "qsv")) { |
| 1672 | ✗ | av_log(ist, AV_LOG_WARNING, | |
| 1673 | "WARNING: defaulting hwaccel_output_format to qsv for compatibility " | ||
| 1674 | "with old commandlines. This behaviour is DEPRECATED and will be removed " | ||
| 1675 | "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n"); | ||
| 1676 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_QSV; | |
| 1677 |
4/6✓ Branch 0 taken 6200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5861 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5861 times.
|
6200 | } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "mediacodec")) { |
| 1678 | // There is no real AVHWFrameContext implementation. Set | ||
| 1679 | // hwaccel_output_format to avoid av_hwframe_transfer_data error. | ||
| 1680 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_MEDIACODEC; | |
| 1681 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
|
6200 | } else if (hwaccel_output_format) { |
| 1682 | ✗ | ds->dec_opts.hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format); | |
| 1683 | ✗ | if (ds->dec_opts.hwaccel_output_format == AV_PIX_FMT_NONE) { | |
| 1684 | ✗ | av_log(ist, AV_LOG_FATAL, "Unrecognised hwaccel output " | |
| 1685 | "format: %s", hwaccel_output_format); | ||
| 1686 | } | ||
| 1687 | } else { | ||
| 1688 | 6200 | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_NONE; | |
| 1689 | } | ||
| 1690 | |||
| 1691 |
2/2✓ Branch 0 taken 5861 times.
✓ Branch 1 taken 339 times.
|
6200 | if (hwaccel) { |
| 1692 | // The NVDEC hwaccels use a CUDA device, so remap the name here. | ||
| 1693 |
2/4✓ Branch 0 taken 5861 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5861 times.
|
5861 | if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid")) |
| 1694 | ✗ | hwaccel = "cuda"; | |
| 1695 | |||
| 1696 |
1/2✓ Branch 0 taken 5861 times.
✗ Branch 1 not taken.
|
5861 | if (!strcmp(hwaccel, "none")) |
| 1697 | 5861 | ds->dec_opts.hwaccel_id = HWACCEL_NONE; | |
| 1698 | ✗ | else if (!strcmp(hwaccel, "auto")) | |
| 1699 | ✗ | ds->dec_opts.hwaccel_id = HWACCEL_AUTO; | |
| 1700 | else { | ||
| 1701 | ✗ | enum AVHWDeviceType type = av_hwdevice_find_type_by_name(hwaccel); | |
| 1702 | ✗ | if (type != AV_HWDEVICE_TYPE_NONE) { | |
| 1703 | ✗ | ds->dec_opts.hwaccel_id = HWACCEL_GENERIC; | |
| 1704 | ✗ | ds->dec_opts.hwaccel_device_type = type; | |
| 1705 | } | ||
| 1706 | |||
| 1707 | ✗ | if (!ds->dec_opts.hwaccel_id) { | |
| 1708 | ✗ | av_log(ist, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n", | |
| 1709 | hwaccel); | ||
| 1710 | ✗ | av_log(ist, AV_LOG_FATAL, "Supported hwaccels: "); | |
| 1711 | ✗ | type = AV_HWDEVICE_TYPE_NONE; | |
| 1712 | ✗ | while ((type = av_hwdevice_iterate_types(type)) != | |
| 1713 | AV_HWDEVICE_TYPE_NONE) | ||
| 1714 | ✗ | av_log(ist, AV_LOG_FATAL, "%s ", | |
| 1715 | av_hwdevice_get_type_name(type)); | ||
| 1716 | ✗ | av_log(ist, AV_LOG_FATAL, "\n"); | |
| 1717 | ✗ | return AVERROR(EINVAL); | |
| 1718 | } | ||
| 1719 | } | ||
| 1720 | } | ||
| 1721 | |||
| 1722 | 6200 | opt_match_per_stream_str(ist, &o->hwaccel_devices, ic, st, &hwaccel_device); | |
| 1723 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6200 times.
|
6200 | if (hwaccel_device) { |
| 1724 | ✗ | ds->dec_opts.hwaccel_device = av_strdup(hwaccel_device); | |
| 1725 | ✗ | if (!ds->dec_opts.hwaccel_device) | |
| 1726 | ✗ | return AVERROR(ENOMEM); | |
| 1727 | } | ||
| 1728 | } | ||
| 1729 | |||
| 1730 | 8225 | ret = choose_decoder(o, ist, ic, st, ds->dec_opts.hwaccel_id, | |
| 1731 | ds->dec_opts.hwaccel_device_type, &ist->dec); | ||
| 1732 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (ret < 0) |
| 1733 | ✗ | return ret; | |
| 1734 | |||
| 1735 |
2/2✓ Branch 0 taken 8130 times.
✓ Branch 1 taken 95 times.
|
8225 | if (ist->dec) { |
| 1736 | 8130 | ret = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, | |
| 1737 | ic, st, ist->dec, &ds->decoder_opts, opts_used); | ||
| 1738 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8130 times.
|
8130 | if (ret < 0) |
| 1739 | ✗ | return ret; | |
| 1740 | } | ||
| 1741 | |||
| 1742 | 8225 | ds->reinit_filters = -1; | |
| 1743 | 8225 | opt_match_per_stream_int(ist, &o->reinit_filters, ic, st, &ds->reinit_filters); | |
| 1744 | |||
| 1745 | 8225 | ds->drop_changed = 0; | |
| 1746 | 8225 | opt_match_per_stream_int(ist, &o->drop_changed, ic, st, &ds->drop_changed); | |
| 1747 | |||
| 1748 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8225 | if (ds->drop_changed && ds->reinit_filters) { |
| 1749 | ✗ | if (ds->reinit_filters > 0) { | |
| 1750 | ✗ | av_log(ist, AV_LOG_ERROR, "drop_changed and reinit_filters both enabled. These are mutually exclusive.\n"); | |
| 1751 | ✗ | return AVERROR(EINVAL); | |
| 1752 | } | ||
| 1753 | ✗ | ds->reinit_filters = 0; | |
| 1754 | } | ||
| 1755 | |||
| 1756 | 8225 | ist->user_set_discard = AVDISCARD_NONE; | |
| 1757 | |||
| 1758 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8225 | if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) || |
| 1759 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
8225 | (o->audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) || |
| 1760 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8224 | (o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) || |
| 1761 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8224 | (o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)) |
| 1762 | 1 | ist->user_set_discard = AVDISCARD_ALL; | |
| 1763 | |||
| 1764 | 8225 | opt_match_per_stream_str(ist, &o->discard, ic, st, &discard_str); | |
| 1765 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (discard_str) { |
| 1766 | ✗ | ret = av_opt_set(ist->st, "discard", discard_str, 0); | |
| 1767 | ✗ | if (ret < 0) { | |
| 1768 | ✗ | av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str); | |
| 1769 | ✗ | return ret; | |
| 1770 | } | ||
| 1771 | ✗ | ist->user_set_discard = ist->st->discard; | |
| 1772 | } | ||
| 1773 | |||
| 1774 |
2/2✓ Branch 0 taken 109 times.
✓ Branch 1 taken 8116 times.
|
8225 | ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; |
| 1775 | |||
| 1776 | 8225 | av_dict_set_int(&ds->decoder_opts, "apply_cropping", | |
| 1777 |
3/4✓ Branch 0 taken 8224 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8224 times.
✗ Branch 3 not taken.
|
8225 | ds->apply_cropping && ds->apply_cropping != CROP_CONTAINER, 0); |
| 1778 | |||
| 1779 | 8225 | av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC); | |
| 1780 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8223 times.
|
8225 | if (ds->force_display_matrix) { |
| 1781 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0)) |
| 1782 | ✗ | av_bprintf(&bp, ","); | |
| 1783 | 2 | av_bprintf(&bp, "displaymatrix"); | |
| 1784 | } | ||
| 1785 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (ds->force_mastering_display) { |
| 1786 | ✗ | if (bp.len || av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0)) | |
| 1787 | ✗ | av_bprintf(&bp, ","); | |
| 1788 | ✗ | av_bprintf(&bp, "mastering_display_metadata"); | |
| 1789 | } | ||
| 1790 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (ds->force_content_light) { |
| 1791 | ✗ | if (bp.len || av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0)) | |
| 1792 | ✗ | av_bprintf(&bp, ","); | |
| 1793 | ✗ | av_bprintf(&bp, "content_light_level"); | |
| 1794 | } | ||
| 1795 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8223 times.
|
8225 | if (bp.len) |
| 1796 | 2 | av_dict_set(&ds->decoder_opts, "side_data_prefer_packet", bp.str, AV_DICT_APPEND); | |
| 1797 | 8225 | av_bprint_finalize(&bp, NULL); | |
| 1798 | |||
| 1799 | /* Attached pics are sparse, therefore we would not want to delay their decoding | ||
| 1800 | * till EOF. */ | ||
| 1801 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8186 times.
|
8225 | if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) |
| 1802 | 39 | av_dict_set(&ds->decoder_opts, "thread_type", "-frame", 0); | |
| 1803 | |||
| 1804 |
4/5✓ Branch 0 taken 6200 times.
✓ Branch 1 taken 1857 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
|
8225 | switch (par->codec_type) { |
| 1805 | 6200 | case AVMEDIA_TYPE_VIDEO: | |
| 1806 | 6200 | opt_match_per_stream_str(ist, &o->frame_rates, ic, st, &framerate); | |
| 1807 |
2/2✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6167 times.
|
6200 | if (framerate) { |
| 1808 | 33 | ret = av_parse_video_rate(&ist->framerate, framerate); | |
| 1809 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
|
33 | if (ret < 0) { |
| 1810 | ✗ | av_log(ist, AV_LOG_ERROR, "Error parsing framerate %s.\n", | |
| 1811 | framerate); | ||
| 1812 | ✗ | return ret; | |
| 1813 | } | ||
| 1814 | } | ||
| 1815 | 6200 | break; | |
| 1816 | 1857 | case AVMEDIA_TYPE_AUDIO: { | |
| 1817 | 1857 | const char *ch_layout_str = NULL; | |
| 1818 | |||
| 1819 | 1857 | opt_match_per_stream_str(ist, &o->audio_ch_layouts, ic, st, &ch_layout_str); | |
| 1820 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1854 times.
|
1857 | if (ch_layout_str) { |
| 1821 | AVChannelLayout ch_layout; | ||
| 1822 | 3 | ret = av_channel_layout_from_string(&ch_layout, ch_layout_str); | |
| 1823 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) { |
| 1824 | ✗ | av_log(ist, AV_LOG_ERROR, "Error parsing channel layout %s.\n", ch_layout_str); | |
| 1825 | ✗ | return ret; | |
| 1826 | } | ||
| 1827 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | if (par->ch_layout.nb_channels <= 0 || par->ch_layout.nb_channels == ch_layout.nb_channels) { |
| 1828 | 3 | av_channel_layout_uninit(&par->ch_layout); | |
| 1829 | 3 | par->ch_layout = ch_layout; | |
| 1830 | } else { | ||
| 1831 | ✗ | av_log(ist, AV_LOG_ERROR, | |
| 1832 | "Specified channel layout '%s' has %d channels, but input has %d channels.\n", | ||
| 1833 | ch_layout_str, ch_layout.nb_channels, par->ch_layout.nb_channels); | ||
| 1834 | ✗ | av_channel_layout_uninit(&ch_layout); | |
| 1835 | ✗ | return AVERROR(EINVAL); | |
| 1836 | } | ||
| 1837 | } else { | ||
| 1838 | 1854 | int guess_layout_max = INT_MAX; | |
| 1839 | 1854 | opt_match_per_stream_int(ist, &o->guess_layout_max, ic, st, &guess_layout_max); | |
| 1840 | 1854 | guess_input_channel_layout(ist, par, guess_layout_max); | |
| 1841 | } | ||
| 1842 | 1857 | break; | |
| 1843 | } | ||
| 1844 | 156 | case AVMEDIA_TYPE_DATA: | |
| 1845 | case AVMEDIA_TYPE_SUBTITLE: { | ||
| 1846 | 156 | const char *canvas_size = NULL; | |
| 1847 | |||
| 1848 | 156 | opt_match_per_stream_int(ist, &o->fix_sub_duration, ic, st, &ist->fix_sub_duration); | |
| 1849 | 156 | opt_match_per_stream_str(ist, &o->canvas_sizes, ic, st, &canvas_size); | |
| 1850 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
|
156 | if (canvas_size) { |
| 1851 | ✗ | ret = av_parse_video_size(&par->width, &par->height, | |
| 1852 | canvas_size); | ||
| 1853 | ✗ | if (ret < 0) { | |
| 1854 | ✗ | av_log(ist, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size); | |
| 1855 | ✗ | return ret; | |
| 1856 | } | ||
| 1857 | } | ||
| 1858 | 156 | break; | |
| 1859 | } | ||
| 1860 | 12 | case AVMEDIA_TYPE_ATTACHMENT: | |
| 1861 | case AVMEDIA_TYPE_UNKNOWN: | ||
| 1862 | 12 | break; | |
| 1863 | ✗ | default: av_assert0(0); | |
| 1864 | } | ||
| 1865 | |||
| 1866 | 8225 | ist->par = avcodec_parameters_alloc(); | |
| 1867 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (!ist->par) |
| 1868 | ✗ | return AVERROR(ENOMEM); | |
| 1869 | |||
| 1870 | 8225 | ret = avcodec_parameters_copy(ist->par, par); | |
| 1871 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (ret < 0) { |
| 1872 | ✗ | av_log(ist, AV_LOG_ERROR, "Error exporting stream parameters.\n"); | |
| 1873 | ✗ | return ret; | |
| 1874 | } | ||
| 1875 | |||
| 1876 |
2/2✓ Branch 0 taken 491 times.
✓ Branch 1 taken 7734 times.
|
8225 | if (ist->st->sample_aspect_ratio.num) |
| 1877 | 491 | ist->par->sample_aspect_ratio = ist->st->sample_aspect_ratio; | |
| 1878 | |||
| 1879 | 8225 | opt_match_per_stream_str(ist, &o->bitstream_filters, ic, st, &bsfs); | |
| 1880 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8223 times.
|
8225 | if (bsfs) { |
| 1881 | 2 | ret = av_bsf_list_parse_str(bsfs, &ds->bsf); | |
| 1882 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) { |
| 1883 | ✗ | av_log(ist, AV_LOG_ERROR, | |
| 1884 | "Error parsing bitstream filter sequence '%s': %s\n", | ||
| 1885 | ✗ | bsfs, av_err2str(ret)); | |
| 1886 | ✗ | return ret; | |
| 1887 | } | ||
| 1888 | |||
| 1889 | 2 | ret = avcodec_parameters_copy(ds->bsf->par_in, ist->par); | |
| 1890 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) |
| 1891 | ✗ | return ret; | |
| 1892 | 2 | ds->bsf->time_base_in = ist->st->time_base; | |
| 1893 | |||
| 1894 | 2 | ret = av_bsf_init(ds->bsf); | |
| 1895 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) { |
| 1896 | ✗ | av_log(ist, AV_LOG_ERROR, "Error initializing bitstream filters: %s\n", | |
| 1897 | ✗ | av_err2str(ret)); | |
| 1898 | ✗ | return ret; | |
| 1899 | } | ||
| 1900 | |||
| 1901 | 2 | ret = avcodec_parameters_copy(ist->par, ds->bsf->par_out); | |
| 1902 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (ret < 0) |
| 1903 | ✗ | return ret; | |
| 1904 | } | ||
| 1905 | |||
| 1906 | 8225 | ds->codec_desc = avcodec_descriptor_get(ist->par->codec_id); | |
| 1907 | |||
| 1908 | 8225 | return 0; | |
| 1909 | } | ||
| 1910 | |||
| 1911 | ✗ | static const char *input_stream_group_item_name(void *obj) | |
| 1912 | { | ||
| 1913 | ✗ | const DemuxStreamGroup *dsg = obj; | |
| 1914 | |||
| 1915 | ✗ | return dsg->log_name; | |
| 1916 | } | ||
| 1917 | |||
| 1918 | static const AVClass input_stream_group_class = { | ||
| 1919 | .class_name = "InputStreamGroup", | ||
| 1920 | .version = LIBAVUTIL_VERSION_INT, | ||
| 1921 | .item_name = input_stream_group_item_name, | ||
| 1922 | .category = AV_CLASS_CATEGORY_DEMUXER, | ||
| 1923 | }; | ||
| 1924 | |||
| 1925 | 75 | static DemuxStreamGroup *demux_stream_group_alloc(Demuxer *d, AVStreamGroup *stg) | |
| 1926 | { | ||
| 1927 | 75 | InputFile *f = &d->f; | |
| 1928 | DemuxStreamGroup *dsg; | ||
| 1929 | |||
| 1930 | 75 | dsg = allocate_array_elem(&f->stream_groups, sizeof(*dsg), &f->nb_stream_groups); | |
| 1931 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
|
75 | if (!dsg) |
| 1932 | ✗ | return NULL; | |
| 1933 | |||
| 1934 | 75 | dsg->istg.stg = stg; | |
| 1935 | 75 | dsg->istg.file = f; | |
| 1936 | 75 | dsg->istg.index = stg->index; | |
| 1937 | 75 | dsg->istg.class = &input_stream_group_class; | |
| 1938 | |||
| 1939 | 75 | snprintf(dsg->log_name, sizeof(dsg->log_name), "istg#%d:%d/%s", | |
| 1940 | d->f.index, stg->index, avformat_stream_group_name(stg->type)); | ||
| 1941 | |||
| 1942 | 75 | return dsg; | |
| 1943 | } | ||
| 1944 | |||
| 1945 | 6 | static int istg_parse_tile_grid(const OptionsContext *o, Demuxer *d, InputStreamGroup *istg) | |
| 1946 | { | ||
| 1947 | 6 | InputFile *f = &d->f; | |
| 1948 | 6 | AVFormatContext *ic = d->f.ctx; | |
| 1949 | 6 | AVStreamGroup *stg = istg->stg; | |
| 1950 | 6 | const AVStreamGroupTileGrid *tg = stg->params.tile_grid; | |
| 1951 | OutputFilterOptions opts; | ||
| 1952 | AVBPrint bp; | ||
| 1953 | char *graph_str; | ||
| 1954 | 6 | int autorotate = 1; | |
| 1955 | 6 | const char *apply_cropping = NULL; | |
| 1956 | int ret; | ||
| 1957 | |||
| 1958 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (tg->nb_tiles == 1) |
| 1959 | ✗ | return 0; | |
| 1960 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (!tg->nb_tiles) { |
| 1961 | ✗ | av_log(istg, AV_LOG_FATAL, "A demuxer exported an invalid tile group stream group. " | |
| 1962 | "This is a bug, please report it.\n"); | ||
| 1963 | ✗ | return AVERROR_BUG; | |
| 1964 | } | ||
| 1965 | |||
| 1966 | 6 | memset(&opts, 0, sizeof(opts)); | |
| 1967 | |||
| 1968 | 6 | opt_match_per_stream_group_int(istg, &o->autorotate, ic, stg, &autorotate); | |
| 1969 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if (autorotate) |
| 1970 | 6 | opts.flags |= OFILTER_FLAG_AUTOROTATE; | |
| 1971 | |||
| 1972 | 6 | opts.flags |= OFILTER_FLAG_CROP; | |
| 1973 | 6 | opt_match_per_stream_group_str(istg, &o->apply_cropping, ic, stg, &apply_cropping); | |
| 1974 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (apply_cropping) { |
| 1975 | char *p; | ||
| 1976 | ✗ | int crop = strtol(apply_cropping, &p, 0); | |
| 1977 | ✗ | if (*p) | |
| 1978 | ✗ | return AVERROR(EINVAL); | |
| 1979 | ✗ | if (!crop) | |
| 1980 | ✗ | opts.flags &= ~OFILTER_FLAG_CROP; | |
| 1981 | } | ||
| 1982 | |||
| 1983 | 6 | av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); | |
| 1984 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 6 times.
|
26 | for (int i = 0; i < tg->nb_tiles; i++) |
| 1985 | 20 | av_bprintf(&bp, "[%d:g:%d:%d]", f->index, stg->index, tg->offsets[i].idx); | |
| 1986 | 6 | av_bprintf(&bp, "xstack=inputs=%d:layout=", tg->nb_tiles); | |
| 1987 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6 times.
|
20 | for (int i = 0; i < tg->nb_tiles - 1; i++) |
| 1988 | 14 | av_bprintf(&bp, "%d_%d|", tg->offsets[i].horizontal, | |
| 1989 | 14 | tg->offsets[i].vertical); | |
| 1990 | 6 | av_bprintf(&bp, "%d_%d:fill=0x%02X%02X%02X@0x%02X", tg->offsets[tg->nb_tiles - 1].horizontal, | |
| 1991 | 6 | tg->offsets[tg->nb_tiles - 1].vertical, | |
| 1992 | 6 | tg->background[0], tg->background[1], | |
| 1993 | 6 | tg->background[2], tg->background[3]); | |
| 1994 | 6 | av_bprintf(&bp, "[%d:g:%d]", f->index, stg->index); | |
| 1995 | 6 | ret = av_bprint_finalize(&bp, &graph_str); | |
| 1996 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) |
| 1997 | ✗ | return ret; | |
| 1998 | |||
| 1999 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | if (tg->coded_width != tg->width || tg->coded_height != tg->height) { |
| 2000 | ✗ | opts.crop_top = tg->vertical_offset; | |
| 2001 | ✗ | opts.crop_bottom = tg->coded_height - tg->height - tg->vertical_offset; | |
| 2002 | ✗ | opts.crop_left = tg->horizontal_offset; | |
| 2003 | ✗ | opts.crop_right = tg->coded_width - tg->width - tg->horizontal_offset; | |
| 2004 | } | ||
| 2005 | |||
| 2006 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | for (int i = 0; i < tg->nb_coded_side_data; i++) { |
| 2007 | ✗ | const AVPacketSideData *sd = &tg->coded_side_data[i]; | |
| 2008 | |||
| 2009 | ✗ | ret = av_packet_side_data_to_frame(&opts.side_data, &opts.nb_side_data, sd, 0); | |
| 2010 | ✗ | if (ret < 0 && ret != AVERROR(EINVAL)) | |
| 2011 | ✗ | goto fail; | |
| 2012 | } | ||
| 2013 | |||
| 2014 | 6 | ret = fg_create(NULL, &graph_str, d->sch, &opts); | |
| 2015 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) |
| 2016 | ✗ | goto fail; | |
| 2017 | |||
| 2018 | 6 | istg->fg = filtergraphs[nb_filtergraphs-1]; | |
| 2019 | 6 | istg->fg->is_internal = 1; | |
| 2020 | |||
| 2021 | 6 | ret = 0; | |
| 2022 | 6 | fail: | |
| 2023 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) |
| 2024 | ✗ | av_freep(&graph_str); | |
| 2025 | |||
| 2026 | 6 | return ret; | |
| 2027 | } | ||
| 2028 | |||
| 2029 | 3 | static int istg_parse_lcevc(const OptionsContext *o, Demuxer *d, DemuxStreamGroup *dsg) | |
| 2030 | { | ||
| 2031 | 3 | InputFile *f = &d->f; | |
| 2032 | 3 | const AVStreamGroup *stg = dsg->istg.stg; | |
| 2033 | 3 | const AVStreamGroupLayeredVideo *lcevc = stg->params.layered_video; | |
| 2034 | 3 | const AVBitStreamFilter *filter, *lcevc_filter = av_bsf_get_by_name("lcevc_merge"); | |
| 2035 | 3 | const InputStream *lcevc_ist = f->streams[stg->streams[lcevc->el_index]->index]; | |
| 2036 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | const InputStream *base_ist = f->streams[stg->streams[!lcevc->el_index]->index]; |
| 2037 | int ret; | ||
| 2038 | |||
| 2039 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | if (!lcevc_filter || stg->nb_streams != 2) |
| 2040 | ✗ | return 0; | |
| 2041 | |||
| 2042 | 3 | dsg->graph = av_bsf_graph_alloc(); | |
| 2043 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if(!dsg->graph) |
| 2044 | ✗ | return AVERROR(ENOMEM); | |
| 2045 | |||
| 2046 | 3 | filter = av_bsf_get_by_name("source"); | |
| 2047 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!filter) |
| 2048 | ✗ | return AVERROR_BUG; | |
| 2049 | |||
| 2050 | 3 | ret = av_bsf_graph_alloc_filter(&dsg->lcevc[0], filter, "lcevc_merge_base", dsg->graph); | |
| 2051 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2052 | ✗ | return ret; | |
| 2053 | 3 | av_opt_set_q(dsg->lcevc[0]->priv_data, "time_base", base_ist->st->time_base, 0); | |
| 2054 | 3 | ret = av_bsf_source_parameters_set(dsg->lcevc[0], base_ist->par); | |
| 2055 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2056 | ✗ | return ret; | |
| 2057 | |||
| 2058 | 3 | ret = av_bsf_graph_alloc_filter(&dsg->lcevc[1], filter, "lcevc_merge_enhancement", dsg->graph); | |
| 2059 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2060 | ✗ | return ret; | |
| 2061 | 3 | av_opt_set_q(dsg->lcevc[1]->priv_data, "time_base", lcevc_ist->st->time_base, 0); | |
| 2062 | 3 | ret = av_bsf_source_parameters_set(dsg->lcevc[1], lcevc_ist->par); | |
| 2063 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2064 | ✗ | return ret; | |
| 2065 | |||
| 2066 | 3 | ret = av_bsf_graph_alloc_filter(NULL, lcevc_filter, "lcevc_merge", dsg->graph); | |
| 2067 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2068 | ✗ | return ret; | |
| 2069 | |||
| 2070 | 3 | filter = av_bsf_get_by_name("sink"); | |
| 2071 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!filter) |
| 2072 | ✗ | return AVERROR_BUG; | |
| 2073 | 3 | ret = av_bsf_graph_alloc_filter(&dsg->sink, filter, "lcevc_merge_sink", dsg->graph); | |
| 2074 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2075 | ✗ | return ret; | |
| 2076 | |||
| 2077 | 3 | return 0; | |
| 2078 | } | ||
| 2079 | |||
| 2080 | 75 | static int istg_add(const OptionsContext *o, Demuxer *d, AVStreamGroup *stg) | |
| 2081 | { | ||
| 2082 | 75 | InputFile *f = &d->f; | |
| 2083 | DemuxStreamGroup *dsg; | ||
| 2084 | InputStreamGroup *istg; | ||
| 2085 | int ret; | ||
| 2086 | |||
| 2087 | 75 | dsg = demux_stream_group_alloc(d, stg); | |
| 2088 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
|
75 | if (!dsg) |
| 2089 | ✗ | return AVERROR(ENOMEM); | |
| 2090 | |||
| 2091 | 75 | istg = &dsg->istg; | |
| 2092 | |||
| 2093 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 72 times.
|
75 | switch (stg->type) { |
| 2094 | 3 | case AV_STREAM_GROUP_PARAMS_LCEVC: | |
| 2095 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
|
9 | for (int i = 0; i < istg->stg->nb_streams; i++) { |
| 2096 | 6 | DemuxStream *ds = ds_from_ist(f->streams[istg->stg->streams[i]->index]); | |
| 2097 | 6 | ret = av_dynarray_add_nofree(&ds->dsg, &ds->nb_dsg, dsg); | |
| 2098 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) |
| 2099 | ✗ | return ret; | |
| 2100 | } | ||
| 2101 | 3 | break; | |
| 2102 | 72 | default: | |
| 2103 | 72 | break; | |
| 2104 | } | ||
| 2105 | |||
| 2106 |
3/3✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 66 times.
|
75 | switch (stg->type) { |
| 2107 | 6 | case AV_STREAM_GROUP_PARAMS_TILE_GRID: | |
| 2108 | 6 | ret = istg_parse_tile_grid(o, d, istg); | |
| 2109 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (ret < 0) |
| 2110 | ✗ | return ret; | |
| 2111 | 6 | break; | |
| 2112 | 3 | case AV_STREAM_GROUP_PARAMS_LCEVC: | |
| 2113 | 3 | ret = istg_parse_lcevc(o, d, dsg); | |
| 2114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) |
| 2115 | ✗ | return ret; | |
| 2116 | 3 | break; | |
| 2117 | 66 | default: | |
| 2118 | 66 | break; | |
| 2119 | } | ||
| 2120 | |||
| 2121 | 75 | return 0; | |
| 2122 | } | ||
| 2123 | |||
| 2124 | ✗ | static int is_windows_reserved_device_name(const char *f) | |
| 2125 | { | ||
| 2126 | #if HAVE_DOS_PATHS | ||
| 2127 | for (const char *p = f; p && *p; ) { | ||
| 2128 | char stem[6], *s; | ||
| 2129 | av_strlcpy(stem, p, sizeof(stem)); | ||
| 2130 | if ((s = strchr(stem, '.'))) | ||
| 2131 | *s = 0; | ||
| 2132 | if ((s = strpbrk(stem, "123456789"))) | ||
| 2133 | *s = '1'; | ||
| 2134 | |||
| 2135 | if( !av_strcasecmp(stem, "AUX") || | ||
| 2136 | !av_strcasecmp(stem, "CON") || | ||
| 2137 | !av_strcasecmp(stem, "NUL") || | ||
| 2138 | !av_strcasecmp(stem, "PRN") || | ||
| 2139 | !av_strcasecmp(stem, "COM1") || | ||
| 2140 | !av_strcasecmp(stem, "LPT1") | ||
| 2141 | ) | ||
| 2142 | return 1; | ||
| 2143 | |||
| 2144 | p = strchr(p, '/'); | ||
| 2145 | if (p) | ||
| 2146 | p++; | ||
| 2147 | } | ||
| 2148 | #endif | ||
| 2149 | ✗ | return 0; | |
| 2150 | } | ||
| 2151 | |||
| 2152 | ✗ | static int safe_filename(const char *f, int allow_subdir) | |
| 2153 | { | ||
| 2154 | ✗ | const char *start = f; | |
| 2155 | |||
| 2156 | ✗ | if (!*f || is_windows_reserved_device_name(f)) | |
| 2157 | ✗ | return 0; | |
| 2158 | |||
| 2159 | ✗ | for (; *f; f++) { | |
| 2160 | /* A-Za-z0-9_- */ | ||
| 2161 | ✗ | if (!((unsigned)((*f | 32) - 'a') < 26 || | |
| 2162 | ✗ | (unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) { | |
| 2163 | ✗ | if (f == start) | |
| 2164 | ✗ | return 0; | |
| 2165 | ✗ | else if (allow_subdir && *f == '/') | |
| 2166 | ✗ | start = f + 1; | |
| 2167 | ✗ | else if (*f != '.') | |
| 2168 | ✗ | return 0; | |
| 2169 | } | ||
| 2170 | } | ||
| 2171 | ✗ | return 1; | |
| 2172 | } | ||
| 2173 | |||
| 2174 | ✗ | static int dump_attachment(InputStream *ist, const char *filename) | |
| 2175 | { | ||
| 2176 | ✗ | AVStream *st = ist->st; | |
| 2177 | int ret; | ||
| 2178 | ✗ | AVIOContext *out = NULL; | |
| 2179 | const AVDictionaryEntry *e; | ||
| 2180 | |||
| 2181 | ✗ | if (!st->codecpar->extradata_size) { | |
| 2182 | ✗ | av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n"); | |
| 2183 | ✗ | return 0; | |
| 2184 | } | ||
| 2185 | ✗ | if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) { | |
| 2186 | ✗ | filename = e->value; | |
| 2187 | ✗ | if (!safe_filename(filename, 0)) { | |
| 2188 | ✗ | av_log(ist, AV_LOG_ERROR, "Filename %s is unsafe\n", filename); | |
| 2189 | ✗ | return AVERROR(EINVAL); | |
| 2190 | } | ||
| 2191 | } | ||
| 2192 | ✗ | if (!*filename) { | |
| 2193 | ✗ | av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag"); | |
| 2194 | ✗ | return AVERROR(EINVAL); | |
| 2195 | } | ||
| 2196 | |||
| 2197 | ✗ | ret = assert_file_overwrite(filename); | |
| 2198 | ✗ | if (ret < 0) | |
| 2199 | ✗ | return ret; | |
| 2200 | |||
| 2201 | ✗ | if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { | |
| 2202 | ✗ | av_log(ist, AV_LOG_FATAL, "Could not open file %s for writing.\n", | |
| 2203 | filename); | ||
| 2204 | ✗ | return ret; | |
| 2205 | } | ||
| 2206 | |||
| 2207 | ✗ | avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size); | |
| 2208 | ✗ | ret = avio_close(out); | |
| 2209 | |||
| 2210 | ✗ | if (ret >= 0) | |
| 2211 | ✗ | av_log(ist, AV_LOG_INFO, "Wrote attachment (%d bytes) to '%s'\n", | |
| 2212 | ✗ | st->codecpar->extradata_size, filename); | |
| 2213 | |||
| 2214 | ✗ | return ret; | |
| 2215 | } | ||
| 2216 | |||
| 2217 | 745 | static const char *input_file_item_name(void *obj) | |
| 2218 | { | ||
| 2219 | 745 | const Demuxer *d = obj; | |
| 2220 | |||
| 2221 | 745 | return d->log_name; | |
| 2222 | } | ||
| 2223 | |||
| 2224 | static const AVClass input_file_class = { | ||
| 2225 | .class_name = "InputFile", | ||
| 2226 | .version = LIBAVUTIL_VERSION_INT, | ||
| 2227 | .item_name = input_file_item_name, | ||
| 2228 | .category = AV_CLASS_CATEGORY_DEMUXER, | ||
| 2229 | }; | ||
| 2230 | |||
| 2231 | 7606 | static Demuxer *demux_alloc(void) | |
| 2232 | { | ||
| 2233 | 7606 | Demuxer *d = allocate_array_elem(&input_files, sizeof(*d), &nb_input_files); | |
| 2234 | |||
| 2235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
|
7606 | if (!d) |
| 2236 | ✗ | return NULL; | |
| 2237 | |||
| 2238 | 7606 | d->f.class = &input_file_class; | |
| 2239 | 7606 | d->f.index = nb_input_files - 1; | |
| 2240 | |||
| 2241 | 7606 | snprintf(d->log_name, sizeof(d->log_name), "in#%d", d->f.index); | |
| 2242 | |||
| 2243 | 7606 | return d; | |
| 2244 | } | ||
| 2245 | |||
| 2246 | 7606 | int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) | |
| 2247 | { | ||
| 2248 | Demuxer *d; | ||
| 2249 | InputFile *f; | ||
| 2250 | AVFormatContext *ic; | ||
| 2251 | 7606 | const AVInputFormat *file_iformat = NULL; | |
| 2252 | 7606 | int err, ret = 0; | |
| 2253 | int64_t timestamp; | ||
| 2254 | 7606 | AVDictionary *opts_used = NULL; | |
| 2255 | 7606 | const char* video_codec_name = NULL; | |
| 2256 | 7606 | const char* audio_codec_name = NULL; | |
| 2257 | 7606 | const char* subtitle_codec_name = NULL; | |
| 2258 | 7606 | const char* data_codec_name = NULL; | |
| 2259 | 7606 | int scan_all_pmts_set = 0; | |
| 2260 | |||
| 2261 | 7606 | int64_t start_time = o->start_time; | |
| 2262 | 7606 | int64_t start_time_eof = o->start_time_eof; | |
| 2263 | 7606 | int64_t stop_time = o->stop_time; | |
| 2264 | 7606 | int64_t recording_time = o->recording_time; | |
| 2265 | |||
| 2266 | 7606 | d = demux_alloc(); | |
| 2267 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
|
7606 | if (!d) |
| 2268 | ✗ | return AVERROR(ENOMEM); | |
| 2269 | |||
| 2270 | 7606 | f = &d->f; | |
| 2271 | |||
| 2272 | 7606 | ret = sch_add_demux(sch, input_thread, d); | |
| 2273 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
|
7606 | if (ret < 0) |
| 2274 | ✗ | return ret; | |
| 2275 | 7606 | d->sch = sch; | |
| 2276 | |||
| 2277 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7606 | if (stop_time != INT64_MAX && recording_time != INT64_MAX) { |
| 2278 | ✗ | stop_time = INT64_MAX; | |
| 2279 | ✗ | av_log(d, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); | |
| 2280 | } | ||
| 2281 | |||
| 2282 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7606 | if (stop_time != INT64_MAX && recording_time == INT64_MAX) { |
| 2283 | ✗ | int64_t start = start_time == AV_NOPTS_VALUE ? 0 : start_time; | |
| 2284 | ✗ | if (stop_time <= start) { | |
| 2285 | ✗ | av_log(d, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); | |
| 2286 | ✗ | return AVERROR(EINVAL); | |
| 2287 | } else { | ||
| 2288 | ✗ | recording_time = stop_time - start; | |
| 2289 | } | ||
| 2290 | } | ||
| 2291 | |||
| 2292 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7605 times.
|
7606 | if (recording_time < 0) { |
| 2293 | 1 | av_log(d, AV_LOG_ERROR, "-t value must be non-negative; aborting.\n"); | |
| 2294 | 1 | return AVERROR(EINVAL); | |
| 2295 | } | ||
| 2296 | |||
| 2297 |
2/2✓ Branch 0 taken 3927 times.
✓ Branch 1 taken 3678 times.
|
7605 | if (o->format) { |
| 2298 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3927 times.
|
3927 | if (!(file_iformat = av_find_input_format(o->format))) { |
| 2299 | ✗ | av_log(d, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format); | |
| 2300 | ✗ | return AVERROR(EINVAL); | |
| 2301 | } | ||
| 2302 | } | ||
| 2303 | |||
| 2304 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | if (!strcmp(filename, "-")) |
| 2305 | ✗ | filename = "fd:"; | |
| 2306 | |||
| 2307 | 22815 | stdin_interaction &= strncmp(filename, "pipe:", 5) && | |
| 2308 |
2/4✓ Branch 0 taken 7605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7605 times.
✗ Branch 3 not taken.
|
15210 | strcmp(filename, "fd:") && |
| 2309 |
1/2✓ Branch 0 taken 7605 times.
✗ Branch 1 not taken.
|
7605 | strcmp(filename, "/dev/stdin"); |
| 2310 | |||
| 2311 | /* get default parameters from command line */ | ||
| 2312 | 7605 | ic = avformat_alloc_context(); | |
| 2313 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | if (!ic) |
| 2314 | ✗ | return AVERROR(ENOMEM); | |
| 2315 | 7605 | ic->name = av_strdup(d->log_name); | |
| 2316 |
2/2✓ Branch 0 taken 67 times.
✓ Branch 1 taken 7538 times.
|
7605 | if (o->audio_sample_rate.nb_opt) { |
| 2317 | 67 | av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0); | |
| 2318 | } | ||
| 2319 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7596 times.
|
7605 | if (o->audio_channels.nb_opt) { |
| 2320 | const AVClass *priv_class; | ||
| 2321 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
18 | if (file_iformat && (priv_class = file_iformat->priv_class) && |
| 2322 | 9 | av_opt_find(&priv_class, "ch_layout", NULL, 0, | |
| 2323 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
| 2324 | char buf[32]; | ||
| 2325 | 9 | snprintf(buf, sizeof(buf), "%dC", o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i); | |
| 2326 | 9 | av_dict_set(&o->g->format_opts, "ch_layout", buf, 0); | |
| 2327 | } | ||
| 2328 | } | ||
| 2329 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7602 times.
|
7605 | if (o->audio_ch_layouts.nb_opt) { |
| 2330 | const AVClass *priv_class; | ||
| 2331 |
4/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
4 | if (file_iformat && (priv_class = file_iformat->priv_class) && |
| 2332 | 1 | av_opt_find(&priv_class, "ch_layout", NULL, 0, | |
| 2333 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
| 2334 | 1 | av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts.opt[o->audio_ch_layouts.nb_opt - 1].u.str, 0); | |
| 2335 | } | ||
| 2336 | } | ||
| 2337 |
2/2✓ Branch 0 taken 33 times.
✓ Branch 1 taken 7572 times.
|
7605 | if (o->frame_rates.nb_opt) { |
| 2338 | const AVClass *priv_class; | ||
| 2339 | /* set the format-level framerate option; | ||
| 2340 | * this is important for video grabbers, e.g. x11 */ | ||
| 2341 |
4/6✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
65 | if (file_iformat && (priv_class = file_iformat->priv_class) && |
| 2342 | 32 | av_opt_find(&priv_class, "framerate", NULL, 0, | |
| 2343 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
| 2344 | 32 | av_dict_set(&o->g->format_opts, "framerate", | |
| 2345 | 32 | o->frame_rates.opt[o->frame_rates.nb_opt - 1].u.str, 0); | |
| 2346 | } | ||
| 2347 | } | ||
| 2348 |
2/2✓ Branch 0 taken 568 times.
✓ Branch 1 taken 7037 times.
|
7605 | if (o->frame_sizes.nb_opt) { |
| 2349 | 568 | av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes.opt[o->frame_sizes.nb_opt - 1].u.str, 0); | |
| 2350 | } | ||
| 2351 |
2/2✓ Branch 0 taken 577 times.
✓ Branch 1 taken 7028 times.
|
7605 | if (o->frame_pix_fmts.nb_opt) |
| 2352 | 577 | av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0); | |
| 2353 | |||
| 2354 | 7605 | video_codec_name = opt_match_per_type_str(&o->codec_names, 'v'); | |
| 2355 | 7605 | audio_codec_name = opt_match_per_type_str(&o->codec_names, 'a'); | |
| 2356 | 7605 | subtitle_codec_name = opt_match_per_type_str(&o->codec_names, 's'); | |
| 2357 | 7605 | data_codec_name = opt_match_per_type_str(&o->codec_names, 'd'); | |
| 2358 | |||
| 2359 |
2/2✓ Branch 0 taken 3163 times.
✓ Branch 1 taken 4442 times.
|
7605 | if (video_codec_name) |
| 2360 | 3163 | ret = err_merge(ret, find_codec(NULL, video_codec_name , AVMEDIA_TYPE_VIDEO , 0, | |
| 2361 | 3163 | &ic->video_codec)); | |
| 2362 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 7588 times.
|
7605 | if (audio_codec_name) |
| 2363 | 17 | ret = err_merge(ret, find_codec(NULL, audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, | |
| 2364 | 17 | &ic->audio_codec)); | |
| 2365 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | if (subtitle_codec_name) |
| 2366 | ✗ | ret = err_merge(ret, find_codec(NULL, subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, | |
| 2367 | ✗ | &ic->subtitle_codec)); | |
| 2368 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | if (data_codec_name) |
| 2369 | ✗ | ret = err_merge(ret, find_codec(NULL, data_codec_name , AVMEDIA_TYPE_DATA, 0, | |
| 2370 | ✗ | &ic->data_codec)); | |
| 2371 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | if (ret < 0) { |
| 2372 | ✗ | avformat_free_context(ic); | |
| 2373 | ✗ | return ret; | |
| 2374 | } | ||
| 2375 | |||
| 2376 |
2/2✓ Branch 0 taken 3163 times.
✓ Branch 1 taken 4442 times.
|
7605 | ic->video_codec_id = video_codec_name ? ic->video_codec->id : AV_CODEC_ID_NONE; |
| 2377 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 7588 times.
|
7605 | ic->audio_codec_id = audio_codec_name ? ic->audio_codec->id : AV_CODEC_ID_NONE; |
| 2378 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | ic->subtitle_codec_id = subtitle_codec_name ? ic->subtitle_codec->id : AV_CODEC_ID_NONE; |
| 2379 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7605 times.
|
7605 | ic->data_codec_id = data_codec_name ? ic->data_codec->id : AV_CODEC_ID_NONE; |
| 2380 | |||
| 2381 | 7605 | ic->flags |= AVFMT_FLAG_NONBLOCK; | |
| 2382 |
2/2✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7507 times.
|
7605 | if (o->bitexact) |
| 2383 | 98 | ic->flags |= AVFMT_FLAG_BITEXACT; | |
| 2384 | 7605 | ic->interrupt_callback = int_cb; | |
| 2385 | |||
| 2386 |
1/2✓ Branch 1 taken 7605 times.
✗ Branch 2 not taken.
|
7605 | if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) { |
| 2387 | 7605 | av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE); | |
| 2388 | 7605 | scan_all_pmts_set = 1; | |
| 2389 | } | ||
| 2390 | /* open the input file with generic avformat function */ | ||
| 2391 | 7605 | err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts); | |
| 2392 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7604 times.
|
7605 | if (err < 0) { |
| 2393 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (err != AVERROR_EXIT) |
| 2394 | 1 | av_log(d, AV_LOG_ERROR, | |
| 2395 | 1 | "Error opening input: %s\n", av_err2str(err)); | |
| 2396 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (err == AVERROR_PROTOCOL_NOT_FOUND) |
| 2397 | ✗ | av_log(d, AV_LOG_ERROR, "Did you mean file:%s?\n", filename); | |
| 2398 | 1 | return err; | |
| 2399 | } | ||
| 2400 | 7604 | f->ctx = ic; | |
| 2401 | |||
| 2402 | 7604 | av_strlcat(d->log_name, "/", sizeof(d->log_name)); | |
| 2403 | 7604 | av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name)); | |
| 2404 | 7604 | av_freep(&ic->name); | |
| 2405 | 7604 | ic->name = av_strdup(d->log_name); | |
| 2406 | |||
| 2407 |
1/2✓ Branch 0 taken 7604 times.
✗ Branch 1 not taken.
|
7604 | if (scan_all_pmts_set) |
| 2408 | 7604 | av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); | |
| 2409 | 7604 | remove_avoptions(&o->g->format_opts, o->g->codec_opts); | |
| 2410 | |||
| 2411 | 7604 | ret = check_avoptions(o->g->format_opts); | |
| 2412 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7604 times.
|
7604 | if (ret < 0) |
| 2413 | ✗ | return ret; | |
| 2414 | |||
| 2415 | /* apply forced codec ids */ | ||
| 2416 |
2/2✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 7604 times.
|
15676 | for (int i = 0; i < ic->nb_streams; i++) { |
| 2417 | const AVCodec *dummy; | ||
| 2418 | 8072 | ret = choose_decoder(o, f, ic, ic->streams[i], HWACCEL_NONE, AV_HWDEVICE_TYPE_NONE, | |
| 2419 | &dummy); | ||
| 2420 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8072 times.
|
8072 | if (ret < 0) |
| 2421 | ✗ | return ret; | |
| 2422 | } | ||
| 2423 | |||
| 2424 |
2/2✓ Branch 0 taken 7602 times.
✓ Branch 1 taken 2 times.
|
7604 | if (o->find_stream_info) { |
| 2425 | AVDictionary **opts; | ||
| 2426 | 7602 | int orig_nb_streams = ic->nb_streams; | |
| 2427 | |||
| 2428 | 7602 | ret = setup_find_stream_info_opts(ic, o->g->codec_opts, &opts); | |
| 2429 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7602 times.
|
7602 | if (ret < 0) |
| 2430 | ✗ | return ret; | |
| 2431 | |||
| 2432 | /* If not enough info to get the stream parameters, we decode the | ||
| 2433 | first frames to get it. (used in mpeg case for example) */ | ||
| 2434 | 7602 | ret = avformat_find_stream_info(ic, opts); | |
| 2435 | |||
| 2436 |
2/2✓ Branch 0 taken 8070 times.
✓ Branch 1 taken 7602 times.
|
15672 | for (int i = 0; i < orig_nb_streams; i++) |
| 2437 | 8070 | av_dict_free(&opts[i]); | |
| 2438 | 7602 | av_freep(&opts); | |
| 2439 | |||
| 2440 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7602 times.
|
7602 | if (ret < 0) { |
| 2441 | ✗ | av_log(d, AV_LOG_FATAL, "could not find codec parameters\n"); | |
| 2442 | ✗ | if (ic->nb_streams == 0) | |
| 2443 | ✗ | return ret; | |
| 2444 | } | ||
| 2445 | } | ||
| 2446 | |||
| 2447 |
3/4✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
|
7604 | if (start_time != AV_NOPTS_VALUE && start_time_eof != AV_NOPTS_VALUE) { |
| 2448 | ✗ | av_log(d, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss\n"); | |
| 2449 | ✗ | start_time_eof = AV_NOPTS_VALUE; | |
| 2450 | } | ||
| 2451 | |||
| 2452 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7604 times.
|
7604 | if (start_time_eof != AV_NOPTS_VALUE) { |
| 2453 | ✗ | if (start_time_eof >= 0) { | |
| 2454 | ✗ | av_log(d, AV_LOG_ERROR, "-sseof value must be negative; aborting\n"); | |
| 2455 | ✗ | return AVERROR(EINVAL); | |
| 2456 | } | ||
| 2457 | ✗ | if (ic->duration > 0) { | |
| 2458 | ✗ | start_time = start_time_eof + ic->duration; | |
| 2459 | ✗ | if (start_time < 0) { | |
| 2460 | ✗ | av_log(d, AV_LOG_WARNING, "-sseof value seeks to before start of file; ignored\n"); | |
| 2461 | ✗ | start_time = AV_NOPTS_VALUE; | |
| 2462 | } | ||
| 2463 | } else | ||
| 2464 | ✗ | av_log(d, AV_LOG_WARNING, "Cannot use -sseof, file duration not known\n"); | |
| 2465 | } | ||
| 2466 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7576 times.
|
7604 | timestamp = (start_time == AV_NOPTS_VALUE) ? 0 : start_time; |
| 2467 | /* add the stream start time */ | ||
| 2468 |
4/4✓ Branch 0 taken 7601 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 5827 times.
✓ Branch 3 taken 1774 times.
|
7604 | if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE) |
| 2469 | 5827 | timestamp += ic->start_time; | |
| 2470 | |||
| 2471 | /* if seeking requested, we execute it */ | ||
| 2472 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7576 times.
|
7604 | if (start_time != AV_NOPTS_VALUE) { |
| 2473 | 28 | int64_t seek_timestamp = timestamp; | |
| 2474 | |||
| 2475 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1 times.
|
28 | if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) { |
| 2476 | 27 | int dts_heuristic = 0; | |
| 2477 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
|
54 | for (int i = 0; i < ic->nb_streams; i++) { |
| 2478 | 27 | const AVCodecParameters *par = ic->streams[i]->codecpar; | |
| 2479 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
|
27 | if (par->video_delay) { |
| 2480 | ✗ | dts_heuristic = 1; | |
| 2481 | ✗ | break; | |
| 2482 | } | ||
| 2483 | } | ||
| 2484 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
|
27 | if (dts_heuristic) { |
| 2485 | ✗ | seek_timestamp -= 3*AV_TIME_BASE / 23; | |
| 2486 | } | ||
| 2487 | } | ||
| 2488 | 28 | ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0); | |
| 2489 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 27 times.
|
28 | if (ret < 0) { |
| 2490 | 1 | av_log(d, AV_LOG_WARNING, "could not seek to position %0.3f\n", | |
| 2491 | 1 | (double)timestamp / AV_TIME_BASE); | |
| 2492 | } | ||
| 2493 | } | ||
| 2494 | |||
| 2495 | 7604 | f->start_time = start_time; | |
| 2496 | 7604 | d->recording_time = recording_time; | |
| 2497 | 7604 | f->input_sync_ref = o->input_sync_ref; | |
| 2498 | 7604 | f->input_ts_offset = o->input_ts_offset; | |
| 2499 |
3/6✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7593 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7604 | f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp); |
| 2500 | 7604 | d->accurate_seek = o->accurate_seek; | |
| 2501 | 7604 | d->loop = o->loop; | |
| 2502 | 7604 | d->nb_streams_warn = ic->nb_streams; | |
| 2503 | |||
| 2504 | 7604 | d->duration = (Timestamp){ .ts = 0, .tb = (AVRational){ 1, 1 } }; | |
| 2505 | 7604 | d->min_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } }; | |
| 2506 | 7604 | d->max_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } }; | |
| 2507 | |||
| 2508 | 7604 | d->readrate = o->readrate ? o->readrate : 0.0; | |
| 2509 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7604 times.
|
7604 | if (d->readrate < 0.0f) { |
| 2510 | ✗ | av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", d->readrate); | |
| 2511 | ✗ | return AVERROR(EINVAL); | |
| 2512 | } | ||
| 2513 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7602 times.
|
7604 | if (o->rate_emu) { |
| 2514 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d->readrate) { |
| 2515 | ✗ | av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", d->readrate); | |
| 2516 | } else | ||
| 2517 | 2 | d->readrate = 1.0f; | |
| 2518 | } | ||
| 2519 | |||
| 2520 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7602 times.
|
7604 | if (d->readrate) { |
| 2521 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.5; |
| 2522 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d->readrate_initial_burst < 0.0) { |
| 2523 | ✗ | av_log(d, AV_LOG_ERROR, | |
| 2524 | "Option -readrate_initial_burst is %0.3f; it must be non-negative.\n", | ||
| 2525 | d->readrate_initial_burst); | ||
| 2526 | ✗ | return AVERROR(EINVAL); | |
| 2527 | } | ||
| 2528 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | d->readrate_catchup = o->readrate_catchup ? o->readrate_catchup : d->readrate * 1.05; |
| 2529 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d->readrate_catchup < d->readrate) { |
| 2530 | ✗ | av_log(d, AV_LOG_ERROR, | |
| 2531 | "Option -readrate_catchup is %0.3f; it must be at least equal to %0.3f.\n", | ||
| 2532 | ✗ | d->readrate_catchup, d->readrate); | |
| 2533 | ✗ | return AVERROR(EINVAL); | |
| 2534 | } | ||
| 2535 | } else { | ||
| 2536 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7602 times.
|
7602 | if (o->readrate_initial_burst) { |
| 2537 | ✗ | av_log(d, AV_LOG_WARNING, "Option -readrate_initial_burst ignored " | |
| 2538 | "since neither -readrate nor -re were given\n"); | ||
| 2539 | } | ||
| 2540 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7602 times.
|
7602 | if (o->readrate_catchup) { |
| 2541 | ✗ | av_log(d, AV_LOG_WARNING, "Option -readrate_catchup ignored " | |
| 2542 | "since neither -readrate nor -re were given\n"); | ||
| 2543 | } | ||
| 2544 | } | ||
| 2545 | |||
| 2546 | /* Add all the streams from the given input file to the demuxer */ | ||
| 2547 |
2/2✓ Branch 0 taken 8225 times.
✓ Branch 1 taken 7604 times.
|
15829 | for (int i = 0; i < ic->nb_streams; i++) { |
| 2548 | 8225 | ret = ist_add(o, d, ic->streams[i], &opts_used); | |
| 2549 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8225 times.
|
8225 | if (ret < 0) { |
| 2550 | ✗ | av_dict_free(&opts_used); | |
| 2551 | ✗ | return ret; | |
| 2552 | } | ||
| 2553 | } | ||
| 2554 | |||
| 2555 | /* Add all the stream groups from the given input file to the demuxer */ | ||
| 2556 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7604 times.
|
7679 | for (int i = 0; i < ic->nb_stream_groups; i++) { |
| 2557 | 75 | ret = istg_add(o, d, ic->stream_groups[i]); | |
| 2558 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
|
75 | if (ret < 0) |
| 2559 | ✗ | return ret; | |
| 2560 | } | ||
| 2561 | |||
| 2562 | /* dump the file content */ | ||
| 2563 | 7604 | av_dump_format(ic, f->index, filename, 0); | |
| 2564 | |||
| 2565 | /* check if all codec options have been used */ | ||
| 2566 | 7604 | ret = check_avoptions_used(o->g->codec_opts, opts_used, d, 1); | |
| 2567 | 7604 | av_dict_free(&opts_used); | |
| 2568 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7604 times.
|
7604 | if (ret < 0) |
| 2569 | ✗ | return ret; | |
| 2570 | |||
| 2571 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7604 times.
|
7604 | for (int i = 0; i < o->dump_attachment.nb_opt; i++) { |
| 2572 | ✗ | for (int j = 0; j < f->nb_streams; j++) { | |
| 2573 | ✗ | InputStream *ist = f->streams[j]; | |
| 2574 | |||
| 2575 | ✗ | if (check_stream_specifier(ic, ist->st, o->dump_attachment.opt[i].specifier) == 1) { | |
| 2576 | ✗ | ret = dump_attachment(ist, o->dump_attachment.opt[i].u.str); | |
| 2577 | ✗ | if (ret < 0) | |
| 2578 | ✗ | return ret; | |
| 2579 | } | ||
| 2580 | } | ||
| 2581 | } | ||
| 2582 | |||
| 2583 | 7604 | return 0; | |
| 2584 | } | ||
| 2585 |