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/mem.h" | ||
32 | #include "libavutil/opt.h" | ||
33 | #include "libavutil/parseutils.h" | ||
34 | #include "libavutil/pixdesc.h" | ||
35 | #include "libavutil/time.h" | ||
36 | #include "libavutil/timestamp.h" | ||
37 | |||
38 | #include "libavcodec/bsf.h" | ||
39 | #include "libavcodec/packet.h" | ||
40 | |||
41 | #include "libavformat/avformat.h" | ||
42 | |||
43 | typedef struct DemuxStream { | ||
44 | InputStream ist; | ||
45 | |||
46 | // name used for logging | ||
47 | char log_name[32]; | ||
48 | |||
49 | int sch_idx_stream; | ||
50 | int sch_idx_dec; | ||
51 | |||
52 | double ts_scale; | ||
53 | |||
54 | /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */ | ||
55 | int decoding_needed; | ||
56 | #define DECODING_FOR_OST 1 | ||
57 | #define DECODING_FOR_FILTER 2 | ||
58 | |||
59 | /* true if stream data should be discarded */ | ||
60 | int discard; | ||
61 | |||
62 | // scheduler returned EOF for this stream | ||
63 | int finished; | ||
64 | |||
65 | int streamcopy_needed; | ||
66 | int have_sub2video; | ||
67 | int reinit_filters; | ||
68 | int autorotate; | ||
69 | |||
70 | |||
71 | int wrap_correction_done; | ||
72 | int saw_first_ts; | ||
73 | ///< dts of the first packet read for this stream (in AV_TIME_BASE units) | ||
74 | int64_t first_dts; | ||
75 | |||
76 | /* predicted dts of the next packet read for this stream or (when there are | ||
77 | * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */ | ||
78 | int64_t next_dts; | ||
79 | ///< dts of the last packet read for this stream (in AV_TIME_BASE units) | ||
80 | int64_t dts; | ||
81 | |||
82 | const AVCodecDescriptor *codec_desc; | ||
83 | |||
84 | AVDictionary *decoder_opts; | ||
85 | DecoderOpts dec_opts; | ||
86 | char dec_name[16]; | ||
87 | // decoded media properties, as estimated by opening the decoder | ||
88 | AVFrame *decoded_params; | ||
89 | |||
90 | AVBSFContext *bsf; | ||
91 | |||
92 | /* number of packets successfully read for this stream */ | ||
93 | uint64_t nb_packets; | ||
94 | // combined size of all the packets read | ||
95 | uint64_t data_size; | ||
96 | } DemuxStream; | ||
97 | |||
98 | typedef struct Demuxer { | ||
99 | InputFile f; | ||
100 | |||
101 | // name used for logging | ||
102 | char log_name[32]; | ||
103 | |||
104 | int64_t wallclock_start; | ||
105 | |||
106 | /** | ||
107 | * Extra timestamp offset added by discontinuity handling. | ||
108 | */ | ||
109 | int64_t ts_offset_discont; | ||
110 | int64_t last_ts; | ||
111 | |||
112 | int64_t recording_time; | ||
113 | int accurate_seek; | ||
114 | |||
115 | /* number of times input stream should be looped */ | ||
116 | int loop; | ||
117 | int have_audio_dec; | ||
118 | /* duration of the looped segment of the input file */ | ||
119 | Timestamp duration; | ||
120 | /* pts with the smallest/largest values ever seen */ | ||
121 | Timestamp min_pts; | ||
122 | Timestamp max_pts; | ||
123 | |||
124 | /* number of streams that the user was warned of */ | ||
125 | int nb_streams_warn; | ||
126 | |||
127 | float readrate; | ||
128 | double readrate_initial_burst; | ||
129 | |||
130 | Scheduler *sch; | ||
131 | |||
132 | AVPacket *pkt_heartbeat; | ||
133 | |||
134 | int read_started; | ||
135 | int nb_streams_used; | ||
136 | int nb_streams_finished; | ||
137 | } Demuxer; | ||
138 | |||
139 | typedef struct DemuxThreadContext { | ||
140 | // packet used for reading from the demuxer | ||
141 | AVPacket *pkt_demux; | ||
142 | // packet for reading from BSFs | ||
143 | AVPacket *pkt_bsf; | ||
144 | } DemuxThreadContext; | ||
145 | |||
146 | 1823307 | static DemuxStream *ds_from_ist(InputStream *ist) | |
147 | { | ||
148 | 1823307 | return (DemuxStream*)ist; | |
149 | } | ||
150 | |||
151 | 20248 | static Demuxer *demuxer_from_ifile(InputFile *f) | |
152 | { | ||
153 | 20248 | return (Demuxer*)f; | |
154 | } | ||
155 | |||
156 | 55 | InputStream *ist_find_unused(enum AVMediaType type) | |
157 | { | ||
158 |
1/2✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
|
74 | for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { |
159 | 74 | DemuxStream *ds = ds_from_ist(ist); | |
160 |
4/4✓ Branch 0 taken 73 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 18 times.
|
74 | if (ist->par->codec_type == type && ds->discard && |
161 |
1/2✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
55 | ist->user_set_discard != AVDISCARD_ALL) |
162 | 55 | return ist; | |
163 | } | ||
164 | ✗ | return NULL; | |
165 | } | ||
166 | |||
167 | 9897 | static void report_new_stream(Demuxer *d, const AVPacket *pkt) | |
168 | { | ||
169 | 9897 | const AVStream *st = d->f.ctx->streams[pkt->stream_index]; | |
170 | |||
171 |
1/2✓ Branch 0 taken 9897 times.
✗ Branch 1 not taken.
|
9897 | if (pkt->stream_index < d->nb_streams_warn) |
172 | 9897 | return; | |
173 | ✗ | av_log(d, AV_LOG_WARNING, | |
174 | "New %s stream with index %d at pos:%"PRId64" and DTS:%ss\n", | ||
175 | ✗ | av_get_media_type_string(st->codecpar->codec_type), | |
176 | ✗ | pkt->stream_index, pkt->pos, av_ts2timestr(pkt->dts, &st->time_base)); | |
177 | ✗ | d->nb_streams_warn = pkt->stream_index + 1; | |
178 | } | ||
179 | |||
180 | 11 | static int seek_to_start(Demuxer *d, Timestamp end_pts) | |
181 | { | ||
182 | 11 | InputFile *ifile = &d->f; | |
183 | 11 | AVFormatContext *is = ifile->ctx; | |
184 | int ret; | ||
185 | |||
186 | 11 | ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0); | |
187 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (ret < 0) |
188 | ✗ | return ret; | |
189 | |||
190 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
|
11 | if (end_pts.ts != AV_NOPTS_VALUE && |
191 |
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 || |
192 | 3 | av_compare_ts(d->max_pts.ts, d->max_pts.tb, end_pts.ts, end_pts.tb) < 0)) | |
193 | 3 | d->max_pts = end_pts; | |
194 | |||
195 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (d->max_pts.ts != AV_NOPTS_VALUE) { |
196 |
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; |
197 | 11 | d->duration.ts = d->max_pts.ts - av_rescale_q(min_pts, d->min_pts.tb, d->max_pts.tb); | |
198 | } | ||
199 | 11 | d->duration.tb = d->max_pts.tb; | |
200 | |||
201 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (d->loop > 0) |
202 | 11 | d->loop--; | |
203 | |||
204 | 11 | return ret; | |
205 | } | ||
206 | |||
207 | 407092 | static void ts_discontinuity_detect(Demuxer *d, InputStream *ist, | |
208 | AVPacket *pkt) | ||
209 | { | ||
210 | 407092 | InputFile *ifile = &d->f; | |
211 | 407092 | DemuxStream *ds = ds_from_ist(ist); | |
212 | 407092 | const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT; | |
213 | 407092 | int disable_discontinuity_correction = copy_ts; | |
214 | 407092 | int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, pkt->time_base, AV_TIME_BASE_Q, | |
215 | AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX); | ||
216 | |||
217 |
6/6✓ Branch 0 taken 194 times.
✓ Branch 1 taken 406898 times.
✓ Branch 2 taken 188 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 115 times.
|
407092 | if (copy_ts && ds->next_dts != AV_NOPTS_VALUE && |
218 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
|
73 | fmt_is_discont && ist->st->pts_wrap_bits < 60) { |
219 | ✗ | int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits), | |
220 | ✗ | pkt->time_base, AV_TIME_BASE_Q, | |
221 | AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); | ||
222 | ✗ | if (FFABS(wrap_dts - ds->next_dts) < FFABS(pkt_dts - ds->next_dts)/10) | |
223 | ✗ | disable_discontinuity_correction = 0; | |
224 | } | ||
225 | |||
226 |
4/4✓ Branch 0 taken 400719 times.
✓ Branch 1 taken 6373 times.
✓ Branch 2 taken 400531 times.
✓ Branch 3 taken 188 times.
|
807623 | if (ds->next_dts != AV_NOPTS_VALUE && !disable_discontinuity_correction) { |
227 | 400531 | int64_t delta = pkt_dts - ds->next_dts; | |
228 |
2/2✓ Branch 0 taken 22514 times.
✓ Branch 1 taken 378017 times.
|
400531 | if (fmt_is_discont) { |
229 |
4/4✓ Branch 0 taken 22458 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 22431 times.
✓ Branch 3 taken 83 times.
|
22514 | if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE || |
230 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22423 times.
|
22431 | pkt_dts + AV_TIME_BASE/10 < ds->dts) { |
231 | 91 | d->ts_offset_discont -= delta; | |
232 | 91 | av_log(ist, AV_LOG_WARNING, | |
233 | "timestamp discontinuity " | ||
234 | "(stream id=%d): %"PRId64", new offset= %"PRId64"\n", | ||
235 | 91 | ist->st->id, delta, d->ts_offset_discont); | |
236 | 91 | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
237 |
1/2✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
|
91 | if (pkt->pts != AV_NOPTS_VALUE) |
238 | 91 | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
239 | } | ||
240 | } else { | ||
241 |
3/4✓ Branch 0 taken 374548 times.
✓ Branch 1 taken 3469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 378017 times.
|
378017 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
242 | ✗ | av_log(NULL, AV_LOG_WARNING, | |
243 | "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n", | ||
244 | pkt->dts, ds->next_dts, pkt->stream_index); | ||
245 | ✗ | pkt->dts = AV_NOPTS_VALUE; | |
246 | } | ||
247 |
2/2✓ Branch 0 taken 375953 times.
✓ Branch 1 taken 2064 times.
|
378017 | if (pkt->pts != AV_NOPTS_VALUE){ |
248 | 375953 | int64_t pkt_pts = av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); | |
249 | 375953 | delta = pkt_pts - ds->next_dts; | |
250 |
3/4✓ Branch 0 taken 372789 times.
✓ Branch 1 taken 3164 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 375953 times.
|
375953 | if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) { |
251 | ✗ | av_log(NULL, AV_LOG_WARNING, | |
252 | "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n", | ||
253 | pkt->pts, ds->next_dts, pkt->stream_index); | ||
254 | ✗ | pkt->pts = AV_NOPTS_VALUE; | |
255 | } | ||
256 | } | ||
257 | } | ||
258 |
6/6✓ Branch 0 taken 6373 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 6367 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 6253 times.
|
6561 | } else if (ds->next_dts == AV_NOPTS_VALUE && !copy_ts && |
259 |
1/2✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
|
114 | fmt_is_discont && d->last_ts != AV_NOPTS_VALUE) { |
260 | 114 | int64_t delta = pkt_dts - d->last_ts; | |
261 |
3/4✓ Branch 0 taken 54 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
|
114 | if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE) { |
262 | ✗ | d->ts_offset_discont -= delta; | |
263 | ✗ | av_log(NULL, AV_LOG_DEBUG, | |
264 | "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n", | ||
265 | delta, d->ts_offset_discont); | ||
266 | ✗ | pkt->dts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
267 | ✗ | if (pkt->pts != AV_NOPTS_VALUE) | |
268 | ✗ | pkt->pts -= av_rescale_q(delta, AV_TIME_BASE_Q, pkt->time_base); | |
269 | } | ||
270 | } | ||
271 | |||
272 | 407092 | d->last_ts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); | |
273 | 407092 | } | |
274 | |||
275 | 453859 | static void ts_discontinuity_process(Demuxer *d, InputStream *ist, | |
276 | AVPacket *pkt) | ||
277 | { | ||
278 | 453859 | int64_t offset = av_rescale_q(d->ts_offset_discont, AV_TIME_BASE_Q, | |
279 | pkt->time_base); | ||
280 | |||
281 | // apply previously-detected timestamp-discontinuity offset | ||
282 | // (to all streams, not just audio/video) | ||
283 |
2/2✓ Branch 0 taken 409796 times.
✓ Branch 1 taken 44063 times.
|
453859 | if (pkt->dts != AV_NOPTS_VALUE) |
284 | 409796 | pkt->dts += offset; | |
285 |
2/2✓ Branch 0 taken 407692 times.
✓ Branch 1 taken 46167 times.
|
453859 | if (pkt->pts != AV_NOPTS_VALUE) |
286 | 407692 | pkt->pts += offset; | |
287 | |||
288 | // detect timestamp discontinuities for audio/video | ||
289 |
2/2✓ Branch 0 taken 277478 times.
✓ Branch 1 taken 176381 times.
|
453859 | if ((ist->par->codec_type == AVMEDIA_TYPE_VIDEO || |
290 |
2/2✓ Branch 0 taken 274770 times.
✓ Branch 1 taken 2708 times.
|
277478 | ist->par->codec_type == AVMEDIA_TYPE_AUDIO) && |
291 |
2/2✓ Branch 0 taken 407092 times.
✓ Branch 1 taken 44059 times.
|
451151 | pkt->dts != AV_NOPTS_VALUE) |
292 | 407092 | ts_discontinuity_detect(d, ist, pkt); | |
293 | 453859 | } | |
294 | |||
295 | 453859 | static int ist_dts_update(DemuxStream *ds, AVPacket *pkt, FrameData *fd) | |
296 | { | ||
297 | 453859 | InputStream *ist = &ds->ist; | |
298 | 453859 | const AVCodecParameters *par = ist->par; | |
299 | |||
300 |
2/2✓ Branch 0 taken 6973 times.
✓ Branch 1 taken 446886 times.
|
453859 | if (!ds->saw_first_ts) { |
301 | 6973 | ds->first_dts = | |
302 |
2/2✓ Branch 0 taken 4772 times.
✓ Branch 1 taken 2201 times.
|
6973 | ds->dts = ist->st->avg_frame_rate.num ? - ist->par->video_delay * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; |
303 |
2/2✓ Branch 0 taken 6394 times.
✓ Branch 1 taken 579 times.
|
6973 | if (pkt->pts != AV_NOPTS_VALUE) { |
304 | 6394 | ds->first_dts = | |
305 | 6394 | ds->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q); | |
306 | } | ||
307 | 6973 | ds->saw_first_ts = 1; | |
308 | } | ||
309 | |||
310 |
2/2✓ Branch 0 taken 6973 times.
✓ Branch 1 taken 446886 times.
|
453859 | if (ds->next_dts == AV_NOPTS_VALUE) |
311 | 6973 | ds->next_dts = ds->dts; | |
312 | |||
313 |
2/2✓ Branch 0 taken 409796 times.
✓ Branch 1 taken 44063 times.
|
453859 | if (pkt->dts != AV_NOPTS_VALUE) |
314 | 409796 | ds->next_dts = ds->dts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q); | |
315 | |||
316 | 453859 | ds->dts = ds->next_dts; | |
317 |
3/3✓ Branch 0 taken 274770 times.
✓ Branch 1 taken 176381 times.
✓ Branch 2 taken 2708 times.
|
453859 | switch (par->codec_type) { |
318 | 274770 | case AVMEDIA_TYPE_AUDIO: | |
319 | av_assert1(pkt->duration >= 0); | ||
320 |
1/2✓ Branch 0 taken 274770 times.
✗ Branch 1 not taken.
|
274770 | if (par->sample_rate) { |
321 | 274770 | ds->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) / | |
322 | 274770 | par->sample_rate; | |
323 | } else { | ||
324 | ✗ | ds->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); | |
325 | } | ||
326 | 274770 | break; | |
327 | 176381 | case AVMEDIA_TYPE_VIDEO: | |
328 |
2/2✓ Branch 0 taken 604 times.
✓ Branch 1 taken 175777 times.
|
176381 | if (ist->framerate.num) { |
329 | // TODO: Remove work-around for c99-to-c89 issue 7 | ||
330 | 604 | AVRational time_base_q = AV_TIME_BASE_Q; | |
331 | 604 | int64_t next_dts = av_rescale_q(ds->next_dts, time_base_q, av_inv_q(ist->framerate)); | |
332 | 604 | ds->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); | |
333 |
2/2✓ Branch 0 taken 173638 times.
✓ Branch 1 taken 2139 times.
|
175777 | } else if (pkt->duration) { |
334 | 173638 | ds->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q); | |
335 |
2/2✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2069 times.
|
2139 | } else if (ist->par->framerate.num != 0) { |
336 | 70 | AVRational field_rate = av_mul_q(ist->par->framerate, | |
337 | 70 | (AVRational){ 2, 1 }); | |
338 | 70 | int fields = 2; | |
339 | |||
340 |
1/2✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
|
70 | if (ds->codec_desc && |
341 |
4/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 10 times.
|
94 | (ds->codec_desc->props & AV_CODEC_PROP_FIELDS) && |
342 | 24 | av_stream_get_parser(ist->st)) | |
343 | 14 | fields = 1 + av_stream_get_parser(ist->st)->repeat_pict; | |
344 | |||
345 | 70 | ds->next_dts += av_rescale_q(fields, av_inv_q(field_rate), AV_TIME_BASE_Q); | |
346 | } | ||
347 | 176381 | break; | |
348 | } | ||
349 | |||
350 | 453859 | fd->dts_est = ds->dts; | |
351 | |||
352 | 453859 | return 0; | |
353 | } | ||
354 | |||
355 | 453859 | static int ts_fixup(Demuxer *d, AVPacket *pkt, FrameData *fd) | |
356 | { | ||
357 | 453859 | InputFile *ifile = &d->f; | |
358 | 453859 | InputStream *ist = ifile->streams[pkt->stream_index]; | |
359 | 453859 | DemuxStream *ds = ds_from_ist(ist); | |
360 | 453859 | const int64_t start_time = ifile->start_time_effective; | |
361 | int64_t duration; | ||
362 | int ret; | ||
363 | |||
364 | 453859 | pkt->time_base = ist->st->time_base; | |
365 | |||
366 | #define SHOW_TS_DEBUG(tag_) \ | ||
367 | if (debug_ts) { \ | ||
368 | av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \ | ||
369 | "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \ | ||
370 | tag_, ifile->index, pkt->stream_index, \ | ||
371 | av_get_media_type_string(ist->st->codecpar->codec_type), \ | ||
372 | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \ | ||
373 | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \ | ||
374 | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \ | ||
375 | } | ||
376 | |||
377 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | SHOW_TS_DEBUG("demuxer"); |
378 | |||
379 |
4/4✓ Branch 0 taken 406308 times.
✓ Branch 1 taken 47551 times.
✓ Branch 2 taken 311009 times.
✓ Branch 3 taken 95299 times.
|
453859 | if (!ds->wrap_correction_done && start_time != AV_NOPTS_VALUE && |
380 |
2/2✓ Branch 0 taken 346 times.
✓ Branch 1 taken 310663 times.
|
311009 | ist->st->pts_wrap_bits < 64) { |
381 | int64_t stime, stime2; | ||
382 | |||
383 | 346 | stime = av_rescale_q(start_time, AV_TIME_BASE_Q, pkt->time_base); | |
384 | 346 | stime2= stime + (1ULL<<ist->st->pts_wrap_bits); | |
385 | 346 | ds->wrap_correction_done = 1; | |
386 | |||
387 |
5/6✓ Branch 0 taken 316 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 282 times.
|
346 | if(stime2 > stime && pkt->dts != AV_NOPTS_VALUE && pkt->dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) { |
388 | ✗ | pkt->dts -= 1ULL<<ist->st->pts_wrap_bits; | |
389 | ✗ | ds->wrap_correction_done = 0; | |
390 | } | ||
391 |
5/6✓ Branch 0 taken 316 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 276 times.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 276 times.
|
346 | if(stime2 > stime && pkt->pts != AV_NOPTS_VALUE && pkt->pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) { |
392 | ✗ | pkt->pts -= 1ULL<<ist->st->pts_wrap_bits; | |
393 | ✗ | ds->wrap_correction_done = 0; | |
394 | } | ||
395 | } | ||
396 | |||
397 |
2/2✓ Branch 0 taken 409796 times.
✓ Branch 1 taken 44063 times.
|
453859 | if (pkt->dts != AV_NOPTS_VALUE) |
398 | 409796 | pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); | |
399 |
2/2✓ Branch 0 taken 407692 times.
✓ Branch 1 taken 46167 times.
|
453859 | if (pkt->pts != AV_NOPTS_VALUE) |
400 | 407692 | pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, pkt->time_base); | |
401 | |||
402 |
2/2✓ Branch 0 taken 407692 times.
✓ Branch 1 taken 46167 times.
|
453859 | if (pkt->pts != AV_NOPTS_VALUE) |
403 | 407692 | pkt->pts *= ds->ts_scale; | |
404 |
2/2✓ Branch 0 taken 409796 times.
✓ Branch 1 taken 44063 times.
|
453859 | if (pkt->dts != AV_NOPTS_VALUE) |
405 | 409796 | pkt->dts *= ds->ts_scale; | |
406 | |||
407 | 453859 | duration = av_rescale_q(d->duration.ts, d->duration.tb, pkt->time_base); | |
408 |
2/2✓ Branch 0 taken 407692 times.
✓ Branch 1 taken 46167 times.
|
453859 | if (pkt->pts != AV_NOPTS_VALUE) { |
409 | // audio decoders take precedence for estimating total file duration | ||
410 |
2/2✓ Branch 0 taken 181137 times.
✓ Branch 1 taken 226555 times.
|
407692 | int64_t pkt_duration = d->have_audio_dec ? 0 : pkt->duration; |
411 | |||
412 | 407692 | pkt->pts += duration; | |
413 | |||
414 | // update max/min pts that will be used to compute total file duration | ||
415 | // when using -stream_loop | ||
416 |
4/4✓ Branch 0 taken 401436 times.
✓ Branch 1 taken 6256 times.
✓ Branch 2 taken 389450 times.
✓ Branch 3 taken 11986 times.
|
809128 | if (d->max_pts.ts == AV_NOPTS_VALUE || |
417 | 401436 | av_compare_ts(d->max_pts.ts, d->max_pts.tb, | |
418 | 401436 | pkt->pts + pkt_duration, pkt->time_base) < 0) { | |
419 | 395706 | d->max_pts = (Timestamp){ .ts = pkt->pts + pkt_duration, | |
420 | 395706 | .tb = pkt->time_base }; | |
421 | } | ||
422 |
4/4✓ Branch 0 taken 401436 times.
✓ Branch 1 taken 6256 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 401413 times.
|
809128 | if (d->min_pts.ts == AV_NOPTS_VALUE || |
423 | 401436 | av_compare_ts(d->min_pts.ts, d->min_pts.tb, | |
424 | pkt->pts, pkt->time_base) > 0) { | ||
425 | 6279 | d->min_pts = (Timestamp){ .ts = pkt->pts, | |
426 | 6279 | .tb = pkt->time_base }; | |
427 | } | ||
428 | } | ||
429 | |||
430 |
2/2✓ Branch 0 taken 409796 times.
✓ Branch 1 taken 44063 times.
|
453859 | if (pkt->dts != AV_NOPTS_VALUE) |
431 | 409796 | pkt->dts += duration; | |
432 | |||
433 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | SHOW_TS_DEBUG("demuxer+tsfixup"); |
434 | |||
435 | // detect and try to correct for timestamp discontinuities | ||
436 | 453859 | ts_discontinuity_process(d, ist, pkt); | |
437 | |||
438 | // update estimated/predicted dts | ||
439 | 453859 | ret = ist_dts_update(ds, pkt, fd); | |
440 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | if (ret < 0) |
441 | ✗ | return ret; | |
442 | |||
443 | 453859 | return 0; | |
444 | } | ||
445 | |||
446 | 453859 | static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags) | |
447 | { | ||
448 | 453859 | InputFile *f = &d->f; | |
449 | 453859 | InputStream *ist = f->streams[pkt->stream_index]; | |
450 | 453859 | DemuxStream *ds = ds_from_ist(ist); | |
451 | FrameData *fd; | ||
452 | 453859 | int ret = 0; | |
453 | |||
454 | 453859 | fd = packet_data(pkt); | |
455 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | if (!fd) |
456 | ✗ | return AVERROR(ENOMEM); | |
457 | |||
458 | 453859 | ret = ts_fixup(d, pkt, fd); | |
459 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | if (ret < 0) |
460 | ✗ | return ret; | |
461 | |||
462 |
2/2✓ Branch 0 taken 236 times.
✓ Branch 1 taken 453623 times.
|
453859 | if (d->recording_time != INT64_MAX) { |
463 | 236 | int64_t start_time = 0; | |
464 |
2/2✓ Branch 0 taken 74 times.
✓ Branch 1 taken 162 times.
|
236 | if (copy_ts) { |
465 |
1/2✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
|
74 | start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0; |
466 |
1/2✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
|
74 | start_time += start_at_zero ? 0 : f->start_time_effective; |
467 | } | ||
468 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 196 times.
|
236 | if (ds->dts >= d->recording_time + start_time) |
469 | 40 | *send_flags |= DEMUX_SEND_STREAMCOPY_EOF; | |
470 | } | ||
471 | |||
472 | 453859 | ds->data_size += pkt->size; | |
473 | 453859 | ds->nb_packets++; | |
474 | |||
475 | 453859 | fd->wallclock[LATENCY_PROBE_DEMUX] = av_gettime_relative(); | |
476 | |||
477 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | if (debug_ts) { |
478 | ✗ | av_log(NULL, 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", | |
479 | f->index, pkt->stream_index, | ||
480 | ✗ | av_get_media_type_string(ist->par->codec_type), | |
481 | ✗ | av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), | |
482 | ✗ | av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), | |
483 | ✗ | av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base), | |
484 | ✗ | av_ts2str(f->ts_offset), av_ts2timestr(f->ts_offset, &AV_TIME_BASE_Q)); | |
485 | } | ||
486 | |||
487 | 453859 | return 0; | |
488 | } | ||
489 | |||
490 | 216 | static void readrate_sleep(Demuxer *d) | |
491 | { | ||
492 | 216 | InputFile *f = &d->f; | |
493 | 432 | int64_t file_start = copy_ts * ( | |
494 |
1/2✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
|
216 | (f->start_time_effective != AV_NOPTS_VALUE ? f->start_time_effective * !start_at_zero : 0) + |
495 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
|
216 | (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) |
496 | ); | ||
497 | 216 | int64_t burst_until = AV_TIME_BASE * d->readrate_initial_burst; | |
498 |
2/2✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
|
432 | for (int i = 0; i < f->nb_streams; i++) { |
499 | 216 | InputStream *ist = f->streams[i]; | |
500 | 216 | DemuxStream *ds = ds_from_ist(ist); | |
501 | int64_t stream_ts_offset, pts, now; | ||
502 |
1/2✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
|
216 | stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start); |
503 | 216 | pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE); | |
504 | 216 | now = (av_gettime_relative() - d->wallclock_start) * d->readrate + stream_ts_offset; | |
505 |
2/2✓ Branch 0 taken 189 times.
✓ Branch 1 taken 27 times.
|
216 | if (pts - burst_until > now) |
506 | 189 | av_usleep(pts - burst_until - now); | |
507 | } | ||
508 | 216 | } | |
509 | |||
510 | 454807 | static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags, | |
511 | const char *pkt_desc) | ||
512 | { | ||
513 | int ret; | ||
514 | |||
515 | 454807 | pkt->stream_index = ds->sch_idx_stream; | |
516 | |||
517 | 454807 | ret = sch_demux_send(d->sch, d->f.index, pkt, flags); | |
518 |
2/2✓ Branch 0 taken 3126 times.
✓ Branch 1 taken 451681 times.
|
454807 | if (ret == AVERROR_EOF) { |
519 | 3126 | av_packet_unref(pkt); | |
520 | |||
521 | 3126 | av_log(ds, AV_LOG_VERBOSE, "All consumers of this stream are done\n"); | |
522 | 3126 | ds->finished = 1; | |
523 | |||
524 |
2/2✓ Branch 0 taken 3099 times.
✓ Branch 1 taken 27 times.
|
3126 | if (++d->nb_streams_finished == d->nb_streams_used) { |
525 | 3099 | av_log(d, AV_LOG_VERBOSE, "All consumers are done\n"); | |
526 | 3099 | return AVERROR_EOF; | |
527 | } | ||
528 |
2/2✓ Branch 0 taken 43 times.
✓ Branch 1 taken 451638 times.
|
451681 | } else if (ret < 0) { |
529 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
43 | if (ret != AVERROR_EXIT) |
530 | ✗ | av_log(d, AV_LOG_ERROR, | |
531 | "Unable to send %s packet to consumers: %s\n", | ||
532 | ✗ | pkt_desc, av_err2str(ret)); | |
533 | 43 | return ret; | |
534 | } | ||
535 | |||
536 | 451665 | return 0; | |
537 | } | ||
538 | |||
539 | 453862 | static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds, | |
540 | AVPacket *pkt, unsigned flags) | ||
541 | { | ||
542 | 453862 | InputFile *f = &d->f; | |
543 | int ret; | ||
544 | |||
545 | // pkt can be NULL only when flushing BSFs | ||
546 |
3/4✓ Branch 0 taken 453847 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 453847 times.
|
453862 | av_assert0(ds->bsf || pkt); |
547 | |||
548 | // send heartbeat for sub2video streams | ||
549 |
4/6✓ Branch 0 taken 948 times.
✓ Branch 1 taken 452914 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 948 times.
✗ Branch 5 not taken.
|
453862 | if (d->pkt_heartbeat && pkt && pkt->pts != AV_NOPTS_VALUE) { |
550 |
2/2✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 948 times.
|
5280 | for (int i = 0; i < f->nb_streams; i++) { |
551 | 4332 | DemuxStream *ds1 = ds_from_ist(f->streams[i]); | |
552 | |||
553 |
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) |
554 | 3384 | continue; | |
555 | |||
556 | 948 | d->pkt_heartbeat->pts = pkt->pts; | |
557 | 948 | d->pkt_heartbeat->time_base = pkt->time_base; | |
558 | 948 | d->pkt_heartbeat->opaque = (void*)(intptr_t)PKT_OPAQUE_SUB_HEARTBEAT; | |
559 | |||
560 | 948 | ret = do_send(d, ds1, d->pkt_heartbeat, 0, "heartbeat"); | |
561 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 948 times.
|
948 | if (ret < 0) |
562 | ✗ | return ret; | |
563 | } | ||
564 | } | ||
565 | |||
566 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 453847 times.
|
453862 | if (ds->bsf) { |
567 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
|
15 | if (pkt) |
568 | 12 | av_packet_rescale_ts(pkt, pkt->time_base, ds->bsf->time_base_in); | |
569 | |||
570 | 15 | ret = av_bsf_send_packet(ds->bsf, pkt); | |
571 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if (ret < 0) { |
572 | ✗ | if (pkt) | |
573 | ✗ | av_packet_unref(pkt); | |
574 | ✗ | av_log(ds, AV_LOG_ERROR, "Error submitting a packet for filtering: %s\n", | |
575 | ✗ | av_err2str(ret)); | |
576 | ✗ | return ret; | |
577 | } | ||
578 | |||
579 | while (1) { | ||
580 | 27 | ret = av_bsf_receive_packet(ds->bsf, dt->pkt_bsf); | |
581 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 15 times.
|
27 | if (ret == AVERROR(EAGAIN)) |
582 | 12 | return 0; | |
583 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
|
15 | else if (ret < 0) { |
584 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret != AVERROR_EOF) |
585 | ✗ | av_log(ds, AV_LOG_ERROR, | |
586 | "Error applying bitstream filters to a packet: %s\n", | ||
587 | ✗ | av_err2str(ret)); | |
588 | 3 | return ret; | |
589 | } | ||
590 | |||
591 | 12 | dt->pkt_bsf->time_base = ds->bsf->time_base_out; | |
592 | |||
593 | 12 | ret = do_send(d, ds, dt->pkt_bsf, 0, "filtered"); | |
594 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (ret < 0) { |
595 | ✗ | av_packet_unref(dt->pkt_bsf); | |
596 | ✗ | return ret; | |
597 | } | ||
598 | } | ||
599 | } else { | ||
600 | 453847 | ret = do_send(d, ds, pkt, flags, "demuxed"); | |
601 |
2/2✓ Branch 0 taken 3142 times.
✓ Branch 1 taken 450705 times.
|
453847 | if (ret < 0) |
602 | 3142 | return ret; | |
603 | } | ||
604 | |||
605 | 450705 | return 0; | |
606 | } | ||
607 | |||
608 | 3642 | static int demux_bsf_flush(Demuxer *d, DemuxThreadContext *dt) | |
609 | { | ||
610 | 3642 | InputFile *f = &d->f; | |
611 | int ret; | ||
612 | |||
613 |
2/2✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 3642 times.
|
7734 | for (unsigned i = 0; i < f->nb_streams; i++) { |
614 | 4092 | DemuxStream *ds = ds_from_ist(f->streams[i]); | |
615 | |||
616 |
2/2✓ Branch 0 taken 4089 times.
✓ Branch 1 taken 3 times.
|
4092 | if (!ds->bsf) |
617 | 4089 | continue; | |
618 | |||
619 | 3 | ret = demux_send(d, dt, ds, NULL, 0); | |
620 |
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; |
621 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (ret < 0) { |
622 | ✗ | av_log(ds, AV_LOG_ERROR, "Error flushing BSFs: %s\n", | |
623 | ✗ | av_err2str(ret)); | |
624 | ✗ | return ret; | |
625 | } | ||
626 | |||
627 | 3 | av_bsf_flush(ds->bsf); | |
628 | } | ||
629 | |||
630 | 3642 | return 0; | |
631 | } | ||
632 | |||
633 | 6773 | static void discard_unused_programs(InputFile *ifile) | |
634 | { | ||
635 |
2/2✓ Branch 0 taken 41 times.
✓ Branch 1 taken 6773 times.
|
6814 | for (int j = 0; j < ifile->ctx->nb_programs; j++) { |
636 | 41 | AVProgram *p = ifile->ctx->programs[j]; | |
637 | 41 | int discard = AVDISCARD_ALL; | |
638 | |||
639 |
1/2✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
|
49 | for (int k = 0; k < p->nb_stream_indexes; k++) { |
640 | 49 | DemuxStream *ds = ds_from_ist(ifile->streams[p->stream_index[k]]); | |
641 | |||
642 |
2/2✓ Branch 0 taken 41 times.
✓ Branch 1 taken 8 times.
|
49 | if (!ds->discard) { |
643 | 41 | discard = AVDISCARD_DEFAULT; | |
644 | 41 | break; | |
645 | } | ||
646 | } | ||
647 | 41 | p->discard = discard; | |
648 | } | ||
649 | 6773 | } | |
650 | |||
651 | 6773 | static void thread_set_name(InputFile *f) | |
652 | { | ||
653 | char name[16]; | ||
654 | 6773 | snprintf(name, sizeof(name), "dmx%d:%s", f->index, f->ctx->iformat->name); | |
655 | 6773 | ff_thread_setname(name); | |
656 | 6773 | } | |
657 | |||
658 | 6773 | static void demux_thread_uninit(DemuxThreadContext *dt) | |
659 | { | ||
660 | 6773 | av_packet_free(&dt->pkt_demux); | |
661 | 6773 | av_packet_free(&dt->pkt_bsf); | |
662 | |||
663 | 6773 | memset(dt, 0, sizeof(*dt)); | |
664 | 6773 | } | |
665 | |||
666 | 6773 | static int demux_thread_init(DemuxThreadContext *dt) | |
667 | { | ||
668 | 6773 | memset(dt, 0, sizeof(*dt)); | |
669 | |||
670 | 6773 | dt->pkt_demux = av_packet_alloc(); | |
671 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6773 times.
|
6773 | if (!dt->pkt_demux) |
672 | ✗ | return AVERROR(ENOMEM); | |
673 | |||
674 | 6773 | dt->pkt_bsf = av_packet_alloc(); | |
675 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6773 times.
|
6773 | if (!dt->pkt_bsf) |
676 | ✗ | return AVERROR(ENOMEM); | |
677 | |||
678 | 6773 | return 0; | |
679 | } | ||
680 | |||
681 | 6773 | static int input_thread(void *arg) | |
682 | { | ||
683 | 6773 | Demuxer *d = arg; | |
684 | 6773 | InputFile *f = &d->f; | |
685 | |||
686 | DemuxThreadContext dt; | ||
687 | |||
688 | 6773 | int ret = 0; | |
689 | |||
690 | 6773 | ret = demux_thread_init(&dt); | |
691 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6773 times.
|
6773 | if (ret < 0) |
692 | ✗ | goto finish; | |
693 | |||
694 | 6773 | thread_set_name(f); | |
695 | |||
696 | 6773 | discard_unused_programs(f); | |
697 | |||
698 | 6773 | d->read_started = 1; | |
699 | 6773 | d->wallclock_start = av_gettime_relative(); | |
700 | |||
701 | 460626 | while (1) { | |
702 | DemuxStream *ds; | ||
703 | 467399 | unsigned send_flags = 0; | |
704 | |||
705 | 467399 | ret = av_read_frame(f->ctx, dt.pkt_demux); | |
706 | |||
707 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 467398 times.
|
467399 | if (ret == AVERROR(EAGAIN)) { |
708 | 1 | av_usleep(10000); | |
709 | 9909 | continue; | |
710 | } | ||
711 |
2/2✓ Branch 0 taken 3642 times.
✓ Branch 1 taken 463756 times.
|
467398 | if (ret < 0) { |
712 | int ret_bsf; | ||
713 | |||
714 |
2/2✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 56 times.
|
3642 | if (ret == AVERROR_EOF) |
715 | 3586 | av_log(d, AV_LOG_VERBOSE, "EOF while reading input\n"); | |
716 | else { | ||
717 | 56 | av_log(d, AV_LOG_ERROR, "Error during demuxing: %s\n", | |
718 | 56 | av_err2str(ret)); | |
719 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
|
56 | ret = exit_on_error ? ret : 0; |
720 | } | ||
721 | |||
722 | 3642 | ret_bsf = demux_bsf_flush(d, &dt); | |
723 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3586 times.
|
3642 | ret = err_merge(ret == AVERROR_EOF ? 0 : ret, ret_bsf); |
724 | |||
725 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3631 times.
|
3642 | if (d->loop) { |
726 | /* signal looping to our consumers */ | ||
727 | 11 | dt.pkt_demux->stream_index = -1; | |
728 | 11 | ret = sch_demux_send(d->sch, f->index, dt.pkt_demux, 0); | |
729 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (ret >= 0) |
730 | 11 | ret = seek_to_start(d, (Timestamp){ .ts = dt.pkt_demux->pts, | |
731 | 11 | .tb = dt.pkt_demux->time_base }); | |
732 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (ret >= 0) |
733 | 11 | continue; | |
734 | |||
735 | /* fallthrough to the error path */ | ||
736 | } | ||
737 | |||
738 | 3631 | break; | |
739 | } | ||
740 | |||
741 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 463756 times.
|
463756 | if (do_pkt_dump) { |
742 | ✗ | av_pkt_dump_log2(NULL, AV_LOG_INFO, dt.pkt_demux, do_hex_dump, | |
743 | ✗ | f->ctx->streams[dt.pkt_demux->stream_index]); | |
744 | } | ||
745 | |||
746 | /* the following test is needed in case new streams appear | ||
747 | dynamically in stream : we ignore them */ | ||
748 | 927512 | ds = dt.pkt_demux->stream_index < f->nb_streams ? | |
749 |
1/2✓ Branch 0 taken 463756 times.
✗ Branch 1 not taken.
|
463756 | ds_from_ist(f->streams[dt.pkt_demux->stream_index]) : NULL; |
750 |
5/6✓ Branch 0 taken 463756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 455628 times.
✓ Branch 3 taken 8128 times.
✓ Branch 4 taken 1769 times.
✓ Branch 5 taken 453859 times.
|
463756 | if (!ds || ds->discard || ds->finished) { |
751 | 9897 | report_new_stream(d, dt.pkt_demux); | |
752 | 9897 | av_packet_unref(dt.pkt_demux); | |
753 | 9897 | continue; | |
754 | } | ||
755 | |||
756 |
2/2✓ Branch 0 taken 98 times.
✓ Branch 1 taken 453761 times.
|
453859 | if (dt.pkt_demux->flags & AV_PKT_FLAG_CORRUPT) { |
757 | 98 | av_log(d, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING, | |
758 | "corrupt input packet in stream %d\n", | ||
759 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
|
98 | dt.pkt_demux->stream_index); |
760 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
|
98 | if (exit_on_error) { |
761 | ✗ | av_packet_unref(dt.pkt_demux); | |
762 | ✗ | ret = AVERROR_INVALIDDATA; | |
763 | ✗ | break; | |
764 | } | ||
765 | } | ||
766 | |||
767 | 453859 | ret = input_packet_process(d, dt.pkt_demux, &send_flags); | |
768 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 453859 times.
|
453859 | if (ret < 0) |
769 | ✗ | break; | |
770 | |||
771 |
2/2✓ Branch 0 taken 216 times.
✓ Branch 1 taken 453643 times.
|
453859 | if (d->readrate) |
772 | 216 | readrate_sleep(d); | |
773 | |||
774 | 453859 | ret = demux_send(d, &dt, ds, dt.pkt_demux, send_flags); | |
775 |
2/2✓ Branch 0 taken 3142 times.
✓ Branch 1 taken 450717 times.
|
453859 | if (ret < 0) |
776 | 3142 | break; | |
777 | } | ||
778 | |||
779 | // EOF/EXIT is normal termination | ||
780 |
4/4✓ Branch 0 taken 3674 times.
✓ Branch 1 taken 3099 times.
✓ Branch 2 taken 3631 times.
✓ Branch 3 taken 43 times.
|
6773 | if (ret == AVERROR_EOF || ret == AVERROR_EXIT) |
781 | 3142 | ret = 0; | |
782 | |||
783 | 3631 | finish: | |
784 | 6773 | demux_thread_uninit(&dt); | |
785 | |||
786 | 6773 | return ret; | |
787 | } | ||
788 | |||
789 | 6773 | static void demux_final_stats(Demuxer *d) | |
790 | { | ||
791 | 6773 | InputFile *f = &d->f; | |
792 | 6773 | uint64_t total_packets = 0, total_size = 0; | |
793 | |||
794 | 6773 | av_log(f, AV_LOG_VERBOSE, "Input file #%d (%s):\n", | |
795 | 6773 | f->index, f->ctx->url); | |
796 | |||
797 |
2/2✓ Branch 0 taken 7274 times.
✓ Branch 1 taken 6773 times.
|
14047 | for (int j = 0; j < f->nb_streams; j++) { |
798 | 7274 | InputStream *ist = f->streams[j]; | |
799 | 7274 | DemuxStream *ds = ds_from_ist(ist); | |
800 | 7274 | enum AVMediaType type = ist->par->codec_type; | |
801 | |||
802 |
3/4✓ Branch 0 taken 6994 times.
✓ Branch 1 taken 280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6994 times.
|
7274 | if (ds->discard || type == AVMEDIA_TYPE_ATTACHMENT) |
803 | 280 | continue; | |
804 | |||
805 | 6994 | total_size += ds->data_size; | |
806 | 6994 | total_packets += ds->nb_packets; | |
807 | |||
808 | 6994 | av_log(f, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", | |
809 | f->index, j, av_get_media_type_string(type)); | ||
810 | 6994 | av_log(f, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", | |
811 | ds->nb_packets, ds->data_size); | ||
812 | |||
813 |
2/2✓ Branch 0 taken 6390 times.
✓ Branch 1 taken 604 times.
|
6994 | if (ds->decoding_needed) { |
814 | 6390 | av_log(f, AV_LOG_VERBOSE, | |
815 | "%"PRIu64" frames decoded; %"PRIu64" decode errors", | ||
816 | 6390 | ist->decoder->frames_decoded, ist->decoder->decode_errors); | |
817 |
2/2✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 5190 times.
|
6390 | if (type == AVMEDIA_TYPE_AUDIO) |
818 | 1200 | av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->decoder->samples_decoded); | |
819 | 6390 | av_log(f, AV_LOG_VERBOSE, "; "); | |
820 | } | ||
821 | |||
822 | 6994 | av_log(f, AV_LOG_VERBOSE, "\n"); | |
823 | } | ||
824 | |||
825 | 6773 | av_log(f, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", | |
826 | total_packets, total_size); | ||
827 | 6773 | } | |
828 | |||
829 | 7289 | static void ist_free(InputStream **pist) | |
830 | { | ||
831 | 7289 | InputStream *ist = *pist; | |
832 | DemuxStream *ds; | ||
833 | |||
834 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (!ist) |
835 | ✗ | return; | |
836 | 7289 | ds = ds_from_ist(ist); | |
837 | |||
838 | 7289 | dec_free(&ist->decoder); | |
839 | |||
840 | 7289 | av_dict_free(&ds->decoder_opts); | |
841 | 7289 | av_freep(&ist->filters); | |
842 | 7289 | av_freep(&ist->outputs); | |
843 | 7289 | av_freep(&ds->dec_opts.hwaccel_device); | |
844 | |||
845 | 7289 | avcodec_parameters_free(&ist->par); | |
846 | |||
847 | 7289 | av_frame_free(&ds->decoded_params); | |
848 | |||
849 | 7289 | av_bsf_free(&ds->bsf); | |
850 | |||
851 | 7289 | av_freep(pist); | |
852 | } | ||
853 | |||
854 | 6787 | void ifile_close(InputFile **pf) | |
855 | { | ||
856 | 6787 | InputFile *f = *pf; | |
857 | 6787 | Demuxer *d = demuxer_from_ifile(f); | |
858 | |||
859 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (!f) |
860 | ✗ | return; | |
861 | |||
862 |
2/2✓ Branch 0 taken 6773 times.
✓ Branch 1 taken 14 times.
|
6787 | if (d->read_started) |
863 | 6773 | demux_final_stats(d); | |
864 | |||
865 |
2/2✓ Branch 0 taken 7289 times.
✓ Branch 1 taken 6787 times.
|
14076 | for (int i = 0; i < f->nb_streams; i++) |
866 | 7289 | ist_free(&f->streams[i]); | |
867 | 6787 | av_freep(&f->streams); | |
868 | |||
869 | 6787 | avformat_close_input(&f->ctx); | |
870 | |||
871 | 6787 | av_packet_free(&d->pkt_heartbeat); | |
872 | |||
873 | 6787 | av_freep(pf); | |
874 | } | ||
875 | |||
876 | 7063 | static int ist_use(InputStream *ist, int decoding_needed) | |
877 | { | ||
878 | 7063 | Demuxer *d = demuxer_from_ifile(ist->file); | |
879 | 7063 | DemuxStream *ds = ds_from_ist(ist); | |
880 | int ret; | ||
881 | |||
882 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7063 times.
|
7063 | if (ist->user_set_discard == AVDISCARD_ALL) { |
883 | ✗ | av_log(ist, AV_LOG_ERROR, "Cannot %s a disabled input stream\n", | |
884 | decoding_needed ? "decode" : "streamcopy"); | ||
885 | ✗ | return AVERROR(EINVAL); | |
886 | } | ||
887 | |||
888 |
3/4✓ Branch 0 taken 6436 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6436 times.
|
7063 | if (decoding_needed && !ist->dec) { |
889 | ✗ | av_log(ist, AV_LOG_ERROR, | |
890 | "Decoding requested, but no decoder found for: %s\n", | ||
891 | ✗ | avcodec_get_name(ist->par->codec_id)); | |
892 | ✗ | return AVERROR(EINVAL); | |
893 | } | ||
894 | |||
895 |
2/2✓ Branch 0 taken 6994 times.
✓ Branch 1 taken 69 times.
|
7063 | if (ds->sch_idx_stream < 0) { |
896 | 6994 | ret = sch_add_demux_stream(d->sch, d->f.index); | |
897 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6994 times.
|
6994 | if (ret < 0) |
898 | ✗ | return ret; | |
899 | 6994 | ds->sch_idx_stream = ret; | |
900 | } | ||
901 | |||
902 |
2/2✓ Branch 0 taken 6994 times.
✓ Branch 1 taken 69 times.
|
7063 | if (ds->discard) { |
903 | 6994 | ds->discard = 0; | |
904 | 6994 | d->nb_streams_used++; | |
905 | } | ||
906 | |||
907 | 7063 | ist->st->discard = ist->user_set_discard; | |
908 | 7063 | ds->decoding_needed |= decoding_needed; | |
909 | 7063 | ds->streamcopy_needed |= !decoding_needed; | |
910 | |||
911 |
4/4✓ Branch 0 taken 6436 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 6390 times.
✓ Branch 3 taken 46 times.
|
7063 | if (decoding_needed && ds->sch_idx_dec < 0) { |
912 | 6390 | int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO; | |
913 | |||
914 | 12780 | ds->dec_opts.flags |= (!!ist->fix_sub_duration * DECODER_FLAG_FIX_SUB_DURATION) | | |
915 | 12780 | (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE) | | |
916 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6388 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
6390 | (!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS) |
917 | #if FFMPEG_OPT_TOP | ||
918 |
2/2✓ Branch 0 taken 1240 times.
✓ Branch 1 taken 5150 times.
|
6390 | | ((ist->top_field_first >= 0) * DECODER_FLAG_TOP_FIELD_FIRST) |
919 | #endif | ||
920 | ; | ||
921 | |||
922 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6365 times.
|
6390 | if (ist->framerate.num) { |
923 | 25 | ds->dec_opts.flags |= DECODER_FLAG_FRAMERATE_FORCED; | |
924 | 25 | ds->dec_opts.framerate = ist->framerate; | |
925 | } else | ||
926 | 6365 | ds->dec_opts.framerate = ist->st->avg_frame_rate; | |
927 | |||
928 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6389 times.
|
6390 | if (ist->dec->id == AV_CODEC_ID_DVB_SUBTITLE && |
929 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | (ds->decoding_needed & DECODING_FOR_OST)) { |
930 | 1 | av_dict_set(&ds->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); | |
931 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ds->decoding_needed & DECODING_FOR_FILTER) |
932 | ✗ | av_log(ist, AV_LOG_WARNING, | |
933 | "Warning using DVB subtitles for filtering and output at the " | ||
934 | "same time is not fully supported, also see -compute_edt [0|1]\n"); | ||
935 | } | ||
936 | |||
937 | 6390 | snprintf(ds->dec_name, sizeof(ds->dec_name), "%d:%d", ist->file->index, ist->index); | |
938 | 6390 | ds->dec_opts.name = ds->dec_name; | |
939 | |||
940 | 6390 | ds->dec_opts.codec = ist->dec; | |
941 | 6390 | ds->dec_opts.par = ist->par; | |
942 | |||
943 | 6390 | ds->dec_opts.log_parent = ist; | |
944 | |||
945 | 6390 | ds->decoded_params = av_frame_alloc(); | |
946 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6390 times.
|
6390 | if (!ds->decoded_params) |
947 | ✗ | return AVERROR(ENOMEM); | |
948 | |||
949 | 6390 | ret = dec_init(&ist->decoder, d->sch, | |
950 | 6390 | &ds->decoder_opts, &ds->dec_opts, ds->decoded_params); | |
951 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6390 times.
|
6390 | if (ret < 0) |
952 | ✗ | return ret; | |
953 | 6390 | ds->sch_idx_dec = ret; | |
954 | |||
955 | 6390 | ret = sch_connect(d->sch, SCH_DSTREAM(d->f.index, ds->sch_idx_stream), | |
956 | 6390 | SCH_DEC(ds->sch_idx_dec)); | |
957 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6390 times.
|
6390 | if (ret < 0) |
958 | ✗ | return ret; | |
959 | |||
960 | 6390 | d->have_audio_dec |= is_audio; | |
961 | } | ||
962 | |||
963 | 7063 | return 0; | |
964 | } | ||
965 | |||
966 | 665 | int ist_output_add(InputStream *ist, OutputStream *ost) | |
967 | { | ||
968 | 665 | DemuxStream *ds = ds_from_ist(ist); | |
969 | int ret; | ||
970 | |||
971 | 665 | ret = ist_use(ist, ost->enc ? DECODING_FOR_OST : 0); | |
972 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 665 times.
|
665 | if (ret < 0) |
973 | ✗ | return ret; | |
974 | |||
975 | 665 | ret = GROW_ARRAY(ist->outputs, ist->nb_outputs); | |
976 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 665 times.
|
665 | if (ret < 0) |
977 | ✗ | return ret; | |
978 | |||
979 | 665 | ist->outputs[ist->nb_outputs - 1] = ost; | |
980 | |||
981 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 627 times.
|
665 | return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream; |
982 | } | ||
983 | |||
984 | 6398 | int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, | |
985 | InputFilterOptions *opts) | ||
986 | { | ||
987 | 6398 | Demuxer *d = demuxer_from_ifile(ist->file); | |
988 | 6398 | DemuxStream *ds = ds_from_ist(ist); | |
989 | 6398 | int64_t tsoffset = 0; | |
990 | int ret; | ||
991 | |||
992 |
2/2✓ Branch 0 taken 6267 times.
✓ Branch 1 taken 131 times.
|
6398 | ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER); |
993 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6398 times.
|
6398 | if (ret < 0) |
994 | ✗ | return ret; | |
995 | |||
996 | 6398 | ret = GROW_ARRAY(ist->filters, ist->nb_filters); | |
997 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6398 times.
|
6398 | if (ret < 0) |
998 | ✗ | return ret; | |
999 | |||
1000 | 6398 | ist->filters[ist->nb_filters - 1] = ifilter; | |
1001 | |||
1002 |
2/2✓ Branch 0 taken 5154 times.
✓ Branch 1 taken 1244 times.
|
6398 | if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { |
1003 |
3/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5129 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
|
5154 | if (ist->framerate.num > 0 && ist->framerate.den > 0) { |
1004 | 25 | opts->framerate = ist->framerate; | |
1005 | 25 | opts->flags |= IFILTER_FLAG_CFR; | |
1006 | } else | ||
1007 | 5129 | opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); | |
1008 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1240 times.
|
1244 | } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
1009 | /* Compute the size of the canvas for the subtitles stream. | ||
1010 | If the subtitles codecpar has set a size, use it. Otherwise use the | ||
1011 | maximum dimensions of the video streams in the same file. */ | ||
1012 | 4 | opts->sub2video_width = ist->par->width; | |
1013 | 4 | opts->sub2video_height = ist->par->height; | |
1014 |
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)) { |
1015 | ✗ | for (int j = 0; j < d->f.nb_streams; j++) { | |
1016 | ✗ | AVCodecParameters *par1 = d->f.streams[j]->par; | |
1017 | ✗ | if (par1->codec_type == AVMEDIA_TYPE_VIDEO) { | |
1018 | ✗ | opts->sub2video_width = FFMAX(opts->sub2video_width, par1->width); | |
1019 | ✗ | opts->sub2video_height = FFMAX(opts->sub2video_height, par1->height); | |
1020 | } | ||
1021 | } | ||
1022 | } | ||
1023 | |||
1024 |
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)) { |
1025 | ✗ | opts->sub2video_width = FFMAX(opts->sub2video_width, 720); | |
1026 | ✗ | opts->sub2video_height = FFMAX(opts->sub2video_height, 576); | |
1027 | } | ||
1028 | |||
1029 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (!d->pkt_heartbeat) { |
1030 | 4 | d->pkt_heartbeat = av_packet_alloc(); | |
1031 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (!d->pkt_heartbeat) |
1032 | ✗ | return AVERROR(ENOMEM); | |
1033 | } | ||
1034 | 4 | ds->have_sub2video = 1; | |
1035 | } | ||
1036 | |||
1037 | 6398 | ret = av_frame_copy_props(opts->fallback, ds->decoded_params); | |
1038 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6398 times.
|
6398 | if (ret < 0) |
1039 | ✗ | return ret; | |
1040 | 6398 | opts->fallback->format = ds->decoded_params->format; | |
1041 | 6398 | opts->fallback->width = ds->decoded_params->width; | |
1042 | 6398 | opts->fallback->height = ds->decoded_params->height; | |
1043 | |||
1044 | 6398 | ret = av_channel_layout_copy(&opts->fallback->ch_layout, &ds->decoded_params->ch_layout); | |
1045 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6398 times.
|
6398 | if (ret < 0) |
1046 | ✗ | return ret; | |
1047 | |||
1048 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6395 times.
|
6398 | if (copy_ts) { |
1049 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | tsoffset = d->f.start_time == AV_NOPTS_VALUE ? 0 : d->f.start_time; |
1050 |
3/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
3 | if (!start_at_zero && d->f.ctx->start_time != AV_NOPTS_VALUE) |
1051 | 2 | tsoffset += d->f.ctx->start_time; | |
1052 | } | ||
1053 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | opts->trim_start_us = ((d->f.start_time == AV_NOPTS_VALUE) || !d->accurate_seek) ? |
1054 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6382 times.
|
6414 | AV_NOPTS_VALUE : tsoffset; |
1055 | 6398 | opts->trim_end_us = d->recording_time; | |
1056 | |||
1057 | 6398 | opts->name = av_strdup(ds->dec_name); | |
1058 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6398 times.
|
6398 | if (!opts->name) |
1059 | ✗ | return AVERROR(ENOMEM); | |
1060 | |||
1061 | 12796 | opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | | |
1062 |
1/2✓ Branch 0 taken 6398 times.
✗ Branch 1 not taken.
|
6398 | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); |
1063 | |||
1064 | 6398 | return ds->sch_idx_dec; | |
1065 | } | ||
1066 | |||
1067 | 14453 | static int choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, | |
1068 | enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type, | ||
1069 | const AVCodec **pcodec) | ||
1070 | |||
1071 | { | ||
1072 | 14453 | char *codec_name = NULL; | |
1073 | |||
1074 |
6/20✓ Branch 1 taken 5513 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 5523 times.
✓ Branch 6 taken 14453 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14453 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
19976 | MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); |
1075 |
2/2✓ Branch 0 taken 5513 times.
✓ Branch 1 taken 8940 times.
|
14453 | if (codec_name) { |
1076 | 5513 | int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec); | |
1077 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5513 times.
|
5513 | if (ret < 0) |
1078 | ✗ | return ret; | |
1079 | 5513 | st->codecpar->codec_id = (*pcodec)->id; | |
1080 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5513 | if (recast_media && st->codecpar->codec_type != (*pcodec)->type) |
1081 | ✗ | st->codecpar->codec_type = (*pcodec)->type; | |
1082 | 5513 | return 0; | |
1083 | } else { | ||
1084 |
3/4✓ Branch 0 taken 5553 times.
✓ Branch 1 taken 3387 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5553 times.
|
8940 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && |
1085 | ✗ | hwaccel_id == HWACCEL_GENERIC && | |
1086 | hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) { | ||
1087 | const AVCodec *c; | ||
1088 | ✗ | void *i = NULL; | |
1089 | |||
1090 | ✗ | while ((c = av_codec_iterate(&i))) { | |
1091 | const AVCodecHWConfig *config; | ||
1092 | |||
1093 | ✗ | if (c->id != st->codecpar->codec_id || | |
1094 | ✗ | !av_codec_is_decoder(c)) | |
1095 | ✗ | continue; | |
1096 | |||
1097 | ✗ | for (int j = 0; config = avcodec_get_hw_config(c, j); j++) { | |
1098 | ✗ | if (config->device_type == hwaccel_device_type) { | |
1099 | ✗ | av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n", | |
1100 | ✗ | c->name, av_hwdevice_get_type_name(hwaccel_device_type)); | |
1101 | ✗ | *pcodec = c; | |
1102 | ✗ | return 0; | |
1103 | } | ||
1104 | } | ||
1105 | } | ||
1106 | } | ||
1107 | |||
1108 | 8940 | *pcodec = avcodec_find_decoder(st->codecpar->codec_id); | |
1109 | 8940 | return 0; | |
1110 | } | ||
1111 | } | ||
1112 | |||
1113 | 1623 | static int guess_input_channel_layout(InputStream *ist, AVCodecParameters *par, | |
1114 | int guess_layout_max) | ||
1115 | { | ||
1116 |
2/2✓ Branch 0 taken 764 times.
✓ Branch 1 taken 859 times.
|
1623 | if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { |
1117 | char layout_name[256]; | ||
1118 | |||
1119 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 760 times.
|
764 | if (par->ch_layout.nb_channels > guess_layout_max) |
1120 | 12 | return 0; | |
1121 | 760 | av_channel_layout_default(&par->ch_layout, par->ch_layout.nb_channels); | |
1122 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 752 times.
|
760 | if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) |
1123 | 8 | return 0; | |
1124 | 752 | av_channel_layout_describe(&par->ch_layout, layout_name, sizeof(layout_name)); | |
1125 | 752 | av_log(ist, AV_LOG_WARNING, "Guessed Channel Layout: %s\n", layout_name); | |
1126 | } | ||
1127 | 1611 | return 1; | |
1128 | } | ||
1129 | |||
1130 | 5524 | static int add_display_matrix_to_stream(const OptionsContext *o, | |
1131 | AVFormatContext *ctx, InputStream *ist) | ||
1132 | { | ||
1133 | 5524 | AVStream *st = ist->st; | |
1134 | AVPacketSideData *sd; | ||
1135 | 5524 | double rotation = DBL_MAX; | |
1136 | 5524 | int hflip = -1, vflip = -1; | |
1137 | 5524 | int hflip_set = 0, vflip_set = 0, rotation_set = 0; | |
1138 | int32_t *buf; | ||
1139 | |||
1140 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5525 | MATCH_PER_STREAM_OPT(display_rotations, dbl, rotation, ctx, st); |
1141 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5524 | MATCH_PER_STREAM_OPT(display_hflips, i, hflip, ctx, st); |
1142 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5524 | MATCH_PER_STREAM_OPT(display_vflips, i, vflip, ctx, st); |
1143 | |||
1144 | 5524 | rotation_set = rotation != DBL_MAX; | |
1145 | 5524 | hflip_set = hflip != -1; | |
1146 | 5524 | vflip_set = vflip != -1; | |
1147 | |||
1148 |
4/6✓ Branch 0 taken 5523 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 5523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5523 times.
✗ Branch 5 not taken.
|
5524 | if (!rotation_set && !hflip_set && !vflip_set) |
1149 | 5523 | return 0; | |
1150 | |||
1151 | 1 | sd = av_packet_side_data_new(&st->codecpar->coded_side_data, | |
1152 | 1 | &st->codecpar->nb_coded_side_data, | |
1153 | AV_PKT_DATA_DISPLAYMATRIX, | ||
1154 | sizeof(int32_t) * 9, 0); | ||
1155 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!sd) { |
1156 | ✗ | av_log(ist, AV_LOG_FATAL, "Failed to generate a display matrix!\n"); | |
1157 | ✗ | return AVERROR(ENOMEM); | |
1158 | } | ||
1159 | |||
1160 | 1 | buf = (int32_t *)sd->data; | |
1161 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | av_display_rotation_set(buf, |
1162 | rotation_set ? -(rotation) : -0.0f); | ||
1163 | |||
1164 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | av_display_matrix_flip(buf, |
1165 | hflip_set ? hflip : 0, | ||
1166 | vflip_set ? vflip : 0); | ||
1167 | |||
1168 | 1 | return 0; | |
1169 | } | ||
1170 | |||
1171 | 1374 | static const char *input_stream_item_name(void *obj) | |
1172 | { | ||
1173 | 1374 | const DemuxStream *ds = obj; | |
1174 | |||
1175 | 1374 | return ds->log_name; | |
1176 | } | ||
1177 | |||
1178 | static const AVClass input_stream_class = { | ||
1179 | .class_name = "InputStream", | ||
1180 | .version = LIBAVUTIL_VERSION_INT, | ||
1181 | .item_name = input_stream_item_name, | ||
1182 | .category = AV_CLASS_CATEGORY_DEMUXER, | ||
1183 | }; | ||
1184 | |||
1185 | 7289 | static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st) | |
1186 | { | ||
1187 | 7289 | const char *type_str = av_get_media_type_string(st->codecpar->codec_type); | |
1188 | 7289 | InputFile *f = &d->f; | |
1189 | DemuxStream *ds; | ||
1190 | |||
1191 | 7289 | ds = allocate_array_elem(&f->streams, sizeof(*ds), &f->nb_streams); | |
1192 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (!ds) |
1193 | ✗ | return NULL; | |
1194 | |||
1195 | 7289 | ds->sch_idx_stream = -1; | |
1196 | 7289 | ds->sch_idx_dec = -1; | |
1197 | |||
1198 | 7289 | ds->ist.st = st; | |
1199 | 7289 | ds->ist.file = f; | |
1200 | 7289 | ds->ist.index = st->index; | |
1201 | 7289 | ds->ist.class = &input_stream_class; | |
1202 | |||
1203 |
1/2✓ Branch 0 taken 7289 times.
✗ Branch 1 not taken.
|
7289 | snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s", |
1204 | 7289 | type_str ? *type_str : '?', d->f.index, st->index, | |
1205 | 7289 | avcodec_get_name(st->codecpar->codec_id)); | |
1206 | |||
1207 | 7289 | return ds; | |
1208 | } | ||
1209 | |||
1210 | 7289 | static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) | |
1211 | { | ||
1212 | 7289 | AVFormatContext *ic = d->f.ctx; | |
1213 | 7289 | AVCodecParameters *par = st->codecpar; | |
1214 | DemuxStream *ds; | ||
1215 | InputStream *ist; | ||
1216 | 7289 | char *framerate = NULL, *hwaccel_device = NULL; | |
1217 | 7289 | const char *hwaccel = NULL; | |
1218 | 7289 | char *hwaccel_output_format = NULL; | |
1219 | 7289 | char *codec_tag = NULL; | |
1220 | 7289 | char *bsfs = NULL; | |
1221 | char *next; | ||
1222 | 7289 | char *discard_str = NULL; | |
1223 | int ret; | ||
1224 | |||
1225 | 7289 | ds = demux_stream_alloc(d, st); | |
1226 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (!ds) |
1227 | ✗ | return AVERROR(ENOMEM); | |
1228 | |||
1229 | 7289 | ist = &ds->ist; | |
1230 | |||
1231 | 7289 | ds->discard = 1; | |
1232 | 7289 | st->discard = AVDISCARD_ALL; | |
1233 | 7289 | ds->first_dts = AV_NOPTS_VALUE; | |
1234 | 7289 | ds->next_dts = AV_NOPTS_VALUE; | |
1235 | |||
1236 | 7289 | ds->dec_opts.time_base = st->time_base; | |
1237 | |||
1238 | 7289 | ds->ts_scale = 1.0; | |
1239 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7289 | MATCH_PER_STREAM_OPT(ts_scale, dbl, ds->ts_scale, ic, st); |
1240 | |||
1241 | 7289 | ds->autorotate = 1; | |
1242 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7289 | MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); |
1243 | |||
1244 |
4/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7291 | MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); |
1245 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7287 times.
|
7289 | if (codec_tag) { |
1246 | 2 | uint32_t tag = strtol(codec_tag, &next, 0); | |
1247 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (*next) { |
1248 | 2 | uint8_t buf[4] = { 0 }; | |
1249 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag))); |
1250 | 2 | tag = AV_RL32(buf); | |
1251 | } | ||
1252 | |||
1253 | 2 | st->codecpar->codec_tag = tag; | |
1254 | } | ||
1255 | |||
1256 |
2/2✓ Branch 0 taken 5524 times.
✓ Branch 1 taken 1765 times.
|
7289 | if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { |
1257 | 5524 | ret = add_display_matrix_to_stream(o, ic, ist); | |
1258 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5524 times.
|
5524 | if (ret < 0) |
1259 | ✗ | return ret; | |
1260 | |||
1261 |
4/20✓ Branch 1 taken 5236 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5236 times.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
10760 | MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st); |
1262 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5524 | MATCH_PER_STREAM_OPT(hwaccel_output_formats, str, |
1263 | hwaccel_output_format, ic, st); | ||
1264 | |||
1265 |
4/6✓ Branch 0 taken 5524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5236 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5236 times.
|
5524 | if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) { |
1266 | ✗ | av_log(ist, AV_LOG_WARNING, | |
1267 | "WARNING: defaulting hwaccel_output_format to cuda for compatibility " | ||
1268 | "with old commandlines. This behaviour is DEPRECATED and will be removed " | ||
1269 | "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n"); | ||
1270 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_CUDA; | |
1271 |
4/6✓ Branch 0 taken 5524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5236 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5236 times.
|
5524 | } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "qsv")) { |
1272 | ✗ | av_log(ist, AV_LOG_WARNING, | |
1273 | "WARNING: defaulting hwaccel_output_format to qsv for compatibility " | ||
1274 | "with old commandlines. This behaviour is DEPRECATED and will be removed " | ||
1275 | "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n"); | ||
1276 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_QSV; | |
1277 |
4/6✓ Branch 0 taken 5524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5236 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5236 times.
|
5524 | } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "mediacodec")) { |
1278 | // There is no real AVHWFrameContext implementation. Set | ||
1279 | // hwaccel_output_format to avoid av_hwframe_transfer_data error. | ||
1280 | ✗ | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_MEDIACODEC; | |
1281 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5524 times.
|
5524 | } else if (hwaccel_output_format) { |
1282 | ✗ | ds->dec_opts.hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format); | |
1283 | ✗ | if (ds->dec_opts.hwaccel_output_format == AV_PIX_FMT_NONE) { | |
1284 | ✗ | av_log(ist, AV_LOG_FATAL, "Unrecognised hwaccel output " | |
1285 | "format: %s", hwaccel_output_format); | ||
1286 | } | ||
1287 | } else { | ||
1288 | 5524 | ds->dec_opts.hwaccel_output_format = AV_PIX_FMT_NONE; | |
1289 | } | ||
1290 | |||
1291 |
2/2✓ Branch 0 taken 5236 times.
✓ Branch 1 taken 288 times.
|
5524 | if (hwaccel) { |
1292 | // The NVDEC hwaccels use a CUDA device, so remap the name here. | ||
1293 |
2/4✓ Branch 0 taken 5236 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5236 times.
|
5236 | if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid")) |
1294 | ✗ | hwaccel = "cuda"; | |
1295 | |||
1296 |
1/2✓ Branch 0 taken 5236 times.
✗ Branch 1 not taken.
|
5236 | if (!strcmp(hwaccel, "none")) |
1297 | 5236 | ds->dec_opts.hwaccel_id = HWACCEL_NONE; | |
1298 | ✗ | else if (!strcmp(hwaccel, "auto")) | |
1299 | ✗ | ds->dec_opts.hwaccel_id = HWACCEL_AUTO; | |
1300 | else { | ||
1301 | ✗ | enum AVHWDeviceType type = av_hwdevice_find_type_by_name(hwaccel); | |
1302 | ✗ | if (type != AV_HWDEVICE_TYPE_NONE) { | |
1303 | ✗ | ds->dec_opts.hwaccel_id = HWACCEL_GENERIC; | |
1304 | ✗ | ds->dec_opts.hwaccel_device_type = type; | |
1305 | } | ||
1306 | |||
1307 | ✗ | if (!ds->dec_opts.hwaccel_id) { | |
1308 | ✗ | av_log(ist, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n", | |
1309 | hwaccel); | ||
1310 | ✗ | av_log(ist, AV_LOG_FATAL, "Supported hwaccels: "); | |
1311 | ✗ | type = AV_HWDEVICE_TYPE_NONE; | |
1312 | ✗ | while ((type = av_hwdevice_iterate_types(type)) != | |
1313 | AV_HWDEVICE_TYPE_NONE) | ||
1314 | ✗ | av_log(ist, AV_LOG_FATAL, "%s ", | |
1315 | av_hwdevice_get_type_name(type)); | ||
1316 | ✗ | av_log(ist, AV_LOG_FATAL, "\n"); | |
1317 | ✗ | return AVERROR(EINVAL); | |
1318 | } | ||
1319 | } | ||
1320 | } | ||
1321 | |||
1322 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5524 | MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st); |
1323 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5524 times.
|
5524 | if (hwaccel_device) { |
1324 | ✗ | ds->dec_opts.hwaccel_device = av_strdup(hwaccel_device); | |
1325 | ✗ | if (!ds->dec_opts.hwaccel_device) | |
1326 | ✗ | return AVERROR(ENOMEM); | |
1327 | } | ||
1328 | } | ||
1329 | |||
1330 | 7289 | ret = choose_decoder(o, ic, st, ds->dec_opts.hwaccel_id, | |
1331 | ds->dec_opts.hwaccel_device_type, &ist->dec); | ||
1332 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (ret < 0) |
1333 | ✗ | return ret; | |
1334 | |||
1335 |
2/2✓ Branch 0 taken 7217 times.
✓ Branch 1 taken 72 times.
|
7289 | if (ist->dec) { |
1336 | 7217 | ret = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, | |
1337 | ic, st, ist->dec, &ds->decoder_opts); | ||
1338 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7217 times.
|
7217 | if (ret < 0) |
1339 | ✗ | return ret; | |
1340 | } | ||
1341 | |||
1342 | 7289 | ds->reinit_filters = -1; | |
1343 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7289 | MATCH_PER_STREAM_OPT(reinit_filters, i, ds->reinit_filters, ic, st); |
1344 | |||
1345 | 7289 | ist->user_set_discard = AVDISCARD_NONE; | |
1346 | |||
1347 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7289 | if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) || |
1348 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
7289 | (o->audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) || |
1349 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7288 | (o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) || |
1350 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7288 | (o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA)) |
1351 | 1 | ist->user_set_discard = AVDISCARD_ALL; | |
1352 | |||
1353 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7289 | MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st); |
1354 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (discard_str) { |
1355 | ✗ | ret = av_opt_set(ist->st, "discard", discard_str, 0); | |
1356 | ✗ | if (ret < 0) { | |
1357 | ✗ | av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str); | |
1358 | ✗ | return ret; | |
1359 | } | ||
1360 | ✗ | ist->user_set_discard = ist->st->discard; | |
1361 | } | ||
1362 | |||
1363 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 7193 times.
|
7289 | ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; |
1364 | |||
1365 | /* Attached pics are sparse, therefore we would not want to delay their decoding | ||
1366 | * till EOF. */ | ||
1367 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 7252 times.
|
7289 | if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) |
1368 | 37 | av_dict_set(&ds->decoder_opts, "thread_type", "-frame", 0); | |
1369 | |||
1370 |
4/5✓ Branch 0 taken 5524 times.
✓ Branch 1 taken 1623 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
7289 | switch (par->codec_type) { |
1371 | 5524 | case AVMEDIA_TYPE_VIDEO: | |
1372 |
4/20✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5550 | MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st); |
1373 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 5498 times.
|
5524 | if (framerate) { |
1374 | 26 | ret = av_parse_video_rate(&ist->framerate, framerate); | |
1375 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
|
26 | if (ret < 0) { |
1376 | ✗ | av_log(ist, AV_LOG_ERROR, "Error parsing framerate %s.\n", | |
1377 | framerate); | ||
1378 | ✗ | return ret; | |
1379 | } | ||
1380 | } | ||
1381 | |||
1382 | #if FFMPEG_OPT_TOP | ||
1383 | 5524 | ist->top_field_first = -1; | |
1384 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5524 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5524 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
5524 | MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st); |
1385 | #endif | ||
1386 | |||
1387 | 5524 | break; | |
1388 | 1623 | case AVMEDIA_TYPE_AUDIO: { | |
1389 | 1623 | int guess_layout_max = INT_MAX; | |
1390 |
4/20✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1623 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1623 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
1627 | MATCH_PER_STREAM_OPT(guess_layout_max, i, guess_layout_max, ic, st); |
1391 | 1623 | guess_input_channel_layout(ist, par, guess_layout_max); | |
1392 | 1623 | break; | |
1393 | } | ||
1394 | 140 | case AVMEDIA_TYPE_DATA: | |
1395 | case AVMEDIA_TYPE_SUBTITLE: { | ||
1396 | 140 | char *canvas_size = NULL; | |
1397 |
4/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 140 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
142 | MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st); |
1398 |
2/20✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 140 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
140 | MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st); |
1399 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
|
140 | if (canvas_size) { |
1400 | ✗ | ret = av_parse_video_size(&par->width, &par->height, | |
1401 | canvas_size); | ||
1402 | ✗ | if (ret < 0) { | |
1403 | ✗ | av_log(ist, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size); | |
1404 | ✗ | return ret; | |
1405 | } | ||
1406 | } | ||
1407 | 140 | break; | |
1408 | } | ||
1409 | 2 | case AVMEDIA_TYPE_ATTACHMENT: | |
1410 | case AVMEDIA_TYPE_UNKNOWN: | ||
1411 | 2 | break; | |
1412 | ✗ | default: av_assert0(0); | |
1413 | } | ||
1414 | |||
1415 | 7289 | ist->par = avcodec_parameters_alloc(); | |
1416 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (!ist->par) |
1417 | ✗ | return AVERROR(ENOMEM); | |
1418 | |||
1419 | 7289 | ret = avcodec_parameters_copy(ist->par, par); | |
1420 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (ret < 0) { |
1421 | ✗ | av_log(ist, AV_LOG_ERROR, "Error exporting stream parameters.\n"); | |
1422 | ✗ | return ret; | |
1423 | } | ||
1424 | |||
1425 |
2/2✓ Branch 0 taken 428 times.
✓ Branch 1 taken 6861 times.
|
7289 | if (ist->st->sample_aspect_ratio.num) |
1426 | 428 | ist->par->sample_aspect_ratio = ist->st->sample_aspect_ratio; | |
1427 | |||
1428 |
4/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 7289 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7289 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7290 | MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, ic, st); |
1429 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7288 times.
|
7289 | if (bsfs) { |
1430 | 1 | ret = av_bsf_list_parse_str(bsfs, &ds->bsf); | |
1431 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ret < 0) { |
1432 | ✗ | av_log(ist, AV_LOG_ERROR, | |
1433 | "Error parsing bitstream filter sequence '%s': %s\n", | ||
1434 | ✗ | bsfs, av_err2str(ret)); | |
1435 | ✗ | return ret; | |
1436 | } | ||
1437 | |||
1438 | 1 | ret = avcodec_parameters_copy(ds->bsf->par_in, ist->par); | |
1439 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ret < 0) |
1440 | ✗ | return ret; | |
1441 | 1 | ds->bsf->time_base_in = ist->st->time_base; | |
1442 | |||
1443 | 1 | ret = av_bsf_init(ds->bsf); | |
1444 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ret < 0) { |
1445 | ✗ | av_log(ist, AV_LOG_ERROR, "Error initializing bitstream filters: %s\n", | |
1446 | ✗ | av_err2str(ret)); | |
1447 | ✗ | return ret; | |
1448 | } | ||
1449 | |||
1450 | 1 | ret = avcodec_parameters_copy(ist->par, ds->bsf->par_out); | |
1451 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (ret < 0) |
1452 | ✗ | return ret; | |
1453 | } | ||
1454 | |||
1455 | 7289 | ds->codec_desc = avcodec_descriptor_get(ist->par->codec_id); | |
1456 | |||
1457 | 7289 | return 0; | |
1458 | } | ||
1459 | |||
1460 | ✗ | static int dump_attachment(InputStream *ist, const char *filename) | |
1461 | { | ||
1462 | ✗ | AVStream *st = ist->st; | |
1463 | int ret; | ||
1464 | ✗ | AVIOContext *out = NULL; | |
1465 | const AVDictionaryEntry *e; | ||
1466 | |||
1467 | ✗ | if (!st->codecpar->extradata_size) { | |
1468 | ✗ | av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n"); | |
1469 | ✗ | return 0; | |
1470 | } | ||
1471 | ✗ | if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) | |
1472 | ✗ | filename = e->value; | |
1473 | ✗ | if (!*filename) { | |
1474 | ✗ | av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag"); | |
1475 | ✗ | return AVERROR(EINVAL); | |
1476 | } | ||
1477 | |||
1478 | ✗ | ret = assert_file_overwrite(filename); | |
1479 | ✗ | if (ret < 0) | |
1480 | ✗ | return ret; | |
1481 | |||
1482 | ✗ | if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { | |
1483 | ✗ | av_log(ist, AV_LOG_FATAL, "Could not open file %s for writing.\n", | |
1484 | filename); | ||
1485 | ✗ | return ret; | |
1486 | } | ||
1487 | |||
1488 | ✗ | avio_write(out, st->codecpar->extradata, st->codecpar->extradata_size); | |
1489 | ✗ | ret = avio_close(out); | |
1490 | |||
1491 | ✗ | if (ret >= 0) | |
1492 | ✗ | av_log(ist, AV_LOG_INFO, "Wrote attachment (%d bytes) to '%s'\n", | |
1493 | ✗ | st->codecpar->extradata_size, filename); | |
1494 | |||
1495 | ✗ | return ret; | |
1496 | } | ||
1497 | |||
1498 | 618 | static const char *input_file_item_name(void *obj) | |
1499 | { | ||
1500 | 618 | const Demuxer *d = obj; | |
1501 | |||
1502 | 618 | return d->log_name; | |
1503 | } | ||
1504 | |||
1505 | static const AVClass input_file_class = { | ||
1506 | .class_name = "InputFile", | ||
1507 | .version = LIBAVUTIL_VERSION_INT, | ||
1508 | .item_name = input_file_item_name, | ||
1509 | .category = AV_CLASS_CATEGORY_DEMUXER, | ||
1510 | }; | ||
1511 | |||
1512 | 6787 | static Demuxer *demux_alloc(void) | |
1513 | { | ||
1514 | 6787 | Demuxer *d = allocate_array_elem(&input_files, sizeof(*d), &nb_input_files); | |
1515 | |||
1516 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (!d) |
1517 | ✗ | return NULL; | |
1518 | |||
1519 | 6787 | d->f.class = &input_file_class; | |
1520 | 6787 | d->f.index = nb_input_files - 1; | |
1521 | |||
1522 | 6787 | snprintf(d->log_name, sizeof(d->log_name), "in#%d", d->f.index); | |
1523 | |||
1524 | 6787 | return d; | |
1525 | } | ||
1526 | |||
1527 | 6787 | int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch) | |
1528 | { | ||
1529 | Demuxer *d; | ||
1530 | InputFile *f; | ||
1531 | AVFormatContext *ic; | ||
1532 | 6787 | const AVInputFormat *file_iformat = NULL; | |
1533 | 6787 | int err, i, ret = 0; | |
1534 | int64_t timestamp; | ||
1535 | 6787 | AVDictionary *unused_opts = NULL; | |
1536 | 6787 | const AVDictionaryEntry *e = NULL; | |
1537 | 6787 | const char* video_codec_name = NULL; | |
1538 | 6787 | const char* audio_codec_name = NULL; | |
1539 | 6787 | const char* subtitle_codec_name = NULL; | |
1540 | 6787 | const char* data_codec_name = NULL; | |
1541 | 6787 | int scan_all_pmts_set = 0; | |
1542 | |||
1543 | 6787 | int64_t start_time = o->start_time; | |
1544 | 6787 | int64_t start_time_eof = o->start_time_eof; | |
1545 | 6787 | int64_t stop_time = o->stop_time; | |
1546 | 6787 | int64_t recording_time = o->recording_time; | |
1547 | |||
1548 | 6787 | d = demux_alloc(); | |
1549 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (!d) |
1550 | ✗ | return AVERROR(ENOMEM); | |
1551 | |||
1552 | 6787 | f = &d->f; | |
1553 | |||
1554 | 6787 | ret = sch_add_demux(sch, input_thread, d); | |
1555 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (ret < 0) |
1556 | ✗ | return ret; | |
1557 | 6787 | d->sch = sch; | |
1558 | |||
1559 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6787 | if (stop_time != INT64_MAX && recording_time != INT64_MAX) { |
1560 | ✗ | stop_time = INT64_MAX; | |
1561 | ✗ | av_log(d, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n"); | |
1562 | } | ||
1563 | |||
1564 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6787 | if (stop_time != INT64_MAX && recording_time == INT64_MAX) { |
1565 | ✗ | int64_t start = start_time == AV_NOPTS_VALUE ? 0 : start_time; | |
1566 | ✗ | if (stop_time <= start) { | |
1567 | ✗ | av_log(d, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n"); | |
1568 | ✗ | return AVERROR(EINVAL); | |
1569 | } else { | ||
1570 | ✗ | recording_time = stop_time - start; | |
1571 | } | ||
1572 | } | ||
1573 | |||
1574 |
2/2✓ Branch 0 taken 3341 times.
✓ Branch 1 taken 3446 times.
|
6787 | if (o->format) { |
1575 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3341 times.
|
3341 | if (!(file_iformat = av_find_input_format(o->format))) { |
1576 | ✗ | av_log(d, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format); | |
1577 | ✗ | return AVERROR(EINVAL); | |
1578 | } | ||
1579 | } | ||
1580 | |||
1581 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (!strcmp(filename, "-")) |
1582 | ✗ | filename = "fd:"; | |
1583 | |||
1584 | 20361 | stdin_interaction &= strncmp(filename, "pipe:", 5) && | |
1585 |
2/4✓ Branch 0 taken 6787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6787 times.
✗ Branch 3 not taken.
|
13574 | strcmp(filename, "fd:") && |
1586 |
1/2✓ Branch 0 taken 6787 times.
✗ Branch 1 not taken.
|
6787 | strcmp(filename, "/dev/stdin"); |
1587 | |||
1588 | /* get default parameters from command line */ | ||
1589 | 6787 | ic = avformat_alloc_context(); | |
1590 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (!ic) |
1591 | ✗ | return AVERROR(ENOMEM); | |
1592 |
2/2✓ Branch 0 taken 66 times.
✓ Branch 1 taken 6721 times.
|
6787 | if (o->audio_sample_rate.nb_opt) { |
1593 | 66 | 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); | |
1594 | } | ||
1595 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6778 times.
|
6787 | if (o->audio_channels.nb_opt) { |
1596 | const AVClass *priv_class; | ||
1597 |
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) && |
1598 | 9 | av_opt_find(&priv_class, "ch_layout", NULL, 0, | |
1599 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
1600 | char buf[32]; | ||
1601 | 9 | snprintf(buf, sizeof(buf), "%dC", o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i); | |
1602 | 9 | av_dict_set(&o->g->format_opts, "ch_layout", buf, 0); | |
1603 | } | ||
1604 | } | ||
1605 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6786 times.
|
6787 | if (o->audio_ch_layouts.nb_opt) { |
1606 | const AVClass *priv_class; | ||
1607 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | if (file_iformat && (priv_class = file_iformat->priv_class) && |
1608 | 1 | av_opt_find(&priv_class, "ch_layout", NULL, 0, | |
1609 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
1610 | 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); | |
1611 | } | ||
1612 | } | ||
1613 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6761 times.
|
6787 | if (o->frame_rates.nb_opt) { |
1614 | const AVClass *priv_class; | ||
1615 | /* set the format-level framerate option; | ||
1616 | * this is important for video grabbers, e.g. x11 */ | ||
1617 |
4/6✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
|
51 | if (file_iformat && (priv_class = file_iformat->priv_class) && |
1618 | 25 | av_opt_find(&priv_class, "framerate", NULL, 0, | |
1619 | AV_OPT_SEARCH_FAKE_OBJ)) { | ||
1620 | 25 | av_dict_set(&o->g->format_opts, "framerate", | |
1621 | 25 | o->frame_rates.opt[o->frame_rates.nb_opt - 1].u.str, 0); | |
1622 | } | ||
1623 | } | ||
1624 |
2/2✓ Branch 0 taken 538 times.
✓ Branch 1 taken 6249 times.
|
6787 | if (o->frame_sizes.nb_opt) { |
1625 | 538 | av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes.opt[o->frame_sizes.nb_opt - 1].u.str, 0); | |
1626 | } | ||
1627 |
2/2✓ Branch 0 taken 547 times.
✓ Branch 1 taken 6240 times.
|
6787 | if (o->frame_pix_fmts.nb_opt) |
1628 | 547 | av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0); | |
1629 | |||
1630 | 6787 | video_codec_name = opt_match_per_type_str(&o->codec_names, 'v'); | |
1631 | 6787 | audio_codec_name = opt_match_per_type_str(&o->codec_names, 'a'); | |
1632 | 6787 | subtitle_codec_name = opt_match_per_type_str(&o->codec_names, 's'); | |
1633 | 6787 | data_codec_name = opt_match_per_type_str(&o->codec_names, 'd'); | |
1634 | |||
1635 |
2/2✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 4065 times.
|
6787 | if (video_codec_name) |
1636 | 2722 | ret = err_merge(ret, find_codec(NULL, video_codec_name , AVMEDIA_TYPE_VIDEO , 0, | |
1637 | 2722 | &ic->video_codec)); | |
1638 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6769 times.
|
6787 | if (audio_codec_name) |
1639 | 18 | ret = err_merge(ret, find_codec(NULL, audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, | |
1640 | 18 | &ic->audio_codec)); | |
1641 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (subtitle_codec_name) |
1642 | ✗ | ret = err_merge(ret, find_codec(NULL, subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0, | |
1643 | ✗ | &ic->subtitle_codec)); | |
1644 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (data_codec_name) |
1645 | ✗ | ret = err_merge(ret, find_codec(NULL, data_codec_name , AVMEDIA_TYPE_DATA, 0, | |
1646 | ✗ | &ic->data_codec)); | |
1647 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (ret < 0) { |
1648 | ✗ | avformat_free_context(ic); | |
1649 | ✗ | return ret; | |
1650 | } | ||
1651 | |||
1652 |
2/2✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 4065 times.
|
6787 | ic->video_codec_id = video_codec_name ? ic->video_codec->id : AV_CODEC_ID_NONE; |
1653 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6769 times.
|
6787 | ic->audio_codec_id = audio_codec_name ? ic->audio_codec->id : AV_CODEC_ID_NONE; |
1654 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | ic->subtitle_codec_id = subtitle_codec_name ? ic->subtitle_codec->id : AV_CODEC_ID_NONE; |
1655 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | ic->data_codec_id = data_codec_name ? ic->data_codec->id : AV_CODEC_ID_NONE; |
1656 | |||
1657 | 6787 | ic->flags |= AVFMT_FLAG_NONBLOCK; | |
1658 |
2/2✓ Branch 0 taken 85 times.
✓ Branch 1 taken 6702 times.
|
6787 | if (o->bitexact) |
1659 | 85 | ic->flags |= AVFMT_FLAG_BITEXACT; | |
1660 | 6787 | ic->interrupt_callback = int_cb; | |
1661 | |||
1662 |
1/2✓ Branch 1 taken 6787 times.
✗ Branch 2 not taken.
|
6787 | if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) { |
1663 | 6787 | av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE); | |
1664 | 6787 | scan_all_pmts_set = 1; | |
1665 | } | ||
1666 | /* open the input file with generic avformat function */ | ||
1667 | 6787 | err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts); | |
1668 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (err < 0) { |
1669 | ✗ | av_log(d, AV_LOG_ERROR, | |
1670 | ✗ | "Error opening input: %s\n", av_err2str(err)); | |
1671 | ✗ | if (err == AVERROR_PROTOCOL_NOT_FOUND) | |
1672 | ✗ | av_log(d, AV_LOG_ERROR, "Did you mean file:%s?\n", filename); | |
1673 | ✗ | return err; | |
1674 | } | ||
1675 | 6787 | f->ctx = ic; | |
1676 | |||
1677 | 6787 | av_strlcat(d->log_name, "/", sizeof(d->log_name)); | |
1678 | 6787 | av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name)); | |
1679 | |||
1680 |
1/2✓ Branch 0 taken 6787 times.
✗ Branch 1 not taken.
|
6787 | if (scan_all_pmts_set) |
1681 | 6787 | av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); | |
1682 | 6787 | remove_avoptions(&o->g->format_opts, o->g->codec_opts); | |
1683 | |||
1684 | 6787 | ret = check_avoptions(o->g->format_opts); | |
1685 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (ret < 0) |
1686 | ✗ | return ret; | |
1687 | |||
1688 | /* apply forced codec ids */ | ||
1689 |
2/2✓ Branch 0 taken 7164 times.
✓ Branch 1 taken 6787 times.
|
13951 | for (i = 0; i < ic->nb_streams; i++) { |
1690 | const AVCodec *dummy; | ||
1691 | 7164 | ret = choose_decoder(o, ic, ic->streams[i], HWACCEL_NONE, AV_HWDEVICE_TYPE_NONE, | |
1692 | &dummy); | ||
1693 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7164 times.
|
7164 | if (ret < 0) |
1694 | ✗ | return ret; | |
1695 | } | ||
1696 | |||
1697 |
2/2✓ Branch 0 taken 6785 times.
✓ Branch 1 taken 2 times.
|
6787 | if (o->find_stream_info) { |
1698 | AVDictionary **opts; | ||
1699 | 6785 | int orig_nb_streams = ic->nb_streams; | |
1700 | |||
1701 | 6785 | ret = setup_find_stream_info_opts(ic, o->g->codec_opts, &opts); | |
1702 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
|
6785 | if (ret < 0) |
1703 | ✗ | return ret; | |
1704 | |||
1705 | /* If not enough info to get the stream parameters, we decode the | ||
1706 | first frames to get it. (used in mpeg case for example) */ | ||
1707 | 6785 | ret = avformat_find_stream_info(ic, opts); | |
1708 | |||
1709 |
2/2✓ Branch 0 taken 7162 times.
✓ Branch 1 taken 6785 times.
|
13947 | for (i = 0; i < orig_nb_streams; i++) |
1710 | 7162 | av_dict_free(&opts[i]); | |
1711 | 6785 | av_freep(&opts); | |
1712 | |||
1713 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
|
6785 | if (ret < 0) { |
1714 | ✗ | av_log(d, AV_LOG_FATAL, "could not find codec parameters\n"); | |
1715 | ✗ | if (ic->nb_streams == 0) | |
1716 | ✗ | return ret; | |
1717 | } | ||
1718 | } | ||
1719 | |||
1720 |
3/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6766 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
|
6787 | if (start_time != AV_NOPTS_VALUE && start_time_eof != AV_NOPTS_VALUE) { |
1721 | ✗ | av_log(d, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss\n"); | |
1722 | ✗ | start_time_eof = AV_NOPTS_VALUE; | |
1723 | } | ||
1724 | |||
1725 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (start_time_eof != AV_NOPTS_VALUE) { |
1726 | ✗ | if (start_time_eof >= 0) { | |
1727 | ✗ | av_log(d, AV_LOG_ERROR, "-sseof value must be negative; aborting\n"); | |
1728 | ✗ | return AVERROR(EINVAL); | |
1729 | } | ||
1730 | ✗ | if (ic->duration > 0) { | |
1731 | ✗ | start_time = start_time_eof + ic->duration; | |
1732 | ✗ | if (start_time < 0) { | |
1733 | ✗ | av_log(d, AV_LOG_WARNING, "-sseof value seeks to before start of file; ignored\n"); | |
1734 | ✗ | start_time = AV_NOPTS_VALUE; | |
1735 | } | ||
1736 | } else | ||
1737 | ✗ | av_log(d, AV_LOG_WARNING, "Cannot use -sseof, file duration not known\n"); | |
1738 | } | ||
1739 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6766 times.
|
6787 | timestamp = (start_time == AV_NOPTS_VALUE) ? 0 : start_time; |
1740 | /* add the stream start time */ | ||
1741 |
4/4✓ Branch 0 taken 6784 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 5096 times.
✓ Branch 3 taken 1688 times.
|
6787 | if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE) |
1742 | 5096 | timestamp += ic->start_time; | |
1743 | |||
1744 | /* if seeking requested, we execute it */ | ||
1745 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6766 times.
|
6787 | if (start_time != AV_NOPTS_VALUE) { |
1746 | 21 | int64_t seek_timestamp = timestamp; | |
1747 | |||
1748 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) { |
1749 | 21 | int dts_heuristic = 0; | |
1750 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
|
42 | for (i=0; i<ic->nb_streams; i++) { |
1751 | 21 | const AVCodecParameters *par = ic->streams[i]->codecpar; | |
1752 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (par->video_delay) { |
1753 | ✗ | dts_heuristic = 1; | |
1754 | ✗ | break; | |
1755 | } | ||
1756 | } | ||
1757 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (dts_heuristic) { |
1758 | ✗ | seek_timestamp -= 3*AV_TIME_BASE / 23; | |
1759 | } | ||
1760 | } | ||
1761 | 21 | ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0); | |
1762 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 20 times.
|
21 | if (ret < 0) { |
1763 | 1 | av_log(d, AV_LOG_WARNING, "could not seek to position %0.3f\n", | |
1764 | 1 | (double)timestamp / AV_TIME_BASE); | |
1765 | } | ||
1766 | } | ||
1767 | |||
1768 | 6787 | f->start_time = start_time; | |
1769 | 6787 | d->recording_time = recording_time; | |
1770 | 6787 | f->input_sync_ref = o->input_sync_ref; | |
1771 | 6787 | f->input_ts_offset = o->input_ts_offset; | |
1772 |
3/6✓ Branch 0 taken 13 times.
✓ Branch 1 taken 6774 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
6787 | f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp); |
1773 | 6787 | d->accurate_seek = o->accurate_seek; | |
1774 | 6787 | d->loop = o->loop; | |
1775 | 6787 | d->nb_streams_warn = ic->nb_streams; | |
1776 | |||
1777 | 6787 | d->duration = (Timestamp){ .ts = 0, .tb = (AVRational){ 1, 1 } }; | |
1778 | 6787 | d->min_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } }; | |
1779 | 6787 | d->max_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } }; | |
1780 | |||
1781 | 6787 | d->readrate = o->readrate ? o->readrate : 0.0; | |
1782 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | if (d->readrate < 0.0f) { |
1783 | ✗ | av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", d->readrate); | |
1784 | ✗ | return AVERROR(EINVAL); | |
1785 | } | ||
1786 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6786 times.
|
6787 | if (o->rate_emu) { |
1787 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (d->readrate) { |
1788 | ✗ | av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", d->readrate); | |
1789 | } else | ||
1790 | 1 | d->readrate = 1.0f; | |
1791 | } | ||
1792 | |||
1793 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6786 times.
|
6787 | if (d->readrate) { |
1794 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.5; |
1795 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (d->readrate_initial_burst < 0.0) { |
1796 | ✗ | av_log(d, AV_LOG_ERROR, | |
1797 | "Option -readrate_initial_burst is %0.3f; it must be non-negative.\n", | ||
1798 | d->readrate_initial_burst); | ||
1799 | ✗ | return AVERROR(EINVAL); | |
1800 | } | ||
1801 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6786 times.
|
6786 | } else if (o->readrate_initial_burst) { |
1802 | ✗ | av_log(d, AV_LOG_WARNING, "Option -readrate_initial_burst ignored " | |
1803 | "since neither -readrate nor -re were given\n"); | ||
1804 | } | ||
1805 | |||
1806 | /* Add all the streams from the given input file to the demuxer */ | ||
1807 |
2/2✓ Branch 0 taken 7289 times.
✓ Branch 1 taken 6787 times.
|
14076 | for (int i = 0; i < ic->nb_streams; i++) { |
1808 | 7289 | ret = ist_add(o, d, ic->streams[i]); | |
1809 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7289 times.
|
7289 | if (ret < 0) |
1810 | ✗ | return ret; | |
1811 | } | ||
1812 | |||
1813 | /* dump the file content */ | ||
1814 | 6787 | av_dump_format(ic, f->index, filename, 0); | |
1815 | |||
1816 | /* check if all codec options have been used */ | ||
1817 | 6787 | unused_opts = strip_specifiers(o->g->codec_opts); | |
1818 |
2/2✓ Branch 0 taken 7289 times.
✓ Branch 1 taken 6787 times.
|
14076 | for (i = 0; i < f->nb_streams; i++) { |
1819 | 7289 | DemuxStream *ds = ds_from_ist(f->streams[i]); | |
1820 | 7289 | e = NULL; | |
1821 |
2/2✓ Branch 1 taken 22227 times.
✓ Branch 2 taken 7289 times.
|
29516 | while ((e = av_dict_iterate(ds->decoder_opts, e))) |
1822 | 22227 | av_dict_set(&unused_opts, e->key, NULL, 0); | |
1823 | } | ||
1824 | |||
1825 | 6787 | e = NULL; | |
1826 |
2/2✓ Branch 1 taken 451 times.
✓ Branch 2 taken 6787 times.
|
7238 | while ((e = av_dict_iterate(unused_opts, e))) { |
1827 | 451 | const AVClass *class = avcodec_get_class(); | |
1828 | 451 | const AVOption *option = av_opt_find(&class, e->key, NULL, 0, | |
1829 | AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); | ||
1830 | 451 | const AVClass *fclass = avformat_get_class(); | |
1831 | 451 | const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0, | |
1832 | AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ); | ||
1833 |
2/4✓ Branch 0 taken 451 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 451 times.
|
451 | if (!option || foption) |
1834 | ✗ | continue; | |
1835 | |||
1836 | |||
1837 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 451 times.
|
451 | if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) { |
1838 | ✗ | av_log(d, AV_LOG_ERROR, "Codec AVOption %s (%s) is not a decoding " | |
1839 | ✗ | "option.\n", e->key, option->help ? option->help : ""); | |
1840 | ✗ | return AVERROR(EINVAL); | |
1841 | } | ||
1842 | |||
1843 | 451 | av_log(d, AV_LOG_WARNING, "Codec AVOption %s (%s) has not been used " | |
1844 | "for any stream. The most likely reason is either wrong type " | ||
1845 | "(e.g. a video option with no video streams) or that it is a " | ||
1846 | "private option of some decoder which was not actually used " | ||
1847 |
2/2✓ Branch 0 taken 447 times.
✓ Branch 1 taken 4 times.
|
902 | "for any stream.\n", e->key, option->help ? option->help : ""); |
1848 | } | ||
1849 | 6787 | av_dict_free(&unused_opts); | |
1850 | |||
1851 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6787 times.
|
6787 | for (i = 0; i < o->dump_attachment.nb_opt; i++) { |
1852 | int j; | ||
1853 | |||
1854 | ✗ | for (j = 0; j < f->nb_streams; j++) { | |
1855 | ✗ | InputStream *ist = f->streams[j]; | |
1856 | |||
1857 | ✗ | if (check_stream_specifier(ic, ist->st, o->dump_attachment.opt[i].specifier) == 1) { | |
1858 | ✗ | ret = dump_attachment(ist, o->dump_attachment.opt[i].u.str); | |
1859 | ✗ | if (ret < 0) | |
1860 | ✗ | return ret; | |
1861 | } | ||
1862 | } | ||
1863 | } | ||
1864 | |||
1865 | 6787 | return 0; | |
1866 | } | ||
1867 |